blecsd 0.3.0 → 0.4.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/README.md +1 -2
- package/dist/3d/index.js +1 -1
- package/dist/{border-Jb7TrMob.d.ts → border-DGNDfT6T.d.ts} +1 -1
- package/dist/chunk-25OEBENM.js +3 -0
- package/dist/chunk-26STV7ZS.js +1 -0
- package/dist/chunk-2NMGUEFC.js +4 -0
- package/dist/{chunk-LYSK5S63.js → chunk-4PRDJTCM.js} +1 -1
- package/dist/chunk-5VEKHA3B.js +5 -0
- package/dist/chunk-6KEM3OS2.js +11 -0
- package/dist/chunk-6PX5R326.js +1 -0
- package/dist/{chunk-3LHLSY3Y.js → chunk-6XWY6GB7.js} +1 -1
- package/dist/{chunk-FCMTWFSE.js → chunk-735KKTP3.js} +1 -1
- package/dist/chunk-7SWJNDOL.js +26 -0
- package/dist/chunk-APKUNIMB.js +1 -0
- package/dist/{chunk-FGHEFXLK.js → chunk-CJCSZRV6.js} +1 -1
- package/dist/chunk-DMBMCCLN.js +1 -0
- package/dist/{chunk-OR3BZY7C.js → chunk-DQTVJITR.js} +1 -1
- package/dist/chunk-DSKQ5J4R.js +1 -0
- package/dist/{chunk-OB66FB4F.js → chunk-EF4DC6IN.js} +1 -1
- package/dist/chunk-EJAKECSN.js +1 -0
- package/dist/chunk-FNQRUMFD.js +1 -0
- package/dist/chunk-GJ3RS2VG.js +1 -0
- package/dist/{chunk-G437VE43.js → chunk-KTVEMB2I.js} +1 -1
- package/dist/chunk-KYAPE44E.js +8 -0
- package/dist/chunk-LI4Y7TBZ.js +1 -0
- package/dist/chunk-NHOL4BN6.js +1 -0
- package/dist/chunk-NPNUUSIB.js +1 -0
- package/dist/chunk-OFRWGW2G.js +1 -0
- package/dist/chunk-OMU5BSAS.js +2 -0
- package/dist/chunk-P3ZLIQJP.js +1 -0
- package/dist/chunk-PWI36BQJ.js +1 -0
- package/dist/{chunk-R7AICVRN.js → chunk-QQMUDJ32.js} +2 -2
- package/dist/chunk-R3ICZOE4.js +1 -0
- package/dist/chunk-RJULLVTH.js +1 -0
- package/dist/chunk-S6WS46FE.js +1 -0
- package/dist/{chunk-TWSWTBYL.js → chunk-TSARUU56.js} +1 -1
- package/dist/{chunk-MKMFUXLB.js → chunk-WJRVUAZR.js} +2 -2
- package/dist/{chunk-XZJRWFOS.js → chunk-WY5EZOOL.js} +1 -1
- package/dist/chunk-YY6RZCZH.js +4 -0
- package/dist/chunk-ZPGJCHXH.js +1 -0
- package/dist/chunk-ZPL2J25N.js +1 -0
- package/dist/components/index.d.ts +6886 -6763
- package/dist/components/index.js +1 -1
- package/dist/core/index.d.ts +3621 -3217
- package/dist/core/index.js +1 -1
- package/dist/debug/index.d.ts +2 -2
- package/dist/debug/index.js +1 -1
- package/dist/game/index.d.ts +6 -6
- package/dist/game/index.js +1 -1
- package/dist/{gameLoop-C-Ez_i54.d.ts → gameLoop-CSTb7e0L.d.ts} +1 -1
- package/dist/index.d.ts +741 -23
- package/dist/index.js +3 -3
- package/dist/input/index.d.ts +1 -1
- package/dist/{inputActions-CRsUtTHM.d.ts → inputActions-Fyw14_Gm.d.ts} +3 -3
- package/dist/{keyParser-BnHbg2iD.d.ts → keyParser-m7fWto6g.d.ts} +18 -18
- package/dist/{mouseParser-Cfrbn3AX.d.ts → mouseParser-B7p5ow7K.d.ts} +1 -1
- package/dist/{scheduler-CMcYew9Z.d.ts → scheduler-DeeZleia.d.ts} +2 -0
- package/dist/systems/index.d.ts +351 -4
- package/dist/systems/index.js +1 -1
- package/dist/terminal/index.d.ts +329 -7
- package/dist/terminal/index.js +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +1 -1
- package/dist/widgets/bigText.js +1 -1
- package/dist/widgets/index.d.ts +1222 -101
- package/dist/widgets/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2IEMMRUO.js +0 -1
- package/dist/chunk-3AV52GY5.js +0 -1
- package/dist/chunk-3O4TQHGK.js +0 -4
- package/dist/chunk-3UJWZ5ZN.js +0 -1
- package/dist/chunk-6M2J5QUA.js +0 -1
- package/dist/chunk-7IQEUVGF.js +0 -1
- package/dist/chunk-A6M6TFBL.js +0 -1
- package/dist/chunk-CIK4AMUA.js +0 -1
- package/dist/chunk-CUEUJAHK.js +0 -3
- package/dist/chunk-D42Q2KKR.js +0 -1
- package/dist/chunk-DYEXOFUU.js +0 -2
- package/dist/chunk-DYU72XLL.js +0 -1
- package/dist/chunk-EAY7B5GL.js +0 -1
- package/dist/chunk-FL56THSI.js +0 -25
- package/dist/chunk-G7GIWWLE.js +0 -1
- package/dist/chunk-GGXNWT36.js +0 -8
- package/dist/chunk-HLFORKXS.js +0 -1
- package/dist/chunk-J7MBKEBY.js +0 -1
- package/dist/chunk-K3SX2LY5.js +0 -1
- package/dist/chunk-LDAFEXN5.js +0 -1
- package/dist/chunk-MQWPHPUM.js +0 -1
- package/dist/chunk-MTI376CU.js +0 -5
- package/dist/chunk-MTV2RJZD.js +0 -1
- package/dist/chunk-PXXGH3BV.js +0 -1
- package/dist/chunk-SHUC6JWA.js +0 -1
- package/dist/chunk-UMGTXSQB.js +0 -11
- package/dist/chunk-X3Q3T2SS.js +0 -4
- package/dist/chunk-ZAHG7Y3X.js +0 -1
- package/dist/{virtualViewport-Bpv6jlKt.d.ts → virtualViewport-DTSN6jFk.d.ts} +152 -152
package/dist/chunk-FL56THSI.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {e as e$6,i as i$2,o as o$2,h as h$2}from'./chunk-3UJWZ5ZN.js';import {c as c$2,d as d$7,h as h$3}from'./chunk-2IEMMRUO.js';import {e}from'./chunk-CUEUJAHK.js';import {mb as mb$1,Q,z as z$1,Z,q as q$1,Y as Y$1,qb as qb$2,y as y$1,P as P$1,J as J$1,G as G$2,E as E$2}from'./chunk-LYSK5S63.js';import {$,qa as qa$1,ka as ka$1,qb as qb$1,tb as tb$1,Hb as Hb$1,Nb as Nb$1,Ta as Ta$1,Za as Za$1,Z as Z$1,Ma as Ma$1,Qa as Qa$1,Oa as Oa$1,La as La$1,Ka as Ka$1,Ha as Ha$1,Ga as Ga$1,L,sa,Y as Y$2,ha as ha$1,U,v as v$1,R,Q as Q$1,P,O,pa as pa$1,oa,na,va as va$1,ua,ta,Pa as Pa$1,X,W,V,ba as ba$1,Fa as Fa$1,Ia as Ia$1,M,N,p as p$1,l as l$2,i,j as j$2,ga,sb as sb$1,Vb as Vb$1,Ob as Ob$1,Sb as Sb$1,Tb as Tb$1,Qb as Qb$1,Rb as Rb$1,Kb as Kb$1,Jb as Jb$1,Mb as Mb$1,Lb as Lb$1,Ub as Ub$1,Cb as Cb$1,Ib as Ib$1,Bb as Bb$1,Fb,Eb as Eb$1,Db,zb as zb$1,yb as yb$1,xb as xb$1,wb as wb$1,Gb as Gb$1,ub as ub$1,vb as vb$1,ab as ab$1,_a as _a$1,gb as gb$1,cb as cb$1,db as db$1,aa as aa$1,rb as rb$1,$a as $a$1,fb as fb$1,ac as ac$1,pc as pc$1,rc as rc$1,cc as cc$1,dc as dc$1,oc as oc$1,fc as fc$1,jc as jc$1,ic as ic$1,nc as nc$1,mc as mc$1,lc as lc$1,kc as kc$1,hc as hc$1,gc as gc$1}from'./chunk-3O4TQHGK.js';import {e as e$7,d as d$6,p as p$3,y as y$2,u as u$2,q as q$3,n as n$2,m as m$2,o as o$3,l as l$3,s as s$1,r as r$2}from'./chunk-TWSWTBYL.js';import {g as g$1,h as h$1,i as i$3,o as o$4,n as n$3,m as m$3,w as w$2}from'./chunk-VOCM5T2G.js';import {a as a$4}from'./chunk-3AV52GY5.js';import {ia,Ua as Ua$1,ab as ab$2,bb as bb$1,o as o$1,x as x$2,p as p$2,I,Z as Z$2,T,$ as $$1,ob as ob$1,ub as ub$2,Eb as Eb$2,Jb as Jb$2,Hb as Hb$2,Lb as Lb$2,pb as pb$1,vb as vb$2,ra,ta as ta$1,tb as tb$2,sb as sb$2,rb as rb$2,Mb as Mb$2,Nb as Nb$2,Ab,Ib as Ib$2,Db as Db$1,zb as zb$2,Gb as Gb$2,Fb as Fb$1,B as B$1,z as z$4,C as C$1,r as r$1,y as y$3,w as w$1,u as u$3,t as t$2,A as A$1,X as X$1,aa as aa$2,W as W$1,Y as Y$3,P as P$2,U as U$1,N as N$1,R as R$1,S,Q as Q$2}from'./chunk-A6M6TFBL.js';import {a}from'./chunk-EAY7B5GL.js';import {b,l as l$1,H,G as G$1,F as F$1,E,D,C,B,A,z as z$3,y,x as x$1,s,v,u as u$1,n as n$1,q as q$2,r,o,p,t as t$1,m as m$1,c as c$1}from'./chunk-3LHLSY3Y.js';import {e as e$5,d as d$5}from'./chunk-OR3BZY7C.js';import {u,a as a$1,l,m,f as f$3,e as e$4,d as d$3,c,b as b$1,t}from'./chunk-DYU72XLL.js';import {e as e$2,f as f$2}from'./chunk-FCMTWFSE.js';import {Y,F,w,d,x,j as j$1,_,ba,aa,g,K,z as z$2,E as E$1,G as G$3,v as v$2}from'./chunk-ZAHG7Y3X.js';import {f,e as e$1,c as c$3}from'./chunk-SHUC6JWA.js';import {f as f$1,d as d$2,i as i$1,a as a$2}from'./chunk-G7GIWWLE.js';import {n,d as d$1,e as e$3,h,g as g$2,f as f$4}from'./chunk-PXXGH3BV.js';import {d as d$4,a as a$3}from'./chunk-5PELJRUQ.js';import {z}from'zod';import {readdirSync,statSync}from'fs';import {resolve,dirname,join}from'path';import {createRequire}from'module';import {pathToFileURL}from'url';n();f();u();n();f();var Eu=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),yi=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Cm=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Sm=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),Au=z.object({left:yi.optional(),top:yi.optional(),right:yi.optional(),bottom:yi.optional(),width:Eu.optional(),height:Eu.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Cm,padding:Sm,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional()}),Tm=1e4,Cr={isBox:new Uint8Array(Tm)};function Wm(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function vm(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function Lm(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function Em(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Bu(e){return e===void 0?0:typeof e=="number"?e:0}function Pu(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Bm(e,r,o){let n=Bu(o.left),t=Bu(o.top);F(e,r,n,t);let i=Pu(o.width),a=Pu(o.height);w(e,r,i,a);}function Pm(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function Am(e,r,o){let n=o.type?Em(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?Lm(o.ch):o.ch;m(e,r,t);}}function Dm(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function Fm(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=Wm(o.align)),o.valign&&(n.valign=vm(o.valign)),e$2(e,r,o.content,n);}function pt(e,r,o={}){let n=Au.parse(o),t=r;Cr.isBox[t]=1,Bm(e,t,n),Pm(e,t,n),n.border&&Am(e,t,n.border),n.padding!==void 0&&Dm(e,t,n.padding),Fm(e,t,n),Y(e,t,{focusable:true});let i={eid:t,show(){return j$1(e,t,true),i},hide(){return j$1(e,t,false),i},move(a,s){return K(e,t,a,s),g(e,t),i},setPosition(a,s){return F(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return aa(e,t),i},blur(){return ba(e,t),i},isFocused(){return _(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},destroy(){Cr.isBox[t]=0,e$3(e,t);}};return i}function Mm(e,r,o){return e$2(e,r,o),g(e,r),r}function km(e,r){return f$2(e,r)}function Rm(e,r){return Cr.isBox[r]===1}function Im(){Cr.isBox.fill(0);}var Vm=z.object({title:z.string(),content:z.union([z.string(),z.number().int().nonnegative()]).optional(),expanded:z.boolean().optional(),onToggle:z.function().nullable().optional()}),_m=z.object({sections:z.array(Vm).optional(),allowMultiple:z.boolean().optional(),defaultExpanded:z.union([z.array(z.number().int().nonnegative()),z.literal("all")]).optional(),icons:z.object({expanded:z.string().optional(),collapsed:z.string().optional()}).optional(),style:z.object({header:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional()}).optional()}),Om=z.object({title:z.string(),content:z.union([z.string(),z.number().int().nonnegative()]).optional(),expanded:z.boolean().optional(),onToggle:z.function().nullable().optional(),icons:z.object({expanded:z.string().optional(),collapsed:z.string().optional()}).optional(),style:z.object({header:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional()}).optional()}),dn=new Map,hi=new Map,xi=new Map;function Gm(){dn.clear(),hi.clear(),xi.clear();}var Du="\u25BC",Fu="\u25B6";function Nm(e,r,o={}){let n=o.sections??[],t=o.allowMultiple??false,i=o.defaultExpanded,a={expanded:o.icons?.expanded??Du,collapsed:o.icons?.collapsed??Fu},s=new Set;if(i==="all")for(let u=0;u<n.length;u++)s.add(u);else if(Array.isArray(i))for(let u of i)s.add(u);else for(let u=0;u<n.length;u++)n[u]?.expanded&&s.add(u);let l=n.map((u,d$3)=>{let f=s.has(d$3),g=d$1(e);if(pt(e,g),F(e,g,0,d$3*2),w(e,g,40,1),e$2(e,g,`${f?a.expanded:a.collapsed} ${u.title}`),Y(e,g,{focusable:true}),d$2(e,r,g),xi.set(g,u.title),e$5(e,g,true),o.style?.header){let b=typeof o.style.header.fg=="string"?e$1(o.style.header.fg):o.style.header.fg,p=typeof o.style.header.bg=="string"?e$1(o.style.header.bg):o.style.header.bg;(b!==void 0||p!==void 0)&&d(e,g,{fg:b,bg:p});}let c=d$1(e);if(pt(e,c),F(e,c,2,d$3*2+1),w(e,c,38,3),b(e,c,{left:1,right:1,top:0,bottom:0}),typeof u.content=="string"?e$2(e,c,u.content):u.content!==void 0&&d$2(e,c,u.content),j$1(e,c,f),d$2(e,r,c),o.style?.content){let b=typeof o.style.content.fg=="string"?e$1(o.style.content.fg):o.style.content.fg,p=typeof o.style.content.bg=="string"?e$1(o.style.content.bg):o.style.content.bg;(b!==void 0||p!==void 0)&&d(e,c,{fg:b,bg:p});}return {headerEntity:g,contentEntity:c,expanded:f,onToggle:u.onToggle}});return dn.set(r,{allowMultiple:t,expandedSections:s,sections:l,icons:a,world:e}),r}function ya(e,r){let o=dn.get(e);if(!o)return;let n=o.sections[r];if(!n)return;let t=!n.expanded;!o.allowMultiple&&t&&o.sections.forEach((i,a)=>{a!==r&&i.expanded&&(i.expanded=false,j$1(o.world,i.contentEntity,false),e$2(o.world,i.headerEntity,`${o.icons.collapsed} ${pa(i.headerEntity)}`),o.expandedSections.delete(a));}),n.expanded=t,j$1(o.world,n.contentEntity,t),e$2(o.world,n.headerEntity,`${t?o.icons.expanded:o.icons.collapsed} ${pa(n.headerEntity)}`),t?o.expandedSections.add(r):o.expandedSections.delete(r),g(o.world,e),n.onToggle?.(t);}function Mu(e,r){let o=dn.get(e);if(!o)return;let n=o.sections[r];!n||n.expanded||ya(e,r);}function zm(e){let r=dn.get(e);!r||!r.allowMultiple||r.sections.forEach((o,n)=>{Mu(e,n);});}function wm(e){let r=dn.get(e);r&&r.sections.forEach((o,n)=>{o.expanded&&ya(e,n);});}function Hm(e){let r=dn.get(e);return r?Array.from(r.expandedSections):[]}function Um(e,r,o){let n=o.expanded??false,t={expanded:o.icons?.expanded??Du,collapsed:o.icons?.collapsed??Fu},i=d$1(e);if(pt(e,i),F(e,i,0,0),w(e,i,40,1),e$2(e,i,`${n?t.expanded:t.collapsed} ${o.title}`),Y(e,i,{focusable:true}),d$2(e,r,i),xi.set(i,o.title),e$5(e,i,true),o.style?.header){let s=typeof o.style.header.fg=="string"?e$1(o.style.header.fg):o.style.header.fg,l=typeof o.style.header.bg=="string"?e$1(o.style.header.bg):o.style.header.bg;(s!==void 0||l!==void 0)&&d(e,i,{fg:s,bg:l});}let a=d$1(e);if(pt(e,a),F(e,a,2,1),w(e,a,38,3),b(e,a,{left:1,right:1,top:0,bottom:0}),typeof o.content=="string"?e$2(e,a,o.content):o.content!==void 0&&d$2(e,a,o.content),j$1(e,a,n),d$2(e,r,a),o.style?.content){let s=typeof o.style.content.fg=="string"?e$1(o.style.content.fg):o.style.content.fg,l=typeof o.style.content.bg=="string"?e$1(o.style.content.bg):o.style.content.bg;(s!==void 0||l!==void 0)&&d(e,a,{fg:s,bg:l});}return hi.set(r,{expanded:n,headerEntity:i,contentEntity:a,onToggle:o.onToggle,icons:t,world:e}),r}function $m(e){let r=hi.get(e);if(!r)return;let o=!r.expanded;r.expanded=o,j$1(r.world,r.contentEntity,o),e$2(r.world,r.headerEntity,`${o?r.icons.expanded:r.icons.collapsed} ${pa(r.headerEntity)}`),g(r.world,e),r.onToggle?.(o);}function ku(e){return dn.has(e)}function jm(e){return hi.has(e)}function Ym(e,r){return ku(e)?{entity:e,world:r}:void 0}function pa(e){return xi.get(e)??""}n();f();var Km=1e4,ha={isAutocomplete:new Uint8Array(Km)},Ru=z.object({items:z.array(z.string()).optional().default([]),placeholder:z.string().optional().default("Type to search..."),maxSuggestions:z.number().int().positive().optional().default(10),fuzzyMatch:z.boolean().optional().default(true),value:z.string().optional().default(""),width:z.number().int().positive().optional().default(30),left:z.number().optional().default(0),top:z.number().optional().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),highlightFg:z.union([z.string(),z.number()]).optional(),highlightBg:z.union([z.string(),z.number()]).optional()}),Je=new Map;function Ci(e,r,o,n){if(!r)return e.slice(0,n).map(a=>({item:a,text:a,score:1,indices:[]}));if(o)return c$2(r,e).slice(0,n);let t=r.toLowerCase(),i=[];for(let a of e){let l=a.toLowerCase().indexOf(t);if(l===-1)continue;let u=1-l/a.length;i.push({item:a,text:a,score:u,indices:Array.from({length:r.length},(d,f)=>l+f)});}return i.sort((a,s)=>s.score-a.score),i.slice(0,n)}function Qm(e,r,o={}){let n=Ru.parse(o),t=r;ha.isAutocomplete[t]=1,F(e,t,n.left,n.top),w(e,t,n.width,1),Y(e,t,{focusable:true}),ia(e,t),Ua$1(e,t,{placeholder:n.placeholder,maxLength:0});let i=n.fg?e$1(n.fg):void 0,a=n.bg?e$1(n.bg):void 0;(i!==void 0||a!==void 0)&&d(e,t,{fg:i,bg:a});let s={items:n.items,inputText:n.value,filteredItems:Ci(n.items,n.value,n.fuzzyMatch,n.maxSuggestions),selectedIndex:0,isOpen:false,fuzzyMatch:n.fuzzyMatch,maxSuggestions:n.maxSuggestions};Je.set(t,s),ab$2(e,t,u=>{let d=Je.get(t);d&&(d.inputText=u,d.filteredItems=Ci(d.items,u,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,d.isOpen=u.length>0&&d.filteredItems.length>0,g(e,t),d.onChangeCallback&&d.onChangeCallback(u));}),bb$1(e,t,u=>{let d=Je.get(t);if(d){if(d.isOpen&&d.filteredItems.length>0){let f=d.filteredItems[d.selectedIndex];f&&(d.inputText=f.item,d.isOpen=false,d.selectedIndex=0,d.onSelectCallback&&d.onSelectCallback(f.item));}else d.onSelectCallback&&d.onSelectCallback(u);g(e,t);}});let l={eid:t,show(){return j$1(e,t,true),g(e,t),l},hide(){return j$1(e,t,false),g(e,t),l},focus(){return aa(e,t),ra(e,t),ta$1(e,t),l},blur(){ba(e,t);let u=Je.get(t);return u&&(u.isOpen=false),g(e,t),l},getValue(){return Je.get(t)?.inputText??""},setValue(u){let d=Je.get(t);return d&&(d.inputText=u,d.filteredItems=Ci(d.items,u,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,d.isOpen=u.length>0&&d.filteredItems.length>0,g(e,t)),l},setItems(u){let d=Je.get(t);return d&&(d.items=u,d.filteredItems=Ci(u,d.inputText,d.fuzzyMatch,d.maxSuggestions),d.selectedIndex=0,g(e,t)),l},getItems(){return Je.get(t)?.items??[]},getSuggestions(){return Je.get(t)?.filteredItems.map(d=>d.item)??[]},isOpen(){return Je.get(t)?.isOpen??false},openDropdown(){let u=Je.get(t);return u&&u.filteredItems.length>0&&(u.isOpen=true,g(e,t)),l},closeDropdown(){let u=Je.get(t);return u&&(u.isOpen=false,g(e,t)),l},onSelect(u){let d=Je.get(t);return d&&(d.onSelectCallback=u),l},onChange(u){let d=Je.get(t);return d&&(d.onChangeCallback=u),l},destroy(){Je.delete(t),e$3(e,t);}};return l}function Xm(e,r){return ha.isAutocomplete[r]===1}function qm(){Je.clear();}n();f();var cn=10240,Ln=[[1,8],[2,16],[4,32],[64,128]];function Jm(e,r){if(e<0||e>1||r<0||r>3)return " ";let o=Ln[r];if(!o)return " ";let n=o[e]??0;return String.fromCharCode(10240|n)}function xa(e){let r=0;for(let[o,n]of e)if(o>=0&&o<=1&&n>=0&&n<=3){let t=Ln[n];t&&(r|=t[o]??0);}return String.fromCharCode(10240|r)}function Iu(e,r=5){if(e===0)return 1;let o=e/r,n=10**Math.floor(Math.log10(o)),t=o/n,i;return t<=1?i=1:t<=2?i=2:t<=5?i=5:i=10,i*n}function Sr(e,r,o=5){if(e===r)return [e];let n=r-e,t=Iu(n,o),i=Math.floor(e/t)*t,a=[];for(let s=i;s<=r;s+=t)s>=e&&a.push(s);return (a.length===0||a[a.length-1]<r)&&a.push(r),a}function mt(e,r,o,n,t){if(o===r)return (n+t)/2;let i=o-r,a=t-n,s=(e-r)/i;return n+s*a}function Xn(e,r=8){if(!Number.isFinite(e))return "NaN";let o=Math.abs(e);if(o<.01&&o>0)return e.toExponential(2);if(o>=1e9)return `${(e/1e9).toFixed(2)}B`;if(o>=1e6)return `${(e/1e6).toFixed(2)}M`;if(o>=1e3)return `${(e/1e3).toFixed(2)}K`;let n=e.toFixed(2);return n.length<=r?n:e.toFixed(0)}function Ca(e){return `${Math.round(e*100)}%`}var Si=[4284790262,4286695300,4294948685,4293227379,4290406600,4294956367,4283289825,4288776319];function Yt(e){return Si[e%Si.length]??Si[0]}function Zm(e,r,o){let n=e>>16&255,t=e>>8&255,i=e&255,a=e>>24&255,s=r>>16&255,l=r>>8&255,u=r&255,d=r>>24&255,f=Math.round(n+(s-n)*o),g=Math.round(t+(l-t)*o),c=Math.round(i+(u-i)*o);return (Math.round(a+(d-a)*o)<<24|f<<16|g<<8|c)>>>0}function ef(e,r){return Xn(e,r-1).padEnd(r," ")}function Tr(e,r){return Xn(e,r).padStart(r," ")}var _u=[" ","\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u2588"],Ou=[" ","\u2581","\u2582","\u2583","\u2584","\u2585","\u2586","\u2587","\u2588"],tf=z.object({label:z.string(),data:z.array(z.number()),color:z.union([z.string(),z.number()]).optional()}),Gu=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(40),height:z.number().int().positive().default(20),orientation:z.enum(["vertical","horizontal"]).default("vertical"),mode:z.enum(["grouped","stacked"]).default("grouped"),labels:z.array(z.string()).default([]),series:z.array(tf).default([]),barChar:z.string().length(1).default("\u2588"),barWidth:z.number().int().positive().default(3),barGap:z.number().int().nonnegative().default(1),showValues:z.boolean().default(false),useBlockChars:z.boolean().default(false),yLabel:z.string().optional(),xLabel:z.string().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Wr=1e4,ze={isBarChart:new Uint8Array(Wr),showValues:new Uint8Array(Wr),orientation:new Uint8Array(Wr),mode:new Uint8Array(Wr),useBlockChars:new Uint8Array(Wr)},gn=new Map;function Ta(e,r){let o=r?Ou:_u,n=Math.round(e*(o.length-1)),t=Math.max(0,Math.min(o.length-1,n));return o[t]??" "}function Vu(e,r,o){if(e>=r+1)return "\u2588";if(e<=r)return " ";let n=e-r;return Ta(n,o)}function nf(e,r,o,n){let t=[],i=e.mode==="stacked",a=Number.NEGATIVE_INFINITY;if(i)for(let p=0;p<e.labels.length;p++){let y=0;for(let v of e.series)y+=v.data[p]??0;y>a&&(a=y);}else for(let p of e.series)for(let y of p.data)y>a&&(a=y);(a===Number.NEGATIVE_INFINITY||a===0)&&(a=100);let s=8,u=o-2,d=r-s,f=Sr(0,a,5),g=i?e.barWidth:e.barWidth*e.series.length+e.barGap*(e.series.length-1);for(let p=0;p<u;p++){let y=u-p-1,v=mt(y,0,u-1,0,a),x=f.find(D=>Math.abs(D-v)<a/u),P=`${x!==void 0?Tr(x,s-2):" ".repeat(s-2)}\u2502 `;for(let D=0;D<e.labels.length;D++){if(i){let L=0,R=" ";for(let Y of e.series){let U=Y.data[D]??0,$e=L+U,Ht=mt(L,0,a,0,u-1),Dt=mt($e,0,a,0,u-1);if(y>=Ht&&y<=Dt){e.useBlockChars&&y===Math.floor(Dt)&&y!==Dt?R=Vu(Dt,y,true):R=e.barChar;break}L=$e;}P+=R.repeat(e.barWidth);}else for(let L=0;L<e.series.length;L++){let R=e.series[L];if(!R)continue;let Y=R.data[D]??0,U=mt(Y,0,a,0,u-1),$e;y>U?$e=" ":e.useBlockChars&&y===Math.floor(U)?$e=Vu(U,y,true):$e=e.barChar,P+=$e.repeat(e.barWidth),L<e.series.length-1&&(P+=" ".repeat(e.barGap));}D<e.labels.length-1&&(P+=" ");}t.push(P.padEnd(r," "));}let c=`${" ".repeat(s)}\u2514${"\u2500".repeat(d-1)}`;t.push(c.padEnd(r," "));let b=`${" ".repeat(s)} `;for(let p=0;p<e.labels.length;p++){let y=e.labels[p]??"",v=g+2;b+=y.slice(0,v).padEnd(v," ");}return t.push(b.padEnd(r," ")),t.join(`
|
|
2
|
-
`)}function rf(e,r,o,n){let t=[],i=e.mode==="stacked",a=Number.NEGATIVE_INFINITY;if(i)for(let u=0;u<e.labels.length;u++){let d=0;for(let f of e.series)d+=f.data[u]??0;d>a&&(a=d);}else for(let u of e.series)for(let d of u.data)d>a&&(a=d);(a===Number.NEGATIVE_INFINITY||a===0)&&(a=100);let s=Math.max(...e.labels.map(u=>u.length),8),l=r-s-2-(n?10:0);for(let u=0;u<e.labels.length;u++){let d=e.labels[u]??"";if(i){let f=`${d.slice(0,s).padStart(s," ")} \u2502`;for(let g of e.series){let c=g.data[u]??0,b=mt(c,0,a,0,l),p=Math.floor(b),y=b-p;f+=e.barChar.repeat(p),e.useBlockChars&&y>0&&(f+=Ta(y,false));}if(n){let g=e.series.reduce((c,b)=>c+(b.data[u]??0),0);f+=` ${Xn(g)}`;}t.push(f.padEnd(r," "));}else {let f=`${d.slice(0,s).padStart(s," ")} \u2502`,g=e.series[0];if(g){let c=g.data[u]??0,b=mt(c,0,a,0,l),p=Math.floor(b),y=b-p;f+=e.barChar.repeat(p),e.useBlockChars&&y>0&&(f+=Ta(y,false)),n&&(f+=` ${Xn(c)}`);}t.push(f.padEnd(r," "));}}return t.join(`
|
|
3
|
-
`)}function Sa(e,r){let o=gn.get(r);if(!o)return;let n=x(e,r);if(!n)return;let t=ze.showValues[r]===1,a=ze.orientation[r]===1?rf(o,n.width,n.height,t):nf(o,n.width,n.height);e$2(e,r,a),g(e,r);}function of(e,r={}){let o=Gu.parse(r),n=d$1(e);F(e,n,o.x,o.y),w(e,n,o.width,o.height),ze.isBarChart[n]=1,ze.showValues[n]=o.showValues?1:0,ze.orientation[n]=o.orientation==="horizontal"?1:0,ze.mode[n]=o.mode==="stacked"?1:0,ze.useBlockChars[n]=o.useBlockChars?1:0,gn.set(n,{labels:[...o.labels],series:o.series.map((i,a)=>({label:i.label,data:[...i.data],color:i.color?e$1(i.color):Yt(a)})),barChar:o.barChar,barWidth:o.barWidth,barGap:o.barGap,yLabel:o.yLabel??"",xLabel:o.xLabel??"",mode:o.mode,useBlockChars:o.useBlockChars}),(o.fg!==void 0||o.bg!==void 0)&&d(e,n,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),Sa(e,n);let t={eid:n,setSeries(i){let a=gn.get(n);return a&&(a.series=i.map((s,l)=>({label:s.label,data:[...s.data],color:s.color?e$1(s.color):Yt(l)})),Sa(e,n)),t},getSeries(){return gn.get(n)?.series??[]},setLabels(i){let a=gn.get(n);return a&&(a.labels=[...i],Sa(e,n)),t},getLabels(){return gn.get(n)?.labels??[]},setPosition(i,a){return F(e,n,i,a),g(e,n),t},destroy(){ze.isBarChart[n]=0,ze.showValues[n]=0,ze.orientation[n]=0,ze.mode[n]=0,ze.useBlockChars[n]=0,gn.delete(n),e$3(e,n);}};return t}function af(e,r){return ze.isBarChart[r]===1}function sf(){ze.isBarChart.fill(0),ze.showValues.fill(0),ze.orientation.fill(0),ze.mode.fill(0),ze.useBlockChars.fill(0),gn.clear();}n();var zu=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(3),label:z.string().default("Button"),focusable:z.boolean().default(true),disabled:z.boolean().default(false)}),lf=1e4,Nu=2,Lr={isButtonWidget:new Uint8Array(lf)},vr=new Map;function uf(e,r={}){let o=zu.parse(r),n=d$1(e);Lr.isButtonWidget[n]=1,o$1(e,n);let t=o.label.length,i=o.width??t+Nu*2;w(e,n,i,o.height),F(e,n,o.x,o.y),vr.set(n,{label:o.label}),e$2(e,n,o.label,{align:1,valign:1}),d$5(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),Y(e,n,{focusable:o.focusable}),o.disabled&&x$2(e,n);let a={eid:n,click(){return A$1(e,n),g(e,n),a},isHovered(){return t$2(e,n)},isPressed(){return u$3(e,n)},isFocused(){return _(e,n)},isDisabled(){return w$1(e,n)},setDisabled(s){return s?x$2(e,n):y$3(e,n),g(e,n),a},setLabel(s){let l=vr.get(n);if(l&&(l.label=s),!o.width){let u=s.length+Nu*2;w(e,n,u,o.height);}return e$2(e,n,s,{align:1,valign:1}),g(e,n),a},getLabel(){return vr.get(n)?.label??""},setPosition(s,l){return F(e,n,s,l),g(e,n),a},move(s,l){return K(e,n,s,l),g(e,n),a},getPosition(){return {x:E$1.x[n]??0,y:E$1.y[n]??0}},focus(){return aa(e,n),r$1(e,n,"focus"),g(e,n),a},blur(){return ba(e,n),r$1(e,n,"blur"),g(e,n),a},handleKey(s){if(!_(e,n))return false;let l=C$1(e,n,s);return l&&g(e,n),l},onClick(s){return z$4(n,s),a},destroy(){Lr.isButtonWidget[n]=0,vr.delete(n),B$1(n),e$3(e,n);}};return a}function df(e,r){return Lr.isButtonWidget[r]===1&&p$2(e,r)}function cf(){Lr.isButtonWidget.fill(0),vr.clear();}n();f();n();f();var wu=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Ti=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),$u=z.object({left:Ti.optional(),top:Ti.optional(),right:Ti.optional(),bottom:Ti.optional(),width:wu.optional(),height:wu.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional(),shrink:z.boolean().optional()}),gf=1e4,Er={isText:new Uint8Array(gf)};function mf(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function ff(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function Hu(e){return e===void 0?0:typeof e=="number"?e:0}function Uu(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function bf(e,r,o){let n=Hu(o.left),t=Hu(o.top);F(e,r,n,t);let i=Uu(o.width),a=Uu(o.height);w(e,r,i,a);let s=o.shrink!==false;z$2(e,r,s);}function pf(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function yf(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=mf(o.align)),o.valign&&(n.valign=ff(o.valign)),e$2(e,r,o.content,n);}function Br(e,r,o={}){let n=$u.parse(o),t=r;Er.isText[t]=1,bf(e,t,n),pf(e,t,n),yf(e,t,n),Y(e,t,{focusable:true});let i={eid:t,show(){return j$1(e,t,true),i},hide(){return j$1(e,t,false),i},move(a,s){return K(e,t,a,s),g(e,t),i},setPosition(a,s){return F(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return aa(e,t),i},blur(){return ba(e,t),i},isFocused(){return _(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},destroy(){Er.isText[t]=0,e$3(e,t);}};return i}function Wa(e,r,o){return e$2(e,r,o),g(e,r),r}function hf(e,r){return f$2(e,r)}function xf(e,r){return Er.isText[r]===1}function Cf(){Er.isText.fill(0);}var Sf=1e4,Wi={isCanvas:new Uint8Array(Sf)},ju=z.object({width:z.number().int().positive().optional().default(40),height:z.number().int().positive().optional().default(40),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),fillChar:z.string().length(1).optional().default(" ")}),qn=new Map;function Tf(e,r){let o=Math.floor(e/2),n=Math.floor(r/4),t=e%2,i=r%4;return {charX:o,charY:n,col:t,row:i}}function Yu(e,r,o){return o*e.widthChars+r}function Ku(e){let r=[];for(let o=0;o<e.heightChars;o++){let n="";for(let t=0;t<e.widthChars;t++){let i=Yu(e,t,o),a=e.pixels[i]??0;n+=String.fromCharCode(10240|a);}r.push(n);}return r.join(`
|
|
4
|
-
`)}function vi(e){let r=Ku(e);Wa(e.world,e.textEntity,r),g(e.world,e.entity);}function Ze(e,r,o,n=true){let t=qn.get(e.entity);if(!t||r<0||r>=t.widthDots||o<0||o>=t.heightDots)return;let{charX:i,charY:a,col:s,row:l}=Tf(r,o),u=Yu(t,i,a),d=Ln[l];if(!d)return;let f=d[s]??0;n?t.pixels[u]=(t.pixels[u]??0)|f:t.pixels[u]=(t.pixels[u]??0)&~f,vi(t);}function Wf(e,r,o,n,t){let i=Math.abs(n-r),a=Math.abs(t-o),s=r<n?1:-1,l=o<t?1:-1,u=i-a,d=r,f=o;for(;Ze(e,d,f,true),!(d===n&&f===t);){let g=2*u;g>-a&&(u-=a,d+=s),g<i&&(u+=i,f+=l);}}function vf(e,r,o,n,t,i=false){if(i)for(let a=0;a<t;a++)for(let s=0;s<n;s++)Ze(e,r+s,o+a,true);else {for(let a=0;a<n;a++)Ze(e,r+a,o,true),Ze(e,r+a,o+t-1,true);for(let a=0;a<t;a++)Ze(e,r,o+a,true),Ze(e,r+n-1,o+a,true);}}function Lf(e,r,o,n,t=false){if(t)for(let i=-n;i<=n;i++){let a=Math.floor(Math.sqrt(n*n-i*i));for(let s=-a;s<=a;s++)Ze(e,r+s,o+i,true);}else {let i=n,a=0,s=0;for(;i>=a;)Ze(e,r+i,o+a,true),Ze(e,r+a,o+i,true),Ze(e,r-a,o+i,true),Ze(e,r-i,o+a,true),Ze(e,r-i,o-a,true),Ze(e,r-a,o-i,true),Ze(e,r+a,o-i,true),Ze(e,r+i,o-a,true),s<=0&&(a+=1,s+=2*a+1),s>0&&(i-=1,s-=2*i+1);}}function Ef(e,r,o,n){let t=qn.get(e.entity);t&&vi(t);}function Bf(e){let r=qn.get(e.entity);r&&(r.pixels.fill(0),vi(r));}function Pf(e){let r=qn.get(e.entity);return r?Ku(r):""}function Af(e,r,o={}){let n=ju.parse(o),t=Math.ceil(n.width/2),i=Math.ceil(n.height/4);Wi.isCanvas[r]=1,pt(e,r),F(e,r,0,0);let a=n.fg?e$1(n.fg):void 0,s=n.bg?e$1(n.bg):void 0;(a!==void 0||s!==void 0)&&d(e,r,{fg:a,bg:s});let l=d$1(e);Br(e,l),F(e,l,0,0),d$2(e,r,l);let u=new Uint8Array(t*i);u.fill(0);let d$3={world:e,entity:r,textEntity:l,widthDots:n.width,heightDots:n.height,widthChars:t,heightChars:i,pixels:u};return qn.set(r,d$3),vi(d$3),{entity:r,world:e,widthDots:n.width,heightDots:n.height}}function Df(e){return Wi.isCanvas[e]===1}function Ff(){qn.clear(),Wi.isCanvas.fill(0);}n();var Qu=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(1),label:z.string().default(""),checked:z.boolean().default(false),checkedChar:z.string().default("\u2611"),uncheckedChar:z.string().default("\u2610"),focusable:z.boolean().default(true),disabled:z.boolean().default(false)}),Mf=1e4,Ar={isCheckboxWidget:new Uint8Array(Mf)},Jn=new Map;function kf(e,r={}){let o=Qu.parse(r),n=d$1(e);Ar.isCheckboxWidget[n]=1,I(e,n,o.checked),Z$2(n,{checkedChar:o.checkedChar,uncheckedChar:o.uncheckedChar});let t=Math.max(o.checkedChar.length,o.uncheckedChar.length),i=o.label.length,a=o.width??t+(i>0?1+i:0);w(e,n,a,o.height),F(e,n,o.x,o.y),Jn.set(n,{label:o.label}),Pr(e,n),d$5(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),Y(e,n,{focusable:o.focusable}),o.disabled&&T(e,n);let s={eid:n,toggle(){return Q$2(e,n),Pr(e,n),g(e,n),s},setChecked(l){return l?R$1(e,n):S(e,n),Pr(e,n),g(e,n),s},isChecked(){return N$1(e,n)},getChar(){return $$1(e,n)},setDisabled(l){return l?T(e,n):U$1(e,n),g(e,n),s},isDisabled(){return P$2(e,n)},setLabel(l){let u=Jn.get(n);u&&(u.label=l);let f=$$1(e,n).length+(l.length>0?1+l.length:0);return w(e,n,f,o.height),Pr(e,n),g(e,n),s},getLabel(){return Jn.get(n)?.label??""},setPosition(l,u){return F(e,n,l,u),g(e,n),s},move(l,u){return K(e,n,l,u),g(e,n),s},getPosition(){return {x:E$1.x[n]??0,y:E$1.y[n]??0}},focus(){return aa(e,n),g(e,n),s},blur(){return ba(e,n),g(e,n),s},isFocused(){return _(e,n)},handleKey(l){if(!_(e,n))return false;let u=Y$3(e,n,l);return u&&(Pr(e,n),g(e,n)),u},onChange(l){return W$1(n,l),s},destroy(){Ar.isCheckboxWidget[n]=0,Jn.delete(n),X$1(n),aa$2(n),e$3(e,n);}};return s}function Pr(e,r){let o=$$1(e,r),t=Jn.get(r)?.label??"",i=t.length>0?`${o} ${t}`:o;e$2(e,r,i);}function Rf(e,r){return Ar.isCheckboxWidget[r]===1}function If(){Ar.isCheckboxWidget.fill(0),Jn.clear();}n();f();n();z.object({item:z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional()}).optional(),selected:z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),prefix:z.string().optional()}).optional(),unselectedPrefix:z.string().optional(),disabledFg:z.number().int().nonnegative().optional()});var Xu=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(10),items:z.array(z.string()).default([]),selected:z.number().int().min(-1).default(0),style:z.object({item:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional(),prefix:z.string().optional()}).optional(),unselectedPrefix:z.string().optional(),disabledFg:z.number().optional()}).optional(),interactive:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true),search:z.boolean().default(false),multiSelect:z.boolean().default(false)});function Dr(e,r,o={}){let n=Xu.parse(o),t=r;F(e,t,n.x,n.y),w(e,t,n.width,n.height);let i$1=n.items.map(s=>({text:s,value:s}));if($(e,t,i$1,{interactive:n.interactive,mouse:n.mouse,keys:n.keys,search:n.search,selectedIndex:n.selected,visibleCount:n.height}),n.multiSelect&&qa$1(t,true),n.style){let s={};n.style.selected?.prefix!==void 0&&(s.selectedPrefix=n.style.selected.prefix),n.style.unselectedPrefix!==void 0&&(s.unselectedPrefix=n.style.unselectedPrefix),n.style.selected?.fg!==void 0&&(s.selectedFg=n.style.selected.fg),n.style.selected?.bg!==void 0&&(s.selectedBg=n.style.selected.bg),n.style.item?.fg!==void 0&&(s.itemFg=n.style.item.fg),n.style.item?.bg!==void 0&&(s.itemBg=n.style.item.bg),n.style.disabledFg!==void 0&&(s.disabledFg=n.style.disabledFg),ka$1(t,s);}let a={eid:t,show(){return j$1(e,t,true),a},hide(){return j$1(e,t,false),a},move(s,l){return E$1.x[t]=(E$1.x[t]??0)+s,E$1.y[t]=(E$1.y[t]??0)+l,g(e,t),a},setPosition(s,l){return F(e,t,s,l),a},focus(){return ga(e,t),a},blur(){return ha$1(e,t),a},setItems(s){let l=s.map(u=>({text:u,value:u}));return j$2(e,t,l),a},getItems(){return i(t)},addItem(s,l){let u=[...i(t)];return u.push({text:s,value:l??s}),j$2(e,t,u),a},removeItem(s){return l$2(e,t,s),a},clearItems(){return p$1(e,t),a},select(s){return N(e,t,s),a},getSelectedIndex(){return L(t)},getSelectedItem(){return M(t)},selectPrev(){return O(e,t),a},selectNext(){return P(e,t),a},selectFirst(){return Q$1(e,t),a},selectLast(){return R(e,t),a},activate(){return U(e,t),a},pageUp(){return v$1(e,t,-1),a},pageDown(){return v$1(e,t,1),a},startSearch(){return Ga$1(e,t),a},endSearch(){return Ha$1(e,t),a},getSearchQuery(){return Ia$1(t)},isSearching(){return Fa$1(e,t)},getState(){return ba$1(e,t)},onSelect(s){return V(t,s)},onActivate(s){return W(t,s)},onCancel(s){return X(t,s)},onSearchChange(s){return Pa$1(t,s)},getSelected(){return ta(t)},selectAll(){return ua(t),a},deselectAll(){return va$1(t),a},setFilter(s){return na(e,t,s),a},clearFilter(){return oa(e,t),a},getVisibleItems(){return pa$1(t)},handleKey(s){let l=Qa$1(e,t,s);if(l)switch(l.type){case "selectPrev":O(e,t);break;case "selectNext":P(e,t);break;case "selectFirst":Q$1(e,t);break;case "selectLast":R(e,t);break;case "pageUp":v$1(e,t,-1);break;case "pageDown":v$1(e,t,1);break;case "confirm":U(e,t);break;case "cancel":Y$2(t),ha$1(e,t);break;case "toggleSelect":{let u=L(t);u>=0&&sa(t,u);break}case "startSearch":Ga$1(e,t);break;case "endSearch":Ha$1(e,t);break;case "searchChar":Ka$1(e,t,l.char);break;case "searchBackspace":La$1(e,t);break;case "searchNextMatch":Oa$1(e,t);break}return l},destroy(){Z$1(t),Ma$1(e,t),e$3(e,t);}};return a}function Vf(e,r){return aa$1(e,r)}var _f=1e4,Li={isCommandPalette:new Uint8Array(_f)},Of=z.object({id:z.string(),label:z.string(),description:z.string().optional(),shortcut:z.string().optional(),category:z.string().optional(),handler:z.function().nullable().optional()}),Gf=z.object({inputFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),inputBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),listFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),listBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),selectedFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),selectedBg:z.union([z.string(),z.number().int().nonnegative()]).optional(),shortcutFg:z.union([z.string(),z.number().int().nonnegative()]).optional(),descriptionFg:z.union([z.string(),z.number().int().nonnegative()]).optional()}),Ju=z.object({commands:z.array(Of).optional(),placeholder:z.string().optional(),maxResults:z.number().int().positive().optional(),theme:Gf.optional(),width:z.number().int().positive().optional(),onClose:z.function().nullable().optional()}),Zn=new Map;function Nf(){Zn.clear(),Li.isCommandPalette.fill(0);}function zf(e,r,o){return r.trim()?d$7(r,e,{getText:t=>[t.label,t.description,t.category].filter(Boolean).join(" "),limit:o}).map(t=>({...t.item,match:t})):e.slice(0,o)}function qu(e){let r=Zn.get(e);r&&g(r.world,r.listEntity);}function wf(e){let r=Zn.get(e);if(!r||r.filteredCommands.length===0)return;let o=r.filteredCommands[r.selectedIndex];if(o){Zu(e);try{let n=o.handler();n instanceof Promise&&n.catch(t=>{console.error(`Command ${o.id} failed:`,t);});}catch(n){console.error(`Command ${o.id} failed:`,n);}}}function Hf(e){let r=Zn.get(e);r&&(r.visible=true,j$1(r.world,e,true),j$1(r.world,r.inputEntity,true),j$1(r.world,r.listEntity,true),g(r.world,e));}function Zu(e){let r=Zn.get(e);r&&(r.visible=false,j$1(r.world,e,false),j$1(r.world,r.inputEntity,false),j$1(r.world,r.listEntity,false),r.onClose?.(),g(r.world,e));}function Uf(e,r,o={}){let n=Ju.omit({commands:true,onClose:true}).parse(o),t=o.commands??[],i=n.placeholder??"Type a command...",a=n.maxResults??10,s=n.width??60,l=n.theme;pt(e,r),F(e,r,0,0),j$1(e,r,false);let u=d$1(e);if(pt(e,u),F(e,u,1,1),d$2(e,r,u),ia(e,u),Ua$1(e,u,{placeholder:i}),l?.inputFg!==void 0||l?.inputBg!==void 0){let c=typeof l.inputFg=="string"?e$1(l.inputFg):l.inputFg,b=typeof l.inputBg=="string"?e$1(l.inputBg):l.inputBg;d(e,u,{fg:c,bg:b});}let d$3=d$1(e);F(e,d$3,1,3),d$2(e,r,d$3);let f={items:[],width:s-2,height:Math.min(a+2,12)};if(l?.listFg!==void 0||l?.listBg!==void 0){let c=typeof l.listFg=="string"?e$1(l.listFg):l.listFg,b=typeof l.listBg=="string"?e$1(l.listBg):l.listBg;(c!==void 0||b!==void 0)&&d(e,d$3,{fg:c,bg:b});}Dr(e,d$3,f);let g={world:e,inputEntity:u,listEntity:d$3,commands:t,filteredCommands:t.slice(0,a),selectedIndex:0,maxResults:a,onClose:o.onClose,visible:false};return Zn.set(r,g),ab$2(e,u,c=>{let b=zf(g.commands,c,g.maxResults);g.filteredCommands=b,g.selectedIndex=0,qu(r);}),bb$1(e,u,()=>{wf(r);}),Li.isCommandPalette[r]=1,{entity:r,world:e,show(){Hf(r);},hide(){Zu(r);},executeCommand(c){let b=g.commands.find(p=>p.id===c);if(b)try{let p=b.handler();p instanceof Promise&&p.catch(y=>{console.error(`Command ${c} failed:`,y);});}catch(p){console.error(`Command ${c} failed:`,p);}},setCommands(c){g.commands=c,g.filteredCommands=c.slice(0,g.maxResults),g.selectedIndex=0,qu(r);}}}function $f(e){return Li.isCommandPalette[e]===1}function jf(e){return e===""?[]:e.split(`
|
|
5
|
-
`)}function fn(e){return e.join(`
|
|
6
|
-
`)}function Gt(e,r){let o=f$2(e,r);return jf(o)}function Yf(e,r){let o=f$2(e,r);if(o==="")return 0;let n=1;for(let t of o)t===`
|
|
7
|
-
`&&n++;return n}function ed(e,r,o){let n=Gt(e,r);return o<0||o>=n.length?"":n[o]??""}function td(e,r,o,n){let t=Gt(e,r);return o<0||o>=t.length||(t[o]=n,e$2(e,r,fn(t)),g(e,r)),r}function Kf(e,r,o){return ed(e,r,o)}function Qf(e,r,o,n){return td(e,r,o,n)}function va(e,r,o,n){let t=Gt(e,r),i=Math.max(0,Math.min(o,t.length));if(t.splice(i,0,n),e$2(e,r,fn(t)),g(e,r),t$1(e,r)){let a=n$1(e,r);i<=a.y&&m$1(e,r,a.x,a.y+1);}return r}function nd(e,r,o){return va(e,r,0,o)}function rd(e,r,o){let n=Gt(e,r);return va(e,r,n.length,o)}function La(e,r,o,n=1){let t=Gt(e,r);if(o<0||o>=t.length||n<=0)return r;let i=Math.min(n,t.length-o);if(t.splice(o,i),e$2(e,r,fn(t)),g(e,r),t$1(e,r)){let a=n$1(e,r),s=Math.max(0,t.length-1),l=a.y;if(o<a.y){let u=Math.min(i,a.y-o);l=a.y-u;}l=Math.max(0,Math.min(l,s)),m$1(e,r,a.x,l);}return r}function Xf(e,r,o=1){return La(e,r,0,o)}function qf(e,r,o=1){let n=Gt(e,r);if(n.length===0)return r;let t=Math.max(0,n.length-o);return La(e,r,t,o)}function Jf(e,r){return e$2(e,r,""),g(e,r),t$1(e,r)&&m$1(e,r,0,0),r}function Zf(e,r,o){if(e$2(e,r,fn(o)),g(e,r),t$1(e,r)){let n=n$1(e,r),t=Math.max(0,o.length-1);n.y>t&&m$1(e,r,n.x,t);}return r}function eb(e,r,o){return rd(e,r,o)}function tb(e,r){let o=Gt(e,r);if(o.length===0)return "";let n=o.pop()??"";if(e$2(e,r,fn(o)),g(e,r),t$1(e,r)){let t=n$1(e,r),i=Math.max(0,o.length-1);t.y>i&&m$1(e,r,t.x,i);}return n}function nb(e,r){let o=Gt(e,r);if(o.length===0)return "";let n=o.shift()??"";if(e$2(e,r,fn(o)),g(e,r),t$1(e,r)){let t=n$1(e,r);t.y>0&&m$1(e,r,t.x,t.y-1);}return n}function rb(e,r,o){return nd(e,r,o)}function ob(e,r,o,n){let t=Gt(e,r);if(o<0||o>=t.length)return r;for(let i=0;i<n.length;i++){let a=o+i;if(a>=t.length)break;t[a]=n[i]??"";}return e$2(e,r,fn(t)),g(e,r),r}function ib(e,r,o,n,t){let i=Gt(e,r),a=t?i.splice(o,n,...t):i.splice(o,n);if(e$2(e,r,fn(i)),g(e,r),t$1(e,r)){let s=(t?.length??0)-a.length,l=n$1(e,r);if(o<=l.y&&s!==0){let u=Math.max(0,l.y+s),d=Math.max(0,i.length-1);m$1(e,r,l.x,Math.min(u,d));}else {let u=Math.max(0,i.length-1);l.y>u&&m$1(e,r,l.x,u);}}return a}n();f();u();n();f();var ab="top",ud=" \u2502 ",dd="\u2715",od=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),id=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),sb=z.object({label:z.string(),content:z.union([z.number(),z.function()]).optional(),closable:z.boolean().optional()}),lb=z.object({activeFg:z.union([z.string(),z.number()]).optional(),activeBg:z.union([z.string(),z.number()]).optional(),inactiveFg:z.union([z.string(),z.number()]).optional(),inactiveBg:z.union([z.string(),z.number()]).optional()}),ub=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),db=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),cb=z.object({tab:lb.optional(),content:ub.optional(),border:db.optional()}),cd=z.object({left:od.optional(),top:od.optional(),width:id.optional(),height:id.optional(),tabs:z.array(sb).optional(),activeTab:z.number().nonnegative().optional(),position:z.enum(["top","bottom"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),style:cb.optional()}),Ei=1e4,ge={isTabs:new Uint8Array(Ei),activeTab:new Uint16Array(Ei),position:new Uint8Array(Ei),tabCount:new Uint16Array(Ei)},Ft=a({iterable:true});function gb(e){return {label:e.label,contentEntity:typeof e.content=="number"?e.content:null,lazyLoader:typeof e.content=="function"?e.content:null,closable:e.closable??false,loaded:typeof e.content=="number"}}function mb(e,r){let o=r?r.map(gb):[];return Ft.set(e,o),o}function ad(e){return e===void 0?0:typeof e=="number"?e:0}function sd(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function fb(e,r){if(e==="Tab"||e==="right")return r.nextTab(),{type:"next"};if(e==="S-Tab"||e==="left")return r.prevTab(),{type:"prev"};if(e>="1"&&e<="9"){let o=Number.parseInt(e,10)-1,n=r.getTabCount();if(o<n)return r.setActiveTab(o),{type:"goto",index:o}}return null}function bb(e,r,o){(o.fg!==void 0||o.bg!==void 0)&&d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function pb(e,r,o){let n=o.style?.border;n?.type!=="none"&&l(e,r,{type:n?.type==="bg"?2:1,fg:n?.fg!==void 0?e$1(n.fg):void 0,bg:n?.bg!==void 0?e$1(n.bg):void 0});}function ld(e,r,o){let n=Ft.get(r);if(!n||o<0||o>=n.length)return;let t=n[o];t&&!t.loaded&&t.lazyLoader&&(t.contentEntity=t.lazyLoader(),t.loaded=true,t.contentEntity!==null&&d$2(e,r,t.contentEntity));}function Ea(e,r){let o=Ft.get(r);if(!o)return;let n=ge.activeTab[r];for(let t=0;t<o.length;t++){let i=o[t];i?.contentEntity!==null&&i?.contentEntity!==void 0&&j$1(e,i.contentEntity,t===n);}}function Fr(e,r,o={}){let n=cd.parse(o),t=r;ge.isTabs[t]=1,ge.position[t]=n.position==="bottom"?1:0;let i=mb(t,n.tabs);ge.tabCount[t]=i.length;let a=Math.min(n.activeTab??0,Math.max(0,i.length-1));ge.activeTab[t]=a,F(e,t,ad(n.left),ad(n.top)),w(e,t,sd(n.width),sd(n.height)),bb(e,t,n),pb(e,t,n),Y(e,t,{focusable:true}),j$1(e,t,true),i.length>0&&(ld(e,t,a),Ea(e,t));let s={eid:t,show(){return j$1(e,t,true),s},hide(){return j$1(e,t,false),s},move(l,u){return K(e,t,l,u),g(e,t),s},setPosition(l,u){return F(e,t,l,u),g(e,t),s},addTab(l){let u=Ft.get(t)??[],d={label:l.label,contentEntity:typeof l.content=="number"?l.content:null,lazyLoader:typeof l.content=="function"?l.content:null,closable:l.closable??false,loaded:typeof l.content=="number"};return u.push(d),Ft.set(t,u),ge.tabCount[t]=u.length,g(e,t),s},removeTab(l){let u=Ft.get(t);return !u||l<0||l>=u.length||(u.splice(l,1),ge.tabCount[t]=u.length,ge.activeTab[t]>=u.length&&u.length>0?ge.activeTab[t]=u.length-1:u.length===0&&(ge.activeTab[t]=0),Ea(e,t),g(e,t)),s},getActiveTab(){return ge.activeTab[t]},setActiveTab(l){let u=Ft.get(t);return !u||l<0||l>=u.length||(ge.activeTab[t]=l,ld(e,t,l),Ea(e,t),g(e,t)),s},getTabCount(){return ge.tabCount[t]},getTab(l){let u=Ft.get(t);if(!(!u||l<0||l>=u.length))return u[l]},setTabLabel(l,u){let d=Ft.get(t);if(!d||l<0||l>=d.length)return s;let f=d[l];return f&&(f.label=u),g(e,t),s},nextTab(){let l=ge.tabCount[t];if(l===0)return s;let d=(ge.activeTab[t]+1)%l;return s.setActiveTab(d)},prevTab(){let l=ge.tabCount[t];if(l===0)return s;let u=ge.activeTab[t],d=u===0?l-1:u-1;return s.setActiveTab(d)},focus(){return aa(e,t),s},blur(){return ba(e,t),s},isFocused(){return _(e,t)},getChildren(){return f$1(e,t)},handleKey(l){return s.isFocused()?fb(l,s):null},destroy(){ge.isTabs[t]=0,ge.activeTab[t]=0,ge.position[t]=0,ge.tabCount[t]=0,Ft.delete(t),e$3(e,t);}};return s}function yb(e,r){return ge.isTabs[r]===1}function hb(e,r){return ge.activeTab[r]}function xb(e,r){return ge.tabCount[r]}function Cb(e,r){return ge.position[r]===1?"bottom":"top"}function Sb(e,r,o){let n=Ft.get(r);if(!n||n.length===0)return " ".repeat(o);let t=ge.activeTab[r],i="";for(let a=0;a<n.length;a++){let s=n[a];if(!s)continue;a>0&&(i+=ud);let l=a===t?`[${s.label}]`:` ${s.label} `,u=s.closable?` ${dd}`:"";i+=l+u;}return i.length>o?i=`${i.slice(0,o-1)}\u2026`:i.length<o&&(i=i+" ".repeat(o-i.length)),i}function Tb(){ge.isTabs.fill(0),ge.activeTab.fill(0),ge.position.fill(0),ge.tabCount.fill(0),Ft.clear();}var Wb=1e4,Ba={isDevTools:new Uint8Array(Wb)},md=z.object({position:z.enum(["bottom","right","floating"]).optional().default("bottom"),initialTab:z.enum(["entities","components","systems","events"]).optional().default("entities"),theme:z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional(),borderBg:z.union([z.string(),z.number()]).optional(),tabActiveFg:z.union([z.string(),z.number()]).optional(),tabActiveBg:z.union([z.string(),z.number()]).optional(),tabInactiveFg:z.union([z.string(),z.number()]).optional(),tabInactiveBg:z.union([z.string(),z.number()]).optional()}).optional(),left:z.number().optional(),top:z.number().optional(),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),scheduler:z.any().optional()}),Oe=new Map;function vb(e,r){let t={left:0,top:0,width:80,height:8};switch(e){case "bottom":t={left:0,top:Math.floor(48/3),width:80,height:Math.floor(24/3)};break;case "right":t={left:Math.floor(160/3),top:0,width:Math.floor(80/3),height:24};break;case "floating":t={left:Math.floor(80/4),top:Math.floor(24/4),width:Math.floor(80/2),height:Math.floor(24/2)};break}return {left:r.left??t.left,top:r.top??t.top,width:r.width??t.width,height:r.height??t.height}}function Bi(e,r){let o=g$2(e),n=[];for(let t of o){if(!f$4(e,t))continue;let i=[],a={eid:t,components:i};r&&!i.some(l=>l.name.toLowerCase().includes(r.toLowerCase()))||n.push(a);}return n}function gd(e){if(!e)return [];let r=[0,1,2,3,4,5,6,7],o=e.getTelemetry();return r.map(n=>{let t=e.getSystemCount(n),i=o?.phases.find(s=>s.phase===n),a={phase:n,systemCount:t};return i?.duration!==void 0&&(a.frameTime=i.duration),a})}function Lb(e,r,o={}){let n=md.parse(o),t=r;Ba.isDevTools[t]=1;let i={};n.left!==void 0&&(i.left=n.left),n.top!==void 0&&(i.top=n.top),n.width!==void 0&&(i.width=n.width),n.height!==void 0&&(i.height=n.height);let a=vb(n.position,i);F(e,t,a.left,a.top),w(e,t,a.width,a.height),Y(e,t,{focusable:true});let s=n.theme;if(s){let b=s.fg?e$1(s.fg):void 0,p=s.bg?e$1(s.bg):void 0;(b!==void 0||p!==void 0)&&d(e,t,{fg:b,bg:p});}let l=d$1(e);d$2(e,t,l);let u;s&&(u={},(s.tabActiveFg!==void 0||s.tabActiveBg!==void 0||s.tabInactiveFg!==void 0||s.tabInactiveBg!==void 0)&&(u.tab={...s.tabActiveFg!==void 0&&{activeFg:s.tabActiveFg},...s.tabActiveBg!==void 0&&{activeBg:s.tabActiveBg},...s.tabInactiveFg!==void 0&&{inactiveFg:s.tabInactiveFg},...s.tabInactiveBg!==void 0&&{inactiveBg:s.tabInactiveBg}}),(s.borderFg!==void 0||s.borderBg!==void 0)&&(u.border={...s.borderFg!==void 0&&{fg:s.borderFg},...s.borderBg!==void 0&&{bg:s.borderBg}}));let d$3={left:0,top:0,width:a.width,height:a.height,tabs:[{label:"Entities",content:d$1(e)},{label:"Components",content:d$1(e)},{label:"Systems",content:d$1(e)},{label:"Events",content:d$1(e)}],activeTab:["entities","components","systems","events"].indexOf(n.initialTab)};u&&(d$3.style=u);let f=Fr(e,l,d$3),g$1={world:e,tabsWidget:f,currentTab:n.initialTab,visible:false,entities:[],systems:[],eventLog:[],filter:null,scheduler:n.scheduler??null};g$1.entities=Bi(e,null),g$1.systems=gd(g$1.scheduler),Oe.set(t,g$1),j$1(e,t,false);let c={eid:t,show(){let b=Oe.get(t);return b&&(b.visible=true,j$1(e,t,true),g(e,t)),c},hide(){let b=Oe.get(t);return b&&(b.visible=false,j$1(e,t,false),g(e,t)),c},toggle(){let b=Oe.get(t);return b&&(b.visible?c.hide():c.show()),c},isVisible(){return Oe.get(t)?.visible??false},focus(){return aa(e,t),c},blur(){return ba(e,t),c},setTab(b){let p=Oe.get(t);if(p){p.currentTab=b;let y=["entities","components","systems","events"].indexOf(b);p.tabsWidget.setActiveTab(y),g(e,t);}return c},getTab(){return Oe.get(t)?.currentTab??"entities"},refreshEntities(){let b=Oe.get(t);return b&&(b.entities=Bi(b.world,b.filter),g(e,t)),c},getEntities(){return Oe.get(t)?.entities??[]},getEntity(b){return Oe.get(t)?.entities.find(y=>y.eid===b)},getSystems(){return Oe.get(t)?.systems??[]},refreshSystems(){let b=Oe.get(t);return b&&(b.systems=gd(b.scheduler),g(e,t)),c},logEvent(b,p){let y=Oe.get(t);return y&&(y.eventLog.push({timestamp:Date.now(),type:b,data:p}),y.eventLog.length>100&&(y.eventLog=y.eventLog.slice(-100)),g(e,t)),c},getEventLog(){return Oe.get(t)?.eventLog??[]},clearEventLog(){let b=Oe.get(t);return b&&(b.eventLog=[],g(e,t)),c},filterByComponent(b){let p=Oe.get(t);return p&&(p.filter=b,p.entities=Bi(p.world,b),g(e,t)),c},clearFilter(){let b=Oe.get(t);return b&&(b.filter=null,b.entities=Bi(b.world,null),g(e,t)),c},destroy(){let b=Oe.get(t);b&&b.tabsWidget.destroy(),Oe.delete(t),e$3(e,t);}};return c}function Eb(e,r){return Ba.isDevTools[r]===1}function Bb(){Oe.clear();}u();n();f();var fd=1e4,Mb=40,kb=20,Rb="\u{1F4C1}",Ib="\u{1F4C4}",Vb="\u2B06\uFE0F",_b="..",Ob=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),Gb=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),pd=z.object({cwd:z.string().optional(),showHidden:z.boolean().optional().default(false),filePattern:z.string().optional(),sortBy:z.enum(["name","size","date"]).optional().default("name"),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),left:z.number().int().optional(),top:z.number().int().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Ob.optional(),padding:Gb.optional(),showIcons:z.boolean().optional().default(true)}),Ee={isFileManager:new Uint8Array(fd),selectedIndex:new Uint32Array(fd)},He=new Map;function Nb(e){return typeof e=="object"?e:e===void 0||e==="single"?b$1:b$1}function zb(e,r){let n=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`,"i").test(e)}function wb(e){try{let r=readdirSync(e),o=[];for(let n of r){let t=join(e,n);try{let i=statSync(t);o.push({name:n,path:t,isDirectory:i.isDirectory(),size:i.isDirectory()?0:i.size,mtime:i.mtimeMs});}catch{}}return o}catch{return []}}function Hb(e,r){return [...e].sort((o,n)=>{if(o.isDirectory!==n.isDirectory)return o.isDirectory?-1:1;switch(r){case "size":return o.size!==n.size?n.size-o.size:o.name.localeCompare(n.name);case "date":return o.mtime!==n.mtime?n.mtime-o.mtime:o.name.localeCompare(n.name);default:return o.name.localeCompare(n.name)}})}function Ub(e,r,o){return e.filter(n=>!(!r&&n.name.startsWith(".")||o&&!n.isDirectory&&!zb(n.name,o)))}function Qt(e){let r;try{r=e.readDirFn(e.cwd);}catch{return []}let o=Ub(r,e.showHidden,e.filePattern);return Hb(o,e.sortBy)}function $b(e){let r=[],o=e.width-4,n=e.cwd;n.length>o&&(n=`...${n.slice(-(o-3))}`),r.push(`[${n}]`);let t=Ee.selectedIndex[0]===-1?"> ":" ",i=e.showIcons?`${Vb} `:"";r.push(`${t}${i}${_b}`);for(let a=0;a<e.entries.length;a++){let s=e.entries[a],u=a===Ee.selectedIndex[0]?"> ":" ",d=e.showIcons?s.isDirectory?`${Rb} `:`${Ib} `:"";r.push(`${u}${d}${s.name}`);}return r.join(`
|
|
8
|
-
`)}function jb(e,r,o,n){o===void 0&&n===void 0||d(e,r,{fg:o!==void 0?e$1(o):void 0,bg:n!==void 0?e$1(n):void 0});}function Yb(e,r,o){if(o?.type==="none")return;let n=o?.type==="bg"?2:1;l(e,r,{type:n,fg:o?.fg!==void 0?e$1(o.fg):void 0,bg:o?.bg!==void 0?e$1(o.bg):void 0}),m(e,r,Nb(o?.ch));}function Kb(e,r,o){if(typeof o=="number"){b(e,r,{left:o,top:o,right:o,bottom:o});return}o&&b(e,r,{left:o.left??0,top:o.top??0,right:o.right??0,bottom:o.bottom??0});}function Mt(e,r,o){let n=$b(o);e$2(e,r,n,{align:0,valign:0}),g(e,r);}function Qb(e,r={}){let o=pd.parse(r),n=d$1(e),t=o.width??Mb,i=o.height??kb,a=o.cwd?resolve(o.cwd):process.cwd();Ee.isFileManager[n]=1,Ee.selectedIndex[n]=0;let s={cwd:a,showHidden:o.showHidden,showIcons:o.showIcons,filePattern:o.filePattern,sortBy:o.sortBy,width:t,height:i,entries:[],onSelectCallbacks:[],onNavigateCallbacks:[],onDeleteCallbacks:[],onRenameCallbacks:[],readDirFn:wb};return He.set(n,s),s.entries=Qt(s),F(e,n,o.left??0,o.top??0),w(e,n,t,i),jb(e,n,o.fg,o.bg),Yb(e,n,o.border),Kb(e,n,o.padding),Mt(e,n,s),j$1(e,n,true),Xb(e,n)}function Xb(e,r){let o={eid:r,show(){return j$1(e,r,true),g(e,r),o},hide(){return j$1(e,r,false),g(e,r),o},move(n,t){return K(e,r,n,t),g(e,r),o},setPosition(n,t){return F(e,r,n,t),g(e,r),o},center(n,t){let i=He.get(r);if(!i)return o;let a=Math.max(0,Math.floor((n-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return F(e,r,a,s),g(e,r),o},setCwd(n){let t=He.get(r);return t&&(t.cwd=resolve(n),t.entries=Qt(t),Ee.selectedIndex[r]=0,Mt(e,r,t)),o},getCwd(){return He.get(r)?.cwd??""},getSelected(){let n=He.get(r);if(!n)return;let t=Ee.selectedIndex[r]??0;return n.entries[t]},refresh(){let n=He.get(r);if(!n)return o;n.entries=Qt(n);let t=Math.max(0,n.entries.length-1);return (Ee.selectedIndex[r]??0)>t&&(Ee.selectedIndex[r]=t),Mt(e,r,n),o},getEntries(){return He.get(r)?.entries??[]},setSortBy(n){let t=He.get(r);return t&&(t.sortBy=n,t.entries=Qt(t),Mt(e,r,t)),o},getSortBy(){return He.get(r)?.sortBy??"name"},toggleHidden(){let n=He.get(r);return n&&(n.showHidden=!n.showHidden,n.entries=Qt(n),Ee.selectedIndex[r]=0,Mt(e,r,n)),o},onSelect(n){let t=He.get(r);return t&&t.onSelectCallbacks.push(n),o},onNavigate(n){let t=He.get(r);return t&&t.onNavigateCallbacks.push(n),o},onDelete(n){let t=He.get(r);return t&&t.onDeleteCallbacks.push(n),o},onRename(n){let t=He.get(r);return t&&t.onRenameCallbacks.push(n),o},destroy(){Ee.isFileManager[r]=0,Ee.selectedIndex[r]=0,He.delete(r),e$3(e,r);}};return o}function qb(e,r,o){let n=Ee.selectedIndex[r]??0,t=o.entries[n];if(t)if(t.isDirectory)yd(e,r,o,t.path);else for(let i of o.onSelectCallbacks)i(t);}function yd(e,r,o,n){o.cwd=n,o.entries=Qt(o),Ee.selectedIndex[r]=0,Mt(e,r,o);for(let t of o.onNavigateCallbacks)t(n);}function Jb(e,r,o){if(Ee.isFileManager[r]!==1)return false;let n=He.get(r);if(!n)return false;switch(o){case "up":{let t=Ee.selectedIndex[r]??0;return t>0&&(Ee.selectedIndex[r]=t-1,Mt(e,r,n)),true}case "down":{let t=Ee.selectedIndex[r]??0;return t<n.entries.length-1&&(Ee.selectedIndex[r]=t+1,Mt(e,r,n)),true}case "enter":return qb(e,r,n),true;case "backspace":{let t=dirname(n.cwd);return t!==n.cwd&&yd(e,r,n,t),true}case "h":return n.showHidden=!n.showHidden,n.entries=Qt(n),Ee.selectedIndex[r]=0,Mt(e,r,n),true;case "d":{let t=Ee.selectedIndex[r]??0,i=n.entries[t];if(i)for(let a of n.onDeleteCallbacks)a(i);return true}case "r":{let t=Ee.selectedIndex[r]??0,i=n.entries[t];if(i)for(let a of n.onRenameCallbacks)a(i,i.name);return true}case "n":return n.sortBy="name",n.entries=Qt(n),Mt(e,r,n),true;case "s":return n.sortBy="size",n.entries=Qt(n),Mt(e,r,n),true;case "t":return n.sortBy="date",n.entries=Qt(n),Mt(e,r,n),true;default:return false}}function Zb(e,r){return Ee.isFileManager[r]===1}function ep(){Ee.isFileManager.fill(0),Ee.selectedIndex.fill(0),He.clear();}function tp(e,r){let o=He.get(e);o&&(o.readDirFn=r);}n();f();var np=1e4,Aa={isFlexContainer:new Uint8Array(np)},hd=z.object({flex:z.number().nonnegative().optional().default(0),flexShrink:z.number().nonnegative().optional().default(1),flexBasis:z.union([z.number().nonnegative(),z.literal("auto")]).optional().default("auto"),alignSelf:z.enum(["start","center","end","stretch"]).optional()}),xd=z.object({direction:z.enum(["row","column"]).optional().default("row"),justifyContent:z.enum(["start","center","end","space-between","space-around","space-evenly"]).optional().default("start"),alignItems:z.enum(["start","center","end","stretch"]).optional().default("stretch"),gap:z.number().nonnegative().optional().default(0),wrap:z.enum(["nowrap","wrap"]).optional().default("nowrap"),left:z.number().optional().default(0),top:z.number().optional().default(0),width:z.union([z.number(),z.string()]).optional().default("auto"),height:z.union([z.number(),z.string()]).optional().default("auto"),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),yt=new Map;function rp(e,r,o){let n=x(e,r),t=G$3(e,r);if(!n||!t)return;let i=n.width,a=n.height,s=o.children;if(s.length===0)return;let l=o.direction==="row",u=l?i:a,d=op(e,s,u,o.gap,l,o.wrap),f=0;for(let g$1 of d){let c=g$1.mainSize,b=g$1.crossSize,{positions:p,sizes:y}=ap(g$1.children,u,c,o.gap,o.justifyContent);for(let v=0;v<g$1.children.length;v++){let x=g$1.children[v];if(!x)continue;let T=x.entity,P=p[v]??0,D=y[v]??0,L=x.alignSelf??o.alignItems,R=Sd(e,T,l),Y=sp(L,b,R);l?(F(e,T,t.x+P,t.y+f+Y),w(e,T,D,R)):(F(e,T,t.x+Y,t.y+f+P),w(e,T,R,D)),g(e,T);}f+=b+o.gap;}}function op(e,r,o,n,t,i){if(i==="nowrap"){let u=ip(e,r,n,t),d=Pa(e,r,t);return [{children:r,mainSize:u,crossSize:d}]}let a=[],s=[],l=0;for(let u of r){let d=Cd(e,u.entity,t,u.flexBasis),f=s.length===0?d:n+d;s.length>0&&l+f>o?(a.push({children:s,mainSize:l-n,crossSize:Pa(e,s,t)}),s=[u],l=d):(s.push(u),l+=f);}return s.length>0&&a.push({children:s,mainSize:l-(s.length>0?n:0),crossSize:Pa(e,s,t)}),a}function ip(e,r,o,n){let t=0;for(let i=0;i<r.length;i++){let a=r[i];a&&(i>0&&(t+=o),t+=Cd(e,a.entity,n,a.flexBasis));}return t}function Pa(e,r,o){let n=0;for(let t of r){let i=Sd(e,t.entity,o);n=Math.max(n,i);}return n}function Cd(e,r,o,n){if(n!=="auto")return n;let t=x(e,r);return t?o?t.width:t.height:0}function Sd(e,r,o){let n=x(e,r);return n?o?n.height:n.width:0}function ap(e,r,o,n,t){let i=[],a=[];if(e.length===0)return {positions:i,sizes:a};let s=0,l=0;for(let y of e)s+=y.flex,l+=y.flexShrink;let u=n*(e.length-1),f=r-u-o,g=[];for(let y of e){let v=0;y.flexBasis==="auto"?v=10:v=y.flexBasis,f>0&&s>0?v+=f*y.flex/s:f<0&&l>0&&(v+=f*y.flexShrink/l),g.push(Math.max(0,v));}let c=0,b=g.reduce((y,v)=>y+v,0)+u,p=r-b;switch(t){case "start":c=0;break;case "center":c=p/2;break;case "end":c=p;break;case "space-between":c=0;break;case "space-around":c=p/(e.length*2);break;case "space-evenly":c=p/(e.length+1);break}for(let y=0;y<e.length;y++)i.push(c),a.push(g[y]??0),t==="space-between"&&e.length>1?c+=(g[y]??0)+n+p/(e.length-1):t==="space-around"?c+=(g[y]??0)+n+p/e.length:t==="space-evenly"?c+=(g[y]??0)+n+p/(e.length+1):c+=(g[y]??0)+n;return {positions:i,sizes:a}}function sp(e,r,o){switch(e){case "start":return 0;case "center":return (r-o)/2;case "end":return r-o;case "stretch":return 0}}function lp(e,r,o={}){let n=xd.parse(o),t=r;Aa.isFlexContainer[t]=1,F(e,t,n.left,n.top),w(e,t,n.width,n.height),Y(e,t,{focusable:true});let i=n.fg?e$1(n.fg):void 0,a=n.bg?e$1(n.bg):void 0;(i!==void 0||a!==void 0)&&d(e,t,{fg:i,bg:a});let s={direction:n.direction,justifyContent:n.justifyContent,alignItems:n.alignItems,gap:n.gap,wrap:n.wrap,children:[]};yt.set(t,s);let l={eid:t,show(){return j$1(e,t,true),g(e,t),l},hide(){return j$1(e,t,false),g(e,t),l},move(u,d){return K(e,t,u,d),g(e,t),l},setPosition(u,d){return F(e,t,u,d),g(e,t),l},addChild(u,d={}){let f=yt.get(t);if(!f)return l;let g$1=hd.parse(d),c=i$1(e,u);return c!==a$2?(console.warn(`Child entity ${u} is already attached to parent ${c}`),l):(d$2(e,t,u),f.children.push({entity:u,flex:g$1.flex,flexShrink:g$1.flexShrink,flexBasis:g$1.flexBasis,alignSelf:g$1.alignSelf}),g(e,t),l)},removeChild(u){let d=yt.get(t);if(!d)return l;let f=d.children.findIndex(g=>g.entity===u);return f!==-1&&(d.children.splice(f,1),g(e,t)),l},getChildren(){return yt.get(t)?.children.map(d=>d.entity)??[]},setDirection(u){let d=yt.get(t);return d&&(d.direction=u,g(e,t)),l},setJustifyContent(u){let d=yt.get(t);return d&&(d.justifyContent=u,g(e,t)),l},setAlignItems(u){let d=yt.get(t);return d&&(d.alignItems=u,g(e,t)),l},setGap(u){let d=yt.get(t);return d&&(d.gap=u,g(e,t)),l},setWrap(u){let d=yt.get(t);return d&&(d.wrap=u,g(e,t)),l},layout(){let u=yt.get(t);return u&&rp(e,t,u),l},focus(){return aa(e,t),l},blur(){return ba(e,t),l},isFocused(){return _(e,t)},destroy(){yt.delete(t),e$3(e,t);}};return l}function up(e,r,o,n={}){let t=yt.get(r);if(!t){console.warn(`Entity ${r} is not a flex container`);return}let i=hd.parse(n),a=i$1(e,o);if(a!==a$2&&a!==r){console.warn(`Child entity ${o} is already attached to parent ${a}`);return}d$2(e,r,o),t.children.push({entity:o,flex:i.flex,flexShrink:i.flexShrink,flexBasis:i.flexBasis,alignSelf:i.alignSelf}),g(e,r);}function dp(e,r){return Aa.isFlexContainer[r]===1}function cp(){yt.clear();}n();f();var gp=1e4,Td={isFooter:new Uint8Array(gp)},Wd=z.object({status:z.string().optional().default(""),left:z.string().optional(),center:z.string().optional(),right:z.string().optional(),height:z.number().int().positive().optional().default(1),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional().default("left")}),er=new Map;function Mr(e,r,o){let{left:n,center:t,right:i,status:a}=e;if(n||t||i){let s=n||"",l=t||"",u=i||"",d=s.length,f=l.length,g=u.length,c=d+f+g;if(r-c>=2){let p=Math.floor((r-f)/2),y=Math.max(0,p-d),v=p+f,x=Math.max(0,r-v-g);return s+" ".repeat(y)+l+" ".repeat(x)+u}return `${s} ${l} ${u}`.slice(0,r)}if(a){if(o==="center"){let s=Math.max(0,Math.floor((r-a.length)/2));return " ".repeat(s)+a}if(o==="right"){let s=Math.max(0,r-a.length);return " ".repeat(s)+a}return a}return ""}function mp(e,r,o={}){let n=Wd.parse(o),t=r;Td.isFooter[t]=1,F(e,t,0,0),w(e,t,"auto",n.height);let i=n.fg?e$1(n.fg):void 0,a=n.bg?e$1(n.bg):void 0;(i!==void 0||a!==void 0)&&d(e,t,{fg:i,bg:a});let s={status:n.status,left:n.left||"",center:n.center||"",right:n.right||""};er.set(t,s);let l=80,u=Mr(s,l,n.align);e$2(e,t,u,{align:0});let d$1={eid:t,show(){return j$1(e,t,true),g(e,t),d$1},hide(){return j$1(e,t,false),g(e,t),d$1},setStatus(f){let g$1=er.get(t);if(g$1){g$1.status=f;let c=Mr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setLeft(f){let g$1=er.get(t);if(g$1){g$1.left=f;let c=Mr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setCenter(f){let g$1=er.get(t);if(g$1){g$1.center=f;let c=Mr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setRight(f){let g$1=er.get(t);if(g$1){g$1.right=f;let c=Mr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},getContent(){return f$2(e,t)},destroy(){er.delete(t),e$3(e,t);}};return d$1}n();var Ld=z.object({x:z.number().int().default(0),y:z.number().int().default(0)}),fp=1e4,kr={isForm:new Uint8Array(fp)},Ie=new Map;function Ma(e){if("getValue"in e)return e.getValue();if("isChecked"in e)return e.isChecked();if("getSelectedValue"in e)return e.getSelectedValue()}function bp(e){"setValue"in e&&typeof e.setValue=="function"?e.setValue(""):"setChecked"in e&&typeof e.setChecked=="function"?e.setChecked(false):"clearSelection"in e&&typeof e.clearSelection=="function"&&e.clearSelection();}function Ed(e){let r=Ie.get(e);if(!r)return;let o={};for(let[n,t]of r.fields)o[n]=Ma(t);for(let n of r.onChangeCallbacks)n(o);}function pp(e,r){let o=Ie.get(e);if(o)for(let n of o.onValidationErrorCallbacks)n(r);}function yp(e,r){"onChange"in r&&typeof r.onChange=="function"&&r.onChange(()=>{Ed(e);});}function hp(e,r){return e==="tab"?(r.focusNext(),true):e==="S-tab"||e==="shift-tab"?(r.focusPrevious(),true):e==="enter"||e==="return"?(r.submit(),true):false}function xp(e,r){if(e.focusedIndex<0)return false;let o=e.fieldOrder[e.focusedIndex];if(!o)return false;let n=e.fields.get(o);return !n||!("handleKey"in n)||typeof n.handleKey!="function"?false:n.handleKey(r)}function vd(e,r){if(r.focusedIndex<0)return;let o=r.fieldOrder[r.focusedIndex];if(!o)return;let n=r.fields.get(o);n&&"blur"in n&&ba(e,n.eid);}function Fa(e,r,o){let n=r.fieldOrder[o];if(!n)return;let t=r.fields.get(n);t&&"focus"in t&&aa(e,t.eid);}function Cp(e,r={}){let o=Ld.parse(r),n=d$1(e);kr.isForm[n]=1,F(e,n,o.x,o.y),Ie.set(n,{fields:new Map,fieldOrder:[],focusedIndex:-1,onSubmitCallbacks:[],onChangeCallbacks:[],onValidationErrorCallbacks:[]});let t={eid:n,addField(i,a){let s=Ie.get(n);if(!s)return t;if(s.fields.has(i)){let l=s.fieldOrder.indexOf(i);l!==-1&&s.fieldOrder.splice(l,1);}return s.fields.set(i,a),s.fieldOrder.push(i),yp(n,a),t},removeField(i){let a=Ie.get(n);if(!a)return t;a.fields.delete(i);let s=a.fieldOrder.indexOf(i);return s!==-1&&a.fieldOrder.splice(s,1),a.focusedIndex>=s&&a.focusedIndex>0&&a.focusedIndex--,t},getField(i){return Ie.get(n)?.fields.get(i)},getFieldNames(){return Ie.get(n)?.fieldOrder??[]},getValue(i){let a=Ie.get(n);if(!a)return;let s=a.fields.get(i);if(s)return Ma(s)},getValues(){let i=Ie.get(n);if(!i)return {};let a={};for(let[s,l]of i.fields)a[s]=Ma(l);return a},setValidator(i){let a=Ie.get(n);return a&&(a.validator=i),t},validate(i){let a=Ie.get(n);if(!a)return {};let s=i??a.validator;if(!s)return {};let l=t.getValues();return s(l)},reset(){let i=Ie.get(n);if(!i)return t;for(let a of i.fields.values())bp(a);return Ed(n),t},submit(){let i=Ie.get(n);if(!i)return;let a=t.validate();if(Object.keys(a).length>0){pp(n,a);return}let s=t.getValues();for(let l of i.onSubmitCallbacks)l(s);},focusFirst(){let i=Ie.get(n);return !i||i.fieldOrder.length===0||(i.focusedIndex=0,Fa(e,i,0)),t},focusNext(){let i=Ie.get(n);return !i||i.fieldOrder.length===0||(vd(e,i),i.focusedIndex=(i.focusedIndex+1)%i.fieldOrder.length,Fa(e,i,i.focusedIndex)),t},focusPrevious(){let i=Ie.get(n);return !i||i.fieldOrder.length===0||(vd(e,i),i.focusedIndex=i.focusedIndex-1,i.focusedIndex<0&&(i.focusedIndex=i.fieldOrder.length-1),Fa(e,i,i.focusedIndex)),t},handleKey(i){let a=Ie.get(n);return a?hp(i,t)?true:xp(a,i):false},setPosition(i,a){return F(e,n,i,a),g(e,n),t},move(i,a){return K(e,n,i,a),g(e,n),t},getPosition(){return {x:E$1.x[n]??0,y:E$1.y[n]??0}},onSubmit(i){let a=Ie.get(n);return a&&a.onSubmitCallbacks.push(i),t},onChange(i){let a=Ie.get(n);return a&&a.onChangeCallbacks.push(i),t},onValidationError(i){let a=Ie.get(n);return a&&a.onValidationErrorCallbacks.push(i),t},destroy(){kr.isForm[n]=0,Ie.delete(n),e$3(e,n);}};return t}function Sp(e,r){return kr.isForm[r]===1}function Tp(){kr.isForm.fill(0),Ie.clear();}n();f();var Wp=z.object({value:z.number().min(0).max(1),color:z.union([z.string(),z.number()])}),Bd=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(1),value:z.number().min(0).max(1).default(0),label:z.string().optional(),fillChar:z.string().length(1).default("\u2588"),emptyChar:z.string().length(1).default("\u2591"),fillColor:z.union([z.string(),z.number()]).optional(),emptyColor:z.union([z.string(),z.number()]).optional(),showPercentage:z.boolean().default(true),showValue:z.boolean().default(false),thresholds:z.array(Wp).optional(),min:z.number().default(0),max:z.number().default(100)}),ka=1e4,xt={isGauge:new Uint8Array(ka),showPercentage:new Uint8Array(ka),showValue:new Uint8Array(ka)},bn=new Map;function vp(e,r){if(!r.thresholds||r.thresholds.length===0)return r.fillColor;let o;for(let n of r.thresholds)e>=n.value&&(!o||n.value>o.value)&&(o=n);return o?e$1(o.color):r.fillColor}function Lp(e,r,o){let n=[],t=Math.round(e.value*r),i=r-t,a=e.fillChar.repeat(t)+e.emptyChar.repeat(i),s="";if(e.label&&(s=e.label),xt.showPercentage[0]===1){let l=Ca(e.value);s=s?`${s} ${l}`:l;}if(xt.showValue[0]===1){let u=`${(e.min+e.value*(e.max-e.min)).toFixed(1)}/${e.max}`;s=s?`${s} ${u}`:u;}if(o===1)if(s&&s.length<r){let l=Math.floor((r-s.length)/2),u=" ".repeat(l)+s,d="";for(let f=0;f<r;f++)f<u.length&&u[f]!==" "?d+=u[f]:d+=a[f]??" ";n.push(d);}else n.push(a);else for(n.push(a),s&&n.push(s.padEnd(r," "));n.length<o;)n.push(" ".repeat(r));return n.join(`
|
|
9
|
-
`)}function Ra(e,r){let o=bn.get(r);if(!o)return;let n=x(e,r);if(!n)return;let t=Lp(o,n.width,n.height);e$2(e,r,t);let i=vp(o.value,o);i!==void 0&&d(e,r,{fg:i}),g(e,r);}function Ep(e,r={}){let o=Bd.parse(r),n=d$1(e);F(e,n,o.x,o.y),w(e,n,o.width,o.height),xt.isGauge[n]=1,xt.showPercentage[n]=o.showPercentage?1:0,xt.showValue[n]=o.showValue?1:0,bn.set(n,{value:o.value,label:o.label??"",fillChar:o.fillChar,emptyChar:o.emptyChar,fillColor:o.fillColor?e$1(o.fillColor):void 0,emptyColor:o.emptyColor?e$1(o.emptyColor):void 0,thresholds:o.thresholds?[...o.thresholds]:[],min:o.min,max:o.max}),Ra(e,n);let t={eid:n,setValue(i){let a=bn.get(n);return a&&(a.value=Math.max(0,Math.min(1,i)),Ra(e,n)),t},getValue(){return bn.get(n)?.value??0},setLabel(i){let a=bn.get(n);return a&&(a.label=i,Ra(e,n)),t},getLabel(){return bn.get(n)?.label??""},setPosition(i,a){return F(e,n,i,a),g(e,n),t},destroy(){xt.isGauge[n]=0,xt.showPercentage[n]=0,xt.showValue[n]=0,bn.delete(n),e$3(e,n);}};return t}function Bp(e,r){return xt.isGauge[r]===1}function Pp(){xt.isGauge.fill(0),xt.showPercentage.fill(0),xt.showValue.fill(0),bn.clear();}n();f();var Ap=1e4,Ia={isGrid:new Uint8Array(Ap)},Pi=z.union([z.number().int().positive(),z.string().regex(/^\d+%$/)]),Ad=z.object({rows:z.number().int().positive().optional().default(1),cols:z.number().int().positive().optional().default(1),gap:z.number().int().min(0).optional().default(0),cellWidths:z.union([Pi,z.array(Pi)]).optional(),cellHeights:z.union([Pi,z.array(Pi)]).optional(),padding:z.number().int().min(0).optional().default(0),left:z.number().optional().default(0),top:z.number().optional().default(0),width:z.union([z.number(),z.string(),z.literal("auto")]).optional().default("auto"),height:z.union([z.number(),z.string(),z.literal("auto")]).optional().default("auto"),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),Nt=new Map;function Dp(e){return typeof e=="string"&&e.endsWith("%")?{value:Number.parseFloat(e),isPercent:true}:{value:typeof e=="number"?e:Number.parseInt(e,10),isPercent:false}}function Pd(e,r,o,n){let t=n*(r-1),i=o-t,a=e.map(Dp),s=0,l=0;for(let{value:f,isPercent:g}of a)g?l+=f:s+=f;let u=i-s,d=[];for(let{value:f,isPercent:g}of a)g?d.push(f/100*u):d.push(f);return d}function tr(e,r,o){let n=x(e,r);if(!n)return;let t=n.width,i=n.height,a=t-o.padding*2,s=i-o.padding*2,l=Pd(o.cellWidths,o.cols,a,o.gap),u=Pd(o.cellHeights,o.rows,s,o.gap),d=[o.padding];for(let c=0;c<o.cols;c++)c>0&&(d[c]=(d[c-1]??0)+(l[c-1]??0)+o.gap);let f=[o.padding];for(let c=0;c<o.rows;c++)c>0&&(f[c]=(f[c-1]??0)+(u[c-1]??0)+o.gap);let g$1=G$3(e,r);if(g$1)for(let c of o.cells){let b=d[c.col]??0,p=f[c.row]??0,y=0;for(let x=c.col;x<c.col+c.colSpan&&x<o.cols;x++)y+=l[x]??0,x<c.col+c.colSpan-1&&(y+=o.gap);let v=0;for(let x=c.row;x<c.row+c.rowSpan&&x<o.rows;x++)v+=u[x]??0,x<c.row+c.rowSpan-1&&(v+=o.gap);F(e,c.entity,g$1.x+b,g$1.y+p),w(e,c.entity,y,v),g(e,c.entity);}}function Fp(e,r,o={}){let n=Ad.parse(o),t=r;Ia.isGrid[t]=1,F(e,t,n.left,n.top),w(e,t,n.width,n.height),Y(e,t,{focusable:true}),n.padding>0&&c$1(e,t,n.padding);let i=n.fg?e$1(n.fg):void 0,a=n.bg?e$1(n.bg):void 0;(i!==void 0||a!==void 0)&&d(e,t,{fg:i,bg:a});let s;if(n.cellWidths)s=Array.isArray(n.cellWidths)?n.cellWidths:Array(n.cols).fill(n.cellWidths);else {let f=`${100/n.cols}%`;s=Array(n.cols).fill(f);}let l;if(n.cellHeights)l=Array.isArray(n.cellHeights)?n.cellHeights:Array(n.rows).fill(n.cellHeights);else {let f=`${100/n.rows}%`;l=Array(n.rows).fill(f);}let u={rows:n.rows,cols:n.cols,gap:n.gap,cellWidths:s,cellHeights:l,padding:n.padding,cells:[]};Nt.set(t,u);let d$1={eid:t,show(){return j$1(e,t,true),g(e,t),d$1},hide(){return j$1(e,t,false),g(e,t),d$1},focus(){return aa(e,t),d$1},blur(){return ba(e,t),d$1},isFocused(){return _(e,t)},addToCell(f,g$1,c,b=1,p=1){let y=Nt.get(t);if(!y)return d$1;if(g$1<0||g$1>=y.rows)throw new Error(`Row ${g$1} out of bounds (0-${y.rows-1})`);if(c<0||c>=y.cols)throw new Error(`Column ${c} out of bounds (0-${y.cols-1})`);if(g$1+b>y.rows)throw new Error(`Row span ${b} exceeds grid bounds (row ${g$1} + span ${b} > ${y.rows})`);if(c+p>y.cols)throw new Error(`Column span ${p} exceeds grid bounds (col ${c} + span ${p} > ${y.cols})`);let v=y.cells.findIndex(x=>x.entity===f);return v>=0&&y.cells.splice(v,1),y.cells.push({entity:f,row:g$1,col:c,rowSpan:b,colSpan:p}),i$1(e,f)===a$2&&d$2(e,t,f),tr(e,t,y),g(e,t),d$1},removeFromGrid(f){let g$1=Nt.get(t);if(!g$1)return d$1;let c=g$1.cells.findIndex(b=>b.entity===f);return c>=0&&(g$1.cells.splice(c,1),g(e,t)),d$1},getCells(){return Nt.get(t)?.cells??[]},layout(){let f=Nt.get(t);return f&&(tr(e,t,f),g(e,t)),d$1},setGap(f){let g$1=Nt.get(t);return g$1&&(g$1.gap=f,tr(e,t,g$1),g(e,t)),d$1},setCellWidths(f){let g$1=Nt.get(t);return g$1&&(g$1.cellWidths=Array.isArray(f)?f:Array(g$1.cols).fill(f),tr(e,t,g$1),g(e,t)),d$1},setCellHeights(f){let g$1=Nt.get(t);return g$1&&(g$1.cellHeights=Array.isArray(f)?f:Array(g$1.rows).fill(f),tr(e,t,g$1),g(e,t)),d$1},destroy(){Nt.delete(t),e$3(e,t);}};return d$1}function Mp(e,r,o,n,t,i=1,a=1){let s=Nt.get(r);if(!s)throw new Error(`Entity ${r} is not a grid`);if(n<0||n>=s.rows)throw new Error(`Row ${n} out of bounds (0-${s.rows-1})`);if(t<0||t>=s.cols)throw new Error(`Column ${t} out of bounds (0-${s.cols-1})`);if(n+i>s.rows)throw new Error(`Row span ${i} exceeds grid bounds (row ${n} + span ${i} > ${s.rows})`);if(t+a>s.cols)throw new Error(`Column span ${a} exceeds grid bounds (col ${t} + span ${a} > ${s.cols})`);let l=s.cells.findIndex(u=>u.entity===o);l>=0&&s.cells.splice(l,1),s.cells.push({entity:o,row:n,col:t,rowSpan:i,colSpan:a}),i$1(e,o)===a$2&&d$2(e,r,o),tr(e,r,s),g(e,r);}function kp(e,r){return Ia.isGrid[r]===1}function Rp(){Nt.clear();}n();f();var Ip=1e4,Dd={isHeader:new Uint8Array(Ip)},Fd=z.object({title:z.string().optional().default(""),left:z.string().optional(),center:z.string().optional(),right:z.string().optional(),height:z.number().int().positive().optional().default(1),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional().default("left")}),nr=new Map;function Rr(e,r,o){let{left:n,center:t,right:i,title:a}=e;if(n||t||i){let s=n||"",l=t||"",u=i||"",d=s.length,f=l.length,g=u.length,c=d+f+g;if(r-c>=2){let p=Math.floor((r-f)/2),y=Math.max(0,p-d),v=p+f,x=Math.max(0,r-v-g);return s+" ".repeat(y)+l+" ".repeat(x)+u}return `${s} ${l} ${u}`.slice(0,r)}if(a){if(o==="center"){let s=Math.max(0,Math.floor((r-a.length)/2));return " ".repeat(s)+a}if(o==="right"){let s=Math.max(0,r-a.length);return " ".repeat(s)+a}return a}return ""}function Vp(e,r,o={}){let n=Fd.parse(o),t=r;Dd.isHeader[t]=1,F(e,t,0,0),w(e,t,"auto",n.height);let i=n.fg?e$1(n.fg):void 0,a=n.bg?e$1(n.bg):void 0;(i!==void 0||a!==void 0)&&d(e,t,{fg:i,bg:a});let s={title:n.title,left:n.left||"",center:n.center||"",right:n.right||""};nr.set(t,s);let l=80,u=Rr(s,l,n.align);e$2(e,t,u,{align:0});let d$1={eid:t,show(){return j$1(e,t,true),g(e,t),d$1},hide(){return j$1(e,t,false),g(e,t),d$1},setTitle(f){let g$1=nr.get(t);if(g$1){g$1.title=f;let c=Rr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setLeft(f){let g$1=nr.get(t);if(g$1){g$1.left=f;let c=Rr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setCenter(f){let g$1=nr.get(t);if(g$1){g$1.center=f;let c=Rr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},setRight(f){let g$1=nr.get(t);if(g$1){g$1.right=f;let c=Rr(g$1,l,n.align);e$2(e,t,c),g(e,t);}return d$1},getContent(){return f$2(e,t)},destroy(){nr.delete(t),e$3(e,t);}};return d$1}var Rd=500,Id=100,Vd=2,_d=1,Od=4294967295,Gd=4281545523,Nd=4287137928,zd=z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),border:z.number().int().nonnegative().optional(),padding:z.number().int().nonnegative().optional()}),_p=z.object({text:z.string(),style:zd.optional(),delay:z.number().positive().optional()}),Op=z.object({showDelay:z.number().nonnegative().optional(),hideDelay:z.number().nonnegative().optional(),offsetX:z.number().optional(),offsetY:z.number().optional(),screenWidth:z.number().int().positive().optional(),screenHeight:z.number().int().positive().optional(),style:zd.optional()}),Ke=new Map;function wd(e){return typeof e=="string"?{text:e}:e}function Gp(e){return e.split(`
|
|
10
|
-
`)}function Md(e,r){let o=0;for(let n of e)n.length>o&&(o=n.length);return o+r*2}function kd(e,r){return e.length+r*2}function Np(e,r,o,n,t,i){let a=e,s=r;return a+o>t&&(a=t-o),a<0&&(a=0),s+n>i&&(s=i-n),s<0&&(s=0),{x:a,y:s}}function Va(e={}){let r=Op.parse(e),o=r.showDelay??Rd,n=r.hideDelay??Id,t=r.offsetX??Vd,i=r.offsetY??_d,a=r.screenWidth??80,s=r.screenHeight??24,l={fg:r.style?.fg??Od,bg:r.style?.bg??Gd,border:r.style?.border??Nd,padding:r.style?.padding??1},u=false,d=null,f="",g=[],c={x:0,y:0},b=null,p=null,y=null,v=0,x=0,T=false,P={setHoverText(L,R){let Y=wd(R),U=_p.parse(Y);Ke.set(L,U);},clearHoverText(L){Ke.delete(L),d===L&&P.hideNow();},getHoverText(L){return Ke.get(L)},hasHoverText(L){return Ke.has(L)},updateMouse(L,R,Y){v=L,x=R,Y!==y&&(y=Y,Y!==null&&Ke.has(Y)?(b=Date.now(),p=null,T=true):u?(p=Date.now(),b=null,T=false):(b=null,p=null,T=false)),u&&d!==null&&D(L,R);},update(L){let R=Date.now();if(T&&b!==null&&y!==null){let U=Ke.get(y)?.delay??o;R-b>=U&&(P.showNow(y,v,x),T=false);}p!==null&&u&&R-p>=n&&P.hideNow();},showNow(L,R,Y){let U=Ke.get(L);U&&(u=true,d=L,f=U.text,g=Gp(U.text),b=null,p=null,T=false,D(R,Y));},hideNow(){u=false,d=null,f="",g=[],b=null,p=null,T=false;},getState(){return {visible:u,sourceEntity:d,text:f,position:c,hoverStartTime:b}},isVisible(){return u},getRenderData(){if(!u||d===null)return null;let L=Ke.get(d),R={fg:L?.style?.fg??l.fg,bg:L?.style?.bg??l.bg,border:L?.style?.border??l.border,padding:L?.style?.padding??l.padding??1},Y=Md(g,R.padding),U=kd(g,R.padding);return {x:c.x,y:c.y,width:Y,height:U,text:f,lines:g,style:R}},setScreenSize(L,R){a=L,s=R;},clearAll(){Ke.clear(),P.hideNow();}};function D(L,R){let Y=d!==null?Ke.get(d):void 0,U={fg:Y?.style?.fg??l.fg,bg:Y?.style?.bg??l.bg,border:Y?.style?.border??l.border,padding:Y?.style?.padding??l.padding},$e=Md(g,U.padding??1),Ht=kd(g,U.padding??1),Dt=L+t,mr=R+i;c=Np(Dt,mr,$e,Ht,a,s);}return P}function zp(e,r){Ke.set(e,wd(r));}function wp(e){Ke.delete(e);}function Hp(e){return Ke.get(e)}function Up(e){return Ke.has(e)}function $p(){Ke.clear();}function jp(){return Ke.size}function Yp(){Ke.clear();}n();z.number().int().min(0).max(255).transform(e=>e);var Kp=z.object({r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255)});Kp.extend({a:z.number().min(0).max(1)});var Qp=z.object({h:z.number().min(0).max(360),s:z.number().min(0).max(100),l:z.number().min(0).max(100)});Qp.extend({a:z.number().min(0).max(1)});z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,"Invalid hex color format. Expected #RGB, #RRGGBB, or #RRGGBBAA");var Xp=[{r:0,g:0,b:0},{r:128,g:0,b:0},{r:0,g:128,b:0},{r:128,g:128,b:0},{r:0,g:0,b:128},{r:128,g:0,b:128},{r:0,g:128,b:128},{r:192,g:192,b:192},{r:128,g:128,b:128},{r:255,g:0,b:0},{r:0,g:255,b:0},{r:255,g:255,b:0},{r:0,g:0,b:255},{r:255,g:0,b:255},{r:0,g:255,b:255},{r:255,g:255,b:255}];function qp(){let e=[0,95,135,175,215,255],r=[];for(let o=0;o<6;o++)for(let n=0;n<6;n++)for(let t=0;t<6;t++)r.push({r:e[o]??0,g:e[n]??0,b:e[t]??0});return r}function Jp(){let e=[];for(let r=0;r<24;r++){let o=8+r*10;e.push({r:o,g:o,b:o});}return e}var Zp=qp(),ey=Jp(),rr=[...Xp,...Zp,...ey];function ty(e){let r=o=>o.toString(16).padStart(2,"0");return `#${r(e.r)}${r(e.g)}${r(e.b)}`}rr.map(ty);function ry(e){let r=e.startsWith("#")?e.slice(1):e;if(!/^[0-9a-fA-F]+$/.test(r))throw new Error(`Invalid hex color: ${e}`);let o,n,t,i;if(r.length===3){let a=r[0]??"0",s=r[1]??"0",l=r[2]??"0";o=Number.parseInt(a+a,16),n=Number.parseInt(s+s,16),t=Number.parseInt(l+l,16);}else if(r.length===6)o=Number.parseInt(r.slice(0,2),16),n=Number.parseInt(r.slice(2,4),16),t=Number.parseInt(r.slice(4,6),16);else if(r.length===8)o=Number.parseInt(r.slice(0,2),16),n=Number.parseInt(r.slice(2,4),16),t=Number.parseInt(r.slice(4,6),16),i=Number.parseInt(r.slice(6,8),16)/255;else throw new Error(`Invalid hex color length: ${e}`);return i!==void 0?{r:o,g:n,b:t,a:i}:{r:o,g:n,b:t}}function pn(e){let r=0,o=Number.POSITIVE_INFINITY;for(let n=0;n<256;n++){let t=rr[n];if(!t)continue;let i=e.r-t.r,a=e.g-t.g,s=e.b-t.b,l=i*i+a*a+s*s;if(l<o&&(o=l,r=n),l===0)break}return r}function Hd(e){let r=Math.max(0,Math.min(255,Math.round(e.r))),o=Math.max(0,Math.min(255,Math.round(e.g))),n=Math.max(0,Math.min(255,Math.round(e.b)));return r<<16|o<<8|n}function fL(e){let r=ry(e);return Hd(r)}function bL(e){let r=rr[e];if(!r)throw new Error(`Invalid Color256: ${e}`);return Hd(r)}function Ud(e){return `38;5;${e}`}function $d(e){return `48;5;${e}`}function jd(e,r){let o=e.a,n=1-o;return {r:Math.round(e.r*o+r.r*n),g:Math.round(e.g*o+r.g*n),b:Math.round(e.b*o+r.b*n)}}z.object({width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),mode:z.enum(["color","ascii","braille"]).optional(),dither:z.boolean().optional(),background:z.object({r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255)}).optional()});var Yd=" .:-=+*#%@",Kd="\u2580",oy=10240;function iy(e){let r=Math.max(0,Math.min(1,e)),o=Math.round(r*(Yd.length-1));return Yd[o]??" "}function Qd(e,r,o){return (e*.299+r*.587+o*.114)/255}function ay(e,r,o){if(r<=0||o<=0)return {width:0,height:0,data:new Uint8Array(0)};let n=new Uint8Array(r*o*4),t=e.width/r,i=e.height/o;for(let a=0;a<o;a++){let s=Math.min(Math.floor(a*i),e.height-1);for(let l=0;l<r;l++){let u=Math.min(Math.floor(l*t),e.width-1),d=(s*e.width+u)*4,f=(a*r+l)*4;n[f]=e.data[d]??0,n[f+1]=e.data[d+1]??0,n[f+2]=e.data[d+2]??0,n[f+3]=e.data[d+3]??0;}}return {width:r,height:o,data:n}}function sy(e,r){let o=e.a/255;return jd({r:e.r,g:e.g,b:e.b,a:o},r)}function ly(e,r,o){let n=(o*e.width+r)*4;return {r:e.data[n]??0,g:e.data[n+1]??0,b:e.data[n+2]??0,a:e.data[n+3]??0}}function Ir(e,r,o,n){let t=ly(e,r,o);return t.a===255?{r:t.r,g:t.g,b:t.b}:t.a===0?n:sy(t,n)}function uy(e,r,o){for(let n=0;n<o;n++)for(let t=0;t<r;t++){let i=n*r+t,a=e[i];if(!a)continue;let s=pn(a),l=rr[s];if(!l)continue;let u=a.r-l.r,d=a.g-l.g,f=a.b-l.b;Ai(e,r,o,t+1,n,u,d,f,7/16),Ai(e,r,o,t-1,n+1,u,d,f,3/16),Ai(e,r,o,t,n+1,u,d,f,5/16),Ai(e,r,o,t+1,n+1,u,d,f,1/16);}}function Ai(e,r,o,n,t,i,a,s,l){if(n<0||n>=r||t<0||t>=o)return;let u=t*r+n,d=e[u];d&&(d.r=Math.max(0,Math.min(255,Math.round(d.r+i*l))),d.g=Math.max(0,Math.min(255,Math.round(d.g+a*l))),d.b=Math.max(0,Math.min(255,Math.round(d.b+s*l))));}function dy(e,r,o){let n=Math.ceil(e.height/2),t=e.width;if(o)return cy(e,r,t,n);let i=[];for(let a=0;a<n;a++){let s=[];for(let l=0;l<t;l++){let u=a*2,d=a*2+1,f=Ir(e,l,u,r),g=d<e.height?Ir(e,l,d,r):r,c=pn(f),b=pn(g);s.push({char:Kd,fg:c,bg:b});}i.push(s);}return {width:t,height:n,cells:i}}function cy(e,r,o,n){let t=[];for(let a=0;a<e.height;a++)for(let s=0;s<e.width;s++){let l=Ir(e,s,a,r);t.push({r:l.r,g:l.g,b:l.b});}uy(t,e.width,e.height);let i=[];for(let a=0;a<n;a++){let s=[];for(let l=0;l<o;l++){let u=a*2,d=a*2+1,f=t[u*e.width+l]??{r:0,g:0,b:0},g=d<e.height?t[d*e.width+l]??{r:0,g:0,b:0}:r,c=pn(f),b=pn(g);s.push({char:Kd,fg:c,bg:b});}i.push(s);}return {width:o,height:n,cells:i}}function gy(e,r){let o=[];for(let n=0;n<e.height;n++){let t=[];for(let i=0;i<e.width;i++){let a=Ir(e,i,n,r),s=Qd(a.r,a.g,a.b),l=iy(s),u=pn(a);t.push({char:l,fg:u,bg:0});}o.push(t);}return {width:e.width,height:e.height,cells:o}}var my=[[1,8],[2,16],[4,32],[64,128]];function fy(e,r,o,n,t){let i={pattern:0,totalR:0,totalG:0,totalB:0,count:0};for(let a=0;a<4;a++)for(let s=0;s<2;s++){let l=r*2+s,u=o*4+a;if(l>=e.width||u>=e.height)continue;let d=Ir(e,l,u,n);if(Qd(d.r,d.g,d.b)>=t){let g=my[a];g&&(i.pattern|=g[s]??0);}i.totalR+=d.r,i.totalG+=d.g,i.totalB+=d.b,i.count++;}return i}function by(e){let r=String.fromCodePoint(oy+e.pattern),o=e.count>0?pn({r:Math.round(e.totalR/e.count),g:Math.round(e.totalG/e.count),b:Math.round(e.totalB/e.count)}):0;return {char:r,fg:o,bg:0}}function py(e,r){let o=Math.ceil(e.width/2),n=Math.ceil(e.height/4),t=[],i=.5;for(let a=0;a<n;a++){let s=[];for(let l=0;l<o;l++){let u=fy(e,l,a,r,i);s.push(by(u));}t.push(s);}return {width:o,height:n,cells:t}}function _a(e,r){let o=r?.mode??"color",n=r?.dither??false,t=r?.background??{r:0,g:0,b:0},i=r?.width??e.width,a=r?.height;a!==void 0&&o==="color"&&(a=a*2),a!==void 0&&o==="braille"&&(a=a*4);let l=(o==="braille"&&r?.width?r.width*2:void 0)??i,u=a??e.height,d=l!==e.width||u!==e.height?ay(e,l,u):e;switch(o){case "color":return dy(d,t,n);case "ascii":return gy(d,t);case "braille":return py(d,t)}}function Oa(e){let r=[];for(let o of e.cells){let n="",t=-1,i=-1;for(let a of o)(a.fg!==t||a.bg!==i)&&(n+=`\x1B[${Ud(a.fg)};${$d(a.bg)}m`,t=a.fg,i=a.bg),n+=a.char;r.push(n);}return `${r.join(`
|
|
11
|
-
`)}\x1B[0m`}var Xd=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),type:z.enum(["ansi","overlay"]).default("ansi"),bitmap:z.object({width:z.number().int().nonnegative(),height:z.number().int().nonnegative(),data:z.instanceof(Uint8Array)}).optional(),renderMode:z.enum(["color","ascii","braille"]).default("color"),dither:z.boolean().default(false),visible:z.boolean().default(true)}),yy=1e4,Or={isImage:new Uint8Array(yy)},yn=new Map,Vr=new Map,En=new Map,_r=new Map,ir=new Map,or=new Map;function Ga(e,r){let o=yn.get(r);if(!o){e$2(e,r,""),ir.delete(r);return}if((Vr.get(r)??"ansi")!=="ansi"){e$2(e,r,"");return}let t=En.get(r)??"color",i=_r.get(r)??false,a=_a(o,{width:void 0,height:void 0,mode:t,dither:i});ir.set(r,a);let s=Oa(a);e$2(e,r,s);}function hy(e,r={}){let o=Xd.parse(r),n=d$1(e);F(e,n,o.x,o.y);let t=o.width??o.bitmap?.width??0,i=o.height??o.bitmap?.height??0;return w(e,n,t,i),Or.isImage[n]=1,Vr.set(n,o.type),En.set(n,o.renderMode),_r.set(n,o.dither),or.set(n,o.visible),o.bitmap&&(yn.set(n,o.bitmap),Ga(e,n)),o.visible||j$1(e,n,false),xy(e,n)}function xy(e,r){return {get eid(){return r},show(){return or.set(r,true),j$1(e,r,true),g(e,r),this},hide(){return or.set(r,false),j$1(e,r,false),g(e,r),this},isVisible(){return or.get(r)??false},move(o,n){let t=E$1.x[r]??0,i=E$1.y[r]??0;return F(e,r,t+o,i+n),g(e,r),this},setPosition(o,n){return F(e,r,o,n),g(e,r),this},getPosition(){return {x:E$1.x[r]??0,y:E$1.y[r]??0}},setImage(o){return yn.set(r,o),Ga(e,r),g(e,r),this},getImage(){return yn.get(r)},getType(){return Vr.get(r)??"ansi"},getCellMap(){return ir.get(r)},setRenderMode(o){return En.set(r,o),Ga(e,r),g(e,r),this},getRenderMode(){return En.get(r)??"color"},render(){let o=yn.get(r);if(!o)return "";let n=En.get(r)??"color",t=_r.get(r)??false,i=_a(o,{mode:n,dither:t});return Oa(i)},destroy(){Or.isImage[r]=0,yn.delete(r),Vr.delete(r),En.delete(r),_r.delete(r),ir.delete(r),or.delete(r),e$3(e,r);}}}function Cy(e,r){return Or.isImage[r]===1}function Sy(e){return yn.get(e)}function Ty(e){return ir.get(e)}function Wy(){Or.isImage.fill(0),yn.clear(),Vr.clear(),En.clear(),_r.clear(),ir.clear(),or.clear();}n();f();var qd=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Jd=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),tc=z.object({left:qd.optional(),top:qd.optional(),width:Jd.optional(),height:Jd.optional(),layout:z.enum(["inline","grid","flex"]).optional(),gap:z.number().nonnegative().optional(),wrap:z.boolean().optional(),justify:z.enum(["start","center","end","space-between"]).optional(),align:z.enum(["start","center","end"]).optional(),cols:z.number().positive().optional(),direction:z.enum(["row","column"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),hn=1e4,J={isLayout:new Uint8Array(hn),mode:new Uint8Array(hn),gap:new Float32Array(hn),wrap:new Uint8Array(hn),justify:new Uint8Array(hn),align:new Uint8Array(hn),cols:new Uint8Array(hn),direction:new Uint8Array(hn)};function Zd(e){return e===void 0?0:typeof e=="number"?e:0}function ec(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function vy(e){switch(e){case "inline":return 0;case "grid":return 1;case "flex":return 2}}function Na(e){switch(e){case 0:return "inline";case 1:return "grid";case 2:return "flex";default:return "inline"}}function Ly(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2;case "space-between":return 3}}function Ey(e){switch(e){case "start":return 0;case "center":return 1;case "end":return 2}}function By(e,r){return r.map(o=>{let n=x(e,o);return {eid:o,width:n?.width??1,height:n?.height??1}})}function nc(e,r,o,n){let t=new Map,i=0,a=0,s=0;for(let l of e)n&&i>0&&i+l.width>r&&(i=0,a+=s+o,s=0),t.set(l.eid,{x:i,y:a}),i+=l.width+o,s=Math.max(s,l.height);return t}function rc(e,r,o){let n=new Map,t=new Array(r).fill(0),i=[];return e.forEach((a,s)=>{let l=s%r,u=Math.floor(s/r);t[l]=Math.max(t[l],a.width),i[u]||(i[u]=0),i[u]=Math.max(i[u],a.height);}),e.forEach((a,s)=>{let l=s%r,u=Math.floor(s/r),d=0;for(let g=0;g<l;g++)d+=t[g]+o;let f=0;for(let g=0;g<u;g++)f+=i[g]+o;n.set(a.eid,{x:d,y:f});}),n}function oc(e,r,o,n,t,i){let a=new Map;if(e.length===0)return a;let s=n==="row",l=e.reduce((p,y)=>p+(s?y.width:y.height),0),u=o*(e.length-1),d=l+u,f=Math.max(0,r-d),g=Math.max(...e.map(p=>s?p.height:p.width)),c=0,b=0;switch(t){case "start":c=0;break;case "center":c=f/2;break;case "end":c=f;break;case "space-between":c=0,e.length>1&&(b=f/(e.length-1));break}for(let p of e){let y=s?p.width:p.height,v=s?p.height:p.width,x=0;switch(i){case "start":x=0;break;case "center":x=(g-v)/2;break;case "end":x=g-v;break}s?a.set(p.eid,{x:c,y:x}):a.set(p.eid,{x,y:c}),c+=y+o+b;}return a}function za(e,r,o={}){let n=tc.parse(o),t=r,i=n.layout??"inline";J.isLayout[t]=1,J.mode[t]=vy(i),J.gap[t]=n.gap??0,J.wrap[t]=n.wrap!==false?1:0,J.justify[t]=Ly(n.justify??"start"),J.align[t]=Ey(n.align??"start"),J.cols[t]=n.cols??3,J.direction[t]=n.direction==="column"?1:0;let a=Zd(n.left),s=Zd(n.top);F(e,t,a,s);let l=ec(n.width),u=ec(n.height);w(e,t,l,u),(n.fg!==void 0||n.bg!==void 0)&&d(e,t,{fg:n.fg!==void 0?e$1(n.fg):void 0,bg:n.bg!==void 0?e$1(n.bg):void 0}),Y(e,t,{focusable:true});function d$1(){let g$1=f$1(e,t);if(g$1.length===0)return;let c=By(e,g$1),b=Py(e,t),p=Ay(e,t,c,b.width,b.height);Dy(e,t,p),g(e,t);}let f={eid:t,show(){return j$1(e,t,true),f},hide(){return j$1(e,t,false),f},move(g$1,c){return K(e,t,g$1,c),g(e,t),f},setPosition(g$1,c){return F(e,t,g$1,c),g(e,t),f},getLayoutMode(){return Na(J.mode[t])},setGap(g$1){return J.gap[t]=g$1,g(e,t),f},getGap(){return J.gap[t]},recalculate(){return d$1(),f},focus(){return aa(e,t),f},blur(){return ba(e,t),f},isFocused(){return _(e,t)},append(g){return d$2(e,t,g),f},getChildren(){return f$1(e,t)},destroy(){J.isLayout[t]=0,J.mode[t]=0,J.gap[t]=0,J.wrap[t]=0,J.justify[t]=0,J.align[t]=0,J.cols[t]=0,J.direction[t]=0,e$3(e,t);}};return f}function Py(e,r){let o=x(e,r);return {width:o?.width??80,height:o?.height??24}}function Ay(e,r,o,n,t){let i=J.gap[r];switch(Na(J.mode[r])){case "inline":{let s=J.wrap[r]===1;return nc(o,n,i,s)}case "grid":{let s=J.cols[r];return rc(o,s,i)}case "flex":{let s=J.direction[r]===0?"row":"column",l=["start","center","end","space-between"][J.justify[r]]??"start",u=["start","center","end"][J.align[r]]??"start";return oc(o,s==="row"?n:t,i,s,l,u)}}}function Dy(e,r,o){let n=G$3(e,r),t=n?.x??0,i=n?.y??0;for(let[a,s]of o)F(e,a,t+s.x,i+s.y),g(e,a);}function Fy(e,r){return J.isLayout[r]===1}function My(e,r){return Na(J.mode[r])}function ky(){J.isLayout.fill(0),J.mode.fill(0),J.gap.fill(0),J.wrap.fill(0),J.justify.fill(0),J.align.fill(0),J.cols.fill(0),J.direction.fill(0);}n();f();var Di="\u2500",lc="\u2502",uc=10,ic=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),dc=z.object({left:ic.optional(),top:ic.optional(),orientation:z.enum(["horizontal","vertical"]).optional(),length:z.number().positive().optional(),char:z.string().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),wa=1e4,et={isLine:new Uint8Array(wa),orientation:new Uint8Array(wa),length:new Float32Array(wa)},Bn=new Map;function ac(e){return e===void 0?0:typeof e=="number"?e:0}function Ry(e,r,o){let n=ac(o.left),t=ac(o.top);F(e,r,n,t);}function sc(e,r,o,n){o==="horizontal"?w(e,r,n,1):w(e,r,1,n);}function Iy(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function Ha(e,r,o={}){let n=dc.parse(o),t=r,i=n.orientation??"horizontal",a=n.length??uc,s=n.char??(i==="horizontal"?Di:lc);et.isLine[t]=1,et.orientation[t]=i==="horizontal"?0:1,et.length[t]=a,Bn.set(t,s),Ry(e,t,n),sc(e,t,i,a),Iy(e,t,n),Y(e,t,{focusable:false});let l={eid:t,show(){return j$1(e,t,true),l},hide(){return j$1(e,t,false),l},move(u,d){return K(e,t,u,d),g(e,t),l},setPosition(u,d){return F(e,t,u,d),g(e,t),l},setChar(u){return Bn.set(t,u),g(e,t),l},getChar(){return Bn.get(t)??Di},getOrientation(){return et.orientation[t]===0?"horizontal":"vertical"},setLength(u){et.length[t]=u;let d=et.orientation[t]===0?"horizontal":"vertical";return sc(e,t,d,u),g(e,t),l},getLength(){return et.length[t]},focus(){return aa(e,t),l},blur(){return ba(e,t),l},isFocused(){return _(e,t)},append(u){return d$2(e,t,u),l},getChildren(){return f$1(e,t)},destroy(){et.isLine[t]=0,et.orientation[t]=0,et.length[t]=0,Bn.delete(t),e$3(e,t);}};return l}function Vy(e,r){return et.isLine[r]===1}function _y(e,r){return Bn.get(r)??Di}function Oy(e,r,o){return Bn.set(r,o),g(e,r),r}function Gy(e,r){return et.orientation[r]===0?"horizontal":"vertical"}function Ny(){et.isLine.fill(0),et.orientation.fill(0),et.length.fill(0),Bn.clear();}n();f();var zy=z.object({label:z.string(),data:z.array(z.number()),color:z.union([z.string(),z.number()]).optional()}),cc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(60),height:z.number().int().positive().default(20),series:z.array(zy).default([]),xLabels:z.array(z.string()).optional(),yLabel:z.string().optional(),xLabel:z.string().optional(),showLegend:z.boolean().default(false),showGrid:z.boolean().default(true),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),minY:z.number().optional(),maxY:z.number().optional()}),Ua=1e4,Tt={isLineChart:new Uint8Array(Ua),showLegend:new Uint8Array(Ua),showGrid:new Uint8Array(Ua)},xn=new Map;function wy(e,r,o,n,t){let i=[],a=e.minY??Number.POSITIVE_INFINITY,s=e.maxY??Number.NEGATIVE_INFINITY;if(e.minY===void 0||e.maxY===void 0)for(let x of e.series)for(let T of x.data)T<a&&(a=T),T>s&&(s=T);a===Number.POSITIVE_INFINITY&&(a=0),s===Number.NEGATIVE_INFINITY&&(s=100);let l=8,u=2,d=t&&e.series.length>0?2:0,f=o-u-d,g=r-l,c=f*4,b=0;for(let x of e.series)x.data.length>b&&(b=x.data.length);let p=Sr(a,s,5),y=Array.from({length:f},()=>Array(g).fill(10240));for(let x of e.series)if(x.data.length!==0)for(let T=0;T<x.data.length;T++){let P=x.data[T]??0,D=Math.floor(T/(b-1||1)*(g*2-1)),L=Math.floor(D/2),R=D%2,Y=Math.round(mt(P,a,s,c-1,0)),U=Math.floor(Y/4),$e=Y%4;if(L>=0&&L<g&&U>=0&&U<f){let Ht=Ln[$e];if(Ht){let Dt=Ht[R]??0;y[U]&&y[U][L]!==void 0&&(y[U][L]|=Dt);}}}for(let x=0;x<f;x++){let T=f-x-1,P=mt(T,0,f-1,a,s),D=p.find(U=>Math.abs(U-P)<(s-a)/f),R=`${D!==void 0?Tr(D,l-2):" ".repeat(l-2)}\u2502`,Y=y[x];if(Y)for(let U=0;U<g;U++){let $e=Y[U]??10240;R+=String.fromCharCode($e);}i.push(R.padEnd(r," "));}let v=`${" ".repeat(l)}\u2514${"\u2500".repeat(g-1)}`;if(i.push(v.padEnd(r," ")),e.xLabels.length>0){let x=`${" ".repeat(l)} `,T=Math.max(1,Math.floor(b/5));for(let P=0;P<b;P+=T){let D=e.xLabels[P]??P.toString();x+=D.slice(0,8).padEnd(8," ");}i.push(x.padEnd(r," "));}else i.push(" ".repeat(r));if(t&&e.series.length>0){let x="Legend: ";for(let T=0;T<e.series.length;T++){let P=e.series[T];P&&(x+=`${P.label} `);}i.push(x.padEnd(r," ")),d>1&&i.push(" ".repeat(r));}return i.join(`
|
|
12
|
-
`)}function Fi(e,r){let o=xn.get(r);if(!o)return;let n=x(e,r);if(!n)return;let t=Tt.showGrid[r]===1,i=Tt.showLegend[r]===1,a=wy(o,n.width,n.height,t,i);e$2(e,r,a),g(e,r);}function Hy(e,r={}){let o=cc.parse(r),n=d$1(e);F(e,n,o.x,o.y),w(e,n,o.width,o.height),Tt.isLineChart[n]=1,Tt.showLegend[n]=o.showLegend?1:0,Tt.showGrid[n]=o.showGrid?1:0,xn.set(n,{series:o.series.map((i,a)=>({label:i.label,data:[...i.data],color:i.color?e$1(i.color):Yt(a)})),xLabels:o.xLabels?[...o.xLabels]:[],yLabel:o.yLabel??"",xLabel:o.xLabel??"",minY:o.minY,maxY:o.maxY}),(o.fg!==void 0||o.bg!==void 0)&&d(e,n,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),Fi(e,n);let t={eid:n,setSeries(i){let a=xn.get(n);return a&&(a.series=i.map((s,l)=>({label:s.label,data:[...s.data],color:s.color?e$1(s.color):Yt(l)})),Fi(e,n)),t},getSeries(){return xn.get(n)?.series??[]},appendToSeries(i,a){let s=xn.get(n);if(s?.series[i]){let l=s.series[i];l&&(l.data.push(a),Fi(e,n));}return t},clear(){let i=xn.get(n);if(i){for(let a of i.series)a.data.length=0;Fi(e,n);}return t},setPosition(i,a){return F(e,n,i,a),g(e,n),t},destroy(){Tt.isLineChart[n]=0,Tt.showLegend[n]=0,Tt.showGrid[n]=0,xn.delete(n),e$3(e,n);}};return t}function Uy(e,r){return Tt.isLineChart[r]===1}function $y(){Tt.isLineChart.fill(0),Tt.showLegend.fill(0),Tt.showGrid.fill(0),xn.clear();}n();var Pn=1e4,jy=z.object({text:z.string(),key:z.string().optional(),callback:z.function().optional(),value:z.string().optional()}),hc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),items:z.array(jy).default([]),selected:z.number().int().min(-1).default(0),style:z.object({item:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),prefix:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),separator:z.string().optional()}).optional(),autoCommandKeys:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true)}),G={isListbar:new Uint8Array(Pn),selectedIndex:new Int32Array(Pn).fill(-1),itemCount:new Uint32Array(Pn),state:new Uint8Array(Pn),autoCommandKeys:new Uint8Array(Pn),mouse:new Uint8Array(Pn),keys:new Uint8Array(Pn)},Wt=new Map,rn=new Map,Nr=new Map,zr=new Map,gc=3435973887,mc=255,fc=255,bc=16777215,pc=4294902015,yc=255,Gr=" | ",Yy={0:"idle",1:"focused"};function Ky(){G.isListbar.fill(0),G.selectedIndex.fill(-1),G.itemCount.fill(0),G.state.fill(0),G.autoCommandKeys.fill(0),G.mouse.fill(0),G.keys.fill(0),Wt.clear(),rn.clear(),Nr.clear(),zr.clear();}function $a(e,r,o={}){let n=hc.parse(o),t=r;G.isListbar[t]=1,F(e,t,n.x,n.y),G.autoCommandKeys[t]=n.autoCommandKeys?1:0,G.mouse[t]=n.mouse?1:0,G.keys[t]=n.keys?1:0;let i=[...n.items];Wt.set(t,i),G.itemCount[t]=i.length,n.selected>=0&&n.selected<i.length?G.selectedIndex[t]=n.selected:i.length>0&&(G.selectedIndex[t]=0);let a={itemFg:n.style?.item?.fg??gc,itemBg:n.style?.item?.bg??mc,selectedFg:n.style?.selected?.fg??fc,selectedBg:n.style?.selected?.bg??bc,prefixFg:n.style?.prefix?.fg??pc,prefixBg:n.style?.prefix?.bg??yc,separator:n.style?.separator??Gr};rn.set(t,a);let s=()=>{let c=Wt.get(t)??[],p=rn.get(t)?.separator??Gr,y=0;for(let v=0;v<c.length;v++){let x=c[v];if(x){let T=u(x,v,G.autoCommandKeys[t]===1);y+=T.length+x.text.length;}v<c.length-1&&(y+=p.length);}return y},l=n.width??s();w(e,t,l,1),Nr.set(t,new Set),zr.set(t,new Set);function u(c,b,p){return c.key?`[${c.key}]`:p&&b<9?`[${b+1}]`:""}let d=()=>{let c=G.selectedIndex[t]??-1,p=(Wt.get(t)??[])[c];if(p&&c>=0){let y=Nr.get(t);if(y)for(let v of y)v(c,p);}},f=()=>{let c=G.selectedIndex[t]??-1,p=(Wt.get(t)??[])[c];if(p&&c>=0){p.callback&&p.callback();let y=zr.get(t);if(y)for(let v of y)v(c,p);}},g$1={eid:t,show(){return j$1(e,t,true),g$1},hide(){return j$1(e,t,false),g$1},move(c,b){return E$1.x[t]=(E$1.x[t]??0)+c,E$1.y[t]=(E$1.y[t]??0)+b,g(e,t),g$1},setPosition(c,b){return F(e,t,c,b),g$1},focus(){return G.state[t]=1,g(e,t),g$1},blur(){return G.state[t]=0,g(e,t),g$1},setItems(c){let b=[...c];return Wt.set(t,b),G.itemCount[t]=b.length,(G.selectedIndex[t]??-1)>=b.length&&(G.selectedIndex[t]=Math.max(0,b.length-1)),g(e,t),g$1},getItems(){return Wt.get(t)??[]},addItem(c){let b=Wt.get(t)??[];return b.push(c),G.itemCount[t]=b.length,g(e,t),g$1},removeItem(c){let b=Wt.get(t)??[];if(c>=0&&c<b.length){b.splice(c,1),G.itemCount[t]=b.length;let p=G.selectedIndex[t]??-1;p>=b.length?G.selectedIndex[t]=Math.max(0,b.length-1):p>c&&(G.selectedIndex[t]=p-1),g(e,t);}return g$1},getItemCount(){return G.itemCount[t]??0},select(c){let b=G.itemCount[t]??0;return c>=0&&c<b&&G.selectedIndex[t]!==c&&(G.selectedIndex[t]=c,g(e,t),d()),g$1},getSelectedIndex(){return G.selectedIndex[t]??-1},getSelectedItem(){let c=G.selectedIndex[t]??-1;return (Wt.get(t)??[])[c]},selectPrev(){let c=G.selectedIndex[t]??0,b=G.itemCount[t]??0;if(b>0){let p=c<=0?b-1:c-1;g$1.select(p);}return g$1},selectNext(){let c=G.selectedIndex[t]??0,b=G.itemCount[t]??0;if(b>0){let p=c>=b-1?0:c+1;g$1.select(p);}return g$1},selectFirst(){return (G.itemCount[t]??0)>0&&g$1.select(0),g$1},selectLast(){let c=G.itemCount[t]??0;return c>0&&g$1.select(c-1),g$1},selectByKey(c){let b=Wt.get(t)??[],p=G.autoCommandKeys[t]===1;for(let y=0;y<b.length;y++)if(b[y]?.key?.toLowerCase()===c.toLowerCase())return g$1.select(y),true;if(p){let y=Number.parseInt(c,10);if(y>=1&&y<=9&&y<=b.length)return g$1.select(y-1),true}return false},activate(){return f(),g$1},getState(){let c=G.state[t]??0;return Yy[c]??"idle"},setStyle(c){let b=rn.get(t)??{itemFg:gc,itemBg:mc,selectedFg:fc,selectedBg:bc,prefixFg:pc,prefixBg:yc,separator:Gr};return c.item?.fg!==void 0&&(b.itemFg=c.item.fg),c.item?.bg!==void 0&&(b.itemBg=c.item.bg),c.selected?.fg!==void 0&&(b.selectedFg=c.selected.fg),c.selected?.bg!==void 0&&(b.selectedBg=c.selected.bg),c.prefix?.fg!==void 0&&(b.prefixFg=c.prefix.fg),c.prefix?.bg!==void 0&&(b.prefixBg=c.prefix.bg),c.separator!==void 0&&(b.separator=c.separator),rn.set(t,b),g(e,t),g$1},getSeparator(){return rn.get(t)?.separator??Gr},setSeparator(c){let b=rn.get(t);return b&&(b.separator=c,g(e,t)),g$1},renderLine(){let c=Wt.get(t)??[],b=G.selectedIndex[t]??-1,p=G.autoCommandKeys[t]===1,v=rn.get(t)?.separator??Gr,x=[];for(let T=0;T<c.length;T++){let P=c[T];if(!P)continue;let D=u(P,T,p),L=T===b,R=D+P.text;L?x.push(`[${R}]`):x.push(` ${R} `);}return x.join(v)},calculateWidth(){return s()},onSelect(c){let b=Nr.get(t);return b&&b.add(c),()=>{b?.delete(c);}},onActivate(c){let b=zr.get(t);return b&&b.add(c),()=>{b?.delete(c);}},handleKey(c){let b=G.state[t]??0,p=G.keys[t]===1;if(b!==1||!p)return null;switch(c.toLowerCase()){case "left":case "h":return g$1.selectPrev(),{type:"selectPrev"};case "right":case "l":return g$1.selectNext(),{type:"selectNext"};case "home":return g$1.selectFirst(),{type:"selectFirst"};case "end":return g$1.selectLast(),{type:"selectLast"};case "enter":case " ":return g$1.activate(),{type:"confirm"};case "escape":return g$1.blur(),{type:"cancel"}}return g$1.selectByKey(c)?{type:"selectByKey",key:c}:null},destroy(){G.isListbar[t]=0,G.selectedIndex[t]=-1,G.itemCount[t]=0,G.state[t]=0,Wt.delete(t),rn.delete(t),Nr.delete(t),zr.delete(t),e$3(e,t);}};return g$1}function Qy(e,r){return G.isListbar[r]===1}n();var Sc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(10),data:z.array(z.array(z.string())).default([]),pad:z.number().int().min(0).max(10).default(1),align:z.enum(["left","center","right"]).default("left"),style:z.object({border:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),header:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),cell:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),altRowBg:z.number().optional()}).optional(),cellBorders:z.boolean().default(true),headerRows:z.number().int().min(0).max(10).default(1),columns:z.array(z.object({header:z.string(),width:z.number().int().positive().optional(),minWidth:z.number().int().positive().optional(),maxWidth:z.number().int().positive().optional(),align:z.enum(["left","center","right"]).optional()})).optional(),selected:z.number().int().min(-1).default(0),interactive:z.boolean().default(true),mouse:z.boolean().default(true),keys:z.boolean().default(true),search:z.boolean().default(false)});function xc(e,r){let o=[];for(let n=r;n<e.length;n++){let t=e[n];if(t){let i=t[0]??"";o.push({text:i,value:t.join(" ")});}}return o}function Cc(e){let r=e.border?.fg,o=e.border?.bg,n=e.header?.fg,t=e.header?.bg,i=e.cell?.fg,a=e.cell?.bg,s=e.altRowBg,l=e.selected?.fg,u=e.selected?.bg;return {...r!==void 0?{borderFg:r}:{},...o!==void 0?{borderBg:o}:{},...n!==void 0?{headerFg:n}:{},...t!==void 0?{headerBg:t}:{},...i!==void 0?{cellFg:i}:{},...a!==void 0?{cellBg:a}:{},...s!==void 0?{altRowBg:s}:{},...l!==void 0?{selectedFg:l}:{},...u!==void 0?{selectedBg:u}:{}}}function ja(e,r,o={}){let n=Sc.parse(o),t=r;F(e,t,n.x,n.y),n.width!==void 0&&w(e,t,n.width,n.height),qb$1(e,t,{headerRows:n.headerRows,pad:n.pad,cellBorders:n.cellBorders}),n.data.length>0&&tb$1(e,t,n.data),n.columns&&Hb$1(e,t,n.columns),n.style&&Nb$1(e,t,Cc(n.style));let i=xc(n.data,n.headerRows);$(e,t,i,{interactive:n.interactive,mouse:n.mouse,keys:n.keys,search:n.search,selectedIndex:n.selected,visibleCount:Math.max(1,n.height-n.headerRows)});let a=()=>{let l=vb$1(e,t),u=Mb$1(e,t),d=xc(l,u);j$2(e,t,d);},s={eid:t,show(){return j$1(e,t,true),s},hide(){return j$1(e,t,false),s},move(l,u){return E$1.x[t]=(E$1.x[t]??0)+l,E$1.y[t]=(E$1.y[t]??0)+u,g(e,t),s},setPosition(l,u){return F(e,t,l,u),s},focus(){return ga(e,t),s},blur(){return ha$1(e,t),s},setData(l){return tb$1(e,t,l),a(),s},getData(){return vb$1(e,t)},getFullData(){return ub$1(e,t)},clearData(){return Gb$1(e,t),a(),s},setCell(l,u,d){return wb$1(e,t,l,u,d),a(),s},getCell(l,u){return xb$1(e,t,l,u)},getCellValue(l,u){return yb$1(e,t,l,u)},getRow(l){return zb$1(e,t,l)},getRowCount(){return Bb$1(e,t)},getDataRowCount(){return Math.max(0,Bb$1(e,t)-Mb$1(e,t))},setColumns(l){return Hb$1(e,t,l),s},getColumns(){return Ib$1(e,t)},getColCount(){return Cb$1(e,t)},setHeaderRowCount(l){return Lb$1(e,t,l),a(),s},getHeaderRowCount(){return Mb$1(e,t)},getHeaderRows(){return Jb$1(e,t)},getDataRows(){return Kb$1(e,t)},setCellPadding(l){return Rb$1(e,t,l),s},getCellPadding(){return Qb$1(e,t)},setCellBorders(l){return Tb$1(e,t,l),s},hasCellBorders(){return Sb$1(e,t)},setStyle(l){return Nb$1(e,t,Cc(l)),g(e,t),s},getDisplay(){return Ob$1(e,t)},select(l){return N(e,t,l),s},getSelectedIndex(){return L(t)},getSelectedRow(){let l=L(t);if(l<0)return;let u=Mb$1(e,t);return zb$1(e,t,u+l)},selectPrev(){return O(e,t),s},selectNext(){return P(e,t),s},selectFirst(){return Q$1(e,t),s},selectLast(){return R(e,t),s},activate(){return U(e,t),s},pageUp(){return v$1(e,t,-1),s},pageDown(){return v$1(e,t,1),s},startSearch(){return Ga$1(e,t),s},endSearch(){return Ha$1(e,t),s},getSearchQuery(){return Ia$1(t)},isSearching(){return Fa$1(e,t)},getState(){return ba$1(e,t)},onSelect(l){return V(t,l)},onActivate(l){return W(t,l)},onSearchChange(l){return Pa$1(t,l)},handleKey(l){let u=Qa$1(e,t,l);if(u)switch(u.type){case "selectPrev":O(e,t);break;case "selectNext":P(e,t);break;case "selectFirst":Q$1(e,t);break;case "selectLast":R(e,t);break;case "pageUp":v$1(e,t,-1);break;case "pageDown":v$1(e,t,1);break;case "confirm":U(e,t);break;case "cancel":ha$1(e,t);break;case "startSearch":Ga$1(e,t);break;case "endSearch":Ha$1(e,t);break;case "searchChar":Ka$1(e,t,u.char);break;case "searchBackspace":La$1(e,t);break;case "searchNextMatch":Oa$1(e,t);break}return u},destroy(){Z$1(t),Ma$1(e,t),sb$1(e,t),e$3(e,t);}};return s}function Xy(e,r){return rb$1(e,r)}n();var qy=4294967295,Jy=0,Tc=z.object({fg:z.number().int().optional(),bg:z.number().int().optional()}),Wc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),message:z.string().default("Loading..."),spinnerChars:z.array(z.string()).readonly().optional(),interval:z.number().int().positive().default(100),style:Tc.optional(),width:z.number().int().positive().optional(),visible:z.boolean().default(true)}),An=new Map,ar=new Map;function Mi(e,r={}){let o=Wc.parse(r),n=d$1(e);F(e,n,o.x,o.y);let t=o.message,i=o.spinnerChars??Ta$1,a=Math.max(...i.map(l=>l.length)),s=o.width??t.length+a+1;return w(e,n,s,1),Za$1(e,n,{frames:i,interval:o.interval}),An.set(n,t),ar.set(n,o.visible),wr(e,n),o.visible||j$1(e,n,false),Zy(e,n)}function Zy(e,r){return {get eid(){return r},show(){return ar.set(r,true),j$1(e,r,true),g(e,r),this},hide(){return ar.set(r,false),j$1(e,r,false),g(e,r),this},isVisible(){return ar.get(r)??false},move(o,n){let t=E$1.x[r]??0,i=E$1.y[r]??0;return F(e,r,t+o,i+n),g(e,r),this},setPosition(o,n){return F(e,r,o,n),g(e,r),this},getPosition(){return {x:E$1.x[r]??0,y:E$1.y[r]??0}},setMessage(o){return An.set(r,o),wr(e,r),g(e,r),this},getMessage(){return An.get(r)??""},setSpinnerChars(o){return db$1(r,o),wr(e,r),g(e,r),this},setInterval(o){return cb$1(r,o),this},getSpinnerChar(){return ab$1(r)},reset(){return gb$1(r),wr(e,r),g(e,r),this},destroy(){_a$1(e,r),An.delete(r),ar.delete(r),e$3(e,r);}}}function wr(e,r){let o=An.get(r)??"",t=`${ab$1(r)} ${o}`;e$2(e,r,t);}function eh(e,r,o={}){return Mi(e,{...o,message:r,visible:true})}function th(e){e.destroy();}function nh(e,r){e.setMessage(r);}function vc(e,r){return $a$1(e,r)&&An.has(r)}function rh(e,r,o){if(!vc(e,r))return false;let n=fb$1(r,o);return n&&(wr(e,r),g(e,r)),n}function oh(){An.clear(),ar.clear();}u();n();f();var Lc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),ki=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),ah=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),sh=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),lh=z.union([z.boolean(),z.object({mode:z.enum(["auto","visible","hidden"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),trackChar:z.string().optional(),thumbChar:z.string().optional()})]).optional(),Ac=z.object({left:ki.optional(),top:ki.optional(),right:ki.optional(),bottom:ki.optional(),width:Lc.optional(),height:Lc.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:ah,padding:sh,scrollbar:lh,mouse:z.boolean().optional(),keys:z.boolean().optional(),scrollback:z.number().int().positive().optional(),scrollOnInput:z.boolean().optional(),timestamps:z.boolean().optional(),timestampFormat:z.string().optional()}),Dn=1e4,de={isLog:new Uint8Array(Dn),mouseEnabled:new Uint8Array(Dn),keysEnabled:new Uint8Array(Dn),scrollOnInput:new Uint8Array(Dn),timestamps:new Uint8Array(Dn),scrollback:new Uint32Array(Dn),lineCount:new Uint32Array(Dn)},Cn=new Map;function uh(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function dh(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Ec(e){return e===void 0?0:typeof e=="number"?e:0}function Bc(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function ch(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function gh(...e){if(e.length===0)return "";if(e.length===1)return String(e[0]);let r=String(e[0]),o=1;return r.replace(/%([sdfjioO%])/g,(n,t)=>{if(t==="%")return "%";if(o>=e.length)return n;let i=e[o++];switch(t){case "s":return String(i);case "d":case "i":return typeof i=="number"?Math.floor(i).toString():"NaN";case "f":return typeof i=="number"?i.toString():"NaN";case "j":case "o":case "O":try{return JSON.stringify(i)}catch{return "[Circular]"}default:return n}})}function mh(e){return h$3(new Date,e)}function Pc(e,r){let o=Cn.get(r);if(!o)return;let n=o.lines.join(`
|
|
13
|
-
`);e$2(e,r,n);let t=o.lines.length;u$1(e,r,0,t),de.lineCount[r]=t,g(e,r);}function fh(e){let r=Cn.get(e);if(!r)return;let o=de.scrollback[e]??0;if(o!==0)for(;r.lines.length>o;)r.lines.shift();}function bh(e,r){de.isLog[e]=1,de.scrollback[e]=r.scrollback??1e3,de.scrollOnInput[e]=r.scrollOnInput!==false?1:0,de.timestamps[e]=r.timestamps?1:0,de.mouseEnabled[e]=r.mouse!==false?1:0,de.keysEnabled[e]=r.keys!==false?1:0,de.lineCount[e]=0,Cn.set(e,{lines:[],timestampFormat:r.timestampFormat??"HH:mm:ss"});}function ph(e,r,o){let n=Ec(o.left),t=Ec(o.top);F(e,r,n,t);let i=Bc(o.width),a=Bc(o.height);w(e,r,i,a);}function yh(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function hh(e,r,o){let n=o.type?dh(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?uh(o.ch):o.ch;m(e,r,t);}}function xh(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function Ch(e,r,o){let n=2;o.scrollbar===false?n=0:typeof o.scrollbar=="object"&&o.scrollbar.mode&&(n=ch(o.scrollbar.mode)),l$1(e,r,{alwaysScroll:true,scrollbarVisible:n});}function Sh(e,r$1,o$1={}){let n=Ac.parse(o$1),t=r$1;bh(t,n),ph(e,t,n),yh(e,t,n),n.border&&hh(e,t,n.border),n.padding!==void 0&&xh(e,t,n.padding),Ch(e,t,n),Y(e,t,{focusable:true}),e$2(e,t,"");let i={eid:t,log(...a){let s=Cn.get(t);if(!s)return i;let l=gh(...a);return de.timestamps[t]===1&&(l=`[${mh(s.timestampFormat)}] ${l}`),s.lines.push(l),fh(t),Pc(e,t),de.scrollOnInput[t]===1&&y(e,t),i},clear(){let a=Cn.get(t);return a&&(a.lines=[],de.lineCount[t]=0,Pc(e,t),x$1(e,t)),i},getLines(){let a=Cn.get(t);return a?[...a.lines]:[]},getLineCount(){return de.lineCount[t]??0},show(){return j$1(e,t,true),i},hide(){return j$1(e,t,false),i},move(a,s){return K(e,t,a,s),g(e,t),i},setPosition(a,s){return F(e,t,a,s),g(e,t),i},focus(){return aa(e,t),i},blur(){return ba(e,t),i},isFocused(){return _(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},scrollTo(a,s){return p(e,t,a,s),g(e,t),i},scrollBy(a,s){return o(e,t,a,s),g(e,t),i},setScrollPerc(a,s){return r(e,t,a,s),g(e,t),i},getScrollPerc(){return q$2(e,t)},getScroll(){return n$1(e,t)},setViewport(a,s){return v(e,t,a,s),g(e,t),i},getScrollable(){return s(e,t)},scrollToTop(){return x$1(e,t),g(e,t),i},scrollToBottom(){return y(e,t),g(e,t),i},scrollToLeft(){return z$3(e,t),g(e,t),i},scrollToRight(){return A(e,t),g(e,t),i},canScroll(){return B(e,t)},canScrollX(){return C(e,t)},canScrollY(){return D(e,t)},isAtTop(){return E(e,t)},isAtBottom(){return F$1(e,t)},isAtLeft(){return G$1(e,t)},isAtRight(){return H(e,t)},destroy(){de.isLog[t]=0,de.mouseEnabled[t]=0,de.keysEnabled[t]=0,de.scrollOnInput[t]=0,de.timestamps[t]=0,de.scrollback[t]=0,de.lineCount[t]=0,Cn.delete(t),e$3(e,t);}};return i}function Th(e,r){return de.isLog[r]===1}function Wh(e,r){return de.mouseEnabled[r]===1}function vh(e,r){return de.keysEnabled[r]===1}function Lh(e,r){return de.scrollback[r]??0}function Eh(){de.isLog.fill(0),de.mouseEnabled.fill(0),de.keysEnabled.fill(0),de.scrollOnInput.fill(0),de.timestamps.fill(0),de.scrollback.fill(0),de.lineCount.fill(0),Cn.clear();}u();n();f();var Dc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Bh=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Ri=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional()}).optional(),Fc=z.object({left:Dc.optional(),top:Dc.optional(),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),content:z.string().optional(),timeout:z.number().int().nonnegative().optional(),dismissOnClick:z.boolean().optional(),dismissOnKey:z.boolean().optional(),type:z.enum(["info","warning","error","success"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Bh,padding:z.number().int().nonnegative().optional(),infoStyle:Ri,warningStyle:Ri,errorStyle:Ri,successStyle:Ri}),Mc=3e3,Ya=1,kc={info:{fg:"#ffffff",bg:"#2196f3",borderFg:"#64b5f6"},warning:{fg:"#000000",bg:"#ff9800",borderFg:"#ffb74d"},error:{fg:"#ffffff",bg:"#f44336",borderFg:"#e57373"},success:{fg:"#ffffff",bg:"#4caf50",borderFg:"#81c784"}},Ii=1e4,Me={isMessage:new Uint8Array(Ii),dismissOnClick:new Uint8Array(Ii),dismissOnKey:new Uint8Array(Ii),dismissed:new Uint8Array(Ii)},It=new Map;function Ph(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function Ah(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Rc(e,r){return {info:r.infoStyle,warning:r.warningStyle,error:r.errorStyle,success:r.successStyle}[e]??kc[e]}function Dh(e,r){let o=e.split(`
|
|
14
|
-
`),n=Math.max(...o.map(s=>s.length),10),t=o.length,i=n+r*2+2,a=t+r*2+2;return {width:i,height:a}}function Fh(e,r){Me.isMessage[e]=1,Me.dismissOnClick[e]=r.dismissOnClick!==false?1:0,Me.dismissOnKey[e]=r.dismissOnKey!==false?1:0,Me.dismissed[e]=0,It.set(e,{content:r.content??""});}function Mh(e,r,o){let n=o.content??"",t=o.padding??Ya,{width:i,height:a}=Dh(n,t),s=o.width??i,l=o.height??a;w(e,r,s,l);let u=0,d=0;o.left!==void 0&&(typeof o.left=="number"?u=o.left:o.left==="center"&&(u=0)),o.top!==void 0&&(typeof o.top=="number"?d=o.top:o.top==="center"&&(d=0)),F(e,r,u,d);}function kh(e,r,o){let n=o.type??"info",t=Rc(n,o),i=o.fg??t.fg,a=o.bg??t.bg;(i!==void 0||a!==void 0)&&d(e,r,{fg:i!==void 0?e$1(i):void 0,bg:a!==void 0?e$1(a):void 0});}function Rh(e,r,o){let n=o.type??"info",t=Rc(n,o),i=o.border?.type?Ah(o.border.type):1,a=o.border?.fg??t.borderFg;l(e,r,{type:i,fg:a!==void 0?e$1(a):void 0,bg:o.border?.bg!==void 0?e$1(o.border.bg):void 0});let s=o.border?.ch?typeof o.border.ch=="string"?Ph(o.border.ch):o.border.ch:d$3;m(e,r,s);}function Ih(e,r,o){let n=o.content??"";e$2(e,r,n,{align:1,valign:1});}function Vh(e,r,o,n){let t=o.timeout??Mc;if(t<=0)return;let i=It.get(r);i&&(i.timerId=setTimeout(()=>{n();},t));}function Hr(e,r={}){let o=Fc.parse(r),n=d$1(e);Fh(n,o),Mh(e,n,o),kh(e,n,o),Rh(e,n,o),Ih(e,n,o);let t=o.padding??Ya;b(e,n,{left:t,top:t,right:t,bottom:t}),Y(e,n,{focusable:true});let i=()=>{if(Me.dismissed[n]===1)return;Me.dismissed[n]=1,j$1(e,n,false);let s=It.get(n);s&&(s.timerId&&(clearTimeout(s.timerId),s.timerId=void 0),s.onDismissCallback&&s.onDismissCallback());};Vh(e,n,o,i);let a={eid:n,setContent(s){let l=It.get(n);return l&&(l.content=s),e$2(e,n,s,{align:1,valign:1}),g(e,n),a},getContent(){return It.get(n)?.content??""},show(){return j$1(e,n,true),a},hide(){return j$1(e,n,false),a},move(s,l){return K(e,n,s,l),g(e,n),a},setPosition(s,l){return F(e,n,s,l),g(e,n),a},center(s,l){let u=x(e,n),d=u?.width??20,f=u?.height??5,g$1=Math.floor((s-d)/2),c=Math.floor((l-f)/2);return F(e,n,g$1,c),g(e,n),a},dismiss:i,isDismissed(){return Me.dismissed[n]===1},onDismiss(s){let l=It.get(n);return l&&(l.onDismissCallback=s),a},destroy(){let s=It.get(n);s?.timerId&&clearTimeout(s.timerId),Me.isMessage[n]=0,Me.dismissOnClick[n]=0,Me.dismissOnKey[n]=0,Me.dismissed[n]=0,It.delete(n),e$3(e,n);}};return a}function _h(e,r,o={}){return Hr(e,{...o,content:r,type:"info"})}function Oh(e,r,o={}){return Hr(e,{...o,content:r,type:"warning"})}function Gh(e,r,o={}){return Hr(e,{...o,content:r,type:"error"})}function Nh(e,r,o={}){return Hr(e,{...o,content:r,type:"success"})}function Ka(e,r){return Me.isMessage[r]===1}function Ic(e,r){return Me.dismissOnClick[r]===1}function Vc(e,r){return Me.dismissOnKey[r]===1}function zh(e,r){if(!Ka(e,r)||!Ic(e,r)||Me.dismissed[r]===1)return false;let o=It.get(r);return o&&(Me.dismissed[r]=1,j$1(e,r,false),o.timerId&&(clearTimeout(o.timerId),o.timerId=void 0),o.onDismissCallback&&o.onDismissCallback()),true}function wh(e,r){if(!Ka(e,r)||!Vc(e,r)||Me.dismissed[r]===1)return false;let o=It.get(r);return o&&(Me.dismissed[r]=1,j$1(e,r,false),o.timerId&&(clearTimeout(o.timerId),o.timerId=void 0),o.onDismissCallback&&o.onDismissCallback()),true}function Hh(){for(let e of It.values())e.timerId&&clearTimeout(e.timerId);Me.isMessage.fill(0),Me.dismissOnClick.fill(0),Me.dismissOnKey.fill(0),Me.dismissed.fill(0),It.clear();}u();n();f();var Qa=1e4,Uh=40,$h=10,jh=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),Yh=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),_c=z.object({backdrop:z.boolean().optional().default(true),backdropColor:z.union([z.string(),z.number()]).optional().default("#000000"),backdropOpacity:z.number().min(0).max(1).optional().default(.5),closeOnBackdropClick:z.boolean().optional().default(true),closeOnEscape:z.boolean().optional().default(true),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),left:z.number().int().optional(),top:z.number().int().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:jh.optional(),padding:Yh.optional(),content:z.string().optional()}),De={isModal:new Uint8Array(Qa),isOpen:new Uint8Array(Qa),backdropEnabled:new Uint8Array(Qa)},vt=new Map,on=[];function Kh(e){if(typeof e=="object")return e;switch(e){case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3;default:return b$1}}function Qh(e){return e==="bg"?2:e==="none"?0:1}function Xh(e,r,o){if(typeof o=="number"){b(e,r,{left:o,top:o,right:o,bottom:o});return}if(o){b(e,r,{left:o.left??0,top:o.top??0,right:o.right??0,bottom:o.bottom??0});return}}function qh(e){let r=on.indexOf(e);r!==-1&&on.splice(r,1),on.push(e);}function Xa(e){let r=on.indexOf(e);r!==-1&&on.splice(r,1);}function Jh(e,r,o,n){o===void 0&&n===void 0||d(e,r,{fg:o!==void 0?e$1(o):void 0,bg:n!==void 0?e$1(n):void 0});}function Zh(e,r,o){o?.type!=="none"&&(l(e,r,{type:Qh(o?.type),fg:o?.fg!==void 0?e$1(o.fg):void 0,bg:o?.bg!==void 0?e$1(o.bg):void 0}),m(e,r,Kh(o?.ch)));}function Oc(e,r={}){let o=_c.parse(r),n=d$1(e),t=o.width??Uh,i=o.height??$h;return De.isModal[n]=1,De.isOpen[n]=0,De.backdropEnabled[n]=o.backdrop?1:0,vt.set(n,{content:o.content??"",backdropColor:e$1(o.backdropColor),backdropOpacity:o.backdropOpacity,closeOnBackdropClick:o.closeOnBackdropClick,closeOnEscape:o.closeOnEscape,width:t,height:i,onCloseCallbacks:[],onOpenCallbacks:[]}),F(e,n,o.left??0,o.top??0),w(e,n,t,i),Jh(e,n,o.fg,o.bg),Zh(e,n,o.border),Xh(e,n,o.padding),o.content&&e$2(e,n,o.content,{align:0,valign:0}),j$1(e,n,false),ex(e,n)}function ex(e,r){let o={eid:r,show(){De.isOpen[r]=1,j$1(e,r,true),qh(r),g(e,r);let n=vt.get(r);if(n)for(let t of n.onOpenCallbacks)t();return o},hide(){return De.isOpen[r]=0,j$1(e,r,false),Xa(r),g(e,r),o},move(n,t){return K(e,r,n,t),g(e,r),o},setPosition(n,t){return F(e,r,n,t),g(e,r),o},center(n,t){let i=vt.get(r);if(!i)return o;let a=Math.max(0,Math.floor((n-i.width)/2)),s=Math.max(0,Math.floor((t-i.height)/2));return F(e,r,a,s),g(e,r),o},setContent(n){let t=vt.get(r);return t&&(t.content=n),e$2(e,r,n,{align:0,valign:0}),g(e,r),o},getContent(){return vt.get(r)?.content??""},close(){if(De.isOpen[r]===0)return;De.isOpen[r]=0,j$1(e,r,false),Xa(r),g(e,r);let n=vt.get(r);if(n)for(let t of n.onCloseCallbacks)t();},isOpen(){return De.isOpen[r]===1},onClose(n){let t=vt.get(r);return t&&t.onCloseCallbacks.push(n),o},onOpen(n){let t=vt.get(r);return t&&t.onOpenCallbacks.push(n),o},destroy(){De.isOpen[r]===1&&o.close(),De.isModal[r]=0,De.isOpen[r]=0,De.backdropEnabled[r]=0,vt.delete(r),e$3(e,r);}};return o}function tx(e,r={}){let o=Oc(e,r);return o.show(),o}function Vi(e,r){if(De.isModal[r]!==1||De.isOpen[r]===0)return;De.isOpen[r]=0,j$1(e,r,false),Xa(r),g(e,r);let o=vt.get(r);if(o)for(let n of o.onCloseCallbacks)n();}function nx(e){let r=[...on];for(let o=r.length-1;o>=0;o--){let n=r[o];Vi(e,n);}}function rx(e){return on.length>0}function ox(e){return [...on]}function ix(e,r){return De.isModal[r]===1}function ax(){De.isModal.fill(0),De.isOpen.fill(0),De.backdropEnabled.fill(0),vt.clear(),on.length=0;}function sx(e,r){return De.isModal[r]!==1||De.isOpen[r]!==1||!vt.get(r)?.closeOnBackdropClick?false:(Vi(e,r),true)}function lx(e,r){return De.isModal[r]!==1||De.isOpen[r]!==1||!vt.get(r)?.closeOnEscape?false:(Vi(e,r),true)}u();n();f();z.object({title:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional(),align:z.enum(["left","center","right"]).optional()}).optional(),content:z.object({fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional()}).optional(),border:z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number().int().nonnegative()]).optional(),bg:z.union([z.string(),z.number().int().nonnegative()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.unknown()]).optional()}).optional()});var _i="",Hc="\u2715",Uc="\u25BC",$c="\u25B6",Gc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Nc=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),ux=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.object({}).passthrough()]).optional()}),dx=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),align:z.enum(["left","center","right"]).optional()}),cx=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),gx=z.object({title:dx.optional(),content:cx.optional(),border:ux.optional()}),mx=z.union([z.number().nonnegative(),z.object({left:z.number().nonnegative().optional(),top:z.number().nonnegative().optional(),right:z.number().nonnegative().optional(),bottom:z.number().nonnegative().optional()})]),jc=z.object({left:Gc.optional(),top:Gc.optional(),width:Nc.optional(),height:Nc.optional(),title:z.string().optional(),titleAlign:z.enum(["left","center","right"]).optional(),closable:z.boolean().optional(),collapsible:z.boolean().optional(),collapsed:z.boolean().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),style:gx.optional(),padding:mx.optional(),content:z.string().optional()}),sr=1e4,q={isPanel:new Uint8Array(sr),collapsed:new Uint8Array(sr),closable:new Uint8Array(sr),collapsible:new Uint8Array(sr),originalHeight:new Float32Array(sr),titleAlign:new Uint8Array(sr)},Sn=new Map,Ur=new Map;function zc(e){return e===void 0?0:typeof e=="number"?e:0}function wc(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function fx(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function Yc(e){switch(e){case 0:return "left";case 1:return "center";case 2:return "right";default:return "left"}}function bx(e){return typeof e=="number"?{left:e,top:e+1,right:e,bottom:e}:e?{left:e.left??0,top:(e.top??0)+1,right:e.right??0,bottom:e.bottom??0}:{left:0,top:1,right:0,bottom:0}}function px(e){return e===void 0||e==="single"?b$1:typeof e=="object"?e:b$1}function yx(e,r,o){(o.fg!==void 0||o.bg!==void 0)&&d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function hx(e,r,o){let n=o.style?.border;n?.type!=="none"&&l(e,r,{type:n?.type==="bg"?2:1,fg:n?.fg!==void 0?e$1(n.fg):void 0,bg:n?.bg!==void 0?e$1(n.bg):void 0}),m(e,r,px(n?.ch));}function qa(e,r,o={}){let n=jc.parse(o),t=r;q.isPanel[t]=1,q.collapsed[t]=n.collapsed?1:0,q.closable[t]=n.closable?1:0,q.collapsible[t]=n.collapsible?1:0,q.titleAlign[t]=fx(n.titleAlign??n.style?.title?.align??"left"),Sn.set(t,n.title??_i),Ur.set(t,n.content??"");let i=zc(n.left),a=zc(n.top);F(e,t,i,a);let s=wc(n.width),l=wc(n.height);w(e,t,s,l);let u=x(e,t);q.originalHeight[t]=u?.height??10,yx(e,t,n),hx(e,t,n),b(e,t,bx(n.padding)),n.content&&e$2(e,t,n.content,{align:0,valign:0}),Y(e,t,{focusable:true}),j$1(e,t,true),n.collapsed&&w(e,t,s,3);let d={eid:t,show(){return j$1(e,t,true),d},hide(){return j$1(e,t,false),d},move(f,g$1){return K(e,t,f,g$1),g(e,t),d},setPosition(f,g$1){return F(e,t,f,g$1),g(e,t),d},setTitle(f){return Sn.set(t,f),g(e,t),d},getTitle(){return Sn.get(t)??_i},setContent(f){return Ur.set(t,f),e$2(e,t,f,{align:0,valign:0}),g(e,t),d},getContent(){return Ur.get(t)??""},collapse(){if(q.collapsible[t]===0||q.collapsed[t]===1)return d;let f=x(e,t);f&&(q.originalHeight[t]=f.height);let g$1=x(e,t);return w(e,t,g$1?.width??"auto",3),q.collapsed[t]=1,g(e,t),d},expand(){if(q.collapsible[t]===0||q.collapsed[t]===0)return d;let f=q.originalHeight[t],g$1=x(e,t);return w(e,t,g$1?.width??"auto",f),q.collapsed[t]=0,g(e,t),d},toggle(){return q.collapsed[t]===1?d.expand():d.collapse()},isCollapsed(){return q.collapsed[t]===1},isClosable(){return q.closable[t]===1},close(){q.closable[t]===1&&j$1(e,t,false);},focus(){return aa(e,t),d},blur(){return ba(e,t),d},isFocused(){return _(e,t)},append(f){return d$2(e,t,f),d},getChildren(){return f$1(e,t)},destroy(){q.isPanel[t]=0,q.collapsed[t]=0,q.closable[t]=0,q.collapsible[t]=0,q.originalHeight[t]=0,q.titleAlign[t]=0,Sn.delete(t),Ur.delete(t),e$3(e,t);}};return d}function xx(e,r){return q.isPanel[r]===1}function Cx(e,r){return Sn.get(r)??_i}function Sx(e,r,o){return Sn.set(r,o),g(e,r),r}function Tx(e,r){return q.collapsed[r]===1}function Wx(e,r){return Yc(q.titleAlign[r])}function vx(e,r,o){let n=Sn.get(r)??"",t=q.closable[r]===1,i=q.collapsible[r]===1,a=q.collapsed[r]===1,s=Yc(q.titleAlign[r]),l=(t?2:0)+(i?2:0),u=Math.max(0,o-l),d=n;d.length>u&&(d=`${d.slice(0,u-1)}\u2026`);let f="";i&&(f+=a?`${$c} `:`${Uc} `),t&&(f+=`${Hc} `),f=f.trimEnd();let g=u-d.length,c=0,b=0;switch(s){case "left":b=g;break;case "center":c=Math.floor(g/2),b=g-c;break;case "right":c=g;break}return `${" ".repeat(c)}${d}${" ".repeat(b)}${f}`}function Lx(){q.isPanel.fill(0),q.collapsed.fill(0),q.closable.fill(0),q.collapsible.fill(0),q.originalHeight.fill(0),q.titleAlign.fill(0),Sn.clear(),Ur.clear();}n();function Za(e){return Math.max(0,Math.min(100,e))}var Qc=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),height:z.number().int().positive().default(1),value:z.number().default(0).transform(e=>Za(e)),fillChar:z.string().default("\u2588"),emptyChar:z.string().default("\u2591"),showPercentage:z.boolean().default(false),label:z.string().default(""),indeterminate:z.boolean().default(false)}),Ja=1e4,Qe={isProgressBar:new Uint8Array(Ja),showPercentage:new Uint8Array(Ja),indeterminate:new Uint8Array(Ja)},bt=new Map;function lr(e,r){let o=bt.get(r);if(!o)return;let n=Qe.indeterminate[r]===1,t=Qe.showPercentage[r]===1,i=Math.floor(o.value/100*o.width),a=o.width-i,s=o.fillChar.repeat(i),l=o.emptyChar.repeat(a),u=s+l,d=u;n?d=u:o.label?d=`${u} ${o.label}`:t&&(d=`${u} ${Math.round(o.value)}%`),e$2(e,r,d);}function Kc(e,r){let o=bt.get(e);if(o)for(let n of o.onChangeCallbacks)n(r);}function Ex(e,r={}){let o=Qc.parse(r),n=d$1(e);Qe.isProgressBar[n]=1,Qe.showPercentage[n]=o.showPercentage?1:0,Qe.indeterminate[n]=o.indeterminate?1:0,w(e,n,o.width,o.height),F(e,n,o.x,o.y),bt.set(n,{value:o.value,fillChar:o.fillChar,emptyChar:o.emptyChar,label:o.label,width:o.width,onChangeCallbacks:[]}),lr(e,n);let t={eid:n,setValue(i){let a=bt.get(n);if(!a)return t;let s=Za(i);return a.value=s,lr(e,n),g(e,n),Kc(n,s),t},getValue(){return bt.get(n)?.value??0},increment(i){let a=bt.get(n);if(!a)return t;let s=Za(a.value+i);return a.value=s,lr(e,n),g(e,n),Kc(n,s),t},setLabel(i){let a=bt.get(n);return a&&(a.label=i,lr(e,n),g(e,n)),t},getLabel(){return bt.get(n)?.label??""},showPercentage(i){return Qe.showPercentage[n]=i?1:0,lr(e,n),g(e,n),t},isPercentageShown(){return Qe.showPercentage[n]===1},getFillChar(){return bt.get(n)?.fillChar??"\u2588"},getEmptyChar(){return bt.get(n)?.emptyChar??"\u2591"},setIndeterminate(i){return Qe.indeterminate[n]=i?1:0,lr(e,n),g(e,n),t},isIndeterminate(){return Qe.indeterminate[n]===1},setPosition(i,a){return F(e,n,i,a),g(e,n),t},move(i,a){return K(e,n,i,a),g(e,n),t},getPosition(){let i=bt.get(n);return {x:E$1.x[n]??0,y:E$1.y[n]??0,width:i?.width??20,height:1}},onChange(i){let a=bt.get(n);return a&&a.onChangeCallbacks.push(i),t},destroy(){Qe.isProgressBar[n]=0,Qe.showPercentage[n]=0,Qe.indeterminate[n]=0,bt.delete(n),e$3(e,n);}};return t}function Bx(e,r){return Qe.isProgressBar[r]===1}function Px(){Qe.isProgressBar.fill(0),Qe.showPercentage.fill(0),Qe.indeterminate.fill(0),bt.clear();}u();n();f();var Ax=1e4,Dx=4294967295,Fx=255,Xc=40,qc=5,Jc=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Zc=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),ts=z.object({message:z.string().default(""),defaultValue:z.string().default(""),placeholder:z.string().default(""),width:z.number().int().positive().default(Xc),height:z.number().int().positive().default(qc),left:z.number().int().default(0),top:z.number().int().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:Jc,padding:Zc}),$r={isPrompt:new Uint8Array(Ax)},tt=new Map;function Mx(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function kx(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Rx(e,r,o,n){o===void 0&&n===void 0||d(e,r,{fg:o!==void 0?e$1(o):void 0,bg:n!==void 0?e$1(n):void 0});}function Ix(e,r,o){let n=o.type?kx(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?Mx(o.ch):o.ch;m(e,r,t);}}function Vx(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function es(e,r){let o=tt.get(r);if(!o)return;let n=o.value||o.placeholder,t=o.message?`${o.message}
|
|
15
|
-
${n}`:n;e$2(e,r,t);}function eg(e,r={}){let o=ts.parse(r),n=d$1(e);return $r.isPrompt[n]=1,F(e,n,o.left,o.top),w(e,n,o.width,o.height),Rx(e,n,o.fg,o.bg),o.border&&Ix(e,n,o.border),o.padding!==void 0&&Vx(e,n,o.padding),tt.set(n,{message:o.message,value:o.defaultValue,placeholder:o.placeholder,visible:true,validator:r.validator,submitCallbacks:[],cancelCallbacks:[]}),es(e,n),_x(e,n)}function _x(e,r){let o={get eid(){return r},show(){let n=tt.get(r);return n&&(n.visible=true),j$1(e,r,true),g(e,r),o},hide(){let n=tt.get(r);return n&&(n.visible=false),j$1(e,r,false),g(e,r),o},move(n,t){let i=E$1.x[r]??0,a=E$1.y[r]??0;return F(e,r,i+n,a+t),g(e,r),o},setPosition(n,t){return F(e,r,n,t),g(e,r),o},center(n,t){if(!tt.get(r))return o;let a=ts.parse({}),s=a.width,l=a.height,u=Math.floor((n-s)/2),d=Math.floor((t-l)/2);return F(e,r,u,d),g(e,r),o},setMessage(n){let t=tt.get(r);return t&&(t.message=n,es(e,r),g(e,r)),o},getMessage(){return tt.get(r)?.message??""},setValue(n){let t=tt.get(r);return t&&(t.value=n,es(e,r),g(e,r)),o},getValue(){return tt.get(r)?.value??""},submit(){let n=tt.get(r);if(!n)return o;if(n.validator){let t=n.validator(n.value);if(t!==true&&typeof t=="string"||t===false)return o}for(let t of n.submitCallbacks)t(n.value);return o},cancel(){let n=tt.get(r);if(!n)return o;for(let t of n.cancelCallbacks)t();return o},onSubmit(n){let t=tt.get(r);return t&&t.submitCallbacks.push(n),o},onCancel(n){let t=tt.get(r);return t&&t.cancelCallbacks.push(n),o},destroy(){$r.isPrompt[r]=0,tt.delete(r),e$3(e,r);}};return o}function Ox(e,r,o={}){return new Promise(n=>{let t=eg(e,{...o,message:r});t.onSubmit(i=>{t.destroy(),n(i);}),t.onCancel(()=>{t.destroy(),n(null);});})}function Gx(e){return $r.isPrompt[e]===1}function Nx(){$r.isPrompt.fill(0),tt.clear();}function zx(e,r){return r==="return"||r==="enter"?(e.submit(),true):r==="escape"?(e.cancel(),true):false}u();n();f();var wx=1e4,Hx=4294967295,Ux=0,tg=40,ng=5,$x=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),jx=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),rg=z.object({message:z.string().default("Are you sure?"),yesText:z.string().default("Yes"),noText:z.string().default("No"),defaultAnswer:z.boolean().default(true),width:z.number().int().positive().default(tg),height:z.number().int().positive().default(ng),left:z.number().int().default(0),top:z.number().int().default(0),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:$x,padding:jx}),jr={isQuestion:new Uint8Array(wx)},nt=new Map;function Yx(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function Kx(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function Oi(e,r){let o=nt.get(r);if(!o)return;let n=o.selectedAnswer?`[${o.yesText}]`:` ${o.yesText} `,t=o.selectedAnswer?` ${o.noText} `:`[${o.noText}]`,i=`${o.message}
|
|
16
|
-
|
|
17
|
-
${n} ${t}`;e$2(e,r,i);}function Qx(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function Xx(e,r,o){let n=o.type?Kx(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?Yx(o.ch):o.ch;m(e,r,t);}}function qx(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function og(e,r={}){let o=rg.parse(r),n=d$1(e);return jr.isQuestion[n]=1,F(e,n,o.left,o.top),w(e,n,o.width,o.height),Qx(e,n,o),o.border&&Xx(e,n,o.border),o.padding!==void 0&&qx(e,n,o.padding),nt.set(n,{message:o.message,yesText:o.yesText,noText:o.noText,selectedAnswer:o.defaultAnswer,visible:true,confirmCallbacks:[],cancelCallbacks:[]}),Oi(e,n),Jx(e,n)}function Jx(e,r){let o={get eid(){return r},show(){let n=nt.get(r);return n&&(n.visible=true),j$1(e,r,true),g(e,r),o},hide(){let n=nt.get(r);return n&&(n.visible=false),j$1(e,r,false),g(e,r),o},move(n,t){let i=E$1.x[r]??0,a=E$1.y[r]??0;return F(e,r,i+n,a+t),g(e,r),o},setPosition(n,t){return F(e,r,n,t),g(e,r),o},center(n,t){let i=x(e,r);if(!i)return o;let a=Math.floor((n-i.width)/2),s=Math.floor((t-i.height)/2);return F(e,r,a,s),g(e,r),o},setMessage(n){let t=nt.get(r);return t&&(t.message=n,Oi(e,r),g(e,r)),o},getMessage(){return nt.get(r)?.message??""},selectYes(){let n=nt.get(r);return n&&(n.selectedAnswer=true,Oi(e,r),g(e,r)),o},selectNo(){let n=nt.get(r);return n&&(n.selectedAnswer=false,Oi(e,r),g(e,r)),o},getSelectedAnswer(){return nt.get(r)?.selectedAnswer??true},confirm(){let n=nt.get(r);if(n)for(let t of n.confirmCallbacks)t(n.selectedAnswer);return o},cancel(){let n=nt.get(r);if(n)for(let t of n.cancelCallbacks)t();return o},onConfirm(n){let t=nt.get(r);return t&&t.confirmCallbacks.push(n),o},onCancel(n){let t=nt.get(r);return t&&t.cancelCallbacks.push(n),o},destroy(){jr.isQuestion[r]=0,nt.delete(r),e$3(e,r);}};return o}function ig(e,r,o={}){return new Promise(n=>{let t=og(e,{...o,message:r});t.onConfirm(i=>{t.destroy(),n(i);}),t.onCancel(()=>{t.destroy(),n(false);});})}function Zx(e,r){return ig(e,r)}function eC(e,r){return jr.isQuestion[r]===1}function tC(e,r){switch(r){case "y":case "Y":return e.selectYes().confirm(),true;case "n":case "N":return e.selectNo().confirm(),true;case "enter":case "return":return e.confirm(),true;case "escape":return e.cancel(),true;default:return false}}function nC(){jr.isQuestion.fill(0),nt.clear();}n();var ag=z.object({x:z.number().int().default(0),y:z.number().int().default(0)}),sg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().default(1),label:z.string().default(""),value:z.string().default(""),selectedChar:z.string().default("\u25C9"),unselectedChar:z.string().default("\u25CB"),focusable:z.boolean().default(true),disabled:z.boolean().default(false),groupId:z.number().int().optional()}),lg=1e4,Kr={isRadioGroupWidget:new Uint8Array(lg)},Qr={isRadioButtonWidget:new Uint8Array(lg)},Gi=new Map,ur=new Map;function rC(e,r={}){let o=ag.parse(r),n=d$1(e);Kr.isRadioGroupWidget[n]=1,ob$1(e,n),F(e,n,o.x,o.y),Gi.set(n,{nextY:o.y,world:e});let t={eid:n,addOption(i,a){let s=Gi.get(n);if(!s)throw new Error("RadioGroup state not found");let l=ug(e,{x:o.x,y:s.nextY,label:a,value:i,groupId:n});return s.nextY+=1,l},getSelectedValue(){return rb$2(n)},onChange(i){return sb$2(n,a=>{i(a);}),t},destroy(){Kr.isRadioGroupWidget[n]=0,Gi.delete(n),tb$2(n),e$3(e,n);}};return t}function ug(e,r={}){let o=sg.parse(r),n=d$1(e);Qr.isRadioButtonWidget[n]=1,ub$2(e,n,o.groupId),Eb$2(n,o.value),Jb$2(n,{selectedChar:o.selectedChar,unselectedChar:o.unselectedChar});let t=Math.max(o.selectedChar.length,o.unselectedChar.length),i=o.label.length,a=o.width??t+(i>0?1+i:0);w(e,n,a,o.height),F(e,n,o.x,o.y),ur.set(n,{label:o.label}),Yr(e,n),d$5(e,n,{clickable:true,hoverable:true,keyable:true,focusable:o.focusable}),Y(e,n,{focusable:o.focusable}),o.disabled&&Hb$2(e,n);let s={eid:n,select(){return Fb$1(e,n),Yr(e,n),g(e,n),s},deselect(){return Gb$2(e,n),Yr(e,n),g(e,n),s},isSelected(){return zb$2(e,n)},getChar(){return Lb$2(e,n)},getValue(){return Db$1(n)??""},setLabel(l){let u=ur.get(n);u&&(u.label=l);let f=Lb$2(e,n).length+(l.length>0?1+l.length:0);return w(e,n,f,o.height),Yr(e,n),g(e,n),s},getLabel(){return ur.get(n)?.label??""},setDisabled(l){return l?Hb$2(e,n):Ib$2(e,n),g(e,n),s},isDisabled(){return Ab(e,n)},setPosition(l,u){return F(e,n,l,u),g(e,n),s},move(l,u){return K(e,n,l,u),g(e,n),s},getPosition(){return {x:E$1.x[n]??0,y:E$1.y[n]??0}},focus(){return aa(e,n),g(e,n),s},blur(){return ba(e,n),g(e,n),s},isFocused(){return _(e,n)},handleKey(l){if(!_(e,n))return false;let u=Nb$2(e,n,l);return u&&(Yr(e,n),g(e,n)),u},destroy(){Qr.isRadioButtonWidget[n]=0,ur.delete(n),Mb$2(n),e$3(e,n);}};return s}function Yr(e,r){let o=Lb$2(e,r),t=ur.get(r)?.label??"",i=t.length>0?`${o} ${t}`:o;e$2(e,r,i);}function oC(e,r){return Kr.isRadioGroupWidget[r]===1&&pb$1(e,r)}function iC(e,r){return Qr.isRadioButtonWidget[r]===1&&vb$2(e,r)}function aC(){Kr.isRadioGroupWidget.fill(0),Qr.isRadioButtonWidget.fill(0),Gi.clear(),ur.clear();}n();u();n();f();var dg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Ni=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),sC=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),lC=z.union([z.number().int().nonnegative(),z.object({left:z.number().int().nonnegative().optional(),top:z.number().int().nonnegative().optional(),right:z.number().int().nonnegative().optional(),bottom:z.number().int().nonnegative().optional()})]).optional(),uC=z.union([z.boolean(),z.object({mode:z.enum(["auto","visible","hidden"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),trackChar:z.string().optional(),thumbChar:z.string().optional()})]).optional(),mg=z.object({left:Ni.optional(),top:Ni.optional(),right:Ni.optional(),bottom:Ni.optional(),width:dg.optional(),height:dg.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:sC,padding:lC,content:z.string().optional(),align:z.enum(["left","center","right"]).optional(),valign:z.enum(["top","middle","bottom"]).optional(),scrollbar:uC,alwaysScroll:z.boolean().optional(),mouse:z.boolean().optional(),keys:z.boolean().optional(),scrollWidth:z.number().nonnegative().optional(),scrollHeight:z.number().nonnegative().optional(),scrollX:z.number().optional(),scrollY:z.number().optional()}),ns=1e4,Lt={isScrollableBox:new Uint8Array(ns),mouseEnabled:new Uint8Array(ns),keysEnabled:new Uint8Array(ns)};function dC(e){switch(e){case "left":return 0;case "center":return 1;case "right":return 2}}function cC(e){switch(e){case "top":return 0;case "middle":return 1;case "bottom":return 2}}function gC(e){let{BORDER_DOUBLE:r,BORDER_ROUNDED:o,BORDER_BOLD:n,BORDER_ASCII:t$1}=(u(),d$4(t));switch(e){case "single":return b$1;case "double":return r;case "rounded":return o;case "bold":return n;case "ascii":return t$1}}function mC(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function cg(e){return e===void 0?0:typeof e=="number"?e:0}function gg(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function fC(e){switch(e){case "auto":return 2;case "visible":return 1;case "hidden":return 0}}function bC(e,r,o){let n=cg(o.left),t=cg(o.top);F(e,r,n,t);let i=gg(o.width),a=gg(o.height);w(e,r,i,a);}function pC(e,r,o){o.fg===void 0&&o.bg===void 0||d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function yC(e,r,o){let n=o.type?mC(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?gC(o.ch):o.ch;m(e,r,t);}}function hC(e,r,o){typeof o=="number"?b(e,r,{left:o,top:o,right:o,bottom:o}):b(e,r,o);}function xC(e,r,o){if(o.content===void 0)return;let n={};o.align&&(n.align=dC(o.align)),o.valign&&(n.valign=cC(o.valign)),e$2(e,r,o.content,n);}function CC(e,r,o){let n={};o.scrollWidth!==void 0&&(n.scrollWidth=o.scrollWidth),o.scrollHeight!==void 0&&(n.scrollHeight=o.scrollHeight),o.scrollX!==void 0&&(n.scrollX=o.scrollX),o.scrollY!==void 0&&(n.scrollY=o.scrollY),o.alwaysScroll!==void 0&&(n.alwaysScroll=o.alwaysScroll),o.scrollbar===true?n.scrollbarVisible=2:o.scrollbar===false?n.scrollbarVisible=0:typeof o.scrollbar=="object"&&o.scrollbar.mode&&(n.scrollbarVisible=fC(o.scrollbar.mode)),l$1(e,r,n),Lt.mouseEnabled[r]=o.mouse!==false?1:0,Lt.keysEnabled[r]=o.keys!==false?1:0;}function Xr(e,r$1,o$1={}){let n=mg.parse(o$1),t=r$1;Lt.isScrollableBox[t]=1,bC(e,t,n),pC(e,t,n),n.border&&yC(e,t,n.border),n.padding!==void 0&&hC(e,t,n.padding),xC(e,t,n),CC(e,t,n),Y(e,t,{focusable:true});let i={eid:t,show(){return j$1(e,t,true),i},hide(){return j$1(e,t,false),i},move(a,s){return K(e,t,a,s),g(e,t),i},setPosition(a,s){return F(e,t,a,s),g(e,t),i},setContent(a){return e$2(e,t,a),g(e,t),i},getContent(){return f$2(e,t)},focus(){return aa(e,t),i},blur(){return ba(e,t),i},isFocused(){return _(e,t)},append(a){return d$2(e,t,a),i},getChildren(){return f$1(e,t)},scrollTo(a,s){return p(e,t,a,s),g(e,t),i},scrollBy(a,s){return o(e,t,a,s),g(e,t),i},setScrollPerc(a,s){return r(e,t,a,s),g(e,t),i},getScrollPerc(){return q$2(e,t)},getScroll(){return n$1(e,t)},setScrollSize(a,s){return u$1(e,t,a,s),g(e,t),i},setViewport(a,s){return v(e,t,a,s),g(e,t),i},getScrollable(){return s(e,t)},scrollToTop(){return x$1(e,t),g(e,t),i},scrollToBottom(){return y(e,t),g(e,t),i},scrollToLeft(){return z$3(e,t),g(e,t),i},scrollToRight(){return A(e,t),g(e,t),i},canScroll(){return B(e,t)},canScrollX(){return C(e,t)},canScrollY(){return D(e,t)},isAtTop(){return E(e,t)},isAtBottom(){return F$1(e,t)},isAtLeft(){return G$1(e,t)},isAtRight(){return H(e,t)},destroy(){Lt.isScrollableBox[t]=0,Lt.mouseEnabled[t]=0,Lt.keysEnabled[t]=0,e$3(e,t);}};return i}function rs(e,r){return Lt.isScrollableBox[r]===1}function SC(e,r){return Lt.mouseEnabled[r]===1}function TC(e,r){return Lt.keysEnabled[r]===1}function WC(){Lt.isScrollableBox.fill(0),Lt.mouseEnabled.fill(0),Lt.keysEnabled.fill(0);}function os(e,r,o={}){return Xr(e,r,{...o,alwaysScroll:true})}n();function fg(e){let r={};return e.border?.fg!==void 0&&(r.borderFg=e.border.fg),e.border?.bg!==void 0&&(r.borderBg=e.border.bg),e.header?.fg!==void 0&&(r.headerFg=e.header.fg),e.header?.bg!==void 0&&(r.headerBg=e.header.bg),e.cell?.fg!==void 0&&(r.cellFg=e.cell.fg),e.cell?.bg!==void 0&&(r.cellBg=e.cell.bg),e.altRowBg!==void 0&&(r.altRowBg=e.altRowBg),e.selected?.fg!==void 0&&(r.selectedFg=e.selected.fg),e.selected?.bg!==void 0&&(r.selectedBg=e.selected.bg),r}var bg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().optional(),height:z.number().int().positive().optional(),data:z.array(z.array(z.string())).default([]),pad:z.number().int().min(0).max(10).default(1),align:z.enum(["left","center","right"]).default("left"),style:z.object({border:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),header:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),cell:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),altRowBg:z.number().optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional()}).optional(),noCellBorders:z.boolean().default(false),headerRows:z.number().int().min(0).max(10).default(1),columns:z.array(z.object({header:z.string(),width:z.number().int().positive().optional(),minWidth:z.number().int().positive().optional(),maxWidth:z.number().int().positive().optional(),align:z.enum(["left","center","right"]).optional()})).optional()});function is(e,r,o={}){let n=bg.parse(o),t=r;F(e,t,n.x,n.y),n.width!==void 0&&n.height!==void 0&&w(e,t,n.width,n.height),qb$1(e,t,{headerRows:n.headerRows,pad:n.pad,cellBorders:!n.noCellBorders}),n.data.length>0&&tb$1(e,t,n.data),n.columns&&Hb$1(e,t,n.columns),n.style&&Nb$1(e,t,fg(n.style));let i={eid:t,show(){return j$1(e,t,true),i},hide(){return j$1(e,t,false),i},move(a,s){return E$1.x[t]=(E$1.x[t]??0)+a,E$1.y[t]=(E$1.y[t]??0)+s,g(e,t),i},setPosition(a,s){return F(e,t,a,s),i},setData(a){return tb$1(e,t,a),i},getData(){return vb$1(e,t)},getFullData(){return ub$1(e,t)},clearData(){return Gb$1(e,t),i},setCell(a,s,l){return wb$1(e,t,a,s,l),i},getCell(a,s){return xb$1(e,t,a,s)},getCellValue(a,s){return yb$1(e,t,a,s)},getRow(a){return zb$1(e,t,a)},appendRow(a){return Db(e,t,a),i},insertRow(a,s){return Eb$1(e,t,a,s),i},removeRow(a){return Fb(e,t,a),i},getRowCount(){return Bb$1(e,t)},setColumns(a){return Hb$1(e,t,a),i},getColumns(){return Ib$1(e,t)},getColCount(){return Cb$1(e,t)},calculateColumnWidths(a){return Ub$1(e,t,a)},setHeaderRowCount(a){return Lb$1(e,t,a),i},getHeaderRowCount(){return Mb$1(e,t)},getHeaderRows(){return Jb$1(e,t)},getDataRows(){return Kb$1(e,t)},setCellPadding(a){return Rb$1(e,t,a),i},getCellPadding(){return Qb$1(e,t)},setCellBorders(a){return Tb$1(e,t,a),i},hasCellBorders(){return Sb$1(e,t)},setStyle(a){return Nb$1(e,t,fg(a)),g(e,t),i},getDisplay(){return Ob$1(e,t)},renderLines(a){return Vb$1(e,t,a)},destroy(){sb$1(e,t),e$3(e,t);}};return i}function vC(e,r){return rb$1(e,r)}n();var Fn=1e4,an={VERTICAL:"\u2502",HORIZONTAL:"\u2500",BRANCH:"\u251C",CORNER:"\u2514",EXPANDED:"\u25BC",COLLAPSED:"\u25B6",SPACE:" "},Tg=z.lazy(()=>z.object({label:z.string(),value:z.unknown().optional(),children:z.array(Tg).optional(),expanded:z.boolean().optional(),icon:z.string().optional(),id:z.string().optional()})),Wg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(40),height:z.number().int().positive().default(10),nodes:z.array(Tg).default([]),selected:z.string().optional(),style:z.object({node:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),selected:z.object({fg:z.number().optional(),bg:z.number().optional()}).optional(),expanded:z.object({fg:z.number().optional()}).optional(),collapsed:z.object({fg:z.number().optional()}).optional()}).optional(),showLines:z.boolean().default(true),keys:z.boolean().default(true),indent:z.number().int().min(1).max(8).default(2)}),j={isTree:new Uint8Array(Fn),state:new Uint8Array(Fn),showLines:new Uint8Array(Fn),keys:new Uint8Array(Fn),indent:new Uint8Array(Fn),firstVisible:new Uint32Array(Fn),visibleCount:new Uint32Array(Fn)},Ye=a({iterable:true}),Xe=new Map,qr=new Map,Jr=new Map,Zr=new Map,eo=new Map,pg=3435973887,yg=255,hg=255,xg=16777215,Cg=2298448127,Sg=2290679807,LC={0:"idle",1:"focused"};function EC(){j.isTree.fill(0),j.state.fill(0),j.showLines.fill(0),j.keys.fill(0),j.indent.fill(0),j.firstVisible.fill(0),j.visibleCount.fill(0),Ye.clear(),Xe.clear(),qr.clear(),Jr.clear(),Zr.clear(),eo.clear();}var BC=0;function PC(){return `node_${++BC}`}function ss(e,r,o=0){let n={label:e.label,value:e.value,children:[],expanded:e.expanded??false,icon:e.icon,id:e.id??PC(),parent:r,depth:o};return e.children&&(n.children=e.children.map(t=>ss(t,n,o+1))),n}function AC(e,r,o){return r?.expanded?(e.collapse(o),{type:"collapse"}):(e.selectParent(),{type:"selectParent"})}function DC(e,r,o){return r&&r.children.length>0&&!r.expanded?(e.expand(o),{type:"expand"}):null}function FC(e,r,o,n){return r&&r.children.length>0?(e.toggle(o),{type:"toggle"}):(n(),{type:"confirm"})}function MC(e,r,o,n,t){if(e===0)return "";if(!o)return an.SPACE.repeat(e*r);let i="";for(let a=0;a<e-1;a++)t[a]?i+=an.SPACE.repeat(r):i+=an.VERTICAL+an.SPACE.repeat(r-1);return i+=n?an.CORNER:an.BRANCH,i+=an.HORIZONTAL.repeat(r-1),i}function kC(e,r,o,n){let t=r;return e.children.length>0?(t+=e.expanded?an.EXPANDED:an.COLLAPSED,t+=" "):t+=" ",e.icon&&(t+=`${e.icon} `),t+=e.label,t.length>n&&(t=`${t.slice(0,n-1)}\u2026`),o?t=`[${t.padEnd(n-2)}]`:t=` ${t.padEnd(n-2)} `,t}function vg(e,r="",o=[]){let n=[];for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=t===e.length-1,s=r?`${r}.${t}`:`${t}`;n.push({node:i,path:s,depth:i.depth,isLastChild:a,parentIsLast:[...o]}),i.expanded&&i.children.length>0&&n.push(...vg(i.children,s,[...o,a]));}return n}function Xt(e,r){if(!r)return e[0];let o=r.split(".").map(Number),n=e[o[0]??0];for(let t=1;t<o.length&&n;t++){let i=o[t];i!==void 0&&(n=n.children[i]);}return n}function as(e,r){e.expanded=r;}function Lg(e){for(let r of e)r.expanded=true,r.children.length>0&&Lg(r.children);}function Eg(e){for(let r of e)r.expanded=false,r.children.length>0&&Eg(r.children);}function ls(e,r,o={}){let n=Wg.parse(o),t=r;j.isTree[t]=1,F(e,t,n.x,n.y),w(e,t,n.width,n.height),j.showLines[t]=n.showLines?1:0,j.keys[t]=n.keys?1:0,j.indent[t]=n.indent,j.visibleCount[t]=n.height;let i=n.nodes.map(c=>ss(c));for(let c=0;c<i.length;c++){let b=i[c];b&&(b.rootIndex=c);}Ye.set(t,i),n.selected?Xe.set(t,n.selected):i.length>0&&Xe.set(t,"0");let a={nodeFg:n.style?.node?.fg??pg,nodeBg:n.style?.node?.bg??yg,selectedFg:n.style?.selected?.fg??hg,selectedBg:n.style?.selected?.bg??xg,expandedFg:n.style?.expanded?.fg??Cg,collapsedFg:n.style?.collapsed?.fg??Sg};qr.set(t,a),Jr.set(t,new Set),Zr.set(t,new Set),eo.set(t,new Set);let s=()=>{let c=Xe.get(t)??"",b=Ye.get(t)??[],p=Xt(b,c);if(p){let y=Jr.get(t);if(y)for(let v of y)v(c,p);}},l=()=>{let c=Xe.get(t)??"",b=Ye.get(t)??[],p=Xt(b,c);if(p){let y=Zr.get(t);if(y)for(let v of y)v(c,p);}},u=(c,b)=>{let p=eo.get(t);if(p)for(let y of p)y(c,b);},d=()=>{let c=Ye.get(t)??[];return vg(c)},f=()=>{let c=d(),b=Xe.get(t)??"",p=c.findIndex(T=>T.path===b);if(p<0)return;let y=j.firstVisible[t]??0,v=j.visibleCount[t]??0,x=y+v-1;p<y?j.firstVisible[t]=p:p>x&&(j.firstVisible[t]=Math.max(0,p-v+1));},g$1={eid:t,show(){return j$1(e,t,true),g$1},hide(){return j$1(e,t,false),g$1},move(c,b){return E$1.x[t]=(E$1.x[t]??0)+c,E$1.y[t]=(E$1.y[t]??0)+b,g(e,t),g$1},setPosition(c,b){return F(e,t,c,b),g$1},focus(){return j.state[t]=1,g(e,t),g$1},blur(){return j.state[t]=0,g(e,t),g$1},setNodes(c){let b=c.map(p=>ss(p));return Ye.set(t,b),b.length>0?Xe.set(t,"0"):Xe.delete(t),j.firstVisible[t]=0,g(e,t),g$1},getNodes(){return Ye.get(t)??[]},getNode(c){let b=Ye.get(t)??[];return Xt(b,c)},getVisibleNodes(){return d()},select(c){let b=Ye.get(t)??[];return Xt(b,c)&&(Xe.set(t,c),f(),g(e,t),s()),g$1},getSelectedPath(){return Xe.get(t)??""},getSelectedNode(){let c=Xe.get(t)??"",b=Ye.get(t)??[];return Xt(b,c)},selectPrev(){let c=d(),b=Xe.get(t)??"",p=c.findIndex(y=>y.path===b);if(p>0){let y=c[p-1];y&&g$1.select(y.path);}return g$1},selectNext(){let c=d(),b=Xe.get(t)??"",p=c.findIndex(y=>y.path===b);if(p<c.length-1){let y=c[p+1];y&&g$1.select(y.path);}return g$1},selectFirst(){let c=d();if(c.length>0){let b=c[0];b&&g$1.select(b.path);}return g$1},selectLast(){let c=d();if(c.length>0){let b=c[c.length-1];b&&g$1.select(b.path);}return g$1},selectParent(){let b=(Xe.get(t)??"").split(".");return b.length>1&&(b.pop(),g$1.select(b.join("."))),g$1},expand(c){let b=Ye.get(t)??[],p=Xt(b,c);return p&&p.children.length>0&&!p.expanded&&(as(p,true),g(e,t),u(c,true)),g$1},collapse(c){let b=Ye.get(t)??[],p=Xt(b,c);return p?.expanded&&(as(p,false),g(e,t),u(c,false)),g$1},toggle(c){let b=Ye.get(t)??[],p=Xt(b,c);if(p&&p.children.length>0){let y=!p.expanded;as(p,y),g(e,t),u(c,y);}return g$1},expandAll(){let c=Ye.get(t)??[];return Lg(c),g(e,t),g$1},collapseAll(){let c=Ye.get(t)??[];return Eg(c),g(e,t),g$1},isExpanded(c){let b=Ye.get(t)??[];return Xt(b,c)?.expanded??false},getState(){let c=j.state[t]??0;return LC[c]??"idle"},setStyle(c){let b=qr.get(t)??{nodeFg:pg,nodeBg:yg,selectedFg:hg,selectedBg:xg,expandedFg:Cg,collapsedFg:Sg};return c.node?.fg!==void 0&&(b.nodeFg=c.node.fg),c.node?.bg!==void 0&&(b.nodeBg=c.node.bg),c.selected?.fg!==void 0&&(b.selectedFg=c.selected.fg),c.selected?.bg!==void 0&&(b.selectedBg=c.selected.bg),c.expanded?.fg!==void 0&&(b.expandedFg=c.expanded.fg),c.collapsed?.fg!==void 0&&(b.collapsedFg=c.collapsed.fg),qr.set(t,b),g(e,t),g$1},setShowLines(c){return j.showLines[t]=c?1:0,g(e,t),g$1},getShowLines(){return j.showLines[t]===1},getFirstVisible(){return j.firstVisible[t]??0},setFirstVisible(c){return j.firstVisible[t]=Math.max(0,c),g(e,t),g$1},getVisibleCount(){return j.visibleCount[t]??0},renderLines(c){let b=d(),p=Xe.get(t)??"",y=j.showLines[t]===1,v=j.indent[t]??2,x=j.firstVisible[t]??0,T=j.visibleCount[t]??b.length,P=[],D=Math.min(x+T,b.length);for(let L=x;L<D;L++){let R=b[L];if(!R)continue;let{node:Y,path:U,isLastChild:$e,parentIsLast:Ht}=R,Dt=U===p,mr=MC(Y.depth,v,y,$e,Ht),so=kC(Y,mr,Dt,c);P.push(so);}return P},onSelect(c){let b=Jr.get(t);return b&&b.add(c),()=>{b?.delete(c);}},onActivate(c){let b=Zr.get(t);return b&&b.add(c),()=>{b?.delete(c);}},onToggle(c){let b=eo.get(t);return b&&b.add(c),()=>{b?.delete(c);}},handleKey(c){let b=j.state[t]??0,p=j.keys[t]===1;if(b!==1||!p)return null;let y=Xe.get(t)??"",v=Ye.get(t)??[],x=Xt(v,y);if(c==="G")return g$1.selectLast(),{type:"selectLast"};switch(c.toLowerCase()){case "up":case "k":return g$1.selectPrev(),{type:"selectPrev"};case "down":case "j":return g$1.selectNext(),{type:"selectNext"};case "left":case "h":return AC(g$1,x,y);case "right":case "l":return DC(g$1,x,y);case "enter":case " ":return FC(g$1,x,y,l);case "escape":return g$1.blur(),{type:"cancel"};case "g":return g$1.selectFirst(),{type:"selectFirst"}}return null},destroy(){j.isTree[t]=0,j.state[t]=0,j.showLines[t]=0,j.keys[t]=0,j.indent[t]=0,j.firstVisible[t]=0,j.visibleCount[t]=0,Ye.delete(t),Xe.delete(t),qr.delete(t),Jr.delete(t),Zr.delete(t),eo.delete(t),e$3(e,t);}};return g$1}function RC(e,r){return j.isTree[r]===1}n();var IC=1e4,zi={isViewport3D:new Uint8Array(IC)},to=new Map;function us(e,r,o={}){let n=mb$1.parse(o),t=r;zi.isViewport3D[t]=1;let i=d$1(e);Q(e,i,{}),z$1(e,i,{fov:n.fov,near:n.near,far:n.far,aspect:n.width/n.height,projectionMode:n.projectionMode}),Z(e,t,{left:n.left,top:n.top,width:n.width,height:n.height,cameraEntity:i,backendType:n.backend});let a=n.backend==="auto"?"braille":n.backend,s=q$1(a),l=s.getPixelDimensions(n.width,n.height);Y$1.pixelWidth[t]=l.width,Y$1.pixelHeight[t]=l.height,F(e,t,n.left,n.top),w(e,t,n.width,n.height),to.set(t,new Set);let u={eid:t,cameraEid:i,addMesh(d,f,g){if(!J$1(d))throw new Error(`Mesh ID ${d} not found in mesh store`);let b=d$1(e);return Q(e,b,f??{}),h(e,b,G$2),G$2.meshId[b]=d,g&&E$2(e,b,g),to.get(t)?.add(b),b},removeMesh(d){to.get(t)?.delete(d),e$3(e,d);},setCameraPosition(d,f,g){return P$1.tx[i]=d,P$1.ty[i]=f,P$1.tz[i]=g,P$1.dirty[i]=1,u},setCameraRotation(d,f,g){return P$1.rx[i]=d,P$1.ry[i]=f,P$1.rz[i]=g,P$1.dirty[i]=1,u},setFov(d){return y$1.fov[i]=d,y$1.dirty[i]=1,u},resize(d,f){Y$1.width[t]=d,Y$1.height[t]=f;let g$1=s.getPixelDimensions(d,f);return Y$1.pixelWidth[t]=g$1.width,Y$1.pixelHeight[t]=g$1.height,y$1.aspect[i]=d/f,w(e,t,d,f),g(e,t),u},show(){return j$1(e,t,true),u},hide(){return j$1(e,t,false),u},destroy(){let d=to.get(t);if(d){for(let f of d)e$3(e,f);to.delete(t);}qb$2.delete(t),e$3(e,i),zi.isViewport3D[t]=0,e$3(e,t);}};return u}function VC(e){return zi.isViewport3D[e]===1}function Bg(){let e=new Map,r=new Map;function o(i){return i.toLowerCase()}function n(i){let a=o(i);return r.get(a)??a}let t={register(i,a){let s=o(i);return e.set(s,a),t},alias(i,a){let s=o(i),l=o(a);if(!e.has(l)&&!r.has(l))throw new Error(`Cannot create alias '${i}' for non-existent widget type '${a}'`);return r.set(s,l),t},has(i){let a=n(i);return e.has(a)},get(i){let a=n(i);return e.get(a)},create(i,a,s){let l=d$1(i);return t.createWithEntity(i,l,a,s)},createWithEntity(i,a,s,l){let u=t.get(s);if(!u){let d=t.list().join(", ");throw new Error(`Unknown widget type '${s}'. Available types: ${d||"none"}`)}return u.factory(i,a,l)},list(){return Array.from(e.keys()).sort()},listByTag(i){let a=i.toLowerCase();return Array.from(e.entries()).filter(([,s])=>s.tags?.some(l=>l.toLowerCase()===a)).map(([s])=>s).sort()},unregister(i){let a=o(i);for(let[s,l]of r.entries())l===a&&r.delete(s);return e.delete(a)},clear(){e.clear(),r.clear();}};return t}var _C=[{name:"bigText",factory:e,description:"Large ASCII art text display widget",tags:["display","text"],aliases:["bigtext"]},{name:"box",factory:pt,description:"Basic container widget with optional border and padding",tags:["container","layout","basic"]},{name:"text",factory:Br,description:"Simple text display widget",tags:["display","text","basic"]},{name:"line",factory:Ha,description:"Horizontal or vertical line separator",tags:["display","decoration","basic"]},{name:"layout",factory:za,description:"Auto-arranging container with flex/grid/inline modes",tags:["container","layout"]},{name:"panel",factory:qa,description:"Container with title bar and optional close/collapse buttons",tags:["container","layout","interactive"]},{name:"tabs",factory:Fr,description:"Tabbed container with navigation",tags:["container","layout","navigation","interactive"]},{name:"scrollableBox",factory:Xr,description:"Scrollable container with scrollbar support",tags:["container","scrolling"],aliases:["scrollbox","scroll"]},{name:"scrollableText",factory:os,description:"Scrollable text display optimized for logs and documents",tags:["display","text","scrolling"],aliases:["log","textarea"]},{name:"list",factory:Dr,description:"Selectable list of items",tags:["selection","interactive","data"]},{name:"listbar",factory:$a,description:"Horizontal menu bar with selectable items",tags:["navigation","interactive","menu"],aliases:["menubar","menu"]},{name:"table",factory:is,description:"Data table with rows and columns",tags:["display","data"]},{name:"listTable",factory:ja,description:"Selectable data table combining list and table features",tags:["selection","interactive","data"],aliases:["datatable","grid"]},{name:"tree",factory:ls,description:"Hierarchical tree view with expandable nodes",tags:["selection","interactive","data","hierarchy"],aliases:["treeview"]},{name:"loading",factory:Mi,description:"Loading indicator with spinner animation",tags:["display","feedback","animation"],aliases:["spinner","progress"]},{name:"hoverText",factory:Va,description:"Tooltip/hover text manager",tags:["feedback","tooltip"],aliases:["tooltip"]},{name:"viewport3d",factory:us,description:"3D rendering viewport with camera and mesh management",tags:["display","3d","rendering"],aliases:["3d","viewport"]}];function Pg(e){for(let r of _C)if(e.register(r.name,{factory:r.factory,description:r.description,tags:r.tags}),r.aliases)for(let o of r.aliases)e.alias(o,r.name);return e}var wi=Pg(Bg());function OC(){return wi.list()}function GC(e){return wi.has(e)}function NC(e){return wi.listByTag(e)}n();f();var Ag=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(20),data:z.array(z.number()).default([]),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),showMin:z.boolean().default(false),showMax:z.boolean().default(false),gradient:z.boolean().default(false),gradientStart:z.union([z.string(),z.number()]).optional(),gradientEnd:z.union([z.string(),z.number()]).optional()}),Hi=1e4,rt={isSparkline:new Uint8Array(Hi),showMin:new Uint8Array(Hi),showMax:new Uint8Array(Hi),gradient:new Uint8Array(Hi)},Tn=new Map;function zC(e,r,o,n){if(e.length===0)return " ".repeat(r);let t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(let l of e)l<t&&(t=l),l>i&&(i=l);if(t===i)return String.fromCharCode(10308).repeat(r);let a=r*2,s=[];for(let l=0;l<r;l++){let u=l*2,d=l*2+1,f=Math.floor(u/a*e.length),g=Math.floor(d/a*e.length),c=e[f]??0,b=e[g]??0,p=Math.round(mt(c,t,i,3,0)),y=Math.round(mt(b,t,i,3,0)),v=[];v.push([0,Math.max(0,Math.min(3,p))]),v.push([1,Math.max(0,Math.min(3,y))]),o&&(c===t||b===t)&&(v.push([0,3]),v.push([1,3])),n&&(c===i||b===i)&&(v.push([0,0]),v.push([1,0])),s.push(xa(v));}return s.join("")}function Ui(e,r){let o=Tn.get(r);if(!o)return;let n=x(e,r);if(!n)return;let t=rt.showMin[r]===1,i=rt.showMax[r]===1,a=zC(o.data,n.width,t,i);e$2(e,r,a),g(e,r);}function wC(e,r={}){let o=Ag.parse(r),n=d$1(e);F(e,n,o.x,o.y),w(e,n,o.width,1),rt.isSparkline[n]=1,rt.showMin[n]=o.showMin?1:0,rt.showMax[n]=o.showMax?1:0,rt.gradient[n]=o.gradient?1:0;let t=Yt(1),i=Yt(3);Tn.set(n,{data:[...o.data],gradientStart:o.gradientStart?e$1(o.gradientStart):t,gradientEnd:o.gradientEnd?e$1(o.gradientEnd):i}),(o.fg!==void 0||o.bg!==void 0)&&d(e,n,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),Ui(e,n);let a={eid:n,setData(s){let l=Tn.get(n);return l&&(l.data=[...s],Ui(e,n)),a},getData(){return Tn.get(n)?.data??[]},append(s){let l=Tn.get(n);return l&&(l.data.push(s),Ui(e,n)),a},clear(){let s=Tn.get(n);return s&&(s.data=[],Ui(e,n)),a},setPosition(s,l){return F(e,n,s,l),g(e,n),a},destroy(){rt.isSparkline[n]=0,rt.showMin[n]=0,rt.showMax[n]=0,rt.gradient[n]=0,Tn.delete(n),e$3(e,n);}};return a}function HC(e,r){return rt.isSparkline[r]===1}function UC(){rt.isSparkline.fill(0),rt.showMin.fill(0),rt.showMax.fill(0),rt.gradient.fill(0),Tn.clear();}n();var Dg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),Fg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),Ig=z.object({left:Dg.optional(),top:Dg.optional(),width:Fg.optional(),height:Fg.optional(),direction:z.enum(["horizontal","vertical"]).optional(),ratios:z.array(z.number().min(0).max(1)).optional(),minPaneSize:z.number().int().nonnegative().optional(),dividerSize:z.number().int().nonnegative().optional(),resizable:z.boolean().optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),dividerFg:z.union([z.string(),z.number()]).optional(),dividerBg:z.union([z.string(),z.number()]).optional(),dividerChar:z.string().optional()}),dr=1e4,Se={isSplitPane:new Uint8Array(dr),direction:new Uint8Array(dr),paneCount:new Uint8Array(dr),minPaneSize:new Uint8Array(dr),dividerSize:new Uint8Array(dr),resizable:new Uint8Array(dr)},Fe=new Map,qt=new Map,Yi=new Map,Jt=new Map,Et=new Map;function $i(e){return typeof e=="string"?c$3(e):e}function Mg(e){if(e===void 0)return 0;if(typeof e=="number")return e;if(e==="left"||e==="top")return 0;if(e==="center")return 50;if(e==="right"||e==="bottom")return 100;if(typeof e=="string"&&e.endsWith("%")){let r=Number.parseFloat(e.slice(0,-1));if(!Number.isNaN(r))return r}return 0}function kg(e){return e===void 0||typeof e=="string"&&e==="auto"?"auto":e}function Rg(e){let r=e.reduce((o,n)=>o+n,0);return r===0?e.map(()=>1/e.length):e.map(o=>o/r)}function $C(e){return e<=0?[]:new Array(e).fill(1/e)}function jC(e,r,o,n,t,i,a){let s=i.length;if(s===0)return [];let l=a*(s-1),u=t==="horizontal"?o-l:n-l,d=Math.max(0,u),f=[],g=0,c=0;for(let b=0;b<s;b++){let p=b===s-1,y=p?Math.max(1,d-c):Math.max(1,Math.round(d*(i[b]??0)));t==="horizontal"?f.push({x:e+g,y:r,width:y,height:n}):f.push({x:e,y:r+g,width:o,height:y}),g+=y,c+=y,p||(g+=a);}return f}function YC(e,r,o,n,t){let i=[...e],a=t>0?n/t:0,s=(i[r]??0)+o,l=(i[r+1]??0)-o;if(s<a){let u=a-(i[r]??0);i[r]=a,i[r+1]=(i[r+1]??0)-u;}else if(l<a){let u=(i[r+1]??0)-a;i[r]=(i[r]??0)+u,i[r+1]=a;}else i[r]=s,i[r+1]=l;return i}function KC(e,r,o,n,t,i){let a=[];for(let s=0;s<Math.max(e.length,r.length);s++){let l=e[s],u=r[s];if(!l||!u){let d=u??l;d&&a.push(d);continue}if(l.x!==u.x||l.y!==u.y||l.width!==u.width||l.height!==u.height){let d=Math.min(l.x,u.x),f=Math.min(l.y,u.y),g=Math.max(l.x+l.width,u.x+u.width),c=Math.max(l.y+l.height,u.y+u.height);a.push({x:Math.max(o,d),y:Math.max(n,f),width:Math.min(o+t,g)-Math.max(o,d),height:Math.min(n+i,c)-Math.max(n,f)});}}return a}function QC(){return {scrollX:0,scrollY:0,contentWidth:0,contentHeight:0}}function ji(e,r){let o=Math.max(0,e.contentWidth-r.width),n=Math.max(0,e.contentHeight-r.height);e.scrollX=Math.max(0,Math.min(e.scrollX,o)),e.scrollY=Math.max(0,Math.min(e.scrollY,n));}function XC(e,r,o,n,t,i,a){Se.isSplitPane[r]=1,Se.direction[r]=n==="horizontal"?0:1,Se.paneCount[r]=0,Se.minPaneSize[r]=t,Se.dividerSize[r]=i,Se.resizable[r]=a?1:0,Fe.set(r,[]),qt.set(r,[]),Et.set(r,[]),Yi.set(r,{fg:o.dividerFg!==void 0?$i(o.dividerFg):void 0,bg:o.dividerBg!==void 0?$i(o.dividerBg):void 0,char:o.dividerChar??(n==="horizontal"?"\u2502":"\u2500")});let s=Mg(o.left),l=Mg(o.top);F(e,r,s,l);let u=kg(o.width),d$1=kg(o.height);w(e,r,u,d$1),(o.fg!==void 0||o.bg!==void 0)&&d(e,r,{fg:o.fg!==void 0?$i(o.fg):void 0,bg:o.bg!==void 0?$i(o.bg):void 0}),Y(e,r,{focusable:true});}function qC(e,r,o={}){let n=Ig.parse(o),t=r,i=n.direction??"horizontal",a=n.minPaneSize??3,s=n.dividerSize??1,l=n.resizable!==false;XC(e,t,n,i,a,s,l);let u=n.ratios?Rg(n.ratios):[];function d(x){let T=Jt.get(x);T&&(T.refCount--,T.refCount<=0&&Jt.delete(x));}function f(){let x$1=x(e,t);return {x:0,y:0,width:x$1?.width??80,height:x$1?.height??24}}function g$1(x,T){for(let P=0;P<x.length;P++){let D=x[P],L=T[P];!D||!L||(D.viewport=L,ji(D.scroll,L),D.dirty=true);}}function c(x){let T=qt.get(t)??[];for(let P=0;P<T.length;P++){let D=T[P];if(!D)continue;let L=0;for(let R=0;R<=P;R++)L+=x[R]??0;D.ratio=L;}}function b(x,T){for(let P=0;P<x.length;P++){let D=x[P],L=T[P];!D||!L||(F(e,D.entity,L.x,L.y),w(e,D.entity,L.width,L.height));}}function p(){let x=Fe.get(t);if(!x||x.length===0)return;let T=f(),P=jC(T.x,T.y,T.width,T.height,i,u,s);g$1(x,P),c(u),b(x,P),Se.paneCount[t]=x.length,g(e,t);}function y(x){let T=Fe.get(t)??[],P={entity:x,viewport:{x:0,y:0,width:0,height:0},scroll:QC(),sharedBufferId:void 0,dirty:true};T.push(P),Fe.set(t,T),u.length<T.length&&(u=$C(T.length));let D=qt.get(t)??[];if(T.length>1&&D.length<T.length-1){let L=0;for(let R=0;R<D.length+1;R++)L+=u[R]??0;D.push({ratio:L,dragging:false,dragStartPos:0,dragStartRatio:0,dragStartRatios:[]}),qt.set(t,D);}d$2(e,t,x),p();}let v={eid:t,show(){return j$1(e,t,true),v},hide(){return j$1(e,t,false),v},move(x,T){return K(e,t,x,T),g(e,t),v},setPosition(x,T){return F(e,t,x,T),p(),v},getDirection(){return i},getRatios(){return [...u]},setRatios(x){let T=Fe.get(t)??[];return x.length!==T.length||(u=Rg(x),p()),v},getPaneCount(){return (Fe.get(t)??[]).length},getPaneViewport(x){return (Fe.get(t)??[])[x]?.viewport},getAllPaneViewports(){return (Fe.get(t)??[]).map(x=>x.viewport)},scrollPane(x,T,P){let L=(Fe.get(t)??[])[x];if(!L)return v;L.scroll.scrollX+=T,L.scroll.scrollY+=P,ji(L.scroll,L.viewport),L.dirty=true;let R=Et.get(t)??[];return R.push(L.viewport),Et.set(t,R),g(e,t),v},setPaneScroll(x,T,P){let L=(Fe.get(t)??[])[x];if(!L)return v;L.scroll.scrollX=T,L.scroll.scrollY=P,ji(L.scroll,L.viewport),L.dirty=true;let R=Et.get(t)??[];return R.push(L.viewport),Et.set(t,R),g(e,t),v},getPaneScroll(x){let P=(Fe.get(t)??[])[x];if(P)return {...P.scroll}},setPaneContentSize(x,T,P){let L=(Fe.get(t)??[])[x];return L&&(L.scroll.contentWidth=T,L.scroll.contentHeight=P,ji(L.scroll,L.viewport)),v},attachBuffer(x,T){let D=(Fe.get(t)??[])[x];if(!D)return v;D.sharedBufferId&&d(D.sharedBufferId),D.sharedBufferId=T.id,Jt.has(T.id)||Jt.set(T.id,T);let L=Jt.get(T.id);return L&&L.refCount++,D.scroll.contentHeight=T.lines.length,D.dirty=true,g(e,t),v},detachBuffer(x){let P=(Fe.get(t)??[])[x];return !P||!P.sharedBufferId||(d(P.sharedBufferId),P.sharedBufferId=void 0,P.dirty=true,g(e,t)),v},getBuffer(x){let P=(Fe.get(t)??[])[x];if(!(!P||!P.sharedBufferId))return Jt.get(P.sharedBufferId)},beginDrag(x,T){if(!l)return v;let D=(qt.get(t)??[])[x];return D&&(D.dragging=true,D.dragStartPos=T,D.dragStartRatio=D.ratio,D.dragStartRatios=[...u]),v},updateDrag(x,T){if(!l)return;let D=(qt.get(t)??[])[x];if(!D||!D.dragging)return;let L=f(),R=i==="horizontal"?L.width:L.height,Y=s*(u.length-1),U=Math.max(1,R-Y),Ht=(T-D.dragStartPos)/U,Dt=(Fe.get(t)??[]).map(qi=>qi.viewport);u=YC(D.dragStartRatios,x,Ht,a,U),p();let mr=(Fe.get(t)??[]).map(qi=>qi.viewport),so=KC(Dt,mr,L.x,L.y,L.width,L.height),Ss=Et.get(t)??[];return Ss.push(...so),Et.set(t,Ss),{dividerIndex:x,ratios:[...u],dirtyRects:so}},endDrag(x){let P=(qt.get(t)??[])[x];return P&&(P.dragging=false,P.dragStartPos=0,P.dragStartRatio=0,P.dragStartRatios=[]),v},isDragging(){return (qt.get(t)??[]).some(T=>T.dragging)},getDirtyRects(){return [...Et.get(t)??[]]},markPaneDirty(x){let P=(Fe.get(t)??[])[x];if(!P)return v;P.dirty=true;let D=Et.get(t)??[];return D.push(P.viewport),Et.set(t,D),g(e,t),v},flushDirty(){let x=Fe.get(t)??[];for(let T of x)T.dirty=false;return Et.set(t,[]),v},recalculate(){return p(),v},focus(){return aa(e,t),v},blur(){return ba(e,t),v},isFocused(){return _(e,t)},append(x){return y(x),v},getChildren(){return f$1(e,t)},destroy(){let x=Fe.get(t)??[];for(let T of x)T.sharedBufferId&&d(T.sharedBufferId);Se.isSplitPane[t]=0,Se.direction[t]=0,Se.paneCount[t]=0,Se.minPaneSize[t]=0,Se.dividerSize[t]=0,Se.resizable[t]=0,Fe.delete(t),qt.delete(t),Yi.delete(t),Et.delete(t),e$3(e,t);}};return v}function JC(e,r){return Se.isSplitPane[r]===1}function ZC(e,r){return Se.direction[r]===0?"horizontal":"vertical"}function eS(e,r){let o=Jt.get(e);if(o)return o;let n={id:e,lines:r,refCount:0};return Jt.set(e,n),n}function tS(e){return Jt.get(e)}function nS(e,r,o,n,t){for(let i=0;i<e.length-1;i++){let a=e[i];if(!a)continue;let s=r?a.viewport.x+a.viewport.width:a.viewport.y+a.viewport.height,l=r?n:t;if(l>=s&&l<s+o)return i}return -1}function rS(e,r,o,n){if(Se.isSplitPane[r]!==1)return -1;let t=Fe.get(r);if(!t||t.length<2)return -1;let i=Se.direction[r]===0,a=Se.dividerSize[r]??1;return nS(t,i,a,o,n)}function oS(e,r){if(Se.isSplitPane[r]!==1)return [];let o=Fe.get(r);if(!o||o.length<2)return [];let n=Se.direction[r]===0?"horizontal":"vertical",t=Se.dividerSize[r]??1,i=Yi.get(r)??{fg:void 0,bg:void 0,char:"\u2502"},a=[];for(let s=0;s<o.length-1;s++){let l=o[s];l&&(n==="horizontal"?a.push({x:l.viewport.x+l.viewport.width,y:l.viewport.y,width:t,height:l.viewport.height,char:i.char,fg:i.fg,bg:i.bg}):a.push({x:l.viewport.x,y:l.viewport.y+l.viewport.height,width:l.viewport.width,height:t,char:i.char,fg:i.fg,bg:i.bg}));}return a}function iS(){Se.isSplitPane.fill(0),Se.direction.fill(0),Se.paneCount.fill(0),Se.minPaneSize.fill(0),Se.dividerSize.fill(0),Se.resizable.fill(0),Fe.clear(),qt.clear(),Yi.clear(),Et.clear(),Jt.clear();}var aS=z.object({maxLines:z.number().int().nonnegative().default(1e4),wrapWidth:z.number().int().positive().default(80),autoScroll:z.boolean().default(true),stripAnsi:z.boolean().default(false)}),sS={maxLines:1e4,wrapWidth:80,autoScroll:true,stripAnsi:false};function cs(e,r){if(r<=0)return [e];if(e.length<=r)return [e];let o=[],n=e;for(;n.length>r;)o.push(n.slice(0,r)),n=n.slice(r);return n.length>0&&o.push(n),o}function Vg(e){return e.replace(/\x1b(?:\[[0-9;?]*[a-zA-Z~]|\][^\x07\x1b]*(?:\x07|\x1b\\)?|[^[\]])/g,"")}function ds(e,r=24){return {lines:[],scrollTop:0,viewportHeight:r,totalBytes:0,isStreaming:false,config:{...sS,...e},partialLine:"",dirty:null}}function Ki(e,r){let o=r;e.config.stripAnsi&&(o=Vg(o));let n=e.totalBytes+o.length,i=(e.partialLine+o).split(`
|
|
18
|
-
`),a=i.pop()??"",s=[];for(let c of i){let b=cs(c,e.config.wrapWidth);for(let p of b)s.push(p);}let l=[...e.lines,...s],u=0;e.config.maxLines>0&&l.length>e.config.maxLines&&(u=l.length-e.config.maxLines,l=l.slice(u));let f={startLine:Math.max(0,l.length-s.length),lineCount:s.length,fullRedraw:u>0},g=e.scrollTop;return u>0&&(g=Math.max(0,g-u)),e.config.autoScroll&&(g=Math.max(0,l.length-e.viewportHeight)),{...e,lines:l,scrollTop:g,totalBytes:n,partialLine:a,dirty:f}}function _g(e){return {...e,lines:[],scrollTop:0,totalBytes:0,partialLine:"",dirty:{startLine:0,lineCount:0,fullRedraw:true}}}function Og(e){let r=e.scrollTop,o=Math.min(r+e.viewportHeight,e.lines.length);return e.lines.slice(r,o)}function ro(e,r){let o=Math.max(0,e.lines.length-e.viewportHeight),n=Math.max(0,Math.min(r,o));return n===e.scrollTop?e:{...e,scrollTop:n,dirty:{startLine:0,lineCount:e.viewportHeight,fullRedraw:true}}}function Gg(e,r){return ro(e,e.scrollTop+r)}function lS(e,r,o){let n=r,t=ds(o),i={eid:n,append(a){return t=Ki(t,a),g(e,n),i},appendLine(a){return t=Ki(t,`${a}
|
|
19
|
-
`),g(e,n),i},clear(){return t=_g(t),g(e,n),i},getState(){return t},getVisibleLines(){return Og(t)},getProgress(){return {totalBytes:t.totalBytes,totalLines:t.lines.length,visibleLines:Math.min(t.viewportHeight,t.lines.length),isAutoScrolling:t.config.autoScroll,isStreaming:t.isStreaming}},consumeDirty(){let a=t.dirty;return t={...t,dirty:null},a},scrollTo(a){return t=ro(t,a),g(e,n),i},scrollBy(a){return t=Gg(t,a),g(e,n),i},scrollToBottom(){let a=Math.max(0,t.lines.length-t.viewportHeight);return t=ro(t,a),g(e,n),i},scrollToTop(){return t=ro(t,0),g(e,n),i},setViewportHeight(a){return t={...t,viewportHeight:a},i},setWrapWidth(a){let s={...t.config,wrapWidth:a},l=t.lines.join(`
|
|
20
|
-
`)+(t.partialLine?t.partialLine:"");return t=ds(s,t.viewportHeight),l.length>0&&(t=Ki(t,l)),g(e,n),i},setAutoScroll(a){return t={...t,config:{...t.config,autoScroll:a}},i},startStream(){return t={...t,isStreaming:true},i},endStream(){if(t.partialLine.length>0){let a=cs(t.partialLine,t.config.wrapWidth),s=[...t.lines,...a];t={...t,lines:s,partialLine:"",isStreaming:false,dirty:{startLine:Math.max(0,s.length-a.length),lineCount:a.length,fullRedraw:false}},t.config.autoScroll&&(t={...t,scrollTop:Math.max(0,s.length-t.viewportHeight)}),g(e,n);}else t={...t,isStreaming:false};return i}};return i}n();f();var zg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),checked:z.boolean().default(false),onLabel:z.string().default("ON"),offLabel:z.string().default("OFF"),onFg:z.union([z.string(),z.number()]).optional(),onBg:z.union([z.string(),z.number()]).optional(),offFg:z.union([z.string(),z.number()]).optional(),offBg:z.union([z.string(),z.number()]).optional(),focusable:z.boolean().default(true),visible:z.boolean().default(true)}),Ng=1e4,uS="#ffffff",dS="#4caf50",cS="#000000",gS="#757575",qe={isSwitch:new Uint8Array(Ng),checked:new Uint8Array(Ng)},Vt=new Map;function cr(e,r){let o=Vt.get(r);if(!o)return;let n=qe.checked[r]===1,t=n?o.onLabel:o.offLabel,i=n?o.onFg:o.offFg,a=n?o.onBg:o.offBg;e$2(e,r,` ${t} `),d(e,r,{fg:i,bg:a}),g(e,r);}function mS(e,r={}){let o=zg.parse(r),n=d$1(e);qe.isSwitch[n]=1,qe.checked[n]=o.checked?1:0;let t=o.onFg!==void 0?e$1(o.onFg):e$1(uS),i=o.onBg!==void 0?e$1(o.onBg):e$1(dS),a=o.offFg!==void 0?e$1(o.offFg):e$1(cS),s=o.offBg!==void 0?e$1(o.offBg):e$1(gS);Vt.set(n,{onLabel:o.onLabel,offLabel:o.offLabel,onFg:t,onBg:i,offFg:a,offBg:s}),F(e,n,o.x,o.y);let l=Math.max(o.onLabel.length,o.offLabel.length);w(e,n,l+2,1),Y(e,n,{focusable:o.focusable}),cr(e,n),o.visible||j$1(e,n,false);let u={eid:n,isChecked(){return qe.checked[n]===1},setChecked(d){let f=qe.checked[n]===1;if(qe.checked[n]=d?1:0,cr(e,n),f!==d){let g=Vt.get(n);g?.onChangeCallback&&g.onChangeCallback(d);}return u},toggle(){let d=qe.checked[n]===0;return u.setChecked(d)},setOnLabel(d){let f=Vt.get(n);return f&&(f.onLabel=d,cr(e,n)),u},setOffLabel(d){let f=Vt.get(n);return f&&(f.offLabel=d,cr(e,n)),u},getOnLabel(){return Vt.get(n)?.onLabel??""},getOffLabel(){return Vt.get(n)?.offLabel??""},onChange(d){let f=Vt.get(n);return f&&(f.onChangeCallback=d),u},show(){return j$1(e,n,true),u},hide(){return j$1(e,n,false),u},setPosition(d,f){return F(e,n,d,f),g(e,n),u},destroy(){qe.isSwitch[n]=0,qe.checked[n]=0,Vt.delete(n),e$3(e,n);}};return u}function gs(e,r){return qe.isSwitch[r]===1}function fS(e,r,o){if(!gs(e,r)||o!==" "&&o!=="enter")return false;let t=!(qe.checked[r]===1);qe.checked[r]=t?1:0,cr(e,r);let i=Vt.get(r);return i?.onChangeCallback&&i.onChangeCallback(t),true}function bS(e,r){if(!gs(e,r))return false;let n=!(qe.checked[r]===1);qe.checked[r]=n?1:0,cr(e,r);let t=Vt.get(r);return t?.onChangeCallback&&t.onChangeCallback(n),true}function pS(){qe.isSwitch.fill(0),qe.checked.fill(0),Vt.clear();}u();n();f();var Hg=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),yS=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","double","rounded","bold","ascii"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),$g=z.object({shell:z.string().min(1).optional(),args:z.array(z.string()).optional(),env:z.record(z.string(),z.string()).optional(),cwd:z.string().min(1).optional(),term:z.string().min(1).default("xterm-256color"),cols:z.number().int().positive().optional(),rows:z.number().int().positive().optional(),autoResize:z.boolean().default(true)}),jg=z.object({width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),scrollback:z.number().int().nonnegative().default(1e3),cursorBlink:z.boolean().default(true),cursorShape:z.enum(["block","underline","bar"]).default("block"),left:Hg.optional(),top:Hg.optional(),border:yS,style:z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}).optional(),mouse:z.boolean().default(true),keys:z.boolean().default(true)}),fs=1e4,Bt={isTerminal:new Uint8Array(fs),mouseEnabled:new Uint8Array(fs),keysEnabled:new Uint8Array(fs)},bs=new Map;function Ug(e){return e===void 0?0:typeof e=="number"?e:0}function hS(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function xS(e){switch(e){case "single":return b$1;case "double":return c;case "rounded":return d$3;case "bold":return e$4;case "ascii":return f$3}}function CS(e){let r=process.env.SHELL??"/bin/sh",o={...process.env};if(typeof e=="string")return {shell:e,args:[],env:o,cwd:void 0,term:"xterm-256color",cols:void 0,rows:void 0,autoResize:true};if(!e)return {shell:r,args:[],env:o,cwd:void 0,term:"xterm-256color",cols:void 0,rows:void 0,autoResize:true};let n=$g.parse(e);return {shell:n.shell??r,args:n.args??[],env:n.env?{...process.env,...n.env}:o,cwd:n.cwd,term:n.term,cols:n.cols,rows:n.rows,autoResize:n.autoResize}}function SS(){let e=[()=>createRequire(pathToFileURL(`${process.cwd()}/`).href)("node-pty"),()=>createRequire(import.meta.url)("node-pty"),()=>{let r=process.argv[1];if(r)return createRequire(pathToFileURL(r).href)("node-pty");throw new Error("No main module")}];for(let r of e)try{return r()}catch{}return null}function TS(e,r,o){if(!o)return;let n=o.type?hS(o.type):1;if(l(e,r,{type:n,fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0}),o.ch){let t=typeof o.ch=="string"?xS(o.ch):o.ch;m(e,r,t);}}function WS(e,r,o){o&&d(e,r,{fg:o.fg!==void 0?e$1(o.fg):void 0,bg:o.bg!==void 0?e$1(o.bg):void 0});}function vS(e,r,o){let n=o!==void 0&&o.type!=="none";return {displayWidth:e+(n?2:0),displayHeight:r+(n?2:0)}}function LS(e,r={}){let o=jg.parse(r),n=d$1(e);Bt.isTerminal[n]=1,Bt.mouseEnabled[n]=o.mouse?1:0,Bt.keysEnabled[n]=o.keys?1:0;let t=Ug(o.left),i=Ug(o.top);F(e,n,t,i);let{displayWidth:a,displayHeight:s}=vS(o.width,o.height,o.border);w(e,n,a,s);let l={width:o.width,height:o.height,scrollbackLines:o.scrollback,cursorBlink:o.cursorBlink,cursorShape:o.cursorShape,cursorVisible:true};ac$1(e,n,l),WS(e,n,o.style),j$1(e,n,true),TS(e,n,o.border),Y(e,n,{focusable:true});let u={pty:null,onDataCallback:null,onExitCallback:null,autoResize:true};bs.set(n,u);let d={eid:n,write(f){return fc$1(e,n,f),d},writeln(f){return fc$1(e,n,`${f}
|
|
21
|
-
`),d},clear(){return gc$1(e,n),d},reset(){return hc$1(e,n),d},scrollUp(f=1){return kc$1(e,n,f),d},scrollDown(f=1){return lc$1(e,n,f),d},scrollToTop(){return mc$1(e,n),d},scrollToBottom(){return nc$1(e,n),d},setCursor(f,g){return ic$1(e,n,f,g),d},showCursor(){return jc$1(e,n,true),d},hideCursor(){return jc$1(e,n,false),d},spawn(f){let g=SS();if(!g)return console.warn("node-pty is not installed. Install it with: pnpm add node-pty"),d;u.pty&&d.kill();let{shell:c,args:b,env:p,cwd:y,term:v,cols:x,rows:T,autoResize:P}=CS(f),D=dc$1(n),L=x??D?.width??80,R=T??D?.height??24;u.autoResize=P;let Y=g.spawn(c,b,{name:v,cols:L,rows:R,...y!==void 0?{cwd:y}:{},env:p});return u.pty=Y,Y.onData(U=>{fc$1(e,n,U),u.onDataCallback&&u.onDataCallback(U);}),Y.onExit(({exitCode:U,signal:$e})=>{u.pty=null,u.onExitCallback&&u.onExitCallback(U,$e);}),d},input(f){let g=u.pty;return g&&g.write(f),d},resize(f,g$1){oc$1(e,n,f,g$1);let c=u.pty;c&&u.autoResize&&c.resize(f,g$1);let b=o.border!==void 0&&o.border.type!=="none",p=f+(b?2:0),y=g$1+(b?2:0);return w(e,n,p,y),g(e,n),d},kill(f="SIGTERM"){let g=u.pty;return g&&(g.kill(f),u.pty=null),d},isRunning(){return u.pty!==null},getPtyHandle(){return u.pty},onData(f){return u.onDataCallback=f,d},onExit(f){return u.onExitCallback=f,d},show(){return j$1(e,n,true),d},hide(){return j$1(e,n,false),d},focus(){return aa(e,n),d},blur(){return ba(e,n),d},isFocused(){return _(e,n)},getDimensions(){let f=dc$1(n);return {width:f?.width??0,height:f?.height??0}},getCursor(){let f=dc$1(n);return {x:f?.cursorX??0,y:f?.cursorY??0}},getState(){return cc$1(n)},getCells(){return rc$1(n)},destroy(){d.kill(),Bt.isTerminal[n]=0,Bt.mouseEnabled[n]=0,Bt.keysEnabled[n]=0,pc$1(n),bs.delete(n),e$3(e,n);},refresh(){return g(e,n),d}};return g(e,n),d}var ES={return:"\r",enter:"\r",backspace:"\x7F",tab:" ",escape:"\x1B",up:"\x1B[A",down:"\x1B[B",right:"\x1B[C",left:"\x1B[D",home:"\x1B[H",end:"\x1B[F",pageup:"\x1B[5~",pagedown:"\x1B[6~",delete:"\x1B[3~",insert:"\x1B[2~"};function BS(e,r){let o=ES[r];return o?(e.input(o),true):false}function PS(e,r){if(!r)return false;let o=r.toUpperCase().charCodeAt(0)-64;return o>=0&&o<=31?(e.input(String.fromCharCode(o)),true):false}function AS(e,r){return r?(e.input(`\x1B${r}`),true):false}function DS(e,r,o,n,t){return BS(e,r)||n&&PS(e,o)||t&&AS(e,o)?true:o&&!n&&!t?(e.input(o),true):false}function FS(e,r,o){return r==="pageup"?(e.scrollUp(e.getDimensions().height),true):r==="pagedown"?(e.scrollDown(e.getDimensions().height),true):r==="home"&&o?(e.scrollToTop(),true):r==="end"&&o?(e.scrollToBottom(),true):false}function MS(e,r,o,n=false,t=false,i=false){return e.isRunning()?DS(e,r,o,n,t):FS(e,r,n)}function kS(e,r){return Bt.isTerminal[r]===1}function RS(e,r){return Bt.mouseEnabled[r]===1}function IS(e,r){return Bt.keysEnabled[r]===1}function VS(){Bt.isTerminal.fill(0),Bt.mouseEnabled.fill(0),Bt.keysEnabled.fill(0),bs.clear();}n();var Yg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),duration:z.number().positive(),format:z.enum(["ss","mm:ss","hh:mm:ss"]).default("mm:ss"),autoStart:z.boolean().default(false),onComplete:z.function().optional()}),Kg=z.object({x:z.number().int().default(0),y:z.number().int().default(0),format:z.enum(["ss","mm:ss","hh:mm:ss"]).default("mm:ss"),lapSupport:z.boolean().default(false),autoStart:z.boolean().default(false)}),oo=1e4,ot={isTimer:new Uint8Array(oo),running:new Uint8Array(oo)},Ue={isStopwatch:new Uint8Array(oo),running:new Uint8Array(oo),lapSupport:new Uint8Array(oo)},Mn=new Map,sn=new Map;function Qg(e,r){let o=Math.max(0,Math.floor(e/1e3)),n=Math.floor(o/3600),t=Math.floor(o%3600/60),i=o%60,a=s=>s.toString().padStart(2,"0");switch(r){case "ss":return a(o);case "mm:ss":return `${a(t)}:${a(i)}`;case "hh:mm:ss":return `${a(n)}:${a(t)}:${a(i)}`}}function ps(e,r){let o=Mn.get(r);if(!o)return;let n=Qg(o.remaining,o.format);e$2(e,r,n);}function ys(e,r){let o=sn.get(r);if(!o)return;let n=Qg(o.elapsed,o.format);e$2(e,r,n);}function Xg(e){switch(e){case "ss":return 2;case "mm:ss":return 5;case "hh:mm:ss":return 8}}function _S(e,r){let o=Yg.parse(r),n=d$1(e);ot.isTimer[n]=1,ot.running[n]=o.autoStart?1:0;let t=Xg(o.format);w(e,n,t,1),F(e,n,o.x,o.y),Mn.set(n,{remaining:o.duration,duration:o.duration,format:o.format,onComplete:o.onComplete}),ps(e,n);let i={eid:n,start(){return ot.running[n]=1,i},pause(){return ot.running[n]=0,i},reset(){let a=Mn.get(n);return a&&(a.remaining=a.duration,ot.running[n]=0,ps(e,n),g(e,n)),i},getState(){let a=Mn.get(n);return a?{remaining:a.remaining,duration:a.duration,running:ot.running[n]===1}:{remaining:0,duration:0,running:false}},setPosition(a,s){return F(e,n,a,s),g(e,n),i},move(a,s){return K(e,n,a,s),g(e,n),i},destroy(){ot.isTimer[n]=0,ot.running[n]=0,Mn.delete(n),e$3(e,n);}};return i}function OS(e,r={}){let o=Kg.parse(r),n=d$1(e);Ue.isStopwatch[n]=1,Ue.running[n]=o.autoStart?1:0,Ue.lapSupport[n]=o.lapSupport?1:0;let t=Xg(o.format);w(e,n,t,1),F(e,n,o.x,o.y),sn.set(n,{elapsed:0,format:o.format,laps:[]}),ys(e,n);let i={eid:n,start(){return Ue.running[n]=1,i},pause(){return Ue.running[n]=0,i},reset(){let a=sn.get(n);return a&&(a.elapsed=0,a.laps=[],Ue.running[n]=0,ys(e,n),g(e,n)),i},lap(){if(Ue.lapSupport[n]!==1)return i;let a=sn.get(n);return a&&a.laps.push(a.elapsed),i},getState(){let a=sn.get(n);return a?{elapsed:a.elapsed,running:Ue.running[n]===1,laps:[...a.laps]}:{elapsed:0,running:false,laps:[]}},getLaps(){return sn.get(n)?.laps??[]},setPosition(a,s){return F(e,n,a,s),g(e,n),i},move(a,s){return K(e,n,a,s),g(e,n),i},destroy(){Ue.isStopwatch[n]=0,Ue.running[n]=0,Ue.lapSupport[n]=0,sn.delete(n),e$3(e,n);}};return i}function GS(e,r,o){let n=Mn.get(r);n&&(n.remaining=Math.max(0,n.remaining-o),n.remaining===0&&(ot.running[r]=0,n.onComplete&&n.onComplete()),ps(e,r),g(e,r));}function NS(e,r,o){let n=sn.get(r);n&&(n.elapsed+=o,ys(e,r),g(e,r));}function zS(e,r){for(let o=0;o<ot.isTimer.length;o++)ot.isTimer[o]===1&&ot.running[o]===1&&GS(e,o,r);for(let o=0;o<Ue.isStopwatch.length;o++)Ue.isStopwatch[o]===1&&Ue.running[o]===1&&NS(e,o,r);}function wS(e,r){return ot.isTimer[r]===1}function HS(e,r){return Ue.isStopwatch[r]===1}function US(){ot.isTimer.fill(0),ot.running.fill(0),Mn.clear();}function $S(){Ue.isStopwatch.fill(0),Ue.running.fill(0),Ue.lapSupport.fill(0),sn.clear();}u();n();f();var jS=z.object({type:z.enum(["line","bg","none"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),ch:z.union([z.enum(["single","rounded"]),z.custom(e=>typeof e=="object"&&e!==null&&"topLeft"in e&&"topRight"in e&&"bottomLeft"in e&&"bottomRight"in e&&"horizontal"in e&&"vertical"in e)]).optional()}).optional(),Qi=z.object({fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),borderFg:z.union([z.string(),z.number()]).optional()}).optional(),Zg=z.object({content:z.string().optional(),type:z.enum(["info","success","warning","error"]).optional(),timeout:z.number().int().nonnegative().optional(),position:z.enum(["top-right","top-center","top-left","bottom-right","bottom-center","bottom-left"]).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),border:jS,padding:z.number().int().nonnegative().optional(),width:z.number().int().positive().optional(),infoStyle:Qi,successStyle:Qi,warningStyle:Qi,errorStyle:Qi}),em=3e3,xs=1,hs=1,tm={info:{fg:"#ffffff",bg:"#2196f3",borderFg:"#64b5f6"},success:{fg:"#ffffff",bg:"#4caf50",borderFg:"#81c784"},warning:{fg:"#000000",bg:"#ff9800",borderFg:"#ffb74d"},error:{fg:"#ffffff",bg:"#f44336",borderFg:"#e57373"}},qg=1e4,wt={isToast:new Uint8Array(qg),dismissed:new Uint8Array(qg)},Zt=new Map,gr={"top-right":new Set,"top-center":new Set,"top-left":new Set,"bottom-right":new Set,"bottom-center":new Set,"bottom-left":new Set};function YS(e){switch(e){case "single":return b$1;case "rounded":return d$3}}function KS(e){switch(e){case "line":return 1;case "bg":return 2;case "none":return 0}}function nm(e,r){return {info:r.infoStyle,success:r.successStyle,warning:r.warningStyle,error:r.errorStyle}[e]??tm[e]}function QS(e,r){let o=e.split(`
|
|
22
|
-
`),n=Math.max(...o.map(s=>s.length),10),t=o.length,i=n+r*2+2,a=t+r*2+2;return {width:i,height:a}}function Jg(e,r,o,n){let t=Array.from(gr[r]),i=0;r.startsWith("bottom")&&(i=n);for(let a of t){let s=x(e,a),l=s?.width??0,u=s?.height??0,d=0,f=0;r.endsWith("right")?d=o-l:r.endsWith("center")?d=Math.floor((o-l)/2):d=0,r.startsWith("top")?(f=i,i+=u+hs):(i-=u,f=i,i-=hs),F(e,a,d,f),g(e,a);}}function XS(e,r,o){wt.isToast[e]=1,wt.dismissed[e]=0,Zt.set(e,{content:r.content??"",position:o}),gr[o].add(e);}function qS(e,r,o){let n=o.content??"",t=o.padding??xs,{width:i,height:a}=QS(n,t),s=o.width??i;w(e,r,s,a),F(e,r,0,0);}function JS(e,r,o){let n=o.type??"info",t=nm(n,o),i=o.fg??t.fg,a=o.bg??t.bg;(i!==void 0||a!==void 0)&&d(e,r,{fg:i!==void 0?e$1(i):void 0,bg:a!==void 0?e$1(a):void 0});}function ZS(e,r,o){let n=o.type??"info",t=nm(n,o),i=o.border?.type?KS(o.border.type):1,a=o.border?.fg??t.borderFg;l(e,r,{type:i,fg:a!==void 0?e$1(a):void 0,bg:o.border?.bg!==void 0?e$1(o.border.bg):void 0});let s=o.border?.ch?typeof o.border.ch=="string"?YS(o.border.ch):o.border.ch:d$3;m(e,r,s);}function eT(e,r,o){let n=o.content??"";e$2(e,r,n,{align:1,valign:1});}function tT(e,r,o,n){let t=o.timeout??em;if(t<=0)return;let i=Zt.get(r);i&&(i.timerId=setTimeout(()=>{n();},t));}function io(e,r={},o=80,n=24){let t=Zg.parse(r),i=d$1(e),a=t.position??"top-right";XS(i,t,a),qS(e,i,t),JS(e,i,t),ZS(e,i,t),eT(e,i,t);let s=t.padding??xs;b(e,i,{left:s,top:s,right:s,bottom:s}),Jg(e,a,o,n);let l=()=>{if(wt.dismissed[i]===1)return;wt.dismissed[i]=1,j$1(e,i,false);let d=Zt.get(i);d&&(gr[d.position].delete(i),Jg(e,d.position,o,n),d.timerId&&(clearTimeout(d.timerId),d.timerId=void 0),d.onDismissCallback&&d.onDismissCallback());};tT(e,i,t,l);let u={eid:i,setContent(d){let f=Zt.get(i);return f&&(f.content=d),e$2(e,i,d,{align:1,valign:1}),g(e,i),u},getContent(){return Zt.get(i)?.content??""},show(){return j$1(e,i,true),u},hide(){return j$1(e,i,false),u},move(d,f){return K(e,i,d,f),g(e,i),u},dismiss:l,isDismissed(){return wt.dismissed[i]===1},onDismiss(d){let f=Zt.get(i);return f&&(f.onDismissCallback=d),u},destroy(){let d=Zt.get(i);d&&(d.timerId&&clearTimeout(d.timerId),gr[d.position].delete(i)),wt.isToast[i]=0,wt.dismissed[i]=0,Zt.delete(i),e$3(e,i);}};return u}function nT(e,r,o={},n=80,t=24){return io(e,{...o,content:r,type:"info"},n,t)}function rT(e,r,o={},n=80,t=24){return io(e,{...o,content:r,type:"success"},n,t)}function oT(e,r,o={},n=80,t=24){return io(e,{...o,content:r,type:"warning"},n,t)}function iT(e,r,o={},n=80,t=24){return io(e,{...o,content:r,type:"error"},n,t)}function aT(e,r){return wt.isToast[r]===1}function sT(){for(let e of Zt.values())e.timerId&&clearTimeout(e.timerId);wt.isToast.fill(0),wt.dismissed.fill(0),Zt.clear();for(let e of Object.keys(gr))gr[e].clear();}n();var rm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),path:z.string().default(""),player:z.enum(["mpv","mplayer"]).optional(),outputDriver:z.enum(["caca","tct","sixel"]).default("caca"),speed:z.number().positive().default(1),autoPlay:z.boolean().default(false),loop:z.boolean().default(false),mute:z.boolean().default(true),visible:z.boolean().default(true)}),lT=1e4,ao={isVideo:new Uint8Array(lT)},pe=new Map,om=["/usr/bin/mpv","/usr/local/bin/mpv","/opt/homebrew/bin/mpv","/snap/bin/mpv"],im=["/usr/bin/mplayer","/usr/local/bin/mplayer","/opt/homebrew/bin/mplayer"];function am(e=sm){for(let r of om)if(e(r))return {player:"mpv",path:r};for(let r of im)if(e(r))return {player:"mplayer",path:r}}function sm(e){try{return a$3("fs").existsSync(e)}catch{return false}}function lm(e,r,o){let n=[];return e.outputDriver==="caca"?n.push("--vo=caca"):e.outputDriver==="tct"?(n.push("--vo=tct"),n.push(`--vo-tct-width=${r}`),n.push(`--vo-tct-height=${o}`)):e.outputDriver==="sixel"&&(n.push("--vo=sixel"),n.push(`--vo-sixel-width=${r*8}`),n.push(`--vo-sixel-height=${o*14}`)),n.push("--no-osc"),n.push("--no-input-default-bindings"),n.push("--terminal=no"),n.push("--no-input-terminal"),e.speed!==1&&n.push(`--speed=${e.speed}`),e.loop&&n.push("--loop=inf"),e.mute&&n.push("--mute=yes"),e.seekPosition>0&&n.push(`--start=${e.seekPosition}`),n.push(e.path),n}function um(e,r,o){let n=[];return e.outputDriver,n.push("-vo","caca"),n.push("-slave"),n.push("-quiet"),e.speed!==1&&n.push("-speed",String(e.speed)),e.loop&&n.push("-loop","0"),e.mute&&n.push("-nosound"),e.seekPosition>0&&n.push("-ss",String(e.seekPosition)),n.push(e.path),n}function dm(e,r,o,n){return e==="mpv"?lm(r,o,n):um(r)}function Cs(e,r){r==="mplayer"&&e.write(`pause
|
|
23
|
-
`);}function cm(e,r,o){r==="mplayer"&&e.write(`seek ${o} 2
|
|
24
|
-
`);}function uT(e,r={},o){let n=rm.parse(r),t=d$1(e);F(e,t,n.x,n.y),w(e,t,n.width,n.height),ao.isVideo[t]=1;let i={path:n.path,player:n.player,outputDriver:n.outputDriver,speed:n.speed,loop:n.loop,mute:n.mute,playbackState:"stopped",visible:n.visible,process:null,seekPosition:0,onEndCallback:null,onErrorCallback:null,onDataCallback:null};pe.set(t,i),n.visible||j$1(e,t,false);let a=bT(e,t,o);return n.autoPlay&&n.path&&a.play(),a}function dT(e){return e.playbackState!=="paused"||!e.process||e.player!=="mplayer"?false:(Cs(e.process,"mplayer"),e.playbackState="playing",true)}function cT(e){e.process&&(e.process.kill(),e.process=null);}function gT(e,r){if(e.player)return true;let o=r?.exists??sm,n=am(o);return n?(e.player=n.player,true):false}function mT(e,r,o,n,t,i){let a=dm(e.player,e,t,i),s=r.spawn(e.player,a);e.process=s,e.playbackState="playing",s.onData(l=>{e$2(o,n,l),g(o,n),e.onDataCallback?.(l);}),s.onExit(l=>{e.process=null,e.playbackState="stopped",l===0?e.onEndCallback?.():e.onErrorCallback?.(`Player exited with code ${l}`);});}function fT(e,r,o,n){if(!e.path)return "No video path set";if(cT(e),!gT(e,r))return "No video player found (mpv or mplayer required)";if(!r)return "No process spawner available";let t=v$2.width[n]||80,i=v$2.height[n]||24;try{mT(e,r,o,n,t,i);}catch(a){return a instanceof Error?a.message:String(a)}return null}function bT(e,r,o){let n=()=>{let s=pe.get(r);if(!s||dT(s))return a;let l=fT(s,o,e,r);return l&&s.onErrorCallback?.(l),a},t=()=>{let s=pe.get(r);return !s||s.playbackState!=="playing"||(s.process&&s.player==="mplayer"&&Cs(s.process,"mplayer"),s.playbackState="paused"),a},i=()=>{let s=pe.get(r);return s&&(s.process&&(s.process.kill(),s.process=null),s.playbackState="stopped",s.seekPosition=0,e$2(e,r,""),g(e,r)),a},a={get eid(){return r},show(){let s=pe.get(r);return s&&(s.visible=true),j$1(e,r,true),g(e,r),a},hide(){let s=pe.get(r);return s&&(s.visible=false),j$1(e,r,false),g(e,r),a},isVisible(){return pe.get(r)?.visible??false},move(s,l){let u=E$1.x[r]??0,d=E$1.y[r]??0;return F(e,r,u+s,d+l),g(e,r),a},setPosition(s,l){return F(e,r,s,l),g(e,r),a},getPosition(){return {x:E$1.x[r]??0,y:E$1.y[r]??0}},setPath(s){let l=pe.get(r);return l&&(l.path=s),a},getPath(){return pe.get(r)?.path??""},play:n,pause:t,stop:i,togglePlayback(){let s=pe.get(r);return s?s.playbackState==="playing"?t():n():a},seek(s){let l=pe.get(r);return l&&(l.seekPosition=Math.max(0,s),l.process&&l.player==="mplayer"?cm(l.process,"mplayer",s):l.playbackState==="playing"&&(i(),l.seekPosition=Math.max(0,s),n())),a},getPlaybackState(){return pe.get(r)?.playbackState??"stopped"},setSpeed(s){let l=pe.get(r);return l&&(l.speed=s),a},getSpeed(){return pe.get(r)?.speed??1},setLoop(s){let l=pe.get(r);return l&&(l.loop=s),a},getLoop(){return pe.get(r)?.loop??false},setMute(s){let l=pe.get(r);return l&&(l.mute=s),a},getMute(){return pe.get(r)?.mute??true},getPlayer(){return pe.get(r)?.player},isRunning(){return pe.get(r)?.process!==null},resize(s,l){w(e,r,s,l);let u=pe.get(r);return u?.process?.resize&&u.process.resize(s,l),g(e,r),a},onEnd(s){let l=pe.get(r);return l&&(l.onEndCallback=s),a},onError(s){let l=pe.get(r);return l&&(l.onErrorCallback=s),a},onData(s){let l=pe.get(r);return l&&(l.onDataCallback=s),a},destroy(){let s=pe.get(r);s?.process&&s.process.kill(),ao.isVideo[r]=0,pe.delete(r),e$3(e,r);}};return a}function pT(e,r){return ao.isVideo[r]===1}function yT(e){return pe.get(e)?.playbackState}function hT(e){return pe.get(e)?.player}function xT(){for(let e of pe.values())e.process&&e.process.kill();ao.isVideo.fill(0),pe.clear();}u();n();var fm=z.object({fg:z.number().int().nonnegative().optional(),bg:z.number().int().nonnegative().optional(),selectedFg:z.number().int().nonnegative().optional(),selectedBg:z.number().int().nonnegative().optional(),cursorFg:z.number().int().nonnegative().optional(),cursorBg:z.number().int().nonnegative().optional(),showLineNumbers:z.boolean().optional(),lineNumberWidth:z.number().int().nonnegative().optional()}),bm=z.object({type:z.nativeEnum(a$1).optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional()}),pm=z.object({x:z.number().int().default(0),y:z.number().int().default(0),width:z.number().int().positive(),height:z.number().int().positive(),lines:z.array(z.string()).optional(),mouse:z.boolean().default(true),keys:z.boolean().default(true),style:fm.optional(),border:bm.optional(),overscan:z.number().int().nonnegative().default(5),maxLines:z.number().int().nonnegative().default(0)}),CT=["fg","bg","selectedFg","selectedBg","cursorFg","cursorBg","showLineNumbers","lineNumberWidth"];function ST(e){let r={};for(let o of CT){let n=e[o];n!==void 0&&(r[o]=n);}return r}var gm=new WeakMap;function Xi(e,r){if(e.store=r,h$2(e.eid,r),r$2(e.world,e.eid,r.lineCount),e.maxLines>0&&r.lineCount>e.maxLines){let o=w$2(r,e.maxLines);e.store=o,h$2(e.eid,o),r$2(e.world,e.eid,o.lineCount);}e.followMode&&p$3(e.world,e.eid),g(e.world,e.eid);}function mm(e,r){return Math.max(1,e-(r?2:0))}function TT(e,r){let o=pm.parse(r),n=d$1(e);F(e,n,o.x,o.y),w(e,n,o.width,o.height),a$4.x[n]=o.x,a$4.y[n]=o.y,a$4.width[n]=o.width,a$4.height[n]=o.height,a$4.valid[n]=1;let t=o.border!==void 0&&o.border.type!==0,i=mm(o.height,t),a;o.lines&&o.lines.length>0?a=g$1(o.lines):a=h$1(),e$6(n,a),e$7(e,n,{totalLineCount:a.lineCount,visibleLineCount:i,overscanBefore:o.overscan,overscanAfter:o.overscan,selectedLine:-1,cursorLine:-1});let s={fg:o.style?.fg??4294967295,bg:o.style?.bg??255};d(e,n,s),j$1(e,n,true);let l$1={};o.style?.fg!==void 0&&(l$1.fg=o.style.fg),o.style?.bg!==void 0&&(l$1.bg=o.style.bg),o.style?.selectedFg!==void 0&&(l$1.selectedFg=o.style.selectedFg),o.style?.selectedBg!==void 0&&(l$1.selectedBg=o.style.selectedBg),o.style?.cursorFg!==void 0&&(l$1.cursorFg=o.style.cursorFg),o.style?.cursorBg!==void 0&&(l$1.cursorBg=o.style.cursorBg),o.style?.showLineNumbers!==void 0&&(l$1.showLineNumbers=o.style.showLineNumbers),o.style?.lineNumberWidth!==void 0&&(l$1.lineNumberWidth=o.style.lineNumberWidth),i$2(n,l$1),o.border&&l(e,n,o.border);let u={world:e,eid:n,store:a,followMode:false,maxLines:o.maxLines,mouseEnabled:o.mouse,keysEnabled:o.keys},d$2={eid:n};gm.set(d$2,u),g(e,n);let f={eid:n,show(){return j$1(e,n,true),g(e,n),f},hide(){return j$1(e,n,false),g(e,n),f},setPosition(g$1,c){return F(e,n,g$1,c),a$4.x[n]=g$1,a$4.y[n]=c,g(e,n),f},setDimensions(g$1,c){w(e,n,g$1,c),a$4.width[n]=g$1,a$4.height[n]=c;let b=mm(c,t);return s$1(e,n,b),g(e,n),f},setLines(g){let c=g.length>0?g$1(g):h$1();return Xi(u,c),f},appendLine(g){let c=m$3(u.store,u.store.byteSize>0?`
|
|
25
|
-
${g}`:g);return Xi(u,c),f},appendLines(g){if(g.length===0)return f;let c=n$3(u.store,g);return Xi(u,c),f},getLineCount(){return o$4(u.store)},getLine(g){return i$3(u.store,g)},clear(){return Xi(u,h$1()),f},scrollToLine(g){return l$3(e,n,g),f},scrollToTop(){return o$3(e,n),f},scrollToBottom(){return p$3(e,n),f},scrollBy(g){return m$2(e,n,g),f},scrollPage(g){return n$2(e,n,g),f},getScrollInfo(){return q$3(e,n)},select(g){return u$2(e,n,g),f},getSelected(){return d$6.selectedLine[n]},clearSelection(){return u$2(e,n,-1),f},cursorUp(g=1){return y$2(e,n,-g),f},cursorDown(g=1){return y$2(e,n,g),f},setCursor(g$1){return d$6.cursorLine[n]=g$1,g(e,n),f},getCursor(){return d$6.cursorLine[n]},follow(g){return u.followMode=g,g&&p$3(e,n),f},isFollowing(){return u.followMode},setStyle(g$1){return i$2(n,ST(g$1)),g(e,n),f},destroy(){o$2(n),gm.delete(d$2),e$3(e,n);},refresh(){return g(e,n),f}};return f}function WT(e,r,o=false,n=false){switch(r){case "up":case "k":return e.cursorUp(n?5:1),true;case "down":case "j":return e.cursorDown(n?5:1),true;case "pageup":return e.scrollPage(-1),true;case "pagedown":return e.scrollPage(1),true;case "home":return o?(e.scrollToTop(),e.setCursor(0)):e.scrollToTop(),true;case "end":if(o){e.scrollToBottom();let t=e.getLineCount();e.setCursor(t-1);}else e.scrollToBottom();return true;case "g":return !o&&!n?(e.scrollToTop(),e.setCursor(0),true):false;case "G":return e.scrollToBottom(),e.setCursor(e.getLineCount()-1),true;case "enter":case "return":return e.select(e.getCursor()),true;default:return false}}function vT(e,r,o=3){return r==="up"?e.scrollBy(-o):e.scrollBy(o),true}function LT(e,r){return d$6.totalLineCount[r]!==void 0&&d$6.visibleLineCount[r]!==void 0}export{df as $,ab as $a,Id as $b,Jy as $c,Cx as $d,os as $e,kS as $f,Qm as A,Dr as Aa,lp as Ab,Fy as Ac,Nh as Ad,tg as Ae,eS as Af,sT as Ag,Xm as B,Vf as Ba,up as Bb,My as Bc,Ka as Bd,ng as Be,tS as Bf,rm as Bg,qm as C,Li as Ca,dp as Cb,ky as Cc,Ic as Cd,rg as Ce,rS as Cf,ao as Cg,cn as D,Ju as Da,cp as Db,Di as Dc,Vc as Dd,jr as De,oS as Df,om as Dg,Ln as E,Nf as Ea,Td as Eb,lc as Ec,zh as Ed,nt as Ee,iS as Ef,im as Eg,Jm as F,Uf as Fa,Wd as Fb,uc as Fc,wh as Fd,og as Fe,aS as Ff,am as Fg,xa as G,$f as Ga,mp as Gb,dc as Gc,Hh as Gd,ig as Ge,cs as Gf,lm as Gg,Iu as H,Gt as Ha,Ld as Hb,et as Hc,_c as Hd,Zx as He,Vg as Hf,um as Hg,Sr as I,Yf as Ia,kr as Ib,Ha as Ic,De as Id,eC as Ie,ds as If,dm as Ig,mt as J,ed as Ja,Cp as Jb,Vy as Jc,Oc as Jd,tC as Je,Ki as Jf,Cs as Jg,Xn as K,td as Ka,Sp as Kb,_y as Kc,tx as Kd,nC as Ke,_g as Kf,cm as Kg,Ca as L,Kf as La,Tp as Lb,Oy as Lc,Vi as Ld,ag as Le,Og as Lf,uT as Lg,Si as M,Qf as Ma,Bd as Mb,Gy as Mc,nx as Md,sg as Me,ro as Mf,pT as Mg,Yt as N,va as Na,xt as Nb,Ny as Nc,rx as Nd,Kr as Ne,Gg as Nf,yT as Ng,Zm as O,nd as Oa,Ep as Ob,cc as Oc,ox as Od,Qr as Oe,lS as Of,hT as Og,ef as P,rd as Pa,Bp as Pb,Tt as Pc,ix as Pd,rC as Pe,zg as Pf,xT as Pg,Tr as Q,La as Qa,Pp as Qb,Hy as Qc,ax as Qd,ug as Qe,qe as Qf,fm as Qg,_u as R,Xf as Ra,Ia as Rb,Uy as Rc,sx as Rd,oC as Re,mS as Rf,bm as Rg,Ou as S,qf as Sa,Ad as Sb,$y as Sc,lx as Sd,iC as Se,gs as Sf,pm as Sg,Gu as T,Jf as Ta,Fp as Tb,hc as Tc,_i as Td,aC as Te,fS as Tf,TT as Tg,ze as U,Zf as Ua,Mp as Ub,Ky as Uc,Hc as Ud,mg as Ue,bS as Uf,WT as Ug,of as V,eb as Va,kp as Vb,$a as Vc,Uc as Vd,Lt as Ve,pS as Vf,vT as Vg,af as W,tb as Wa,Rp as Wb,Qy as Wc,$c as Wd,Xr as We,$g as Wf,LT as Wg,sf as X,nb as Xa,Dd as Xb,Sc as Xc,jc as Xd,rs as Xe,jg as Xf,zu as Y,rb as Ya,Fd as Yb,ja as Yc,q as Yd,SC as Ye,Bt as Yf,Lr as Z,ob as Za,Vp as Zb,Xy as Zc,qa as Zd,TC as Ze,LS as Zf,uf as _,ib as _a,Rd as _b,qy as _c,xx as _d,WC as _e,MS as _f,rr as a,cf as aa,ud as ab,Vd as ac,Tc as ad,Sx as ae,bg as af,RS as ag,fL as b,$u as ba,dd as bb,_d as bc,Wc as bd,Tx as be,is as bf,IS as bg,bL as c,Er as ca,cd as cb,Od as cc,Mi as cd,Wx as ce,vC as cf,VS as cg,Au as d,Br as da,ge as db,Gd as dc,eh as dd,vx as de,Wg as df,Yg as dg,Cr as e,Wa as ea,Fr as eb,Nd as ec,th as ed,Lx as ee,EC as ef,Kg as eg,pt as f,hf as fa,yb as fb,Va as fc,nh as fd,Qc as fe,ls as ff,ot as fg,Mm as g,xf as ga,hb as gb,zp as gc,vc as gd,Qe as ge,RC as gf,Ue as gg,km as h,Cf as ha,xb as hb,wp as hc,rh as hd,Ex as he,zi as hf,_S as hg,Rm as i,Wi as ia,Cb as ib,Hp as ic,oh as id,Bx as ie,us as if,OS as ig,Im as j,ju as ja,Sb as jb,Up as jc,Ac as jd,Px as je,VC as jf,zS as jg,_m as k,Ze as ka,Tb as kb,$p as kc,de as kd,Dx as ke,Bg as kf,wS as kg,Om as l,Wf as la,Ba as lb,jp as lc,Sh as ld,Fx as le,Pg as lf,HS as lg,Gm as m,vf as ma,md as mb,Yp as mc,Th as md,Xc as me,wi as mf,US as mg,Nm as n,Lf as na,Lb as nb,Xd as nc,Wh as nd,qc as ne,OC as nf,$S as ng,ya as o,Ef as oa,Eb as ob,Or as oc,vh as od,Jc as oe,GC as of,Zg as og,Mu as p,Bf as pa,Bb as pb,hy as pc,Lh as pd,Zc as pe,NC as pf,em as pg,zm as q,Pf as qa,pd as qb,Cy as qc,Eh as qd,ts as qe,Ag as qf,xs as qg,wm as r,Af as ra,Ee as rb,Sy as rc,Fc as rd,$r as re,rt as rf,hs as rg,Hm as s,Df as sa,He as sb,Ty as sc,Mc as sd,tt as se,wC as sf,tm as sg,Um as t,Ff as ta,Qb as tb,Wy as tc,Ya as td,eg as te,HC as tf,wt as tg,$m as u,Qu as ua,Jb as ub,tc as uc,kc as ud,Ox as ue,UC as uf,io as ug,ku as v,Ar as va,Zb as vb,J as vc,Me as vd,Gx as ve,Ig as vf,nT as vg,jm as w,kf as wa,ep as wb,nc as wc,Hr as wd,Nx as we,Se as wf,rT as wg,Ym as x,Rf as xa,tp as xb,rc as xc,_h as xd,zx as xe,qC as xf,oT as xg,ha as y,If as ya,Aa as yb,oc as yc,Oh as yd,Hx as ye,JC as yf,iT as yg,Ru as z,Xu as za,xd as zb,za as zc,Gh as zd,Ux as ze,ZC as zf,aT as zg};
|
package/dist/chunk-G7GIWWLE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {n as n$1,i,h as h$1}from'./chunk-PXXGH3BV.js';n$1();var p=1e4,s=0,n={parent:new Uint32Array(p),firstChild:new Uint32Array(p),nextSibling:new Uint32Array(p),prevSibling:new Uint32Array(p),childCount:new Uint16Array(p),depth:new Uint16Array(p)};function m(i){n.parent[i]=s,n.firstChild[i]=s,n.nextSibling[i]=s,n.prevSibling[i]=s,n.childCount[i]=0,n.depth[i]=0;}function E(i$1,t){i(i$1,t,n)||(h$1(i$1,t,n),m(t));}function c(i,t){n.depth[i]=t;let r=n.firstChild[i];for(;r!==s;)c(r,t+1),r=n.nextSibling[r];}function b(i,t,r){E(i,t),r!==s&&E(i,r);let e=n.parent[t];return e===r||(e!==s&&h(t,e),r!==s?v(t,r):(n.parent[t]=s,c(t,0))),t}function h(i,t){let r=n.prevSibling[i],e=n.nextSibling[i];r!==s?n.nextSibling[r]=e:n.firstChild[t]=e,e!==s&&(n.prevSibling[e]=r),n.prevSibling[i]=s,n.nextSibling[i]=s,n.childCount[t]=n.childCount[t]-1;}function v(i,t){n.parent[i]=t;let r=n.firstChild[t];if(r===s)n.firstChild[t]=i;else {let o=r;for(;n.nextSibling[o]!==s;)o=n.nextSibling[o];n.nextSibling[o]=i,n.prevSibling[i]=o;}n.childCount[t]=n.childCount[t]+1;let e=n.depth[t];c(i,e+1);}function W(i,t,r){return b(i,r,t),t}function P(i$1,t,r){return !i(i$1,r,n)||n.parent[r]!==t||b(i$1,r,s),t}function I(i$1,t){if(!i(i$1,t,n))return [];let r=[],e=n.firstChild[t];for(;e!==s;)r.push(e),e=n.nextSibling[e];return r}function U(i$1,t){if(!i(i$1,t,n))return [];let r=[],e=n.parent[t];for(;e!==s;)r.push(e),e=n.parent[e];return r}function H(i$1,t){if(!i(i$1,t,n))return [];let r=[],e=[],o=n.firstChild[t];for(;o!==s;)e.push(o),o=n.nextSibling[o];for(;e.length>0;){let u=e.pop();r.push(u);let y=[],l=n.firstChild[u];for(;l!==s;)y.push(l),l=n.nextSibling[l];for(let f=y.length-1;f>=0;f--)e.push(y[f]);}return r}function L(i$1,t){return i(i$1,t,n)?n.parent[t]:s}function F(i$1,t){if(i(i$1,t,n))return {parent:n.parent[t],firstChild:n.firstChild[t],nextSibling:n.nextSibling[t],prevSibling:n.prevSibling[t],childCount:n.childCount[t],depth:n.depth[t]}}function N(i$1,t){return i(i$1,t,n)}function R(i$1,t){return i(i$1,t,n)?n.parent[t]===s:true}function Y(i$1,t){return i(i$1,t,n)?n.childCount[t]===0:true}function _(i$1,t){return i(i$1,t,n)?n.depth[t]:0}function B(i$1,t){return i(i$1,t,n)?n.nextSibling[t]:s}function M(i$1,t){return i(i$1,t,n)?n.prevSibling[t]:s}function A(i,t,r){E(i,r),E(i,t);let e=n.parent[r];e!==s&&h(r,e);let o=n.firstChild[t];n.parent[r]=t,n.firstChild[t]=r,n.prevSibling[r]=s,n.nextSibling[r]=o,o!==s&&(n.prevSibling[o]=r),n.childCount[t]=n.childCount[t]+1;let u=n.depth[t];return c(r,u+1),t}function j(i,t,r,e){E(i,t);let o=n.childCount[t],u=e;if(u<0&&(u=Math.max(0,o+u)),u>=o)return W(i,t,r);if(u===0)return A(i,t,r);let y=n.firstChild[t];for(let l=0;l<u;l++)y=n.nextSibling[y];return T(i,r,y)}function T(i$1,t,r){if(!i(i$1,r,n))return t;let e=n.parent[r];if(e===s)return t;E(i$1,t);let o=n.parent[t];o!==s&&h(t,o);let u=n.prevSibling[r];n.parent[t]=e,n.prevSibling[t]=u,n.nextSibling[t]=r,n.prevSibling[r]=t,u!==s?n.nextSibling[u]=t:n.firstChild[e]=t,n.childCount[e]=n.childCount[e]+1;let y=n.depth[e];return c(t,y+1),t}function q(i$1,t,r){if(!i(i$1,r,n))return t;let e=n.parent[r];if(e===s)return t;E(i$1,t);let o=n.parent[t];o!==s&&h(t,o);let u=n.nextSibling[r];n.parent[t]=e,n.prevSibling[t]=r,n.nextSibling[t]=u,n.nextSibling[r]=t,u!==s&&(n.prevSibling[u]=t),n.childCount[e]=n.childCount[e]+1;let y=n.depth[e];return c(t,y+1),t}function z(i,t){return b(i,t,s)}function G(i$1,t){if(!i(i$1,t,n))return s;let r=n.firstChild[t];if(r===s)return s;for(;n.nextSibling[r]!==s;)r=n.nextSibling[r];return r}function J(i$1,t){return i(i$1,t,n)?n.firstChild[t]:s}function K(i$1,t){if(!i(i$1,t,n))return -1;let r=n.parent[t];if(r===s)return -1;let e=0,o=n.firstChild[r];for(;o!==s;){if(o===t)return e;e++,o=n.nextSibling[o];}return -1}function O(i$1,t,r){if(!i(i$1,t,n)||r<0)return s;let e=n.firstChild[t];for(let o=0;o<r&&e!==s;o++)e=n.nextSibling[e];return e}function g(i,t){let r=[],e=n.firstChild[i];for(;e!==s;)r.push({entity:e,depth:t}),e=n.nextSibling[e];return r}function C(i,t){for(let r=i.length-1;r>=0;r--){let e=i[r];e&&t.push(e);}}function Q(i$1,t,r){if(!i(i$1,t,n))return true;let e=[],o=n.depth[t]??0,u=g(t,o+1);for(C(u,e);e.length>0;){let y=e.pop();if(!y)continue;let{entity:l,depth:f}=y;if(r(l,f-o)===false)return false;let S=g(l,f+1);C(S,e);}return true}function V(i$1,t,r){if(!i(i$1,t,n))return true;let e=1,o=n.parent[t];for(;o!==s;){if(r(o,e)===false)return false;o=n.parent[o],e++;}return true}function k(i$1,t,r){if(!i(i$1,t,n)||!i(i$1,r,n)||t===r)return false;let e=n.parent[r];for(;e!==s;){if(e===t)return true;e=n.parent[e];}return false}function X(i,t,r){return k(i,r,t)}function Z(i$1,t){if(!i(i$1,t,n))return t;let r=t,e=n.parent[r];for(;e!==s;)r=e,e=n.parent[r];return r}function $(i$1,t,r){if(!i(i$1,t,n)||!i(i$1,r,n))return s;let e=new Set;e.add(t);let o=n.parent[t];for(;o!==s;)e.add(o),o=n.parent[o];if(e.has(r))return r;for(o=n.parent[r];o!==s;){if(e.has(o))return o;o=n.parent[o];}return s}function tt(i$1,t){if(!i(i$1,t,n))return [];let r=n.parent[t];if(r===s)return [];let e=[],o=n.firstChild[r];for(;o!==s;)o!==t&&e.push(o),o=n.nextSibling[o];return e}export{V as A,k as B,X as C,Z as D,$ as E,tt as F,s as a,n as b,b as c,W as d,P as e,I as f,U as g,H as h,L as i,F as j,N as k,R as l,Y as m,_ as n,B as o,M as p,A as q,j as r,T as s,q as t,z as u,G as v,J as w,K as x,O as y,Q as z};
|