@nick-skriabin/glyph 0.1.40 → 0.1.41

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 CHANGED
@@ -19,6 +19,7 @@
19
19
 
20
20
  <p align="center">
21
21
  <a href="https://www.npmjs.com/package/@nick-skriabin/glyph"><img src="https://img.shields.io/npm/v/@nick-skriabin/glyph?color=crimson&logo=npm" alt="npm version"></a>
22
+ <a href="https://github.com/nick-skriabin/glyph/actions/workflows/test.yml"><img src="https://github.com/nick-skriabin/glyph/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
22
23
  <img src="https://img.shields.io/badge/React-18%2B-61dafb?logo=react&logoColor=white" alt="React 18+">
23
24
  <img src="https://img.shields.io/badge/Yoga-Flexbox-mediumpurple?logo=meta&logoColor=white" alt="Yoga Flexbox">
24
25
  <img src="https://img.shields.io/badge/TypeScript-First-3178c6?logo=typescript&logoColor=white" alt="TypeScript">
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import ee,{createContext,forwardRef,useState,useContext,useRef,useEffect,useLayoutEffect,useMemo,useCallback}from'react';import An from'react-reconciler';import ue from'string-width';import nn,{FlexDirection,Justify,Align,Direction,Edge,Wrap,Gutter,PositionType,Overflow,MeasureMode}from'yoga-layout';var Hn=0;function Lt(){return `glyph-focus-${Hn++}`}function Bt(e,t){let n=t.style??{};return {type:e,props:t,style:n,children:[],rawTextChildren:[],parent:null,yogaNode:null,text:null,layout:{x:0,y:0,width:0,height:0,innerX:0,innerY:0,innerWidth:0,innerHeight:0},focusId:e==="input"||t.focusable?Lt():null,hidden:false}}function st(e,t){t.parent=e,e.children.push(t);}function Mt(e,t){let n=e.children.indexOf(t);n!==-1&&(e.children.splice(n,1),t.parent=null);}function Vt(e,t,n){t.parent=e;let r=e.children.indexOf(n);r!==-1?e.children.splice(r,0,t):e.children.push(t);}function qe(e){let t={},n=e;for(;n;){let r=n.style;t.color===void 0&&r.color!==void 0&&(t.color=r.color),t.bg===void 0&&r.bg!==void 0&&(t.bg=r.bg),t.bold===void 0&&r.bold!==void 0&&(t.bold=r.bold),t.dim===void 0&&r.dim!==void 0&&(t.dim=r.dim),t.italic===void 0&&r.italic!==void 0&&(t.italic=r.italic),t.underline===void 0&&r.underline!==void 0&&(t.underline=r.underline),n=n.parent;}return t}function it(e){if(e.text!=null)return e.text;let t="";for(let n of e.children)t+=it(n);return t}var lt=32,Ht={supportsMutation:true,supportsPersistence:false,supportsHydration:false,isPrimaryRenderer:true,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,supportsMicrotasks:true,scheduleMicrotask:queueMicrotask,getCurrentUpdatePriority:()=>lt,setCurrentUpdatePriority:e=>{},resolveUpdatePriority:()=>lt,getCurrentEventPriority:()=>lt,resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,shouldAttemptEagerTransition:()=>false,getInstanceFromNode:()=>null,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},prepareScopeUpdate:()=>{},getInstanceFromScope:()=>null,detachDeletedInstance:()=>{},requestPostPaintCallback:e=>{},maySuspendCommit:(e,t)=>false,preloadInstance:(e,t)=>true,startSuspendingCommit:()=>{},suspendInstance:(e,t)=>{},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:{$$typeof:Symbol.for("react.context"),_currentValue:null},resetFormInstance:e=>{},bindToConsole:(e,t,n)=>Function.prototype.bind.call(console[e],console,...t),supportsResources:false,isHostHoistableType:(e,t)=>false,supportsSingletons:false,isHostSingletonType:e=>false,supportsTestSelectors:false,createInstance(e,t,n,r,o){return Bt(e,t)},createTextInstance(e,t,n,r){return {type:"raw-text",text:e,parent:null}},appendInitialChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=e,e.rawTextChildren.push(n),e.text=e.rawTextChildren.map(r=>r.text).join("");}else st(e,t);},finalizeInitialChildren(e,t,n,r,o){return false},shouldSetTextContent(e,t){return false},getRootHostContext(e){return {}},getChildHostContext(e,t,n){return e},getPublicInstance(e){return e},prepareForCommit(e){return null},resetAfterCommit(e){e.onCommit();},preparePortalMount(){},appendChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=e,e.rawTextChildren.push(n),e.text=e.rawTextChildren.map(r=>r.text).join("");}else st(e,t);},appendChildToContainer(e,t){if(t.type==="raw-text")return;let n=t;n.parent=null,e.children.push(n);},insertBefore(e,t,n){t.type==="raw-text"||n.type==="raw-text"||Vt(e,t,n);},insertInContainerBefore(e,t,n){if(t.type==="raw-text"||n.type==="raw-text")return;let r=t,o=n,s=e.children.indexOf(o);s!==-1?e.children.splice(s,0,r):e.children.push(r);},removeChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=null;let r=e.rawTextChildren.indexOf(n);r!==-1&&e.rawTextChildren.splice(r,1),e.text=e.rawTextChildren.map(o=>o.text).join("")||null;return}Mt(e,t);},removeChildFromContainer(e,t){if(t.type==="raw-text")return;let n=t,r=e.children.indexOf(n);r!==-1&&e.children.splice(r,1);},commitTextUpdate(e,t,n){e.text=n,e.parent&&(e.parent.text=e.parent.rawTextChildren.map(r=>r.text).join(""));},commitUpdate(e,t,n,r,o){e.props=r,e.style=r.style??{},r.focusable&&!e.focusId&&(e.focusId=`focus-${Math.random().toString(36).slice(2,9)}`);},hideInstance(e){e.hidden=true;},hideTextInstance(e){e.text="";},unhideInstance(e,t){e.hidden=false;},unhideTextInstance(e,t){e.text=t;},clearContainer(e){e.children.length=0;},resetTextContent(e){e.text=null;}};var Ie=An(Ht);Ie.injectIntoDevTools({bundleType:process.env.NODE_ENV==="production"?0:1,version:"0.1.0",rendererPackageName:"glyph"});var _e=class{stdout;stdin;wasRaw=false;cleanedUp=false;dataHandlers=new Set;stdinAttached=false;oscState="normal";oscAccum="";escFlushTimer=null;palette=new Map;paletteResolve=null;constructor(t=process.stdout,n=process.stdin){this.stdout=t,this.stdin=n;}get columns(){return this.stdout.columns||80}get rows(){return this.stdout.rows||24}enterRawMode(){this.stdin.isTTY&&(this.wasRaw=this.stdin.isRaw,this.stdin.setRawMode(true),this.stdin.resume(),this.stdin.setEncoding("utf-8"));}exitRawMode(){this.stdin.isTTY&&!this.wasRaw&&(this.stdin.setRawMode(false),this.stdin.pause());}write(t){this.stdout.write(t);}hideCursor(){this.write("\x1B[?25l");}showCursor(){this.write("\x1B[?25h");}moveCursor(t,n){this.write(`\x1B[${n+1};${t+1}H`);}setCursorColor(t){this.write(`\x1B]12;${t}\x07`);}resetCursorColor(){this.write("\x1B]112\x07");}enterAltScreen(){this.write("\x1B[?1049h");}exitAltScreen(){this.write("\x1B[?1049l");}clearScreen(){this.write("\x1B[2J\x1B[H");}resetStyles(){this.write("\x1B[0m");}enableKittyKeyboard(){this.write("\x1B[>1u");}disableKittyKeyboard(){this.write("\x1B[<u");}setup(){this.enterRawMode(),this.enterAltScreen(),this.enableKittyKeyboard(),this.hideCursor(),this.clearScreen(),this.attachStdinListener(),this.installCleanupHandlers();}cleanup(){this.cleanedUp||(this.cleanedUp=true,this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null),this.resetStyles(),this.resetCursorColor(),this.disableKittyKeyboard(),this.showCursor(),this.exitAltScreen(),this.exitRawMode());}suspend(){this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null),this.oscState="normal",this.oscAccum="",this.resetStyles(),this.resetCursorColor(),this.disableKittyKeyboard(),this.showCursor(),this.exitAltScreen(),this.exitRawMode();}resume(){this.enterRawMode(),this.enterAltScreen(),this.enableKittyKeyboard(),this.hideCursor(),this.clearScreen();}attachStdinListener(){this.stdinAttached||(this.stdinAttached=true,this.stdin.on("data",t=>{let n=typeof t=="string"?t:t.toString("utf-8");this.dispatchFiltered(n);}));}onData(t){return this.dataHandlers.add(t),()=>{this.dataHandlers.delete(t);}}dispatchFiltered(t){this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null);let n=this.filterOsc(t);if(n.length>0)for(let r of this.dataHandlers)r(n);this.oscState==="esc"&&(this.escFlushTimer=setTimeout(()=>{this.escFlushTimer=null,this.oscState="normal";for(let r of this.dataHandlers)r("\x1B");},50));}filterOsc(t){let n="";for(let r=0;r<t.length;r++){let o=t[r],s=t.charCodeAt(r);switch(this.oscState){case "normal":s===27?this.oscState="esc":n+=o;break;case "esc":o==="]"?(this.oscState="osc",this.oscAccum=""):(n+="\x1B"+o,this.oscState="normal");break;case "osc":s===7?(this.handleOscResponse(this.oscAccum),this.oscAccum="",this.oscState="normal"):s===27?this.oscState="osc_esc":this.oscAccum+=o;break;case "osc_esc":o==="\\"?(this.handleOscResponse(this.oscAccum),this.oscAccum="",this.oscState="normal"):(this.oscAccum+="\x1B"+o,this.oscState="osc");break}}return n}handleOscResponse(t){let n=t.match(/^4;(\d+);rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(n){let r=parseInt(n[1],10),o=parseInt(n[2].substring(0,2),16),s=parseInt(n[3].substring(0,2),16),i=parseInt(n[4].substring(0,2),16);this.palette.set(r,[o,s,i]),this.palette.size>=16&&this.paletteResolve&&(this.paletteResolve(),this.paletteResolve=null);}}queryPalette(){return new Promise(t=>{let n=()=>t(this.palette),r=setTimeout(n,200);this.paletteResolve=()=>{clearTimeout(r),n();};let o="";for(let s=0;s<16;s++)o+=`\x1B]4;${s};?\x07`;this.write(o);})}onResize(t){return this.stdout.on("resize",t),()=>{this.stdout.off("resize",t);}}installCleanupHandlers(){let t=()=>this.cleanup();process.on("exit",t);let n=r=>{t(),process.kill(process.pid,r);};process.once("SIGINT",()=>n("SIGINT")),process.once("SIGTERM",()=>n("SIGTERM")),process.on("uncaughtException",r=>{t(),console.error(r),process.exit(1);}),process.on("unhandledRejection",r=>{t(),console.error(r),process.exit(1);});}};function At(e){switch(e){case 9:return "tab";case 13:return "return";case 27:return "escape";case 32:return " ";case 127:return "backspace";case 57358:return "capslock";case 57359:return "scrolllock";case 57360:return "numlock";case 57361:return "printscreen";case 57362:return "pause";case 57363:return "menu";case 57364:return "f13";case 57365:return "f14";case 57366:return "f15";case 57367:return "f16";case 57368:return "f17";case 57369:return "f18";case 57370:return "f19";case 57371:return "f20";case 57372:return "f21";case 57373:return "f22";case 57374:return "f23";case 57375:return "f24";case 57376:return "f25";case 57399:return "kp0";case 57400:return "kp1";case 57401:return "kp2";case 57402:return "kp3";case 57403:return "kp4";case 57404:return "kp5";case 57405:return "kp6";case 57406:return "kp7";case 57407:return "kp8";case 57408:return "kp9";case 57409:return "kpdecimal";case 57410:return "kpdivide";case 57411:return "kpmultiply";case 57412:return "kpminus";case 57413:return "kpplus";case 57414:return "kpenter";case 57415:return "kpequal";case 57416:return "kpleft";case 57417:return "kpright";case 57418:return "kpup";case 57419:return "kpdown";case 57420:return "kppageup";case 57421:return "kppagedown";case 57422:return "kphome";case 57423:return "kpend";case 57424:return "kpinsert";case 57425:return "kpdelete";case 57428:return "mediaplaypause";case 57429:return "mediastop";case 57430:return "mediaprev";case 57431:return "medianext";case 57432:return "mediarewind";case 57433:return "mediafastforward";case 57434:return "mediamute";case 57435:return "volumedown";case 57436:return "volumeup";default:return e>=32&&e<=126?String.fromCharCode(e).toLowerCase():"unknown"}}function jn(e){switch(e.split(";")[0]){case "1":return "home";case "2":return "insert";case "3":return "delete";case "4":return "end";case "5":return "pageup";case "6":return "pagedown";case "7":return "home";case "8":return "end";case "11":return "f1";case "12":return "f2";case "13":return "f3";case "14":return "f4";case "15":return "f5";case "17":return "f6";case "18":return "f7";case "19":return "f8";case "20":return "f9";case "21":return "f10";case "23":return "f11";case "24":return "f12";case "25":return "f13";case "26":return "f14";case "28":return "f15";case "29":return "f16";case "31":return "f17";case "32":return "f18";case "33":return "f19";case "34":return "f20";default:return "unknown"}}function $e(e,t){let n=t-1;n&1&&(e.shift=true),n&2&&(e.alt=true),n&4&&(e.ctrl=true),n&8&&(e.meta=true);}function jt(e){let t=[],n=0;for(;n<e.length;){let r=e[n],o=e.charCodeAt(n);if(r==="\x1B"){if(e[n+1]==="["){let s=Dn(e,n);if(s){t.push(s.key),n=s.end;continue}}if(e[n+1]==="O"){let s=On(e,n);if(s){t.push(s.key),n=s.end;continue}}if(n+1<e.length&&e.charCodeAt(n+1)>=32){t.push({name:e[n+1].toLowerCase(),sequence:e.substring(n,n+2),alt:true}),n+=2;continue}t.push({name:"escape",sequence:"\x1B"}),n++;continue}if(o>=1&&o<=26){let s=String.fromCharCode(o+96);o===13?t.push({name:"return",sequence:"\r"}):o===9?t.push({name:"tab",sequence:" "}):o===8?t.push({name:"backspace",sequence:"\b"}):t.push({name:s,sequence:r,ctrl:true}),n++;continue}if(o===127){t.push({name:"backspace",sequence:r}),n++;continue}t.push({name:r,sequence:r}),n++;}return t}function On(e,t){if(t+2>=e.length)return null;let n=e[t+2],r=e.substring(t,t+3),o;switch(n){case "A":o={name:"up",sequence:r};break;case "B":o={name:"down",sequence:r};break;case "C":o={name:"right",sequence:r};break;case "D":o={name:"left",sequence:r};break;case "H":o={name:"home",sequence:r};break;case "F":o={name:"end",sequence:r};break;case "P":o={name:"f1",sequence:r};break;case "Q":o={name:"f2",sequence:r};break;case "R":o={name:"f3",sequence:r};break;case "S":o={name:"f4",sequence:r};break;case "j":o={name:"kpmultiply",sequence:r};break;case "k":o={name:"kpplus",sequence:r};break;case "l":o={name:"kpcomma",sequence:r};break;case "m":o={name:"kpminus",sequence:r};break;case "n":o={name:"kpdecimal",sequence:r};break;case "o":o={name:"kpdivide",sequence:r};break;case "p":o={name:"kp0",sequence:r};break;case "q":o={name:"kp1",sequence:r};break;case "r":o={name:"kp2",sequence:r};break;case "s":o={name:"kp3",sequence:r};break;case "t":o={name:"kp4",sequence:r};break;case "u":o={name:"kp5",sequence:r};break;case "v":o={name:"kp6",sequence:r};break;case "w":o={name:"kp7",sequence:r};break;case "x":o={name:"kp8",sequence:r};break;case "y":o={name:"kp9",sequence:r};break;case "M":o={name:"kpenter",sequence:r};break;default:return null}return {key:o,end:t+3}}function Dn(e,t){let n=t+2,r="";for(;n<e.length;){let c=e.charCodeAt(n);if(c>=48&&c<=63)r+=e[n],n++;else break}if(n>=e.length)return null;let o=e[n],s=e.substring(t,n+1);n++;let i;switch(o){case "A":i={name:"up",sequence:s};break;case "B":i={name:"down",sequence:s};break;case "C":i={name:"right",sequence:s};break;case "D":i={name:"left",sequence:s};break;case "H":i={name:"home",sequence:s};break;case "F":i={name:"end",sequence:s};break;case "Z":i={name:"tab",sequence:s,shift:true};break;case "P":i={name:"f1",sequence:s};break;case "Q":i={name:"f2",sequence:s};break;case "R":i={name:"f3",sequence:s};break;case "S":i={name:"f4",sequence:s};break;case "~":{if(r.startsWith("27;")){let c=r.split(";"),l=parseInt(c[1]??"1",10),a=parseInt(c[2]??"0",10);i={name:At(a),sequence:s},$e(i,l);break}if(i={name:jn(r),sequence:s},r.includes(";")){let c=r.split(";"),l=parseInt(c[1]??"1",10);$e(i,l);}break}case "u":{let c=r.split(";"),l=parseInt(c[0]??"0",10),a=parseInt(c[1]??"1",10);i={name:At(l),sequence:s},$e(i,a);break}case "I":i={name:"focus",sequence:s};break;case "O":i={name:"blur",sequence:s};break;default:i={name:"unknown",sequence:s};}if(r.includes(";")&&!["~","u"].includes(o)){let c=r.split(";"),l=parseInt(c[c.length-1]??"1",10);l>=1&&l<=16&&$e(i,l);}return {key:i,end:n}}var Kn={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",blackBright:"\x1B[90m",redBright:"\x1B[91m",greenBright:"\x1B[92m",yellowBright:"\x1B[93m",blueBright:"\x1B[94m",magentaBright:"\x1B[95m",cyanBright:"\x1B[96m",whiteBright:"\x1B[97m"},Wn={black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m",blackBright:"\x1B[100m",redBright:"\x1B[101m",greenBright:"\x1B[102m",yellowBright:"\x1B[103m",blueBright:"\x1B[104m",magentaBright:"\x1B[105m",cyanBright:"\x1B[106m",whiteBright:"\x1B[107m"};function ct(e){let t=e.replace("#",""),n=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16);return {r:n,g:r,b:o}}function Ot(e){if(typeof e=="string"){if(e.startsWith("#")){let{r:o,g:s,b:i}=ct(e);return `\x1B[38;2;${o};${s};${i}m`}return Kn[e]??"\x1B[39m"}if(typeof e=="number")return `\x1B[38;5;${e}m`;let{r:t,g:n,b:r}=e;return `\x1B[38;2;${t};${n};${r}m`}function Dt(e){if(typeof e=="string"){if(e.startsWith("#")){let{r:o,g:s,b:i}=ct(e);return `\x1B[48;2;${o};${s};${i}m`}return Wn[e]??"\x1B[49m"}if(typeof e=="number")return `\x1B[48;5;${e}m`;let{r:t,g:n,b:r}=e;return `\x1B[48;2;${t};${n};${r}m`}var Kt={black:[0,0,0],red:[170,0,0],green:[0,170,0],yellow:[170,170,0],blue:[0,0,170],magenta:[170,0,170],cyan:[0,170,170],white:[170,170,170],blackBright:[85,85,85],redBright:[255,85,85],greenBright:[85,255,85],yellowBright:[255,255,85],blueBright:[85,85,255],magentaBright:[255,85,255],cyanBright:[85,255,255],whiteBright:[255,255,255]},Wt=["black","red","green","yellow","blue","magenta","cyan","white","blackBright","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright"],Te=null;function qt(e){e.size>0&&(Te=e);}function qn(e){if(Te){let t=Wt.indexOf(e);if(t!==-1){let n=Te.get(t);if(n)return n}}return Kt[e]??null}function _n(e){if(typeof e=="string"){if(e.startsWith("#")){let t=ct(e);return [t.r,t.g,t.b]}return qn(e)}if(typeof e=="number"){if(e<16){if(Te){let s=Te.get(e);if(s)return s}return Kt[Wt[e]]}if(e>=232){let s=(e-232)*10+8;return [s,s,s]}let t=e-16,n=t%6*51,r=Math.floor(t/6)%6*51;return [Math.floor(t/36)*51,r,n]}return [e.r,e.g,e.b]}function ze(e){let t=_n(e);if(!t)return false;let[n,r,o]=t.map(i=>{let c=i/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)});return .2126*n+.7152*r+.0722*o>.4}function ut(e,t){return e===t?true:e==null||t==null?false:typeof e=="object"&&typeof t=="object"?e.r===t.r&&e.g===t.g&&e.b===t.b:false}function _t(e){return e&&ze(e)?"black":"white"}var Ne=class e{width;height;cells;constructor(t,n){this.width=t,this.height=n,this.cells=new Array(t*n),this.clear();}clear(){for(let t=0;t<this.cells.length;t++)this.cells[t]={ch:" "};}resize(t,n){this.width=t,this.height=n,this.cells=new Array(t*n),this.clear();}get(t,n){if(!(t<0||t>=this.width||n<0||n>=this.height))return this.cells[n*this.width+t]}set(t,n,r){t<0||t>=this.width||n<0||n>=this.height||(this.cells[n*this.width+t]=r);}setChar(t,n,r,o,s,i,c,l,a){t<0||t>=this.width||n<0||n>=this.height||(this.cells[n*this.width+t]={ch:r,fg:o,bg:s,bold:i,dim:c,italic:l,underline:a});}fillRect(t,n,r,o,s,i,c){for(let l=n;l<n+o;l++)for(let a=t;a<t+r;a++)this.setChar(a,l,s,i,c);}clone(){let t=new e(this.width,this.height);for(let n=0;n<this.cells.length;n++){let r=this.cells[n];t.cells[n]={...r};}return t}cellsEqual(t,n){return t.ch===n.ch&&ut(t.fg,n.fg)&&ut(t.bg,n.bg)&&(t.bold??false)===(n.bold??false)&&(t.dim??false)===(n.dim??false)&&(t.italic??false)===(n.italic??false)&&(t.underline??false)===(n.underline??false)}};var $n={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551"},round:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502"},ascii:{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|"}};function $t(e){return e==="none"?null:$n[e]}function zt(e,t,n,r){if(e.length===0)return {width:0,height:0};let o=e.split(`
2
- `);if(n===MeasureMode.Undefined||r==="none"){let l=0;for(let a of o){let p=ue(a);p>l&&(l=p);}return {width:l,height:o.length}}let s=Math.max(1,Math.floor(t)),i=ce(o,s,r),c=0;for(let l of i){let a=ue(l);a>c&&(c=a);}return {width:c,height:i.length}}function ce(e,t,n){let r=[];for(let o of e){if(ue(o)<=t){r.push(o);continue}if(n==="truncate"){r.push(Xt(o,t));continue}if(n==="ellipsis"){r.push(Xn(o,t));continue}let i=Jn(o,t);r.push(...i);}return r}function Xt(e,t){let n="",r=0;for(let o of e){let s=ue(o);if(r+s>t)break;n+=o,r+=s;}return n}function Xn(e,t){if(t<=1)return t===1?"\u2026":"";let n=Xt(e,t-1);return ue(n)<ue(e)?n+"\u2026":e}function Jn(e,t){let n=[],r="",o=0,s="",i=0;for(let c=0;c<=e.length;c++){let l=e[c],a=c===e.length,p=l===" ";if(a||p){if(s.length>0){if(o+i<=t)r+=s,o+=i;else if(i<=t)r.length>0&&n.push(r),r=s,o=i;else for(let d of s){let S=ue(d);o+S>t&&r.length>0&&(n.push(r),r="",o=0),r+=d,o+=S;}s="",i=0;}p&&(o+1<=t?(r+=" ",o+=1):(r.length>0&&n.push(r),r=" ",o=1));}else l&&(s+=l,i+=ue(l));}return r.length>0&&n.push(r),n.length>0?n:[""]}function Jt(e,t,n={}){t.clear();let r={},o=[],s={x:0,y:0,width:t.width,height:t.height};for(let i of e)i.hidden||Yt(i,s,i.style.zIndex??0,o);o.sort((i,c)=>i.zIndex-c.zIndex);for(let i of o){let c=Un(i.node,t,i.clip,n);c?.cursorPosition&&(r.cursorPosition=c.cursorPosition);}return r}function Yt(e,t,n,r){if(e.hidden)return;let o=e.style.zIndex??n,s=e.style.clip?Yn(t,{x:e.layout.innerX,y:e.layout.innerY,width:e.layout.innerWidth,height:e.layout.innerHeight}):t;if(r.push({node:e,clip:t,zIndex:o}),e.type!=="text"&&e.type!=="input")for(let i of e.children)Yt(i,s,o,r);}function Yn(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height);return {x:n,y:r,width:Math.max(0,o-n),height:Math.max(0,s-r)}}function Xe(e,t,n){return e>=n.x&&e<n.x+n.width&&t>=n.y&&t<n.y+n.height}function Un(e,t,n,r={}){let{x:o,y:s,width:i,height:c,innerX:l,innerY:a,innerWidth:p,innerHeight:d}=e.layout,S=e.style;if(i<=0||c<=0)return;let I=qe(e).bg;if(S.bg)for(let u=s;u<s+c;u++)for(let R=o;R<o+i;R++)Xe(R,u,n)&&t.setChar(R,u," ",void 0,S.bg);let f=S.border?$t(S.border):null;if(f&&i>=2&&c>=2){let u=S.borderColor,R=I;ie(t,n,o,s,f.topLeft,u,R);for(let P=o+1;P<o+i-1;P++)ie(t,n,P,s,f.horizontal,u,R);ie(t,n,o+i-1,s,f.topRight,u,R),ie(t,n,o,s+c-1,f.bottomLeft,u,R);for(let P=o+1;P<o+i-1;P++)ie(t,n,P,s+c-1,f.horizontal,u,R);ie(t,n,o+i-1,s+c-1,f.bottomRight,u,R);for(let P=s+1;P<s+c-1;P++)ie(t,n,o,P,f.vertical,u,R),ie(t,n,o+i-1,P,f.vertical,u,R);}if(e.type==="text")Zn(e,t,n);else if(e.type==="input")return Qn(e,t,n,r)}function ie(e,t,n,r,o,s,i,c,l,a,p){Xe(n,r,t)&&e.setChar(n,r,o,s,i,c,l,a,p);}function Ut(e,t){if(e!==void 0)return e;if(t!==void 0)return ze(t)?"black":"white"}function Zn(e,t,n){let{innerX:r,innerY:o,innerWidth:s,innerHeight:i}=e.layout,c=qe(e),l=it(e);if(!l)return;let a=Ut(c.color,c.bg),p=e.style.wrap??"wrap",d=e.style.textAlign??"left",S=l.split(`
3
- `),v=ce(S,s,p);for(let I=0;I<v.length&&I<i;I++){let f=v[I],u=ue(f),R=0;d==="center"?R=Math.max(0,Math.floor((s-u)/2)):d==="right"&&(R=Math.max(0,s-u));let P=0;for(let E of f){let A=ue(E);A>0&&ie(t,n,r+R+P,o+I,E,a,c.bg,c.bold,c.dim,c.italic,c.underline),P+=A;}}}function Qn(e,t,n,r={}){let{cursorInfo:o,useNativeCursor:s}=r,{innerX:i,innerY:c,innerWidth:l,innerHeight:a}=e.layout;if(l<=0||a<=0)return;let p=e.props.value??e.props.defaultValue??"",d=e.props.placeholder??"",S=p||d,v=!p&&!!d,I=e.props.multiline??false,f=qe(e),u=Ut(f.color,f.bg),R=f.bg?ze(f.bg)?"blackBright":"whiteBright":"blackBright",P=v?R:u??f.color??e.style.color,E=v?R:P,A=v?true:f.dim,W=o&&o.nodeId===e.focusId,k;if(I&&!v){let G=e.style.wrap??"wrap",T=S.split(`
4
- `),B=ce(T,l,G),C=0,x=0;if(W){let b=o.position,M=0,_=b,q=0;for(let X=0;X<T.length;X++){let J=T[X].length;if(b<=q+J){M=X,_=b-q;break}q+=J+1;}let z=0;for(let X=0;X<M;X++)z+=ce([T[X]],l,G).length;let j=ce([T[M]],l,G),D=0,L=0;for(let X=0;X<j.length;X++){let J=j[X];if(_<=D+J.length){L=X;break}D+=J.length;}C=z+L,x=ue(T[M].slice(D,D+(_-D)));}let w=Math.max(0,C-a+1);for(let b=0;b<a;b++){let M=w+b;if(M>=B.length)break;let _=B[M],q=0;for(let z of _){if(q>=l)break;let j=ue(z);j>0&&ie(t,n,i+q,c+b,z,E,f.bg,f.bold,A,f.italic,f.underline),q+=j;}}if(W){let b=C-w;if(b>=0&&b<a){let M=Math.min(x,l-1),_=i+M,q=c+b;if(Xe(_,q,n)&&_<i+l)if(s)k={cursorPosition:{x:_,y:q,bg:f.bg}};else {let z=t.get(_,q),j=z?.ch&&z.ch!==" "?z.ch:"\u258C",D=f.bg??"black",L=f.color??"white";t.setChar(_,q,j,D,L,z?.bold,z?.dim,z?.italic,false);}}}}else {let G=0;for(let T of S){if(G>=l)break;let B=ue(T);B>0&&ie(t,n,i+G,c,T,E,f.bg,f.bold,A,f.italic,f.underline),G+=B;}if(W){let T=Math.min(o.position,l-1),B=i+T;if(Xe(B,c,n)&&B<i+l)if(s)k={cursorPosition:{x:B,y:c,bg:f.bg}};else {let C=t.get(B,c),x=C?.ch&&C.ch!==" "?C.ch:"\u258C",w=f.bg??"black",b=f.color??"white";t.setChar(B,c,x,w,b,C?.bold,C?.dim,C?.italic,false);}}}return k}var er="\x1B",de=`${er}[`;function tr(e,t){return `${de}${t+1};${e+1}H`}function nr(e){let t=`${de}0m`;return e.bold&&(t+=`${de}1m`),e.dim&&(t+=`${de}2m`),e.italic&&(t+=`${de}3m`),e.underline&&(t+=`${de}4m`),e.fg!=null&&(t+=Ot(e.fg)),e.bg!=null&&(t+=Dt(e.bg)),t}function Zt(e,t,n){let r="",o=-1,s=-1,i="";for(let c=0;c<t.height;c++)for(let l=0;l<t.width;l++){let a=t.get(l,c);if(!n){let d=e.get(l,c);if(d&&t.cellsEqual(a,d))continue}(s!==c||o!==l)&&(r+=tr(l,c));let p=nr(a);p!==i&&(r+=p,i=p),r+=a.ch,o=l+1,s=c;}return r.length>0&&(r+=`${de}0m`),r}var ir={row:FlexDirection.Row,column:FlexDirection.Column},lr={"flex-start":Justify.FlexStart,center:Justify.Center,"flex-end":Justify.FlexEnd,"space-between":Justify.SpaceBetween,"space-around":Justify.SpaceAround},cr={"flex-start":Align.FlexStart,center:Align.Center,"flex-end":Align.FlexEnd,stretch:Align.Stretch};function tn(e,t,n){n!==void 0&&(typeof n=="string"&&n.endsWith("%"),t(n));}function ae(e,t,n){n!==void 0&&(typeof n=="string"&&n.endsWith("%")?e.setPositionPercent(t,parseFloat(n)):e.setPosition(t,n));}function ur(e,t,n){tn(e,o=>e.setWidth(o),t.width),tn(e,o=>e.setHeight(o),t.height),t.minWidth!==void 0&&e.setMinWidth(t.minWidth),t.minHeight!==void 0&&e.setMinHeight(t.minHeight),t.maxWidth!==void 0&&e.setMaxWidth(t.maxWidth),t.maxHeight!==void 0&&e.setMaxHeight(t.maxHeight),t.padding!==void 0&&e.setPadding(Edge.All,t.padding),t.paddingX!==void 0&&e.setPadding(Edge.Horizontal,t.paddingX),t.paddingY!==void 0&&e.setPadding(Edge.Vertical,t.paddingY),t.paddingTop!==void 0&&e.setPadding(Edge.Top,t.paddingTop),t.paddingRight!==void 0&&e.setPadding(Edge.Right,t.paddingRight),t.paddingBottom!==void 0&&e.setPadding(Edge.Bottom,t.paddingBottom),t.paddingLeft!==void 0&&e.setPadding(Edge.Left,t.paddingLeft);let r=t.border!=null&&t.border!=="none";e.setBorder(Edge.All,r?1:0),t.flexDirection&&e.setFlexDirection(ir[t.flexDirection]??FlexDirection.Column),t.flexWrap&&e.setFlexWrap(t.flexWrap==="wrap"?Wrap.Wrap:Wrap.NoWrap),t.justifyContent&&e.setJustifyContent(lr[t.justifyContent]??Justify.FlexStart),t.alignItems&&e.setAlignItems(cr[t.alignItems]??Align.Stretch),t.flexGrow!==void 0&&e.setFlexGrow(t.flexGrow),t.flexShrink!==void 0&&e.setFlexShrink(t.flexShrink),t.gap!==void 0&&e.setGap(Gutter.All,t.gap),t.position==="absolute"?e.setPositionType(PositionType.Absolute):e.setPositionType(PositionType.Relative),t.inset!==void 0&&(ae(e,Edge.Top,t.inset),ae(e,Edge.Right,t.inset),ae(e,Edge.Bottom,t.inset),ae(e,Edge.Left,t.inset)),ae(e,Edge.Top,t.top),ae(e,Edge.Right,t.right),ae(e,Edge.Bottom,t.bottom),ae(e,Edge.Left,t.left),t.clip&&e.setOverflow(Overflow.Hidden);}function rn(e){let t=nn.Node.create();if(e.yogaNode=t,ur(t,e.style,e.type),e.type==="text"||e.type==="input")t.setMeasureFunc((n,r,o,s)=>{let i;return e.type==="input"?(i=e.props.value??e.props.defaultValue??e.props.placeholder??"",i.length===0&&(i=" ")):i=on(e),zt(i,n,r,e.style.wrap??"wrap")});else for(let n=0;n<e.children.length;n++){let r=e.children[n];r.hidden||(rn(r),t.insertChild(r.yogaNode,t.getChildCount()));}}function on(e){if(e.text!=null)return e.text;let t="";for(let n of e.children)t+=on(n);if(t===""&&e.props.children!=null){if(typeof e.props.children=="string")return e.props.children;if(typeof e.props.children=="number")return String(e.props.children)}return t}function sn(e,t,n){let r=e.yogaNode,o=r.getComputedLayout(),s=t+o.left,i=n+o.top,c=o.width,l=o.height,a=e.style.border&&e.style.border!=="none"?1:0,p=r.getComputedPadding(Edge.Top),d=r.getComputedPadding(Edge.Right),S=r.getComputedPadding(Edge.Bottom),v=r.getComputedPadding(Edge.Left),I=s+a+v,f=i+a+p,u=Math.max(0,c-a*2-v-d),R=Math.max(0,l-a*2-p-S);e.layout={x:s,y:i,width:c,height:l,innerX:I,innerY:f,innerWidth:u,innerHeight:R};for(let P of e.children)P.hidden||!P.yogaNode||sn(P,s,i);}function ln(e,t,n){let r=nn.Node.create();r.setWidth(t),r.setHeight(n),r.setFlexDirection(FlexDirection.Column);for(let o of e)o.hidden||(rn(o),r.insertChild(o.yogaNode,r.getChildCount()));r.calculateLayout(t,n,Direction.LTR);for(let o of e)o.hidden||!o.yogaNode||sn(o,0,0);r.freeRecursive(),cn(e);}function cn(e){for(let t of e)t.yogaNode=null,cn(t.children);}var Y=createContext(null),$=createContext(null),oe=createContext(null),be=createContext(null),Ye=createContext(null);function ar(e,t={}){let n=t.stdout??process.stdout,r=t.stdin??process.stdin,o=t.debug??false,s=t.useNativeCursor??true,i=new _e(n,r);i.setup();let c=false;i.queryPalette().then(m=>{qt(m),p=true,b();});let l=new Ne(i.columns,i.rows),a=new Ne(i.columns,i.rows),p=true,d=new Set,S=new Set,v=new Map,I={subscribe(m){return d.add(m),()=>d.delete(m)},subscribePriority(m){return S.add(m),()=>S.delete(m)},registerInputHandler(m,g){return v.set(m,g),()=>v.delete(m)}},f=null,u=new Map,R=[],P=new Set,E=[],A=new Set;function W(m){if(f!==m){f=m,b();for(let g of A)g(f);}}function k(){let m=[...R];if(E.length>0){let g=E[E.length-1];m=m.filter(y=>g.has(y));}return m=m.filter(g=>!P.has(g)),m.sort((g,y)=>{let O=u.get(g),K=u.get(y);if(!O||!K)return 0;let F=O.layout,h=K.layout;return F.y!==h.y?F.y-h.y:F.x-h.x}),m}let G={get focusedId(){return f},register(m,g){if(u.set(m,g),R.includes(m)||R.push(m),E.length>0&&E[E.length-1].add(m),f===null){let y=k();y.length>0&&W(y[0]);}return ()=>{u.delete(m);let y=R.indexOf(m);if(y!==-1&&R.splice(y,1),f===m){let O=k();W(O[0]??null);}}},requestFocus(m){W(m);},focusNext(){let m=k();if(m.length===0)return;let y=((f?m.indexOf(f):-1)+1)%m.length;W(m[y]);},focusPrev(){let m=k();if(m.length===0)return;let y=((f?m.indexOf(f):0)-1+m.length)%m.length;W(m[y]);},setSkippable(m,g){if(g){if(P.add(m),f===m){let y=k();y.length>0&&W(y[0]);}}else P.delete(m);},trapIds:null,pushTrap(m){return E.push(m),()=>{let g=E.indexOf(m);g!==-1&&E.splice(g,1);}},onFocusChange(m){return A.add(m),()=>{A.delete(m);}},getRegisteredElements(){let m=[];for(let g of R){if(P.has(g))continue;let y=u.get(g);y&&m.push({id:g,node:y});}return m},getActiveElements(){let m=k(),g=[];for(let y of m){if(P.has(y))continue;let O=u.get(y);O&&g.push({id:y,node:O});}return g}},T=new Map,B={getLayout(m){return m.layout},subscribe(m,g){return T.has(m)||T.set(m,new Set),T.get(m).add(g),()=>{let y=T.get(m);y&&(y.delete(g),y.size===0&&T.delete(m));}}},C={registerNode(){},unregisterNode(){},scheduleRender:b,exit(m){le.exit(m);},get columns(){return i.columns},get rows(){return i.rows}},x={type:"root",children:[],onCommit(){b();}},w=false;function b(){w||(w=true,queueMicrotask(()=>{w=false,M();}));}function M(){let m=i.columns,g=i.rows;(a.width!==m||a.height!==g)&&(a.resize(m,g),l.resize(m,g),p=true),ln(x.children,m,g),_(x.children);let y;if(f){let F=u.get(f);F?.type==="input"&&(y={nodeId:f,position:F.props.cursorPosition??F.props.value?.length??0});}let O=Jt(x.children,a,{cursorInfo:y,useNativeCursor:s}),K=Zt(l,a,p);if(K.length>0&&i.write(K),s)if(O.cursorPosition){let F=_t(O.cursorPosition.bg);i.setCursorColor(F),i.moveCursor(O.cursorPosition.x,O.cursorPosition.y),c||(i.showCursor(),c=true);}else c&&(i.hideCursor(),c=false);for(let F=0;F<a.cells.length;F++)l.cells[F]={...a.cells[F]};p=false;}function _(m){for(let g of m){let y=T.get(g);if(y)for(let O of y)O(g.layout);_(g.children);}}let q=i.onData(m=>{let g=jt(m);for(let y of g){if(y.ctrl&&y.name==="c"){le.exit();return}if(y.ctrl&&y.name==="z"){i.suspend(),process.kill(0,"SIGSTOP");return}if(y.name==="tab"&&!y.ctrl&&!y.alt){y.shift?G.focusPrev():G.focusNext();continue}let O=false;for(let K of S)if(K(y)){O=true;break}if(!O&&f){let K=v.get(f);K&&(O=K(y));}if(!O)for(let K of d)K(y);}}),z=i.onResize(()=>{p=true,b();}),j=()=>{i.resume(),p=true,b();};process.on("SIGCONT",j);let D=ee.createElement(be.Provider,{value:C},ee.createElement(Y.Provider,{value:I},ee.createElement($.Provider,{value:G},ee.createElement(oe.Provider,{value:B},e)))),L=m=>{o&&console.error("Uncaught error:",m);},X=m=>{o&&console.error("Error caught by boundary:",m);},J=m=>{o&&console.error("Recoverable error:",m);},se=Ie.createContainer(x,0,null,false,null,"",L,X,J,null);Ie.updateContainer(D,se,null,null);let le={unmount(){Ie.updateContainer(null,se,null,null),q(),z(),process.off("SIGCONT",j),i.cleanup();},exit(m){le.unmount(),process.exit(m??0);}};return le}var dr=forwardRef(function({children:t,style:n,focusable:r},o){return ee.createElement("box",{style:n,focusable:r,ref:o},t)});var gr=forwardRef(function({children:t,style:n,wrap:r},o){let s=r?{...n,wrap:r}:n;return ee.createElement("text",{style:s,ref:o},t)});function un(e,t,n){if(n<=0)return {visualLine:0,visualCol:t,totalVisualLines:1,lineStartOffset:0,lineLength:e.length};let r=e.split(`
1
+ import ee,{createContext,forwardRef,useState,useContext,useRef,useEffect,useLayoutEffect,useMemo,useCallback}from'react';import An from'react-reconciler';import ue from'string-width';import nn,{FlexDirection,Justify,Align,Direction,Edge,Wrap,Gutter,PositionType,Overflow,MeasureMode}from'yoga-layout';var Hn=0;function Lt(){return `glyph-focus-${Hn++}`}function Bt(e,t){let n=t.style??{};return {type:e,props:t,style:n,children:[],rawTextChildren:[],parent:null,yogaNode:null,text:null,layout:{x:0,y:0,width:0,height:0,innerX:0,innerY:0,innerWidth:0,innerHeight:0},focusId:e==="input"||t.focusable?Lt():null,hidden:false}}function st(e,t){t.parent=e,e.children.push(t);}function Mt(e,t){let n=e.children.indexOf(t);n!==-1&&(e.children.splice(n,1),t.parent=null);}function Vt(e,t,n){t.parent=e;let r=e.children.indexOf(n);r!==-1?e.children.splice(r,0,t):e.children.push(t);}function _e(e){let t={},n=e;for(;n;){let r=n.style;t.color===void 0&&r.color!==void 0&&(t.color=r.color),t.bg===void 0&&r.bg!==void 0&&(t.bg=r.bg),t.bold===void 0&&r.bold!==void 0&&(t.bold=r.bold),t.dim===void 0&&r.dim!==void 0&&(t.dim=r.dim),t.italic===void 0&&r.italic!==void 0&&(t.italic=r.italic),t.underline===void 0&&r.underline!==void 0&&(t.underline=r.underline),n=n.parent;}return t}function it(e){if(e.text!=null)return e.text;let t="";for(let n of e.children)t+=it(n);return t}var lt=32,Ht={supportsMutation:true,supportsPersistence:false,supportsHydration:false,isPrimaryRenderer:true,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,supportsMicrotasks:true,scheduleMicrotask:queueMicrotask,getCurrentUpdatePriority:()=>lt,setCurrentUpdatePriority:e=>{},resolveUpdatePriority:()=>lt,getCurrentEventPriority:()=>lt,resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,shouldAttemptEagerTransition:()=>false,getInstanceFromNode:()=>null,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},prepareScopeUpdate:()=>{},getInstanceFromScope:()=>null,detachDeletedInstance:()=>{},requestPostPaintCallback:e=>{},maySuspendCommit:(e,t)=>false,preloadInstance:(e,t)=>true,startSuspendingCommit:()=>{},suspendInstance:(e,t)=>{},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:{$$typeof:Symbol.for("react.context"),_currentValue:null},resetFormInstance:e=>{},bindToConsole:(e,t,n)=>Function.prototype.bind.call(console[e],console,...t),supportsResources:false,isHostHoistableType:(e,t)=>false,supportsSingletons:false,isHostSingletonType:e=>false,supportsTestSelectors:false,createInstance(e,t,n,r,o){return Bt(e,t)},createTextInstance(e,t,n,r){return {type:"raw-text",text:e,parent:null}},appendInitialChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=e,e.rawTextChildren.push(n),e.text=e.rawTextChildren.map(r=>r.text).join("");}else st(e,t);},finalizeInitialChildren(e,t,n,r,o){return false},shouldSetTextContent(e,t){return false},getRootHostContext(e){return {}},getChildHostContext(e,t,n){return e},getPublicInstance(e){return e},prepareForCommit(e){return null},resetAfterCommit(e){e.onCommit();},preparePortalMount(){},appendChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=e,e.rawTextChildren.push(n),e.text=e.rawTextChildren.map(r=>r.text).join("");}else st(e,t);},appendChildToContainer(e,t){if(t.type==="raw-text")return;let n=t;n.parent=null,e.children.push(n);},insertBefore(e,t,n){t.type==="raw-text"||n.type==="raw-text"||Vt(e,t,n);},insertInContainerBefore(e,t,n){if(t.type==="raw-text"||n.type==="raw-text")return;let r=t,o=n,s=e.children.indexOf(o);s!==-1?e.children.splice(s,0,r):e.children.push(r);},removeChild(e,t){if(t.type==="raw-text"){let n=t;n.parent=null;let r=e.rawTextChildren.indexOf(n);r!==-1&&e.rawTextChildren.splice(r,1),e.text=e.rawTextChildren.map(o=>o.text).join("")||null;return}Mt(e,t);},removeChildFromContainer(e,t){if(t.type==="raw-text")return;let n=t,r=e.children.indexOf(n);r!==-1&&e.children.splice(r,1);},commitTextUpdate(e,t,n){e.text=n,e.parent&&(e.parent.text=e.parent.rawTextChildren.map(r=>r.text).join(""));},commitUpdate(e,t,n,r,o){e.props=r,e.style=r.style??{},r.focusable&&!e.focusId&&(e.focusId=`focus-${Math.random().toString(36).slice(2,9)}`);},hideInstance(e){e.hidden=true;},hideTextInstance(e){e.text="";},unhideInstance(e,t){e.hidden=false;},unhideTextInstance(e,t){e.text=t;},clearContainer(e){e.children.length=0;},resetTextContent(e){e.text=null;}};var Ie=An(Ht);Ie.injectIntoDevTools({bundleType:process.env.NODE_ENV==="production"?0:1,version:"0.1.0",rendererPackageName:"glyph"});var $e=class{stdout;stdin;wasRaw=false;cleanedUp=false;dataHandlers=new Set;stdinAttached=false;oscState="normal";oscAccum="";escFlushTimer=null;palette=new Map;paletteResolve=null;constructor(t=process.stdout,n=process.stdin){this.stdout=t,this.stdin=n;}get columns(){return this.stdout.columns||80}get rows(){return this.stdout.rows||24}enterRawMode(){this.stdin.isTTY&&(this.wasRaw=this.stdin.isRaw,this.stdin.setRawMode(true),this.stdin.resume(),this.stdin.setEncoding("utf-8"));}exitRawMode(){this.stdin.isTTY&&!this.wasRaw&&(this.stdin.setRawMode(false),this.stdin.pause());}write(t){this.stdout.write(t);}hideCursor(){this.write("\x1B[?25l");}showCursor(){this.write("\x1B[?25h");}moveCursor(t,n){this.write(`\x1B[${n+1};${t+1}H`);}setCursorColor(t){this.write(`\x1B]12;${t}\x07`);}resetCursorColor(){this.write("\x1B]112\x07");}enterAltScreen(){this.write("\x1B[?1049h");}exitAltScreen(){this.write("\x1B[?1049l");}clearScreen(){this.write("\x1B[2J\x1B[H");}resetStyles(){this.write("\x1B[0m");}enableKittyKeyboard(){this.write("\x1B[>1u");}disableKittyKeyboard(){this.write("\x1B[<u");}setup(){this.enterRawMode(),this.enterAltScreen(),this.enableKittyKeyboard(),this.hideCursor(),this.clearScreen(),this.attachStdinListener(),this.installCleanupHandlers();}cleanup(){this.cleanedUp||(this.cleanedUp=true,this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null),this.resetStyles(),this.resetCursorColor(),this.disableKittyKeyboard(),this.showCursor(),this.exitAltScreen(),this.exitRawMode());}suspend(){this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null),this.oscState="normal",this.oscAccum="",this.resetStyles(),this.resetCursorColor(),this.disableKittyKeyboard(),this.showCursor(),this.exitAltScreen(),this.exitRawMode();}resume(){this.enterRawMode(),this.enterAltScreen(),this.enableKittyKeyboard(),this.hideCursor(),this.clearScreen();}attachStdinListener(){this.stdinAttached||(this.stdinAttached=true,this.stdin.on("data",t=>{let n=typeof t=="string"?t:t.toString("utf-8");this.dispatchFiltered(n);}));}onData(t){return this.dataHandlers.add(t),()=>{this.dataHandlers.delete(t);}}dispatchFiltered(t){this.escFlushTimer!==null&&(clearTimeout(this.escFlushTimer),this.escFlushTimer=null);let n=this.filterOsc(t);if(n.length>0)for(let r of this.dataHandlers)r(n);this.oscState==="esc"&&(this.escFlushTimer=setTimeout(()=>{this.escFlushTimer=null,this.oscState="normal";for(let r of this.dataHandlers)r("\x1B");},50));}filterOsc(t){let n="";for(let r=0;r<t.length;r++){let o=t[r],s=t.charCodeAt(r);switch(this.oscState){case "normal":s===27?this.oscState="esc":n+=o;break;case "esc":o==="]"?(this.oscState="osc",this.oscAccum=""):(n+="\x1B"+o,this.oscState="normal");break;case "osc":s===7?(this.handleOscResponse(this.oscAccum),this.oscAccum="",this.oscState="normal"):s===27?this.oscState="osc_esc":this.oscAccum+=o;break;case "osc_esc":o==="\\"?(this.handleOscResponse(this.oscAccum),this.oscAccum="",this.oscState="normal"):(this.oscAccum+="\x1B"+o,this.oscState="osc");break}}return n}handleOscResponse(t){let n=t.match(/^4;(\d+);rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(n){let r=parseInt(n[1],10),o=parseInt(n[2].substring(0,2),16),s=parseInt(n[3].substring(0,2),16),i=parseInt(n[4].substring(0,2),16);this.palette.set(r,[o,s,i]),this.palette.size>=16&&this.paletteResolve&&(this.paletteResolve(),this.paletteResolve=null);}}queryPalette(){return new Promise(t=>{let n=()=>t(this.palette),r=setTimeout(n,200);this.paletteResolve=()=>{clearTimeout(r),n();};let o="";for(let s=0;s<16;s++)o+=`\x1B]4;${s};?\x07`;this.write(o);})}onResize(t){return this.stdout.on("resize",t),()=>{this.stdout.off("resize",t);}}installCleanupHandlers(){let t=()=>this.cleanup();process.on("exit",t);let n=r=>{t(),process.kill(process.pid,r);};process.once("SIGINT",()=>n("SIGINT")),process.once("SIGTERM",()=>n("SIGTERM")),process.on("uncaughtException",r=>{t(),console.error(r),process.exit(1);}),process.on("unhandledRejection",r=>{t(),console.error(r),process.exit(1);});}};function At(e){switch(e){case 9:return "tab";case 13:return "return";case 27:return "escape";case 32:return " ";case 127:return "backspace";case 57358:return "capslock";case 57359:return "scrolllock";case 57360:return "numlock";case 57361:return "printscreen";case 57362:return "pause";case 57363:return "menu";case 57364:return "f13";case 57365:return "f14";case 57366:return "f15";case 57367:return "f16";case 57368:return "f17";case 57369:return "f18";case 57370:return "f19";case 57371:return "f20";case 57372:return "f21";case 57373:return "f22";case 57374:return "f23";case 57375:return "f24";case 57376:return "f25";case 57399:return "kp0";case 57400:return "kp1";case 57401:return "kp2";case 57402:return "kp3";case 57403:return "kp4";case 57404:return "kp5";case 57405:return "kp6";case 57406:return "kp7";case 57407:return "kp8";case 57408:return "kp9";case 57409:return "kpdecimal";case 57410:return "kpdivide";case 57411:return "kpmultiply";case 57412:return "kpminus";case 57413:return "kpplus";case 57414:return "kpenter";case 57415:return "kpequal";case 57416:return "kpleft";case 57417:return "kpright";case 57418:return "kpup";case 57419:return "kpdown";case 57420:return "kppageup";case 57421:return "kppagedown";case 57422:return "kphome";case 57423:return "kpend";case 57424:return "kpinsert";case 57425:return "kpdelete";case 57428:return "mediaplaypause";case 57429:return "mediastop";case 57430:return "mediaprev";case 57431:return "medianext";case 57432:return "mediarewind";case 57433:return "mediafastforward";case 57434:return "mediamute";case 57435:return "volumedown";case 57436:return "volumeup";default:return e>=32&&e<=126?String.fromCharCode(e).toLowerCase():"unknown"}}function jn(e){switch(e.split(";")[0]){case "1":return "home";case "2":return "insert";case "3":return "delete";case "4":return "end";case "5":return "pageup";case "6":return "pagedown";case "7":return "home";case "8":return "end";case "11":return "f1";case "12":return "f2";case "13":return "f3";case "14":return "f4";case "15":return "f5";case "17":return "f6";case "18":return "f7";case "19":return "f8";case "20":return "f9";case "21":return "f10";case "23":return "f11";case "24":return "f12";case "25":return "f13";case "26":return "f14";case "28":return "f15";case "29":return "f16";case "31":return "f17";case "32":return "f18";case "33":return "f19";case "34":return "f20";default:return "unknown"}}function qe(e,t){let n=t-1;n&1&&(e.shift=true),n&2&&(e.alt=true),n&4&&(e.ctrl=true),n&8&&(e.meta=true);}function jt(e){let t=[],n=0;for(;n<e.length;){let r=e[n],o=e.charCodeAt(n);if(r==="\x1B"){if(e[n+1]==="["){let s=Dn(e,n);if(s){t.push(s.key),n=s.end;continue}}if(e[n+1]==="O"){let s=On(e,n);if(s){t.push(s.key),n=s.end;continue}}if(n+1<e.length&&e.charCodeAt(n+1)>=32){t.push({name:e[n+1].toLowerCase(),sequence:e.substring(n,n+2),alt:true}),n+=2;continue}t.push({name:"escape",sequence:"\x1B"}),n++;continue}if(o>=1&&o<=26){let s=String.fromCharCode(o+96);o===13?t.push({name:"return",sequence:"\r"}):o===9?t.push({name:"tab",sequence:" "}):o===8?t.push({name:"backspace",sequence:"\b"}):t.push({name:s,sequence:r,ctrl:true}),n++;continue}if(o===127){t.push({name:"backspace",sequence:r}),n++;continue}t.push({name:r,sequence:r}),n++;}return t}function On(e,t){if(t+2>=e.length)return null;let n=e[t+2],r=e.substring(t,t+3),o;switch(n){case "A":o={name:"up",sequence:r};break;case "B":o={name:"down",sequence:r};break;case "C":o={name:"right",sequence:r};break;case "D":o={name:"left",sequence:r};break;case "H":o={name:"home",sequence:r};break;case "F":o={name:"end",sequence:r};break;case "P":o={name:"f1",sequence:r};break;case "Q":o={name:"f2",sequence:r};break;case "R":o={name:"f3",sequence:r};break;case "S":o={name:"f4",sequence:r};break;case "j":o={name:"kpmultiply",sequence:r};break;case "k":o={name:"kpplus",sequence:r};break;case "l":o={name:"kpcomma",sequence:r};break;case "m":o={name:"kpminus",sequence:r};break;case "n":o={name:"kpdecimal",sequence:r};break;case "o":o={name:"kpdivide",sequence:r};break;case "p":o={name:"kp0",sequence:r};break;case "q":o={name:"kp1",sequence:r};break;case "r":o={name:"kp2",sequence:r};break;case "s":o={name:"kp3",sequence:r};break;case "t":o={name:"kp4",sequence:r};break;case "u":o={name:"kp5",sequence:r};break;case "v":o={name:"kp6",sequence:r};break;case "w":o={name:"kp7",sequence:r};break;case "x":o={name:"kp8",sequence:r};break;case "y":o={name:"kp9",sequence:r};break;case "M":o={name:"kpenter",sequence:r};break;default:return null}return {key:o,end:t+3}}function Dn(e,t){let n=t+2,r="";for(;n<e.length;){let c=e.charCodeAt(n);if(c>=48&&c<=63)r+=e[n],n++;else break}if(n>=e.length)return null;let o=e[n],s=e.substring(t,n+1);n++;let i;switch(o){case "A":i={name:"up",sequence:s};break;case "B":i={name:"down",sequence:s};break;case "C":i={name:"right",sequence:s};break;case "D":i={name:"left",sequence:s};break;case "H":i={name:"home",sequence:s};break;case "F":i={name:"end",sequence:s};break;case "Z":i={name:"tab",sequence:s,shift:true};break;case "P":i={name:"f1",sequence:s};break;case "Q":i={name:"f2",sequence:s};break;case "R":i={name:"f3",sequence:s};break;case "S":i={name:"f4",sequence:s};break;case "~":{if(r.startsWith("27;")){let c=r.split(";"),l=parseInt(c[1]??"1",10),a=parseInt(c[2]??"0",10);i={name:At(a),sequence:s},qe(i,l);break}if(i={name:jn(r),sequence:s},r.includes(";")){let c=r.split(";"),l=parseInt(c[1]??"1",10);qe(i,l);}break}case "u":{let c=r.split(";"),l=parseInt(c[0]??"0",10),a=parseInt(c[1]??"1",10);i={name:At(l),sequence:s},qe(i,a);break}case "I":i={name:"focus",sequence:s};break;case "O":i={name:"blur",sequence:s};break;default:i={name:"unknown",sequence:s};}if(r.includes(";")&&!["~","u"].includes(o)){let c=r.split(";"),l=parseInt(c[c.length-1]??"1",10);l>=1&&l<=16&&qe(i,l);}return {key:i,end:n}}var Kn={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",blackBright:"\x1B[90m",redBright:"\x1B[91m",greenBright:"\x1B[92m",yellowBright:"\x1B[93m",blueBright:"\x1B[94m",magentaBright:"\x1B[95m",cyanBright:"\x1B[96m",whiteBright:"\x1B[97m"},Wn={black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m",blackBright:"\x1B[100m",redBright:"\x1B[101m",greenBright:"\x1B[102m",yellowBright:"\x1B[103m",blueBright:"\x1B[104m",magentaBright:"\x1B[105m",cyanBright:"\x1B[106m",whiteBright:"\x1B[107m"};function ct(e){let t=e.replace("#",""),n=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),o=parseInt(t.substring(4,6),16);return {r:n,g:r,b:o}}function Ot(e){if(typeof e=="string"){if(e.startsWith("#")){let{r:o,g:s,b:i}=ct(e);return `\x1B[38;2;${o};${s};${i}m`}return Kn[e]??"\x1B[39m"}if(typeof e=="number")return `\x1B[38;5;${e}m`;let{r:t,g:n,b:r}=e;return `\x1B[38;2;${t};${n};${r}m`}function Dt(e){if(typeof e=="string"){if(e.startsWith("#")){let{r:o,g:s,b:i}=ct(e);return `\x1B[48;2;${o};${s};${i}m`}return Wn[e]??"\x1B[49m"}if(typeof e=="number")return `\x1B[48;5;${e}m`;let{r:t,g:n,b:r}=e;return `\x1B[48;2;${t};${n};${r}m`}var Kt={black:[0,0,0],red:[170,0,0],green:[0,170,0],yellow:[170,170,0],blue:[0,0,170],magenta:[170,0,170],cyan:[0,170,170],white:[170,170,170],blackBright:[85,85,85],redBright:[255,85,85],greenBright:[85,255,85],yellowBright:[255,255,85],blueBright:[85,85,255],magentaBright:[255,85,255],cyanBright:[85,255,255],whiteBright:[255,255,255]},Wt=["black","red","green","yellow","blue","magenta","cyan","white","blackBright","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright"],Te=null;function _t(e){e.size>0&&(Te=e);}function _n(e){if(Te){let t=Wt.indexOf(e);if(t!==-1){let n=Te.get(t);if(n)return n}}return Kt[e]??null}function $n(e){if(typeof e=="string"){if(e.startsWith("#")){let t=ct(e);return [t.r,t.g,t.b]}return _n(e)}if(typeof e=="number"){if(e<16){if(Te){let s=Te.get(e);if(s)return s}return Kt[Wt[e]]}if(e>=232){let s=(e-232)*10+8;return [s,s,s]}let t=e-16,n=t%6*51,r=Math.floor(t/6)%6*51;return [Math.floor(t/36)*51,r,n]}return [e.r,e.g,e.b]}function ze(e){let t=$n(e);if(!t)return false;let[n,r,o]=t.map(i=>{let c=i/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)});return .2126*n+.7152*r+.0722*o>.4}function ut(e,t){return e===t?true:e==null||t==null?false:typeof e=="object"&&typeof t=="object"?e.r===t.r&&e.g===t.g&&e.b===t.b:false}function $t(e){return e&&ze(e)?"black":"white"}var Ne=class e{width;height;cells;constructor(t,n){this.width=t,this.height=n,this.cells=new Array(t*n),this.clear();}clear(){for(let t=0;t<this.cells.length;t++)this.cells[t]={ch:" "};}resize(t,n){this.width=t,this.height=n,this.cells=new Array(t*n),this.clear();}get(t,n){if(!(t<0||t>=this.width||n<0||n>=this.height))return this.cells[n*this.width+t]}set(t,n,r){t<0||t>=this.width||n<0||n>=this.height||(this.cells[n*this.width+t]=r);}setChar(t,n,r,o,s,i,c,l,a){t<0||t>=this.width||n<0||n>=this.height||(this.cells[n*this.width+t]={ch:r,fg:o,bg:s,bold:i,dim:c,italic:l,underline:a});}fillRect(t,n,r,o,s,i,c){for(let l=n;l<n+o;l++)for(let a=t;a<t+r;a++)this.setChar(a,l,s,i,c);}clone(){let t=new e(this.width,this.height);for(let n=0;n<this.cells.length;n++){let r=this.cells[n];t.cells[n]={...r};}return t}cellsEqual(t,n){return t.ch===n.ch&&ut(t.fg,n.fg)&&ut(t.bg,n.bg)&&(t.bold??false)===(n.bold??false)&&(t.dim??false)===(n.dim??false)&&(t.italic??false)===(n.italic??false)&&(t.underline??false)===(n.underline??false)}};var qn={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551"},round:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502"},ascii:{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|"}};function qt(e){return e==="none"?null:qn[e]}function zt(e,t,n,r){if(e.length===0)return {width:0,height:0};let o=e.split(`
2
+ `);if(n===MeasureMode.Undefined||r==="none"){let l=0;for(let a of o){let p=ue(a);p>l&&(l=p);}return {width:l,height:o.length}}let s=Math.max(1,Math.floor(t)),i=ce(o,s,r),c=0;for(let l of i){let a=ue(l);a>c&&(c=a);}return {width:c,height:i.length}}function ce(e,t,n){let r=[];for(let o of e){if(ue(o)<=t){r.push(o);continue}if(n==="truncate"){r.push(Xt(o,t));continue}if(n==="ellipsis"){r.push(Xn(o,t));continue}let i=Jn(o,t);r.push(...i);}return r}function Xt(e,t){let n="",r=0;for(let o of e){let s=ue(o);if(r+s>t)break;n+=o,r+=s;}return n}function Xn(e,t){if(t<=1)return t===1?"\u2026":"";let n=Xt(e,t-1);return ue(n)<ue(e)?n+"\u2026":e}function Jn(e,t){let n=[],r="",o=0,s="",i=0;for(let c=0;c<=e.length;c++){let l=e[c],a=c===e.length,p=l===" ";if(a||p){if(s.length>0){if(o+i<=t)r+=s,o+=i;else if(i<=t)r.length>0&&n.push(r),r=s,o=i;else for(let d of s){let S=ue(d);o+S>t&&r.length>0&&(n.push(r),r="",o=0),r+=d,o+=S;}s="",i=0;}p&&(o+1<=t?(r+=" ",o+=1):(r.length>0&&n.push(r),r=" ",o=1));}else l&&(s+=l,i+=ue(l));}return r.length>0&&n.push(r),n.length>0?n:[""]}function Jt(e,t,n={}){t.clear();let r={},o=[],s={x:0,y:0,width:t.width,height:t.height};for(let i of e)i.hidden||Yt(i,s,i.style.zIndex??0,o);o.sort((i,c)=>i.zIndex-c.zIndex);for(let i of o){let c=Un(i.node,t,i.clip,n);c?.cursorPosition&&(r.cursorPosition=c.cursorPosition);}return r}function Yt(e,t,n,r){if(e.hidden)return;let o=e.style.zIndex??n,s=e.style.clip?Yn(t,{x:e.layout.innerX,y:e.layout.innerY,width:e.layout.innerWidth,height:e.layout.innerHeight}):t;if(r.push({node:e,clip:t,zIndex:o}),e.type!=="text"&&e.type!=="input")for(let i of e.children)Yt(i,s,o,r);}function Yn(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height);return {x:n,y:r,width:Math.max(0,o-n),height:Math.max(0,s-r)}}function Xe(e,t,n){return e>=n.x&&e<n.x+n.width&&t>=n.y&&t<n.y+n.height}function Un(e,t,n,r={}){let{x:o,y:s,width:i,height:c,innerX:l,innerY:a,innerWidth:p,innerHeight:d}=e.layout,S=e.style;if(i<=0||c<=0)return;let I=_e(e).bg;if(S.bg)for(let u=s;u<s+c;u++)for(let R=o;R<o+i;R++)Xe(R,u,n)&&t.setChar(R,u," ",void 0,S.bg);let f=S.border?qt(S.border):null;if(f&&i>=2&&c>=2){let u=S.borderColor,R=I;ie(t,n,o,s,f.topLeft,u,R);for(let P=o+1;P<o+i-1;P++)ie(t,n,P,s,f.horizontal,u,R);ie(t,n,o+i-1,s,f.topRight,u,R),ie(t,n,o,s+c-1,f.bottomLeft,u,R);for(let P=o+1;P<o+i-1;P++)ie(t,n,P,s+c-1,f.horizontal,u,R);ie(t,n,o+i-1,s+c-1,f.bottomRight,u,R);for(let P=s+1;P<s+c-1;P++)ie(t,n,o,P,f.vertical,u,R),ie(t,n,o+i-1,P,f.vertical,u,R);}if(e.type==="text")Zn(e,t,n);else if(e.type==="input")return Qn(e,t,n,r)}function ie(e,t,n,r,o,s,i,c,l,a,p){Xe(n,r,t)&&e.setChar(n,r,o,s,i,c,l,a,p);}function Ut(e,t){if(e!==void 0)return e;if(t!==void 0)return ze(t)?"black":"white"}function Zn(e,t,n){let{innerX:r,innerY:o,innerWidth:s,innerHeight:i}=e.layout,c=_e(e),l=it(e);if(!l)return;let a=Ut(c.color,c.bg),p=e.style.wrap??"wrap",d=e.style.textAlign??"left",S=l.split(`
3
+ `),v=ce(S,s,p);for(let I=0;I<v.length&&I<i;I++){let f=v[I],u=ue(f),R=0;d==="center"?R=Math.max(0,Math.floor((s-u)/2)):d==="right"&&(R=Math.max(0,s-u));let P=0;for(let E of f){let H=ue(E);H>0&&ie(t,n,r+R+P,o+I,E,a,c.bg,c.bold,c.dim,c.italic,c.underline),P+=H;}}}function Qn(e,t,n,r={}){let{cursorInfo:o,useNativeCursor:s}=r,{innerX:i,innerY:c,innerWidth:l,innerHeight:a}=e.layout;if(l<=0||a<=0)return;let p=e.props.value??e.props.defaultValue??"",d=e.props.placeholder??"",S=p||d,v=!p&&!!d,I=e.props.multiline??false,f=_e(e),u=Ut(f.color,f.bg),R=f.bg?ze(f.bg)?"blackBright":"whiteBright":"blackBright",P=v?R:u??f.color??e.style.color,E=v?R:P,H=v?true:f.dim,_=o&&o.nodeId===e.focusId,k;if(I&&!v){let G=e.style.wrap??"wrap",T=S.split(`
4
+ `),B=ce(T,l,G),C=0,x=0;if(_){let b=o.position,M=0,$=b,K=0;for(let X=0;X<T.length;X++){let J=T[X].length;if(b<=K+J){M=X,$=b-K;break}K+=J+1;}let z=0;for(let X=0;X<M;X++)z+=ce([T[X]],l,G).length;let O=ce([T[M]],l,G),j=0,L=0;for(let X=0;X<O.length;X++){let J=O[X];if($<=j+J.length){L=X;break}j+=J.length;}C=z+L,x=ue(T[M].slice(j,j+($-j)));}let w=Math.max(0,C-a+1);for(let b=0;b<a;b++){let M=w+b;if(M>=B.length)break;let $=B[M],K=0;for(let z of $){if(K>=l)break;let O=ue(z);O>0&&ie(t,n,i+K,c+b,z,E,f.bg,f.bold,H,f.italic,f.underline),K+=O;}}if(_){let b=C-w;if(b>=0&&b<a){let M=Math.min(x,l-1),$=i+M,K=c+b;if(Xe($,K,n)&&$<i+l)if(s)k={cursorPosition:{x:$,y:K,bg:f.bg}};else {let z=t.get($,K),O=z?.ch&&z.ch!==" "?z.ch:"\u258C",j=f.bg??"black",L=f.color??"white";t.setChar($,K,O,j,L,z?.bold,z?.dim,z?.italic,false);}}}}else {let G=0;for(let T of S){if(G>=l)break;let B=ue(T);B>0&&ie(t,n,i+G,c,T,E,f.bg,f.bold,H,f.italic,f.underline),G+=B;}if(_){let T=Math.min(o.position,l-1),B=i+T;if(Xe(B,c,n)&&B<i+l)if(s)k={cursorPosition:{x:B,y:c,bg:f.bg}};else {let C=t.get(B,c),x=C?.ch&&C.ch!==" "?C.ch:"\u258C",w=f.bg??"black",b=f.color??"white";t.setChar(B,c,x,w,b,C?.bold,C?.dim,C?.italic,false);}}}return k}var er="\x1B",de=`${er}[`;function tr(e,t){return `${de}${t+1};${e+1}H`}function nr(e){let t=`${de}0m`;return e.bold&&(t+=`${de}1m`),e.dim&&(t+=`${de}2m`),e.italic&&(t+=`${de}3m`),e.underline&&(t+=`${de}4m`),e.fg!=null&&(t+=Ot(e.fg)),e.bg!=null&&(t+=Dt(e.bg)),t}function Zt(e,t,n){let r="",o=-1,s=-1,i="";for(let c=0;c<t.height;c++)for(let l=0;l<t.width;l++){let a=t.get(l,c);if(!n){let d=e.get(l,c);if(d&&t.cellsEqual(a,d))continue}(s!==c||o!==l)&&(r+=tr(l,c));let p=nr(a);p!==i&&(r+=p,i=p),r+=a.ch,o=l+1,s=c;}return r.length>0&&(r+=`${de}0m`),r}var ir={row:FlexDirection.Row,column:FlexDirection.Column},lr={"flex-start":Justify.FlexStart,center:Justify.Center,"flex-end":Justify.FlexEnd,"space-between":Justify.SpaceBetween,"space-around":Justify.SpaceAround},cr={"flex-start":Align.FlexStart,center:Align.Center,"flex-end":Align.FlexEnd,stretch:Align.Stretch};function tn(e,t,n){n!==void 0&&(typeof n=="string"&&n.endsWith("%"),t(n));}function ae(e,t,n){n!==void 0&&(typeof n=="string"&&n.endsWith("%")?e.setPositionPercent(t,parseFloat(n)):e.setPosition(t,n));}function ur(e,t,n){tn(e,o=>e.setWidth(o),t.width),tn(e,o=>e.setHeight(o),t.height),t.minWidth!==void 0&&e.setMinWidth(t.minWidth),t.minHeight!==void 0&&e.setMinHeight(t.minHeight),t.maxWidth!==void 0&&e.setMaxWidth(t.maxWidth),t.maxHeight!==void 0&&e.setMaxHeight(t.maxHeight),t.padding!==void 0&&e.setPadding(Edge.All,t.padding),t.paddingX!==void 0&&e.setPadding(Edge.Horizontal,t.paddingX),t.paddingY!==void 0&&e.setPadding(Edge.Vertical,t.paddingY),t.paddingTop!==void 0&&e.setPadding(Edge.Top,t.paddingTop),t.paddingRight!==void 0&&e.setPadding(Edge.Right,t.paddingRight),t.paddingBottom!==void 0&&e.setPadding(Edge.Bottom,t.paddingBottom),t.paddingLeft!==void 0&&e.setPadding(Edge.Left,t.paddingLeft);let r=t.border!=null&&t.border!=="none";e.setBorder(Edge.All,r?1:0),t.flexDirection&&e.setFlexDirection(ir[t.flexDirection]??FlexDirection.Column),t.flexWrap&&e.setFlexWrap(t.flexWrap==="wrap"?Wrap.Wrap:Wrap.NoWrap),t.justifyContent&&e.setJustifyContent(lr[t.justifyContent]??Justify.FlexStart),t.alignItems&&e.setAlignItems(cr[t.alignItems]??Align.Stretch),t.flexGrow!==void 0&&e.setFlexGrow(t.flexGrow),t.flexShrink!==void 0&&e.setFlexShrink(t.flexShrink),t.gap!==void 0&&e.setGap(Gutter.All,t.gap),t.position==="absolute"?e.setPositionType(PositionType.Absolute):e.setPositionType(PositionType.Relative),t.inset!==void 0&&(ae(e,Edge.Top,t.inset),ae(e,Edge.Right,t.inset),ae(e,Edge.Bottom,t.inset),ae(e,Edge.Left,t.inset)),ae(e,Edge.Top,t.top),ae(e,Edge.Right,t.right),ae(e,Edge.Bottom,t.bottom),ae(e,Edge.Left,t.left),t.clip&&e.setOverflow(Overflow.Hidden);}function rn(e){let t=nn.Node.create();if(e.yogaNode=t,ur(t,e.style,e.type),e.type==="text"||e.type==="input")t.setMeasureFunc((n,r,o,s)=>{let i;return e.type==="input"?(i=e.props.value??e.props.defaultValue??e.props.placeholder??"",i.length===0&&(i=" ")):i=on(e),zt(i,n,r,e.style.wrap??"wrap")});else for(let n=0;n<e.children.length;n++){let r=e.children[n];r.hidden||(rn(r),t.insertChild(r.yogaNode,t.getChildCount()));}}function on(e){if(e.text!=null)return e.text;let t="";for(let n of e.children)t+=on(n);if(t===""&&e.props.children!=null){if(typeof e.props.children=="string")return e.props.children;if(typeof e.props.children=="number")return String(e.props.children)}return t}function sn(e,t,n){let r=e.yogaNode,o=r.getComputedLayout(),s=t+o.left,i=n+o.top,c=o.width,l=o.height,a=e.style.border&&e.style.border!=="none"?1:0,p=r.getComputedPadding(Edge.Top),d=r.getComputedPadding(Edge.Right),S=r.getComputedPadding(Edge.Bottom),v=r.getComputedPadding(Edge.Left),I=s+a+v,f=i+a+p,u=Math.max(0,c-a*2-v-d),R=Math.max(0,l-a*2-p-S);e.layout={x:s,y:i,width:c,height:l,innerX:I,innerY:f,innerWidth:u,innerHeight:R};for(let P of e.children)P.hidden||!P.yogaNode||sn(P,s,i);}function ln(e,t,n){let r=nn.Node.create();r.setWidth(t),r.setHeight(n),r.setFlexDirection(FlexDirection.Column);for(let o of e)o.hidden||(rn(o),r.insertChild(o.yogaNode,r.getChildCount()));r.calculateLayout(t,n,Direction.LTR);for(let o of e)o.hidden||!o.yogaNode||sn(o,0,0);r.freeRecursive(),cn(e);}function cn(e){for(let t of e)t.yogaNode=null,cn(t.children);}var Y=createContext(null),q=createContext(null),oe=createContext(null),be=createContext(null),Ye=createContext(null);function ar(e,t={}){let n=t.stdout??process.stdout,r=t.stdin??process.stdin,o=t.debug??false,s=t.useNativeCursor??true,i=new $e(n,r);i.setup();let c=false;i.queryPalette().then(m=>{_t(m),p=true,b();});let l=new Ne(i.columns,i.rows),a=new Ne(i.columns,i.rows),p=true,d=new Set,S=new Set,v=new Map,I={subscribe(m){return d.add(m),()=>d.delete(m)},subscribePriority(m){return S.add(m),()=>S.delete(m)},registerInputHandler(m,g){return v.set(m,g),()=>v.delete(m)}},f=null,u=new Map,R=[],P=new Set,E=[],H=new Set;function _(m){if(f!==m){f=m,b();for(let g of H)g(f);}}function k(){let m=[...R];if(E.length>0){let g=E[E.length-1];m=m.filter(y=>g.has(y));}return m=m.filter(g=>!P.has(g)),m.sort((g,y)=>{let D=u.get(g),W=u.get(y);if(!D||!W)return 0;let F=D.layout,h=W.layout;return F.y!==h.y?F.y-h.y:F.x-h.x}),m}let G={get focusedId(){return f},register(m,g){if(u.set(m,g),R.includes(m)||R.push(m),E.length>0&&E[E.length-1].add(m),f===null){let y=k();y.length>0&&_(y[0]);}return ()=>{u.delete(m);let y=R.indexOf(m);if(y!==-1&&R.splice(y,1),f===m){let D=k();_(D[0]??null);}}},requestFocus(m){_(m);},focusNext(){let m=k();if(m.length===0)return;let y=((f?m.indexOf(f):-1)+1)%m.length;_(m[y]);},focusPrev(){let m=k();if(m.length===0)return;let y=((f?m.indexOf(f):0)-1+m.length)%m.length;_(m[y]);},setSkippable(m,g){if(g){if(P.add(m),f===m){let y=k();y.length>0&&_(y[0]);}}else P.delete(m);},trapIds:null,pushTrap(m){return E.push(m),()=>{let g=E.indexOf(m);g!==-1&&E.splice(g,1);}},onFocusChange(m){return H.add(m),()=>{H.delete(m);}},getRegisteredElements(){let m=[];for(let g of R){if(P.has(g))continue;let y=u.get(g);y&&m.push({id:g,node:y});}return m},getActiveElements(){let m=k(),g=[];for(let y of m){if(P.has(y))continue;let D=u.get(y);D&&g.push({id:y,node:D});}return g}},T=new Map,B={getLayout(m){return m.layout},subscribe(m,g){return T.has(m)||T.set(m,new Set),T.get(m).add(g),()=>{let y=T.get(m);y&&(y.delete(g),y.size===0&&T.delete(m));}}},C={registerNode(){},unregisterNode(){},scheduleRender:b,exit(m){le.exit(m);},get columns(){return i.columns},get rows(){return i.rows}},x={type:"root",children:[],onCommit(){b();}},w=false;function b(){w||(w=true,queueMicrotask(()=>{w=false,M();}));}function M(){let m=i.columns,g=i.rows;(a.width!==m||a.height!==g)&&(a.resize(m,g),l.resize(m,g),p=true),ln(x.children,m,g),$(x.children);let y;if(f){let F=u.get(f);F?.type==="input"&&(y={nodeId:f,position:F.props.cursorPosition??F.props.value?.length??0});}let D=Jt(x.children,a,{cursorInfo:y,useNativeCursor:s}),W=Zt(l,a,p);if(W.length>0&&i.write(W),s)if(D.cursorPosition){let F=$t(D.cursorPosition.bg);i.setCursorColor(F),i.moveCursor(D.cursorPosition.x,D.cursorPosition.y),c||(i.showCursor(),c=true);}else c&&(i.hideCursor(),c=false);for(let F=0;F<a.cells.length;F++)l.cells[F]={...a.cells[F]};p=false;}function $(m){for(let g of m){let y=T.get(g);if(y)for(let D of y)D(g.layout);$(g.children);}}let K=i.onData(m=>{let g=jt(m);for(let y of g){if(y.ctrl&&y.name==="c"){le.exit();return}if(y.ctrl&&y.name==="z"){i.suspend(),process.kill(0,"SIGSTOP");return}if(y.name==="tab"&&!y.ctrl&&!y.alt){y.shift?G.focusPrev():G.focusNext();continue}let D=false;for(let W of S)if(W(y)){D=true;break}if(!D&&f){let W=v.get(f);W&&(D=W(y));}if(!D)for(let W of d)W(y);}}),z=i.onResize(()=>{p=true,b();}),O=()=>{i.resume(),p=true,b();};process.on("SIGCONT",O);let j=ee.createElement(be.Provider,{value:C},ee.createElement(Y.Provider,{value:I},ee.createElement(q.Provider,{value:G},ee.createElement(oe.Provider,{value:B},e)))),L=m=>{o&&console.error("Uncaught error:",m);},X=m=>{o&&console.error("Error caught by boundary:",m);},J=m=>{o&&console.error("Recoverable error:",m);},se=Ie.createContainer(x,0,null,false,null,"",L,X,J,null);Ie.updateContainer(j,se,null,null);let le={unmount(){Ie.updateContainer(null,se,null,null),K(),z(),process.off("SIGCONT",O),i.cleanup();},exit(m){le.unmount(),process.exit(m??0);}};return le}var dr=forwardRef(function({children:t,style:n,focusable:r},o){return ee.createElement("box",{style:n,focusable:r,ref:o},t)});var gr=forwardRef(function({children:t,style:n,wrap:r},o){let s=r?{...n,wrap:r}:n;return ee.createElement("text",{style:s,ref:o},t)});function un(e,t,n){if(n<=0)return {visualLine:0,visualCol:t,totalVisualLines:1,lineStartOffset:0,lineLength:e.length};let r=e.split(`
5
5
  `),o=[],s=0;for(let l of r){let a=ce([l],n,"wrap"),p=0;for(let d of a)o.push({text:d,logicalOffset:s+p}),p+=d.length;s+=l.length+1;}let i=0;for(let l=0;l<o.length;l++){let a=o[l],p=a.text.length,d=l+1<o.length&&o[l+1].logicalOffset!==a.logicalOffset+p,S=p+(d?1:0);if(t<i+p||l===o.length-1)return {visualLine:l,visualCol:Math.min(t-i,p),totalVisualLines:o.length,lineStartOffset:i,lineLength:p};i+=S;}let c=o.length-1;return {visualLine:c,visualCol:o[c].text.length,totalVisualLines:o.length,lineStartOffset:i-o[c].text.length,lineLength:o[c].text.length}}function an(e,t,n,r){if(r<=0)return Math.min(n,e.length);let o=e.split(`
6
6
  `),s=[],i=0;for(let p of o){let d=ce([p],r,"wrap"),S=0;for(let v of d)s.push({text:v,startOffset:i+S}),S+=v.length;i+=p.length+1;}let c=Math.max(0,Math.min(t,s.length-1)),l=s[c],a=Math.min(n,l.text.length);return l.startOffset+a}function Ge(e,t){let n=e.split(`
7
- `),r=t;for(let s=0;s<n.length;s++){if(r<=n[s].length)return {line:s,col:r,lines:n};r-=n[s].length+1;}let o=n.length-1;return {line:o,col:n[o].length,lines:n}}function Le(e,t,n){let r=0;for(let o=0;o<t&&o<e.length;o++)r+=e[o].length+1;return r+Math.min(n,e[t]?.length??0)}function xr(e){let{value:t,defaultValue:n="",onChange:r,onKeyPress:o,onBeforeChange:s,placeholder:i,style:c,focusedStyle:l,multiline:a,autoFocus:p,type:d="text"}=e,[S,v]=useState(n),[I,f]=useState(n.length),[u,R]=useState(0),[P,E]=useState(false),[A,W]=useState(false),k=useContext(Y),G=useContext($),T=useContext(oe),B=useRef(null),C=useRef(null),x=t!==void 0,w=x?t:S;useEffect(()=>{if(!T||!B.current)return;let j=T.getLayout(B.current);return R(j.innerWidth),T.subscribe(B.current,D=>{R(D.innerWidth);})},[T]);let b=useRef(w),M=useRef(I);useEffect(()=>{b.current=w,M.current>w.length&&(M.current=w.length,f(w.length));},[w]),useEffect(()=>{M.current=I;},[I]);let _=useRef({isControlled:x,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:a??false,innerWidth:u,type:d});_.current={isControlled:x,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:a??false,innerWidth:u,type:d},useEffect(()=>{if(!(!G||!C.current||!B.current))return G.register(C.current,B.current)},[G,A]);let q=useRef(false);useEffect(()=>{if(p&&!q.current&&G&&C.current){q.current=true;let j=C.current;queueMicrotask(()=>{G.requestFocus(j);});}},[p,G,A]),useEffect(()=>{if(!G||!C.current)return;let j=C.current;return E(G.focusedId===j),G.onFocusChange(D=>{E(D===j);})},[G,A]),useEffect(()=>{if(!k||!C.current)return;let j=C.current,D=L=>{let{isControlled:X,onChange:J,onKeyPress:se,onBeforeChange:le,multiline:m}=_.current;if(se?.(L)===true)return true;let g=b.current,y=M.current;if(L.name==="escape")return false;let O=(h,N)=>{let V=h,Q=N;if(le){let H=le(h,g);if(H===false)return;typeof H=="string"&&(V=H,Q=H.length);}b.current=V,M.current=Q,X||v(V),J?.(V),f(Q);},K=h=>{M.current=h,f(h);};if(L.name==="return"){if(m){let h=g.slice(0,y)+`
8
- `+g.slice(y);return O(h,y+1),true}return false}if(L.ctrl){if(L.name==="w"){if(y>0){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&(!m||g[h-1]!==`
9
- `);)h--;let N=g.slice(0,h)+g.slice(y);O(N,h);}return true}if(L.name==="a"){if(m){let{line:h,lines:N}=Ge(g,y);K(Le(N,h,0));}else K(0);return true}if(L.name==="e"){if(m){let{line:h,lines:N}=Ge(g,y);K(Le(N,h,N[h].length));}else K(g.length);return true}if(L.name==="k"){if(m){let{line:h,lines:N}=Ge(g,y),V=Le(N,h,N[h].length);if(y<V){let Q=g.slice(0,y)+g.slice(V);O(Q,y);}}else if(y<g.length){let h=g.slice(0,y);O(h,y);}return true}return false}if(L.alt){if(L.name==="left"||L.name==="b"){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&g[h-1]!==`
10
- `;)h--;return K(h),true}if(L.name==="right"||L.name==="f"){let h=y;for(;h<g.length&&g[h]!==" "&&g[h]!==`
11
- `;)h++;for(;h<g.length&&g[h]===" ";)h++;return K(h),true}if(L.name==="backspace"||L.name==="d")if(L.name==="backspace"){if(y>0){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&g[h-1]!==`
12
- `;)h--;let N=g.slice(0,h)+g.slice(y);O(N,h);}return true}else {if(y<g.length){let h=y;for(;h<g.length&&g[h]!==" "&&g[h]!==`
13
- `;)h++;for(;h<g.length&&g[h]===" ";)h++;let N=g.slice(0,y)+g.slice(h);O(N,y);}return true}return false}if(L.name==="left")return K(Math.max(0,y-1)),true;if(L.name==="right")return K(Math.min(g.length,y+1)),true;if(L.name==="up"){let{innerWidth:h}=_.current,N=un(g,y,h);return N.visualLine>0&&K(an(g,N.visualLine-1,N.visualCol,h)),true}if(L.name==="down"){let{innerWidth:h}=_.current,N=un(g,y,h);return N.visualLine<N.totalVisualLines-1&&K(an(g,N.visualLine+1,N.visualCol,h)),true}if(L.name==="home"){if(m){let{line:h,lines:N}=Ge(g,y);K(Le(N,h,0));}else K(0);return true}if(L.name==="end"){if(m){let{line:h,lines:N}=Ge(g,y);K(Le(N,h,N[h].length));}else K(g.length);return true}if(L.name==="backspace"){if(y>0){let h=g.slice(0,y-1)+g.slice(y);O(h,y-1);}return true}if(L.name==="delete"){if(y<g.length){let h=g.slice(0,y)+g.slice(y+1);O(h,y);}return true}if(L.name.length>1)return false;let F=L.sequence;if(F.length===1&&F.charCodeAt(0)>=32){let{type:h}=_.current;if(h==="number"){let V=/[0-9]/.test(F),Q=F==="."&&!g.includes("."),H=F==="-"&&y===0&&!g.includes("-");if(!V&&!Q&&!H)return true}let N=g.slice(0,y)+F+g.slice(y);return O(N,y+1),true}return false};return k.registerInputHandler(j,D)},[k,A]);let z={...c,...P&&l?l:{}};return ee.createElement("input",{style:z,value:w,defaultValue:n,placeholder:i,onChange:r,cursorPosition:I,multiline:a??false,focused:P,ref:j=>{j?(B.current=j,C.current=j.focusId,W(true)):(B.current=null,C.current=null,W(false));}})}function ft({trap:e=false,children:t}){let n=useContext($),r=useRef(null),o=useRef(new Set);return useLayoutEffect(()=>{if(!e||!n)return;r.current=n.focusedId;let s=n.pushTrap(o.current);return ()=>{s(),r.current&&n.requestFocus(r.current);}},[e,n]),useEffect(()=>{if(!(!e||!n)&&o.current.size>0){let s=o.current.values().next().value;s&&n.requestFocus(s);}},[e,n]),ee.createElement(ee.Fragment,null,t)}function Rr({size:e}){return ee.createElement("box",{style:{flexGrow:e??1}})}function hn(e){let t=e.toLowerCase().split("+");return {name:t[t.length-1],ctrl:t.includes("ctrl"),alt:t.includes("alt"),shift:t.includes("shift"),meta:t.includes("meta")||t.includes("cmd")||t.includes("super")||t.includes("win")}}function gn(e,t){return !(t.name!==e.name||e.ctrl!==!!t.ctrl||e.alt!==!!t.alt||e.shift!==!!t.shift||e.meta!==!!t.meta)}function Ir({keypress:e,onPress:t,whenFocused:n,priority:r,disabled:o}){let s=useContext(Y),i=useContext($),c=useRef(t);c.current=t;let l=useRef(hn(e));return l.current=hn(e),useEffect(()=>{if(!(!s||o))if(r){let a=p=>!gn(l.current,p)||n&&i?.focusedId!==n?false:(c.current(),true);return s.subscribePriority(a)}else {let a=p=>{gn(l.current,p)&&(n&&i?.focusedId!==n||c.current());};return s.subscribe(a)}},[s,i,n,r,o]),null}function Nr({children:e,zIndex:t=1e3}){return ee.createElement("box",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:t}},e)}function Er({onPress:e,style:t,focusedStyle:n,children:r,disabled:o}){let s=useContext($),i=useContext(Y),c=useRef(null),l=useRef(null),a=useRef(e);a.current=e;let[p,d]=useState(false),[S,v]=useState(false);useEffect(()=>{if(!(!s||!l.current||!c.current||o))return s.register(l.current,c.current)},[s,o,p]),useEffect(()=>{if(!s||!l.current)return;let f=l.current;return v(s.focusedId===f),s.onFocusChange(u=>{v(u===f);})},[s,p]),useEffect(()=>{if(!i||!l.current||o)return;let f=l.current,u=R=>s?.focusedId!==f?false:R.name==="return"||R.name===" "||R.sequence===" "?(a.current?.(),true):false;return i.registerInputHandler(f,u)},[i,s,o,p]);let I={...t,...S&&n?n:{}};return ee.createElement("box",{style:I,focusable:!o,ref:f=>{f?(c.current=f,l.current=f.focusId,d(true)):(c.current=null,l.current=null,d(false));}},r)}var Lr={x:0,y:0,width:0,height:0,innerX:0,innerY:0,innerWidth:0,innerHeight:0};function fe(e){let t=useContext(oe),[n,r]=useState(Lr);return useEffect(()=>{if(!(!t||!e?.current))return r(t.getLayout(e.current)),t.subscribe(e.current,r)},[t,e]),n}function Be(e,t=[]){let n=useContext(Y);useEffect(()=>{if(n)return n.subscribe(e)},[n,...t]);}function Ar({children:e,style:t,scrollOffset:n,onScroll:r,defaultScrollOffset:o=0,scrollStep:s=1,disableKeyboard:i,scrollToFocus:c=true,showScrollbar:l=true,focusable:a=true,focusedStyle:p}){let d=n!==void 0,[S,v]=useState(o),I=d?n:S,f=useRef(null),u=useRef(null),R=fe(f),P=fe(u),E=useContext($),A=useContext(oe),W=useRef(null);a&&!W.current&&(W.current=`scrollview-${Math.random().toString(36).slice(2,9)}`);let k=a?W.current:null;useEffect(()=>{if(!(!a||!k||!E||!f.current))return E.register(k,f.current)},[a,k,E]);let G=a&&k&&E?.focusedId===k,T=R.innerHeight,B=P.height,C=Math.max(0,B-T),x=Math.max(0,Math.min(I,C)),w=useMemo(()=>({getBounds:()=>{let H=R.y;return {visibleTop:H,visibleBottom:H+T,viewportHeight:T,scrollOffset:x}}}),[R.y,T,x]),b=useCallback(H=>{let re=Math.max(0,Math.min(H,C));d?r?.(re):v(re);},[d,r,C]);useEffect(()=>{I>C&&C>=0&&b(C);},[I,C,b]),useEffect(()=>!c||!E||!A||!u.current?void 0:E.onFocusChange(re=>{if(!re||!u.current)return;let Z=Ke=>{if(Ke.focusId===re)return Ke;for(let We of Ke.children){let ye=Z(We);if(ye)return ye}return null},pe=Z(u.current);if(!pe)return;let ge=A.getLayout(pe),Re=u.current.layout?.y??0,Oe=ge.y-Re,De=Oe+ge.height,ve=I,ot=I+T;Oe<ve?b(Oe):De>ot&&b(De-T);}),[c,E,A,I,T,b]);let M=useCallback(()=>{if(!E)return false;let H=E.focusedId;if(!H)return false;if(a&&k&&H===k)return true;if(!u.current)return false;let re=Z=>{if(Z.focusId===H)return true;for(let pe of Z.children)if(re(pe))return true;return false};return re(u.current)},[E,a,k]);Be(H=>{if(i||!M())return;let re=Math.max(1,Math.floor(T/2)),Z=Math.max(1,T);switch(H.name){case "pageup":b(I-Z);break;case "pagedown":b(I+Z);break;default:H.ctrl&&(H.name==="d"?b(I+re):H.name==="u"?b(I-re):H.name==="f"?b(I+Z):H.name==="b"&&b(I-Z));break}},[I,s,T,C,i,b,M]);let{padding:_,paddingX:q,paddingY:z,paddingTop:j,paddingRight:D,paddingBottom:L,paddingLeft:X,...J}=t??{},le=J.border!=null&&J.border!=="none"?2:0,m=B>0?B+le:void 0,g={...J,...G?p:{},clip:true,...J.height===void 0&&m!==void 0?{height:m,flexShrink:J.flexShrink??1,minHeight:J.minHeight??0}:{}},y={position:"absolute",top:-x,left:0,right:0,flexDirection:"column",..._!==void 0&&{padding:_},...q!==void 0&&{paddingX:q},...z!==void 0&&{paddingY:z},...j!==void 0&&{paddingTop:j},...D!==void 0&&{paddingRight:D},...L!==void 0&&{paddingBottom:L},...X!==void 0&&{paddingLeft:X}},O=B>T&&T>0,K=l&&O,F=Math.max(1,Math.floor(T/B*T)),h=B-T,N=h>0?Math.floor(x/h*(T-F)):0,V=[];if(K)for(let H=0;H<T;H++)H>=N&&H<N+F?V.push("\u2588"):V.push("\u2591");let Q={position:"absolute",top:0,right:0,width:1,height:T,flexDirection:"column"};return ee.createElement(Ye.Provider,{value:w},ee.createElement("box",{style:g,ref:H=>{f.current=H??null;},...a?{focusable:true,focusId:k}:{}},ee.createElement("box",{style:{...y,paddingRight:K?(y.paddingRight??0)+1:y.paddingRight},ref:H=>{u.current=H??null;}},e),K&&ee.createElement("box",{style:Q},ee.createElement("text",{style:{color:"blackBright"}},V.join(`
14
- `)))))}function Ct({count:e,renderItem:t,selectedIndex:n,onSelectionChange:r,onSelect:o,defaultSelectedIndex:s=0,disabledIndices:i,style:c,focusable:l=true}){let a=n!==void 0,[p,d]=useState(s),S=a?n:p,v=useContext($),I=useContext(Y),f=useRef(null),u=useRef(null),R=useRef(o);R.current=o;let[P,E]=useState(false),[A,W]=useState(false),k=useRef(null),G=useCallback(x=>{let w=Math.max(0,Math.min(x,e-1));a?r?.(w):d(w);},[a,r,e]),T=useCallback((x,w)=>{if(!i||i.size===0)return Math.max(0,Math.min(x+w,e-1));let b=x+w;for(;b>=0&&b<e&&i.has(b);)b+=w;return b<0||b>=e?x:b},[i,e]);useEffect(()=>{if(!(!v||!u.current||!f.current||!l))return v.register(u.current,f.current)},[v,l,P]),useEffect(()=>{if(!v||!u.current)return;let x=u.current;return W(v.focusedId===x),v.onFocusChange(w=>{W(w===x);})},[v,P]);let B=useCallback(x=>{let w=x?e-1:0,b=x?-1:1,M=w;for(;M>=0&&M<e&&i?.has(M);)M+=b;return M>=0&&M<e?M:x?e-1:0},[i,e]);useEffect(()=>{if(!I||!u.current||!l)return;let x=u.current,w=b=>v?.focusedId!==x?false:b.name==="g"&&!b.ctrl&&!b.alt?k.current==="g"?(G(B(false)),k.current=null,true):(k.current="g",true):b.name==="G"||b.name==="g"&&b.shift?(k.current=null,G(B(true)),true):(k.current=null,b.name==="up"||b.name==="k"?(G(T(S,-1)),true):b.name==="down"||b.name==="j"?(G(T(S,1)),true):b.name==="return"?(i?.has(S)||R.current?.(S),true):false);return I.registerInputHandler(x,w)},[I,v,l,S,G,T,B,i,P]);let C=[];for(let x=0;x<e;x++)C.push(ee.createElement(ee.Fragment,{key:x},t({index:x,selected:x===S,focused:A})));return ee.createElement("box",{style:{flexDirection:"column",...c},focusable:l,ref:x=>{x?(f.current=x,u.current=x.focusId,E(true)):(f.current=null,u.current=null,E(false));}},...C)}function jr({items:e,selectedIndex:t,onSelectionChange:n,onSelect:r,defaultSelectedIndex:o=0,style:s,highlightColor:i="cyan",focusable:c=true}){let l=new Set;for(let p=0;p<e.length;p++)e[p].disabled&&l.add(p);let a=p=>{let d=e[p];d&&!d.disabled&&r?.(d.value,p);};return ee.createElement(Ct,{count:e.length,selectedIndex:t,onSelectionChange:n,onSelect:a,defaultSelectedIndex:o,disabledIndices:l.size>0?l:void 0,style:s,focusable:c,renderItem:({index:p,selected:d,focused:S})=>{let v=e[p],I=v.disabled,f=d&&S,u=d?">":" ";return ee.createElement("box",{style:{flexDirection:"row",...f?{bg:i}:{}}},ee.createElement("text",{style:f?{bold:true,color:"black"}:I?{dim:true}:{}},`${u} ${v.label}`))}})}function Wr({value:e,indeterminate:t=false,width:n="100%",label:r,showPercent:o=false,style:s,filled:i="\u2588",empty:c="\u2591"}){let l=useRef(null),p=fe(l).innerWidth,[d,S]=useState(0);useEffect(()=>{if(!t)return;let R=setInterval(()=>{S(P=>(P+1)%Math.max(1,p+6));},100);return ()=>clearInterval(R)},[t,p]);let v=Math.max(0,Math.min(1,e??0)),I=o?` ${Math.round(v*100)}%`:"",f="";if(p>0)if(t&&e===void 0){let R=Math.max(1,Math.min(3,Math.floor(p/4))),P=[];for(let E=0;E<p;E++)E>=d-R&&E<d?P.push(i):P.push(c);f=P.join("");}else {let R=Math.round(v*p);f=i.repeat(R)+c.repeat(p-R);}let u=[];return r&&u.push(ee.createElement("text",{key:"label",style:{bold:true}},r+" ")),u.push(ee.createElement("box",{key:"track",style:{flexGrow:1,flexShrink:1},ref:R=>{l.current=R??null;}},ee.createElement("text",{key:"bar",style:{}},f))),o&&u.push(ee.createElement("text",{key:"pct",style:{bold:true}},I)),ee.createElement("box",{style:{flexDirection:"row",width:n,...s}},...u)}var $r=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function zr({frames:e=$r,intervalMs:t=80,label:n,style:r}){let[o,s]=useState(0);useEffect(()=>{let c=setInterval(()=>{s(l=>(l+1)%e.length);},t);return ()=>clearInterval(c)},[e.length,t]);let i=[ee.createElement("text",{key:"frame",style:r},e[o])];return n&&i.push(ee.createElement("text",{key:"label",style:{}}," "+n)),ee.createElement("box",{style:{flexDirection:"row"}},...i)}var Rn=createContext(null),Qr=0;function eo(){let e=useContext(Rn);if(!e)throw new Error("useToast must be used within a <ToastHost>");return e.push}var to={info:{bg:"blackBright",title:"cyanBright",text:"white"},success:{bg:"blackBright",title:"greenBright",text:"white"},warning:{bg:"blackBright",title:"yellowBright",text:"white"},error:{bg:"blackBright",title:"redBright",text:"white"}};function no({position:e="bottom-right",maxVisible:t=5,children:n}){let[r,o]=useState([]),s=useRef(new Map),i=useCallback(v=>{let I=`toast-${Qr++}`,f={id:I,durationMs:3e3,variant:"info",...v};if(o(u=>[...u,f]),f.durationMs&&f.durationMs>0){let u=setTimeout(()=>{s.current.delete(I),o(R=>R.filter(P=>P.id!==I));},f.durationMs);s.current.set(I,u);}},[]);useEffect(()=>()=>{for(let v of s.current.values())clearTimeout(v);s.current.clear();},[]);let c=useRef({push:i});c.current.push=i;let l=e.startsWith("top"),a=e.endsWith("right"),p={position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:900,flexDirection:"column",justifyContent:l?"flex-start":"flex-end",alignItems:a?"flex-end":"flex-start",padding:1},S=r.slice(-t).map(v=>{let I=v.variant??"info",f=to[I],u=[];return v.title&&u.push(ee.createElement("text",{key:"title",style:{bold:true,color:f.title}},v.title)),u.push(ee.createElement("text",{key:"msg",style:{color:f.text}},v.message)),ee.createElement("box",{key:v.id,style:{bg:f.bg,paddingX:1,flexDirection:"column",minWidth:20,maxWidth:50}},...u)});return ee.createElement(Rn.Provider,{value:c.current},n,S.length>0?ee.createElement("box",{style:p},...S):null)}function oo({items:e,value:t,onChange:n,placeholder:r="Select...",style:o,focusedStyle:s,dropdownStyle:i,highlightColor:c="cyan",maxVisible:l=8,searchable:a=true,disabled:p}){let d=useContext($),S=useContext(Y),v=useContext(be),I=useContext(Ye),f=useRef(null),u=useRef(null),R=useRef(n);R.current=n;let[P,E]=useState(false),[A,W]=useState(false),[k,G]=useState(false),[T,B]=useState(0),[C,x]=useState(""),[w,b]=useState(0),M=fe(f),_=v?.rows??24,q=I?.getBounds(),j=e.find(F=>F.value===t)?.label??"",D=useMemo(()=>{if(!C)return e;let F=C.toLowerCase();return e.filter(h=>h.label.toLowerCase().includes(F))},[e,C]),L=Math.min(l,D.length),X=D.slice(w,w+L);useEffect(()=>{B(0),b(0);},[C]),useEffect(()=>{!A&&k&&(G(false),x(""));},[A,k]),useEffect(()=>{if(!(!d||!u.current||!f.current))return d.register(u.current,f.current)},[d,P]),useEffect(()=>{!d||!u.current||d.setSkippable(u.current,!!p);},[d,p,P]),useEffect(()=>{if(!d||!u.current)return;let F=u.current;return W(d.focusedId===F),d.onFocusChange(h=>{W(h===F);})},[d,P]);let J=useCallback((F,h)=>{let N=F+h;for(;N>=0&&N<D.length;){if(!D[N].disabled)return N;N+=h;}return F},[D]),se=useCallback(F=>{F<w?b(F):F>=w+L&&b(F-L+1);},[w,L]);useEffect(()=>{if(!S||!u.current||p)return;let F=u.current,h=N=>{if(d?.focusedId!==F)return false;if(!k){if(N.name==="return"||N.name===" "||N.sequence===" "||N.name==="down"){G(true),x("");let V=D.findIndex(H=>H.value===t),Q=V>=0?V:0;return B(Q),b(Math.max(0,Q-Math.floor(l/2))),true}return false}if(N.name==="tab")return G(false),x(""),false;if(N.name==="escape")return G(false),x(""),true;if(N.name==="return"){let V=D[T];return V&&!V.disabled&&(R.current?.(V.value),G(false),x("")),true}if(N.name==="up"){let V=J(T,-1);return B(V),se(V),true}if(N.name==="down"){let V=J(T,1);return B(V),se(V),true}if(N.name==="backspace")return a&&C.length>0&&x(V=>V.slice(0,-1)),true;if(N.name==="home"){let V=J(-1,1);return B(V),se(V),true}if(N.name==="end"){let V=J(D.length,-1);return B(V),se(V),true}if(a&&N.sequence&&N.sequence.length===1&&!N.ctrl&&!N.alt){let V=N.sequence;if(V>=" "&&V<="~")return x(Q=>Q+V),true}return true};return S.registerInputHandler(F,h)},[S,d,p,k,T,D,t,l,a,C,J,se,P]);let m={flexDirection:"row",width:"100%",...!o?.bg&&o?.border===void 0?{border:"single"}:{},...o,...A&&s?s:{}},g=j?o?.color??void 0:"blackBright",y=[ee.createElement("text",{key:"label",style:{flexGrow:1,flexShrink:1,color:g,wrap:"ellipsis",...j?{}:{dim:true}}},j||r),ee.createElement("text",{key:"arrow",style:{flexShrink:0,color:A?c:"blackBright"}},k?" \u25B2":" \u25BC")],O=null;if(k){let F=[];a&&C&&F.push(ee.createElement("box",{key:"search",style:{paddingX:1}},ee.createElement("text",{style:{color:"blackBright",dim:true}},`/${C}`))),D.length===0&&F.push(ee.createElement("box",{key:"empty",style:{paddingX:1}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"No matches"))),w>0&&F.push(ee.createElement("box",{key:"scroll-up",style:{justifyContent:"center",alignItems:"center"}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"\u25B2"))),X.forEach((ve,ot)=>{let We=w+ot===T,ye=ve.disabled,Mn={paddingX:1,...We&&!ye?{bg:c}:{}},Vn={...We&&!ye?{color:"black",bold:true}:{},...ye?{dim:true,color:"blackBright"}:{}};F.push(ee.createElement("box",{key:`item-${ve.value}`,style:Mn},ee.createElement("text",{style:Vn},ve.label)));}),w+L<D.length&&F.push(ee.createElement("box",{key:"scroll-down",style:{justifyContent:"center",alignItems:"center"}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"\u25BC")));let h=w>0,N=w+L<D.length,V=a&&C,Q=D.length===0,H=!i?.bg&&i?.border===void 0,Z=L+(H?2:0);h&&(Z+=1),N&&(Z+=1),V&&(Z+=1),Q&&(Z+=1);let pe=M.y+M.height,ge,Re;q?(ge=q.visibleBottom-pe,Re=M.y-q.visibleTop):(ge=_-pe,Re=M.y);let De=ge<Z&&Re>=Z?-Z:M.height||1;O=ee.createElement("box",{style:{position:"absolute",top:De,left:0,right:0,zIndex:9999,...H?{border:"single"}:{},bg:"black",flexDirection:"column",...i}},...F);}let K={flexDirection:"column",width:m.width??"100%",minWidth:m.minWidth,maxWidth:m.maxWidth,flexGrow:m.flexGrow,flexShrink:m.flexShrink??1};return ee.createElement("box",{style:K},ee.createElement("box",{style:m,focusable:true,ref:F=>{F?(f.current=F,u.current=F.focusId,E(true)):(f.current=null,u.current=null,E(false));}},...y),O)}function so({checked:e,onChange:t,label:n,style:r,focusedStyle:o,disabled:s,checkedChar:i="\u2713",uncheckedChar:c=" "}){let l=useContext($),a=useContext(Y),p=useRef(null),d=useRef(null),S=useRef(t);S.current=t;let v=useRef(e);v.current=e;let[I,f]=useState(false),[u,R]=useState(false);useEffect(()=>{if(!(!l||!d.current||!p.current||s))return l.register(d.current,p.current)},[l,s,I]),useEffect(()=>{if(!l||!d.current)return;let k=d.current;return R(l.focusedId===k),l.onFocusChange(G=>{R(G===k);})},[l,I]),useEffect(()=>{if(!a||!d.current||s)return;let k=d.current,G=T=>l?.focusedId!==k?false:T.name==="return"||T.name===" "||T.sequence===" "?(S.current(!v.current),true):false;return a.registerInputHandler(k,G)},[a,l,s,I]);let P={flexDirection:"row",gap:1,...r,...u&&o?o:{}},E=e?i:c,A={color:s?"blackBright":u?"white":r?.color},W={color:s?"blackBright":r?.color};return ee.createElement("box",{style:P,focusable:!s,ref:k=>{k?(p.current=k,d.current=k.focusId,f(true)):(p.current=null,d.current=null,f(false));}},ee.createElement("text",{key:"box",style:A},`[${E}]`),n?ee.createElement("text",{key:"label",style:W},n):null)}function lo({items:e,value:t,onChange:n,style:r,itemStyle:o,focusedItemStyle:s,selectedItemStyle:i,disabled:c,direction:l="column",gap:a=0,selectedChar:p="\u25CF",unselectedChar:d="\u25CB"}){let S=useContext($),v=useContext(Y),I=useRef(null),f=useRef(null),u=useRef(n);u.current=n;let[R,P]=useState(false),[E,A]=useState(false),[W,k]=useState(()=>{let C=e.findIndex(x=>x.value===t);return C>=0?C:e.findIndex(x=>!x.disabled)}),G=useCallback((C,x)=>{let w=C;for(let b=0;b<e.length;b++)if(w=(w+x+e.length)%e.length,!e[w]?.disabled)return w;return C},[e]);useEffect(()=>{if(!(!S||!f.current||!I.current||c))return S.register(f.current,I.current)},[S,c,R]),useEffect(()=>{if(!S||!f.current)return;let C=f.current;return A(S.focusedId===C),S.onFocusChange(x=>{A(x===C);})},[S,R]),useEffect(()=>{if(!v||!f.current||c)return;let C=f.current,x=w=>{if(S?.focusedId!==C)return false;if(w.name==="up"||w.name==="left"||w.name==="k"||w.name==="tab"&&w.shift)return k(b=>G(b,-1)),true;if(w.name==="down"||w.name==="right"||w.name==="j"||w.name==="tab"&&!w.shift)return k(b=>G(b,1)),true;if(w.name==="return"||w.name===" "||w.sequence===" "){let b=e[W];return b&&!b.disabled&&u.current(b.value),true}return false};return v.registerInputHandler(C,x)},[v,S,c,e,W,G,R]),useEffect(()=>{let C=e.findIndex(x=>x.value===t);C>=0&&k(C);},[t,e]);let T={flexDirection:l,gap:a,...r},B=e.map((C,x)=>{let w=C.value===t,b=x===W,M=c||C.disabled,_=w?p:d,q={flexDirection:"row",gap:1,...o};w&&i&&(q={...q,...i}),E&&b&&s&&(q={...q,...s});let z=M?"blackBright":E&&b?s?.color??"white":w?i?.color??o?.color:o?.color;return ee.createElement("box",{key:x,style:q},ee.createElement("text",{key:"radio",style:{color:z}},`(${_})`),ee.createElement("text",{key:"label",style:{color:z}},C.label))});return ee.createElement("box",{style:T,focusable:!c,ref:C=>{C?(I.current=C,f.current=C.focusId,P(true)):(I.current=null,f.current=null,P(false));}},...B)}var kn=createContext(null);function uo(){let e=useContext(kn);if(!e)throw new Error("useDialog must be used within a DialogHost");return e}function ao({children:e}){let[t,n]=useState([]),r=useRef(0),o=useCallback((a,p)=>new Promise(d=>{let S=++r.current;n(v=>[...v,{id:S,type:"alert",content:a,okText:p?.okText??"OK",cancelText:"",style:p?.style,resolve:()=>d()}]);}),[]),s=useCallback((a,p)=>new Promise(d=>{let S=++r.current;n(v=>[...v,{id:S,type:"confirm",content:a,okText:p?.okText??"OK",cancelText:p?.cancelText??"Cancel",style:p?.style,resolve:d}]);}),[]),i=useCallback((a,p)=>{n(d=>{let S=d.find(v=>v.id===a);return S&&S.resolve(p),d.filter(v=>v.id!==a)});},[]),c={alert:o,confirm:s},l=t[t.length-1];return ee.createElement(kn.Provider,{value:c},e,l&&ee.createElement(fo,{key:l.id,dialog:l,onDismiss:i}))}function fo({dialog:e,onDismiss:t}){let n=useContext($),r=useRef(null),o=useRef(null),s=useRef(null),i=useRef(null),[c,l]=useState("ok"),[a,p]=useState(0);useEffect(()=>{if(!n||a===0)return;let u=[];return r.current&&s.current&&u.push(n.register(s.current,r.current)),o.current&&i.current&&u.push(n.register(i.current,o.current)),s.current&&n.requestFocus(s.current),()=>u.forEach(R=>R())},[n,a]),useEffect(()=>{if(n)return n.onFocusChange(u=>{u===s.current?l("ok"):u===i.current&&l("cancel");})},[n]),Be(u=>{if(u.name==="return"||u.name==="space"){e.type==="alert"?t(e.id,true):t(e.id,c==="ok");return}if(u.name==="escape"){t(e.id,false);return}e.type==="confirm"&&n&&(u.name==="left"||u.name==="right")&&(c==="ok"&&i.current?n.requestFocus(i.current):s.current&&n.requestFocus(s.current));},[e,c,n,t]);let d=typeof e.content=="string",S=d?e.content.length:0,I={minWidth:Math.max(20,d?Math.min(S+6,50):30),maxWidth:50,bg:"black",border:"round",borderColor:"white",padding:1,flexDirection:"column",gap:1,...e.style},f=u=>({paddingX:2,bg:u?"white":"blackBright",color:u?"black":"white",bold:u});return ee.createElement(ft,{trap:true},ee.createElement("box",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:999}}),ee.createElement("box",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center",zIndex:1e3}},ee.createElement("box",{style:I},ee.createElement("box",{style:{flexDirection:"column"}},typeof e.content=="string"?ee.createElement("text",null,e.content):e.content),ee.createElement("box",{style:{flexDirection:"row",justifyContent:"flex-end",gap:1}},e.type==="confirm"&&ee.createElement("box",{style:f(c==="cancel"),focusable:true,ref:u=>{u&&u.focusId&&!i.current&&(o.current=u,i.current=u.focusId,p(R=>R+1));}},ee.createElement("text",null,e.cancelText)),ee.createElement("box",{style:f(c==="ok"),focusable:true,ref:u=>{u&&u.focusId&&!s.current&&(r.current=u,s.current=u.focusId,p(R=>R+1));}},ee.createElement("text",null,e.okText))))))}function ho(e,t){let n=[],r=t.split("");if(e<=r.length)for(let o=0;o<e;o++)n.push(r[o]);else for(let o=0;o<r.length&&n.length<e;o++)for(let s=0;s<r.length&&n.length<e;s++)n.push(r[o]+r[s]);return n}function go({children:e,activationKey:t="ctrl+o",hintStyle:n,hintBg:r="yellow",hintFg:o="black",hintChars:s="asdfghjklqwertyuiopzxcvbnm",enabled:i=true,debug:c=false}){let l=c?(...C)=>console.error("[JumpNav]",...C):()=>{},[a,p]=useState(false),[d,S]=useState(""),[v,I]=useState([]),f=useContext(Y),u=useContext($),R=useContext(oe);useEffect(()=>{l("Mounted, inputCtx:",!!f,"focusCtx:",!!u,"enabled:",i);},[]);let E=useCallback(C=>{let x=C.toLowerCase().split("+");return {ctrl:x.includes("ctrl"),alt:x.includes("alt"),shift:x.includes("shift"),meta:x.includes("meta"),name:x[x.length-1]??""}},[])(t),A=useCallback(()=>{if(!u?.getActiveElements){l("refreshElements: no getActiveElements");return}let C=u.getActiveElements();l("getActiveElements returned",C.length,"elements");let x=C.map(({id:w,node:b})=>({id:w,node:b,layout:R?.getLayout(b)??b.layout}));x.sort((w,b)=>w.layout.y!==b.layout.y?w.layout.y-b.layout.y:w.layout.x-b.layout.x),I(x);},[u,R,l]),W=useRef(false);useEffect(()=>{a&&!W.current&&(l("Activated! Refreshing elements..."),A()),W.current=a;},[a,A,l]);let k=v.filter(C=>C.layout.width>0&&C.layout.height>0),G=ho(k.length,s),T=useMemo(()=>{let C=new Map;return k.forEach((x,w)=>{G[w]&&C.set(G[w],x.id);}),C},[k,G]);useEffect(()=>{if(!f||!i){l("Not subscribing - inputCtx:",!!f,"enabled:",i);return}l("Subscribing to priority input, activation key:",t);let C=x=>{let w=x.name===E.name,b=!!x.ctrl===E.ctrl,M=!!x.alt===E.alt,_=!!x.shift===E.shift,q=!!x.meta===E.meta;if(!a&&w&&b&&M&&_&&q)return l("Activation key matched! Activating..."),p(true),S(""),true;if(a){if(x.name==="escape")return l("Escape pressed, deactivating"),p(false),S(""),true;if(x.name==="backspace")return S(""),true;if(x.sequence&&x.sequence.length===1&&/[a-z]/i.test(x.sequence)){let z=d+x.sequence.toLowerCase();l("Buffer:",z);let j=T.get(z);return j?(l("Jumping to",j),u?.requestFocus(j),p(false),S(""),true):[...T.keys()].some(L=>L.startsWith(z))?(S(z),true):(S(""),true)}return true}return false};return f.subscribePriority(C)},[f,i,a,E,d,T,u,t,l]);let B=a?ee.createElement("box",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:99998}},...k.map((C,x)=>{let w=G[x];if(!w)return null;let{x:b,y:M}=C.layout,_=w.startsWith(d)&&d.length>0;return ee.createElement("box",{key:C.id,style:{position:"absolute",top:M,left:Math.max(0,b-w.length-2),bg:_?"cyan":r,color:o,paddingX:1,zIndex:99999,...n}},ee.createElement("text",{style:{bold:true,color:o}},w))}),ee.createElement("box",{style:{position:"absolute",bottom:0,left:0,right:0,bg:"blackBright",paddingX:1,zIndex:99999}},ee.createElement("text",{style:{color:"white"}},d?`Jump: ${d}_`:"Press a key to jump \u2022 ESC to cancel"))):null;return ee.createElement(ee.Fragment,null,e,B)}function So(e){let t=useContext($),[n]=useState(()=>`focus-${Math.random().toString(36).slice(2,9)}`),r=t?t.focusedId===n:false;useEffect(()=>{if(!(!t||!e?.current))return e.current.focusId=n,t.register(n,e.current)},[t,n,e]);let o=useMemo(()=>()=>{t?.requestFocus(n);},[t,n]);return {focused:r,focus:o}}function Ro(e={}){let{disabled:t,onFocus:n,onBlur:r,onKeyPress:o}=e,s=useContext($),i=useContext(Y),c=useRef(null),l=useRef(null),[a,p]=useState(false),d=useRef(n),S=useRef(r),v=useRef(o);d.current=n,S.current=r,v.current=o;let I=useCallback(u=>{c.current=u,u?l.current=u.focusId??null:l.current=null;},[]);useEffect(()=>{if(!(!s||!l.current||!c.current))return s.register(l.current,c.current)},[s]),useEffect(()=>{!s||!l.current||s.setSkippable(l.current,!!t);},[s,t]),useEffect(()=>{if(!s||!l.current)return;let u=l.current,R=s.focusedId===u;return p(R),s.onFocusChange(P=>{let E=P===u;p(A=>(E&&!A?d.current?.():!E&&A&&S.current?.(),E));})},[s]),useEffect(()=>{if(!i||!l.current||t)return;let u=l.current,R=P=>s?.focusedId!==u?false:v.current?.(P)===true;return i.registerInputHandler(u,R)},[i,s,t]);let f=useCallback(()=>{s&&l.current&&s.requestFocus(l.current);},[s]);return {ref:I,isFocused:a,focus:f,focusId:l.current}}function Io(){let e=useContext(be);if(!e)throw new Error("useApp must be used within a Glyph render tree");return {exit:e.exit,get columns(){return e.columns},get rows(){return e.rows}}}function ko(){let e=useContext($),t=useContext(oe),[n,r]=useState([]),o=useRef(()=>{}),s=useCallback(()=>{if(!e)return;let c=(e.getActiveElements?.()??e.getRegisteredElements?.()??[]).map(({id:l,node:a})=>({id:l,node:a,layout:t?.getLayout(a)??a.layout,type:a.type}));c.sort((l,a)=>l.layout.y!==a.layout.y?l.layout.y-a.layout.y:l.layout.x-a.layout.x),r(c);},[e,t]);return o.current=s,useEffect(()=>{if(!e)return;s();let i=e.onFocusChange(()=>{s();}),c=setTimeout(s,50);return ()=>{i(),clearTimeout(c);}},[e,t,s]),e?{elements:n,focusedId:e.focusedId,requestFocus:e.requestFocus,focusNext:e.focusNext,focusPrev:e.focusPrev,refresh:()=>o.current()}:null}function Fo(e){let t=[];for(let n of e)switch(n){case "9":t.push({type:"digit",char:n});break;case "a":t.push({type:"letter",char:n});break;case "*":t.push({type:"alphanumeric",char:n});break;default:t.push({type:"literal",char:n});break}return t}function Go(e,t){switch(t){case "digit":return /\d/.test(e);case "letter":return /[a-zA-Z]/.test(e);case "alphanumeric":return /[a-zA-Z0-9]/.test(e);case "literal":return true}}function te(e){let t=typeof e=="string"?{mask:e}:e,{mask:n,placeholder:r="_",showPlaceholder:o=false}=t,s=Fo(n);return (i,c)=>{let l=[];for(let d of i)(d!==r&&!/[\s\-\(\)\/\.\:]/.test(d)||/[a-zA-Z0-9]/.test(d))&&/[a-zA-Z0-9]/.test(d)&&l.push(d);let a="",p=0;for(let d of s)if(d.type==="literal")(p<l.length||o)&&(a+=d.char);else if(p<l.length){let S=l[p];if(Go(S,d.type))a+=S,p++;else {p++;continue}}else o&&(a+=r);return a}}var Lo={usPhone:te("(999) 999-9999"),intlPhone:te("+9 999 999 9999"),dateUS:te("99/99/9999"),dateEU:te("99/99/9999"),dateISO:te("9999-99-99"),time:te("99:99"),timeFull:te("99:99:99"),creditCard:te("9999 9999 9999 9999"),ssn:te("999-99-9999"),zip:te("99999"),zipPlus4:te("99999-9999"),ipv4:te("999.999.999.999"),mac:te("**:**:**:**:**:**")};export{dr as Box,Er as Button,so as Checkbox,ao as DialogHost,ft as FocusScope,xr as Input,go as JumpNav,Ir as Keybind,Ct as List,jr as Menu,Nr as Portal,Wr as Progress,lo as Radio,Ar as ScrollView,oo as Select,Rr as Spacer,zr as Spinner,gr as Text,no as ToastHost,te as createMask,Lo as masks,ar as render,Io as useApp,uo as useDialog,So as useFocus,ko as useFocusRegistry,Ro as useFocusable,Be as useInput,fe as useLayout,eo as useToast};//# sourceMappingURL=index.js.map
7
+ `),r=t;for(let s=0;s<n.length;s++){if(r<=n[s].length)return {line:s,col:r,lines:n};r-=n[s].length+1;}let o=n.length-1;return {line:o,col:n[o].length,lines:n}}function Le(e,t,n){let r=0;for(let o=0;o<t&&o<e.length;o++)r+=e[o].length+1;return r+Math.min(n,e[t]?.length??0)}function xr(e){let{value:t,defaultValue:n="",onChange:r,onKeyPress:o,onBeforeChange:s,placeholder:i,style:c,focusedStyle:l,multiline:a,autoFocus:p,type:d="text"}=e,[S,v]=useState(n),[I,f]=useState(n.length),[u,R]=useState(0),[P,E]=useState(false),[H,_]=useState(false),k=useContext(Y),G=useContext(q),T=useContext(oe),B=useRef(null),C=useRef(null),x=t!==void 0,w=x?t:S;useEffect(()=>{if(!T||!B.current)return;let O=T.getLayout(B.current);return R(O.innerWidth),T.subscribe(B.current,j=>{R(j.innerWidth);})},[T]);let b=useRef(w),M=useRef(I);useEffect(()=>{b.current=w,M.current>w.length&&(M.current=w.length,f(w.length));},[w]),useEffect(()=>{M.current=I;},[I]);let $=useRef({isControlled:x,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:a??false,innerWidth:u,type:d});$.current={isControlled:x,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:a??false,innerWidth:u,type:d},useEffect(()=>{if(!(!G||!C.current||!B.current))return G.register(C.current,B.current)},[G,H]);let K=useRef(false);useEffect(()=>{if(!H){K.current=false;return}if(p&&!K.current&&G&&C.current){K.current=true;let O=C.current,j=setTimeout(()=>{G.requestFocus(O);},0);return ()=>clearTimeout(j)}},[p,G,H]),useEffect(()=>{if(!G||!C.current)return;let O=C.current;return E(G.focusedId===O),G.onFocusChange(j=>{E(j===O);})},[G,H]),useEffect(()=>{if(!k||!C.current)return;let O=C.current,j=L=>{let{isControlled:X,onChange:J,onKeyPress:se,onBeforeChange:le,multiline:m}=$.current;if(se?.(L)===true)return true;let g=b.current,y=M.current;if(L.name==="escape")return false;let D=(h,N)=>{let V=h,Q=N;if(le){let A=le(h,g);if(A===false)return;typeof A=="string"&&(V=A,Q=A.length);}b.current=V,M.current=Q,X||v(V),J?.(V),f(Q);},W=h=>{M.current=h,f(h);};if(L.name==="return"){if(m){let h=g.slice(0,y)+`
8
+ `+g.slice(y);return D(h,y+1),true}return false}if(L.ctrl){if(L.name==="w"){if(y>0){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&(!m||g[h-1]!==`
9
+ `);)h--;let N=g.slice(0,h)+g.slice(y);D(N,h);}return true}if(L.name==="a"){if(m){let{line:h,lines:N}=Ge(g,y);W(Le(N,h,0));}else W(0);return true}if(L.name==="e"){if(m){let{line:h,lines:N}=Ge(g,y);W(Le(N,h,N[h].length));}else W(g.length);return true}if(L.name==="k"){if(m){let{line:h,lines:N}=Ge(g,y),V=Le(N,h,N[h].length);if(y<V){let Q=g.slice(0,y)+g.slice(V);D(Q,y);}}else if(y<g.length){let h=g.slice(0,y);D(h,y);}return true}return false}if(L.alt){if(L.name==="left"||L.name==="b"){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&g[h-1]!==`
10
+ `;)h--;return W(h),true}if(L.name==="right"||L.name==="f"){let h=y;for(;h<g.length&&g[h]!==" "&&g[h]!==`
11
+ `;)h++;for(;h<g.length&&g[h]===" ";)h++;return W(h),true}if(L.name==="backspace"||L.name==="d")if(L.name==="backspace"){if(y>0){let h=y;for(;h>0&&g[h-1]===" ";)h--;for(;h>0&&g[h-1]!==" "&&g[h-1]!==`
12
+ `;)h--;let N=g.slice(0,h)+g.slice(y);D(N,h);}return true}else {if(y<g.length){let h=y;for(;h<g.length&&g[h]!==" "&&g[h]!==`
13
+ `;)h++;for(;h<g.length&&g[h]===" ";)h++;let N=g.slice(0,y)+g.slice(h);D(N,y);}return true}return false}if(L.name==="left")return W(Math.max(0,y-1)),true;if(L.name==="right")return W(Math.min(g.length,y+1)),true;if(L.name==="up"){let{innerWidth:h}=$.current,N=un(g,y,h);return N.visualLine>0&&W(an(g,N.visualLine-1,N.visualCol,h)),true}if(L.name==="down"){let{innerWidth:h}=$.current,N=un(g,y,h);return N.visualLine<N.totalVisualLines-1&&W(an(g,N.visualLine+1,N.visualCol,h)),true}if(L.name==="home"){if(m){let{line:h,lines:N}=Ge(g,y);W(Le(N,h,0));}else W(0);return true}if(L.name==="end"){if(m){let{line:h,lines:N}=Ge(g,y);W(Le(N,h,N[h].length));}else W(g.length);return true}if(L.name==="backspace"){if(y>0){let h=g.slice(0,y-1)+g.slice(y);D(h,y-1);}return true}if(L.name==="delete"){if(y<g.length){let h=g.slice(0,y)+g.slice(y+1);D(h,y);}return true}if(L.name.length>1)return false;let F=L.sequence;if(F.length===1&&F.charCodeAt(0)>=32){let{type:h}=$.current;if(h==="number"){let V=/[0-9]/.test(F),Q=F==="."&&!g.includes("."),A=F==="-"&&y===0&&!g.includes("-");if(!V&&!Q&&!A)return true}let N=g.slice(0,y)+F+g.slice(y);return D(N,y+1),true}return false};return k.registerInputHandler(O,j)},[k,H]);let z={...c,...P&&l?l:{}};return ee.createElement("input",{style:z,value:w,defaultValue:n,placeholder:i,onChange:r,cursorPosition:I,multiline:a??false,focused:P,ref:O=>{O?(B.current=O,C.current=O.focusId,_(true)):(B.current=null,C.current=null,_(false));}})}function ft({trap:e=false,children:t}){let n=useContext(q),r=useRef(null),o=useRef(new Set);return useLayoutEffect(()=>{if(!e||!n)return;r.current=n.focusedId;let s=n.pushTrap(o.current);return ()=>{s(),r.current&&n.requestFocus(r.current);}},[e,n]),useEffect(()=>{if(!(!e||!n)&&o.current.size>0){let s=o.current.values().next().value;s&&n.requestFocus(s);}},[e,n]),ee.createElement(ee.Fragment,null,t)}function Rr({size:e}){return ee.createElement("box",{style:{flexGrow:e??1}})}function hn(e){let t=e.toLowerCase().split("+");return {name:t[t.length-1],ctrl:t.includes("ctrl"),alt:t.includes("alt"),shift:t.includes("shift"),meta:t.includes("meta")||t.includes("cmd")||t.includes("super")||t.includes("win")}}function gn(e,t){return !(t.name!==e.name||e.ctrl!==!!t.ctrl||e.alt!==!!t.alt||e.shift!==!!t.shift||e.meta!==!!t.meta)}function Ir({keypress:e,onPress:t,whenFocused:n,priority:r,disabled:o}){let s=useContext(Y),i=useContext(q),c=useRef(t);c.current=t;let l=useRef(hn(e));return l.current=hn(e),useEffect(()=>{if(!(!s||o))if(r){let a=p=>!gn(l.current,p)||n&&i?.focusedId!==n?false:(c.current(),true);return s.subscribePriority(a)}else {let a=p=>{gn(l.current,p)&&(n&&i?.focusedId!==n||c.current());};return s.subscribe(a)}},[s,i,n,r,o]),null}function Nr({children:e,zIndex:t=1e3}){return ee.createElement("box",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:t}},e)}function Er({onPress:e,style:t,focusedStyle:n,children:r,disabled:o}){let s=useContext(q),i=useContext(Y),c=useRef(null),l=useRef(null),a=useRef(e);a.current=e;let[p,d]=useState(false),[S,v]=useState(false);useEffect(()=>{if(!(!s||!l.current||!c.current||o))return s.register(l.current,c.current)},[s,o,p]),useEffect(()=>{if(!s||!l.current)return;let f=l.current;return v(s.focusedId===f),s.onFocusChange(u=>{v(u===f);})},[s,p]),useEffect(()=>{if(!i||!l.current||o)return;let f=l.current,u=R=>s?.focusedId!==f?false:R.name==="return"||R.name===" "||R.sequence===" "?(a.current?.(),true):false;return i.registerInputHandler(f,u)},[i,s,o,p]);let I={...t,...S&&n?n:{}};return ee.createElement("box",{style:I,focusable:!o,ref:f=>{f?(c.current=f,l.current=f.focusId,d(true)):(c.current=null,l.current=null,d(false));}},r)}var Lr={x:0,y:0,width:0,height:0,innerX:0,innerY:0,innerWidth:0,innerHeight:0};function fe(e){let t=useContext(oe),[n,r]=useState(Lr);return useEffect(()=>{if(!(!t||!e?.current))return r(t.getLayout(e.current)),t.subscribe(e.current,r)},[t,e]),n}function Be(e,t=[]){let n=useContext(Y);useEffect(()=>{if(n)return n.subscribe(e)},[n,...t]);}function Ar({children:e,style:t,scrollOffset:n,onScroll:r,defaultScrollOffset:o=0,scrollStep:s=1,disableKeyboard:i,scrollToFocus:c=true,showScrollbar:l=true,focusable:a=true,focusedStyle:p}){let d=n!==void 0,[S,v]=useState(o),I=d?n:S,f=useRef(null),u=useRef(null),R=fe(f),P=fe(u),E=useContext(q),H=useContext(oe),_=useRef(null);a&&!_.current&&(_.current=`scrollview-${Math.random().toString(36).slice(2,9)}`);let k=a?_.current:null;useEffect(()=>{if(!(!a||!k||!E||!f.current))return E.register(k,f.current)},[a,k,E]);let G=a&&k&&E?.focusedId===k,T=R.innerHeight,B=P.height,C=Math.max(0,B-T),x=Math.max(0,Math.min(I,C)),w=useMemo(()=>({getBounds:()=>{let A=R.y;return {visibleTop:A,visibleBottom:A+T,viewportHeight:T,scrollOffset:x}}}),[R.y,T,x]),b=useCallback(A=>{let re=Math.max(0,Math.min(A,C));d?r?.(re):v(re);},[d,r,C]);useEffect(()=>{I>C&&C>=0&&b(C);},[I,C,b]),useEffect(()=>!c||!E||!H||!u.current?void 0:E.onFocusChange(re=>{if(!re||!u.current)return;let Z=Ke=>{if(Ke.focusId===re)return Ke;for(let We of Ke.children){let ye=Z(We);if(ye)return ye}return null},pe=Z(u.current);if(!pe)return;let ge=H.getLayout(pe),Re=u.current.layout?.y??0,Oe=ge.y-Re,De=Oe+ge.height,ve=I,ot=I+T;Oe<ve?b(Oe):De>ot&&b(De-T);}),[c,E,H,I,T,b]);let M=useCallback(()=>{if(!E)return false;let A=E.focusedId;if(!A)return false;if(a&&k&&A===k)return true;if(!u.current)return false;let re=Z=>{if(Z.focusId===A)return true;for(let pe of Z.children)if(re(pe))return true;return false};return re(u.current)},[E,a,k]);Be(A=>{if(i||!M())return;let re=Math.max(1,Math.floor(T/2)),Z=Math.max(1,T);switch(A.name){case "pageup":b(I-Z);break;case "pagedown":b(I+Z);break;default:A.ctrl&&(A.name==="d"?b(I+re):A.name==="u"?b(I-re):A.name==="f"?b(I+Z):A.name==="b"&&b(I-Z));break}},[I,s,T,C,i,b,M]);let{padding:$,paddingX:K,paddingY:z,paddingTop:O,paddingRight:j,paddingBottom:L,paddingLeft:X,...J}=t??{},le=J.border!=null&&J.border!=="none"?2:0,m=B>0?B+le:void 0,g={...J,...G?p:{},clip:true,...J.height===void 0&&m!==void 0?{height:m,flexShrink:J.flexShrink??1,minHeight:J.minHeight??0}:{}},y={position:"absolute",top:-x,left:0,right:0,flexDirection:"column",...$!==void 0&&{padding:$},...K!==void 0&&{paddingX:K},...z!==void 0&&{paddingY:z},...O!==void 0&&{paddingTop:O},...j!==void 0&&{paddingRight:j},...L!==void 0&&{paddingBottom:L},...X!==void 0&&{paddingLeft:X}},D=B>T&&T>0,W=l&&D,F=Math.max(1,Math.floor(T/B*T)),h=B-T,N=h>0?Math.floor(x/h*(T-F)):0,V=[];if(W)for(let A=0;A<T;A++)A>=N&&A<N+F?V.push("\u2588"):V.push("\u2591");let Q={position:"absolute",top:0,right:0,width:1,height:T,flexDirection:"column"};return ee.createElement(Ye.Provider,{value:w},ee.createElement("box",{style:g,ref:A=>{f.current=A??null;},...a?{focusable:true,focusId:k}:{}},ee.createElement("box",{style:{...y,paddingRight:W?(y.paddingRight??0)+1:y.paddingRight},ref:A=>{u.current=A??null;}},e),W&&ee.createElement("box",{style:Q},ee.createElement("text",{style:{color:"blackBright"}},V.join(`
14
+ `)))))}function Ct({count:e,renderItem:t,selectedIndex:n,onSelectionChange:r,onSelect:o,defaultSelectedIndex:s=0,disabledIndices:i,style:c,focusable:l=true}){let a=n!==void 0,[p,d]=useState(s),S=a?n:p,v=useContext(q),I=useContext(Y),f=useRef(null),u=useRef(null),R=useRef(o);R.current=o;let[P,E]=useState(false),[H,_]=useState(false),k=useRef(null),G=useCallback(x=>{let w=Math.max(0,Math.min(x,e-1));a?r?.(w):d(w);},[a,r,e]),T=useCallback((x,w)=>{if(!i||i.size===0)return Math.max(0,Math.min(x+w,e-1));let b=x+w;for(;b>=0&&b<e&&i.has(b);)b+=w;return b<0||b>=e?x:b},[i,e]);useEffect(()=>{if(!(!v||!u.current||!f.current||!l))return v.register(u.current,f.current)},[v,l,P]),useEffect(()=>{if(!v||!u.current)return;let x=u.current;return _(v.focusedId===x),v.onFocusChange(w=>{_(w===x);})},[v,P]);let B=useCallback(x=>{let w=x?e-1:0,b=x?-1:1,M=w;for(;M>=0&&M<e&&i?.has(M);)M+=b;return M>=0&&M<e?M:x?e-1:0},[i,e]);useEffect(()=>{if(!I||!u.current||!l)return;let x=u.current,w=b=>v?.focusedId!==x?false:b.name==="g"&&!b.ctrl&&!b.alt?k.current==="g"?(G(B(false)),k.current=null,true):(k.current="g",true):b.name==="G"||b.name==="g"&&b.shift?(k.current=null,G(B(true)),true):(k.current=null,b.name==="up"||b.name==="k"?(G(T(S,-1)),true):b.name==="down"||b.name==="j"?(G(T(S,1)),true):b.name==="return"?(i?.has(S)||R.current?.(S),true):false);return I.registerInputHandler(x,w)},[I,v,l,S,G,T,B,i,P]);let C=[];for(let x=0;x<e;x++)C.push(ee.createElement(ee.Fragment,{key:x},t({index:x,selected:x===S,focused:H})));return ee.createElement("box",{style:{flexDirection:"column",...c},focusable:l,ref:x=>{x?(f.current=x,u.current=x.focusId,E(true)):(f.current=null,u.current=null,E(false));}},...C)}function jr({items:e,selectedIndex:t,onSelectionChange:n,onSelect:r,defaultSelectedIndex:o=0,style:s,highlightColor:i="cyan",focusable:c=true}){let l=new Set;for(let p=0;p<e.length;p++)e[p].disabled&&l.add(p);let a=p=>{let d=e[p];d&&!d.disabled&&r?.(d.value,p);};return ee.createElement(Ct,{count:e.length,selectedIndex:t,onSelectionChange:n,onSelect:a,defaultSelectedIndex:o,disabledIndices:l.size>0?l:void 0,style:s,focusable:c,renderItem:({index:p,selected:d,focused:S})=>{let v=e[p],I=v.disabled,f=d&&S,u=d?">":" ";return ee.createElement("box",{style:{flexDirection:"row",...f?{bg:i}:{}}},ee.createElement("text",{style:f?{bold:true,color:"black"}:I?{dim:true}:{}},`${u} ${v.label}`))}})}function Wr({value:e,indeterminate:t=false,width:n="100%",label:r,showPercent:o=false,style:s,filled:i="\u2588",empty:c="\u2591"}){let l=useRef(null),p=fe(l).innerWidth,[d,S]=useState(0);useEffect(()=>{if(!t)return;let R=setInterval(()=>{S(P=>(P+1)%Math.max(1,p+6));},100);return ()=>clearInterval(R)},[t,p]);let v=Math.max(0,Math.min(1,e??0)),I=o?` ${Math.round(v*100)}%`:"",f="";if(p>0)if(t&&e===void 0){let R=Math.max(1,Math.min(3,Math.floor(p/4))),P=[];for(let E=0;E<p;E++)E>=d-R&&E<d?P.push(i):P.push(c);f=P.join("");}else {let R=Math.round(v*p);f=i.repeat(R)+c.repeat(p-R);}let u=[];return r&&u.push(ee.createElement("text",{key:"label",style:{bold:true}},r+" ")),u.push(ee.createElement("box",{key:"track",style:{flexGrow:1,flexShrink:1},ref:R=>{l.current=R??null;}},ee.createElement("text",{key:"bar",style:{}},f))),o&&u.push(ee.createElement("text",{key:"pct",style:{bold:true}},I)),ee.createElement("box",{style:{flexDirection:"row",width:n,...s}},...u)}var qr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function zr({frames:e=qr,intervalMs:t=80,label:n,style:r}){let[o,s]=useState(0);useEffect(()=>{let c=setInterval(()=>{s(l=>(l+1)%e.length);},t);return ()=>clearInterval(c)},[e.length,t]);let i=[ee.createElement("text",{key:"frame",style:r},e[o])];return n&&i.push(ee.createElement("text",{key:"label",style:{}}," "+n)),ee.createElement("box",{style:{flexDirection:"row"}},...i)}var Rn=createContext(null),Qr=0;function eo(){let e=useContext(Rn);if(!e)throw new Error("useToast must be used within a <ToastHost>");return e.push}var to={info:{bg:"blackBright",title:"cyanBright",text:"white"},success:{bg:"blackBright",title:"greenBright",text:"white"},warning:{bg:"blackBright",title:"yellowBright",text:"white"},error:{bg:"blackBright",title:"redBright",text:"white"}};function no({position:e="bottom-right",maxVisible:t=5,children:n}){let[r,o]=useState([]),s=useRef(new Map),i=useCallback(v=>{let I=`toast-${Qr++}`,f={id:I,durationMs:3e3,variant:"info",...v};if(o(u=>[...u,f]),f.durationMs&&f.durationMs>0){let u=setTimeout(()=>{s.current.delete(I),o(R=>R.filter(P=>P.id!==I));},f.durationMs);s.current.set(I,u);}},[]);useEffect(()=>()=>{for(let v of s.current.values())clearTimeout(v);s.current.clear();},[]);let c=useRef({push:i});c.current.push=i;let l=e.startsWith("top"),a=e.endsWith("right"),p={position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:900,flexDirection:"column",justifyContent:l?"flex-start":"flex-end",alignItems:a?"flex-end":"flex-start",padding:1},S=r.slice(-t).map(v=>{let I=v.variant??"info",f=to[I],u=[];return v.title&&u.push(ee.createElement("text",{key:"title",style:{bold:true,color:f.title}},v.title)),u.push(ee.createElement("text",{key:"msg",style:{color:f.text}},v.message)),ee.createElement("box",{key:v.id,style:{bg:f.bg,paddingX:1,flexDirection:"column",minWidth:20,maxWidth:50}},...u)});return ee.createElement(Rn.Provider,{value:c.current},n,S.length>0?ee.createElement("box",{style:p},...S):null)}function oo({items:e,value:t,onChange:n,placeholder:r="Select...",style:o,focusedStyle:s,dropdownStyle:i,highlightColor:c="cyan",maxVisible:l=8,searchable:a=true,disabled:p}){let d=useContext(q),S=useContext(Y),v=useContext(be),I=useContext(Ye),f=useRef(null),u=useRef(null),R=useRef(n);R.current=n;let[P,E]=useState(false),[H,_]=useState(false),[k,G]=useState(false),[T,B]=useState(0),[C,x]=useState(""),[w,b]=useState(0),M=fe(f),$=v?.rows??24,K=I?.getBounds(),O=e.find(F=>F.value===t)?.label??"",j=useMemo(()=>{if(!C)return e;let F=C.toLowerCase();return e.filter(h=>h.label.toLowerCase().includes(F))},[e,C]),L=Math.min(l,j.length),X=j.slice(w,w+L);useEffect(()=>{B(0),b(0);},[C]),useEffect(()=>{!H&&k&&(G(false),x(""));},[H,k]),useEffect(()=>{if(!(!d||!u.current||!f.current))return d.register(u.current,f.current)},[d,P]),useEffect(()=>{!d||!u.current||d.setSkippable(u.current,!!p);},[d,p,P]),useEffect(()=>{if(!d||!u.current)return;let F=u.current;return _(d.focusedId===F),d.onFocusChange(h=>{_(h===F);})},[d,P]);let J=useCallback((F,h)=>{let N=F+h;for(;N>=0&&N<j.length;){if(!j[N].disabled)return N;N+=h;}return F},[j]),se=useCallback(F=>{F<w?b(F):F>=w+L&&b(F-L+1);},[w,L]);useEffect(()=>{if(!S||!u.current||p)return;let F=u.current,h=N=>{if(d?.focusedId!==F)return false;if(!k){if(N.name==="return"||N.name===" "||N.sequence===" "||N.name==="down"){G(true),x("");let V=j.findIndex(A=>A.value===t),Q=V>=0?V:0;return B(Q),b(Math.max(0,Q-Math.floor(l/2))),true}return false}if(N.name==="tab")return G(false),x(""),false;if(N.name==="escape")return G(false),x(""),true;if(N.name==="return"){let V=j[T];return V&&!V.disabled&&(R.current?.(V.value),G(false),x("")),true}if(N.name==="up"){let V=J(T,-1);return B(V),se(V),true}if(N.name==="down"){let V=J(T,1);return B(V),se(V),true}if(N.name==="backspace")return a&&C.length>0&&x(V=>V.slice(0,-1)),true;if(N.name==="home"){let V=J(-1,1);return B(V),se(V),true}if(N.name==="end"){let V=J(j.length,-1);return B(V),se(V),true}if(a&&N.sequence&&N.sequence.length===1&&!N.ctrl&&!N.alt){let V=N.sequence;if(V>=" "&&V<="~")return x(Q=>Q+V),true}return true};return S.registerInputHandler(F,h)},[S,d,p,k,T,j,t,l,a,C,J,se,P]);let m={flexDirection:"row",width:"100%",...!o?.bg&&o?.border===void 0?{border:"single"}:{},...o,...H&&s?s:{}},g=O?o?.color??void 0:"blackBright",y=[ee.createElement("text",{key:"label",style:{flexGrow:1,flexShrink:1,color:g,wrap:"ellipsis",...O?{}:{dim:true}}},O||r),ee.createElement("text",{key:"arrow",style:{flexShrink:0,color:H?c:"blackBright"}},k?" \u25B2":" \u25BC")],D=null;if(k){let F=[];a&&C&&F.push(ee.createElement("box",{key:"search",style:{paddingX:1}},ee.createElement("text",{style:{color:"blackBright",dim:true}},`/${C}`))),j.length===0&&F.push(ee.createElement("box",{key:"empty",style:{paddingX:1}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"No matches"))),w>0&&F.push(ee.createElement("box",{key:"scroll-up",style:{justifyContent:"center",alignItems:"center"}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"\u25B2"))),X.forEach((ve,ot)=>{let We=w+ot===T,ye=ve.disabled,Mn={paddingX:1,...We&&!ye?{bg:c}:{}},Vn={...We&&!ye?{color:"black",bold:true}:{},...ye?{dim:true,color:"blackBright"}:{}};F.push(ee.createElement("box",{key:`item-${ve.value}`,style:Mn},ee.createElement("text",{style:Vn},ve.label)));}),w+L<j.length&&F.push(ee.createElement("box",{key:"scroll-down",style:{justifyContent:"center",alignItems:"center"}},ee.createElement("text",{style:{dim:true,color:"blackBright"}},"\u25BC")));let h=w>0,N=w+L<j.length,V=a&&C,Q=j.length===0,A=!i?.bg&&i?.border===void 0,Z=L+(A?2:0);h&&(Z+=1),N&&(Z+=1),V&&(Z+=1),Q&&(Z+=1);let pe=M.y+M.height,ge,Re;K?(ge=K.visibleBottom-pe,Re=M.y-K.visibleTop):(ge=$-pe,Re=M.y);let De=ge<Z&&Re>=Z?-Z:M.height||1;D=ee.createElement("box",{style:{position:"absolute",top:De,left:0,right:0,zIndex:9999,...A?{border:"single"}:{},bg:"black",flexDirection:"column",...i}},...F);}let W={flexDirection:"column",width:m.width??"100%",minWidth:m.minWidth,maxWidth:m.maxWidth,flexGrow:m.flexGrow,flexShrink:m.flexShrink??1};return ee.createElement("box",{style:W},ee.createElement("box",{style:m,focusable:true,ref:F=>{F?(f.current=F,u.current=F.focusId,E(true)):(f.current=null,u.current=null,E(false));}},...y),D)}function so({checked:e,onChange:t,label:n,style:r,focusedStyle:o,disabled:s,checkedChar:i="\u2713",uncheckedChar:c=" "}){let l=useContext(q),a=useContext(Y),p=useRef(null),d=useRef(null),S=useRef(t);S.current=t;let v=useRef(e);v.current=e;let[I,f]=useState(false),[u,R]=useState(false);useEffect(()=>{if(!(!l||!d.current||!p.current||s))return l.register(d.current,p.current)},[l,s,I]),useEffect(()=>{if(!l||!d.current)return;let k=d.current;return R(l.focusedId===k),l.onFocusChange(G=>{R(G===k);})},[l,I]),useEffect(()=>{if(!a||!d.current||s)return;let k=d.current,G=T=>l?.focusedId!==k?false:T.name==="return"||T.name===" "||T.sequence===" "?(S.current(!v.current),true):false;return a.registerInputHandler(k,G)},[a,l,s,I]);let P={flexDirection:"row",gap:1,...r,...u&&o?o:{}},E=e?i:c,H={color:s?"blackBright":u?"white":r?.color},_={color:s?"blackBright":r?.color};return ee.createElement("box",{style:P,focusable:!s,ref:k=>{k?(p.current=k,d.current=k.focusId,f(true)):(p.current=null,d.current=null,f(false));}},ee.createElement("text",{key:"box",style:H},`[${E}]`),n?ee.createElement("text",{key:"label",style:_},n):null)}function lo({items:e,value:t,onChange:n,style:r,itemStyle:o,focusedItemStyle:s,selectedItemStyle:i,disabled:c,direction:l="column",gap:a=0,selectedChar:p="\u25CF",unselectedChar:d="\u25CB"}){let S=useContext(q),v=useContext(Y),I=useRef(null),f=useRef(null),u=useRef(n);u.current=n;let[R,P]=useState(false),[E,H]=useState(false),[_,k]=useState(()=>{let C=e.findIndex(x=>x.value===t);return C>=0?C:e.findIndex(x=>!x.disabled)}),G=useCallback((C,x)=>{let w=C;for(let b=0;b<e.length;b++)if(w=(w+x+e.length)%e.length,!e[w]?.disabled)return w;return C},[e]);useEffect(()=>{if(!(!S||!f.current||!I.current||c))return S.register(f.current,I.current)},[S,c,R]),useEffect(()=>{if(!S||!f.current)return;let C=f.current;return H(S.focusedId===C),S.onFocusChange(x=>{H(x===C);})},[S,R]),useEffect(()=>{if(!v||!f.current||c)return;let C=f.current,x=w=>{if(S?.focusedId!==C)return false;if(w.name==="up"||w.name==="left"||w.name==="k"||w.name==="tab"&&w.shift)return k(b=>G(b,-1)),true;if(w.name==="down"||w.name==="right"||w.name==="j"||w.name==="tab"&&!w.shift)return k(b=>G(b,1)),true;if(w.name==="return"||w.name===" "||w.sequence===" "){let b=e[_];return b&&!b.disabled&&u.current(b.value),true}return false};return v.registerInputHandler(C,x)},[v,S,c,e,_,G,R]),useEffect(()=>{let C=e.findIndex(x=>x.value===t);C>=0&&k(C);},[t,e]);let T={flexDirection:l,gap:a,...r},B=e.map((C,x)=>{let w=C.value===t,b=x===_,M=c||C.disabled,$=w?p:d,K={flexDirection:"row",gap:1,...o};w&&i&&(K={...K,...i}),E&&b&&s&&(K={...K,...s});let z=M?"blackBright":E&&b?s?.color??"white":w?i?.color??o?.color:o?.color;return ee.createElement("box",{key:x,style:K},ee.createElement("text",{key:"radio",style:{color:z}},`(${$})`),ee.createElement("text",{key:"label",style:{color:z}},C.label))});return ee.createElement("box",{style:T,focusable:!c,ref:C=>{C?(I.current=C,f.current=C.focusId,P(true)):(I.current=null,f.current=null,P(false));}},...B)}var kn=createContext(null);function uo(){let e=useContext(kn);if(!e)throw new Error("useDialog must be used within a DialogHost");return e}function ao({children:e}){let[t,n]=useState([]),r=useRef(0),o=useCallback((a,p)=>new Promise(d=>{let S=++r.current;n(v=>[...v,{id:S,type:"alert",content:a,okText:p?.okText??"OK",cancelText:"",style:p?.style,resolve:()=>d()}]);}),[]),s=useCallback((a,p)=>new Promise(d=>{let S=++r.current;n(v=>[...v,{id:S,type:"confirm",content:a,okText:p?.okText??"OK",cancelText:p?.cancelText??"Cancel",style:p?.style,resolve:d}]);}),[]),i=useCallback((a,p)=>{n(d=>{let S=d.find(v=>v.id===a);return S&&S.resolve(p),d.filter(v=>v.id!==a)});},[]),c={alert:o,confirm:s},l=t[t.length-1];return ee.createElement(kn.Provider,{value:c},e,l&&ee.createElement(fo,{key:l.id,dialog:l,onDismiss:i}))}function fo({dialog:e,onDismiss:t}){let n=useContext(q),r=useRef(null),o=useRef(null),s=useRef(null),i=useRef(null),[c,l]=useState("ok"),[a,p]=useState(0);useEffect(()=>{if(!n||a===0)return;let u=[];return r.current&&s.current&&u.push(n.register(s.current,r.current)),o.current&&i.current&&u.push(n.register(i.current,o.current)),s.current&&n.requestFocus(s.current),()=>u.forEach(R=>R())},[n,a]),useEffect(()=>{if(n)return n.onFocusChange(u=>{u===s.current?l("ok"):u===i.current&&l("cancel");})},[n]),Be(u=>{if(u.name==="return"||u.name==="space"){e.type==="alert"?t(e.id,true):t(e.id,c==="ok");return}if(u.name==="escape"){t(e.id,false);return}e.type==="confirm"&&n&&(u.name==="left"||u.name==="right")&&(c==="ok"&&i.current?n.requestFocus(i.current):s.current&&n.requestFocus(s.current));},[e,c,n,t]);let d=typeof e.content=="string",S=d?e.content.length:0,I={minWidth:Math.max(20,d?Math.min(S+6,50):30),maxWidth:50,bg:"black",border:"round",borderColor:"white",padding:1,flexDirection:"column",gap:1,...e.style},f=u=>({paddingX:2,bg:u?"white":"blackBright",color:u?"black":"white",bold:u});return ee.createElement(ft,{trap:true},ee.createElement("box",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:999}}),ee.createElement("box",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center",zIndex:1e3}},ee.createElement("box",{style:I},ee.createElement("box",{style:{flexDirection:"column"}},typeof e.content=="string"?ee.createElement("text",null,e.content):e.content),ee.createElement("box",{style:{flexDirection:"row",justifyContent:"flex-end",gap:1}},e.type==="confirm"&&ee.createElement("box",{style:f(c==="cancel"),focusable:true,ref:u=>{u&&u.focusId&&!i.current&&(o.current=u,i.current=u.focusId,p(R=>R+1));}},ee.createElement("text",null,e.cancelText)),ee.createElement("box",{style:f(c==="ok"),focusable:true,ref:u=>{u&&u.focusId&&!s.current&&(r.current=u,s.current=u.focusId,p(R=>R+1));}},ee.createElement("text",null,e.okText))))))}function ho(e,t){let n=[],r=t.split("");if(e<=r.length)for(let o=0;o<e;o++)n.push(r[o]);else for(let o=0;o<r.length&&n.length<e;o++)for(let s=0;s<r.length&&n.length<e;s++)n.push(r[o]+r[s]);return n}function go({children:e,activationKey:t="ctrl+o",hintStyle:n,hintBg:r="yellow",hintFg:o="black",hintChars:s="asdfghjklqwertyuiopzxcvbnm",enabled:i=true,debug:c=false}){let l=c?(...C)=>console.error("[JumpNav]",...C):()=>{},[a,p]=useState(false),[d,S]=useState(""),[v,I]=useState([]),f=useContext(Y),u=useContext(q),R=useContext(oe);useEffect(()=>{l("Mounted, inputCtx:",!!f,"focusCtx:",!!u,"enabled:",i);},[]);let E=useCallback(C=>{let x=C.toLowerCase().split("+");return {ctrl:x.includes("ctrl"),alt:x.includes("alt"),shift:x.includes("shift"),meta:x.includes("meta"),name:x[x.length-1]??""}},[])(t),H=useCallback(()=>{if(!u?.getActiveElements){l("refreshElements: no getActiveElements");return}let C=u.getActiveElements();l("getActiveElements returned",C.length,"elements");let x=C.map(({id:w,node:b})=>({id:w,node:b,layout:R?.getLayout(b)??b.layout}));x.sort((w,b)=>w.layout.y!==b.layout.y?w.layout.y-b.layout.y:w.layout.x-b.layout.x),I(x);},[u,R,l]),_=useRef(false);useEffect(()=>{a&&!_.current&&(l("Activated! Refreshing elements..."),H()),_.current=a;},[a,H,l]);let k=v.filter(C=>C.layout.width>0&&C.layout.height>0),G=ho(k.length,s),T=useMemo(()=>{let C=new Map;return k.forEach((x,w)=>{G[w]&&C.set(G[w],x.id);}),C},[k,G]);useEffect(()=>{if(!f||!i){l("Not subscribing - inputCtx:",!!f,"enabled:",i);return}l("Subscribing to priority input, activation key:",t);let C=x=>{let w=x.name===E.name,b=!!x.ctrl===E.ctrl,M=!!x.alt===E.alt,$=!!x.shift===E.shift,K=!!x.meta===E.meta;if(!a&&w&&b&&M&&$&&K)return l("Activation key matched! Activating..."),p(true),S(""),true;if(a){if(x.name==="escape")return l("Escape pressed, deactivating"),p(false),S(""),true;if(x.name==="backspace")return S(""),true;if(x.sequence&&x.sequence.length===1&&/[a-z]/i.test(x.sequence)){let z=d+x.sequence.toLowerCase();l("Buffer:",z);let O=T.get(z);return O?(l("Jumping to",O),u?.requestFocus(O),p(false),S(""),true):[...T.keys()].some(L=>L.startsWith(z))?(S(z),true):(S(""),true)}return true}return false};return f.subscribePriority(C)},[f,i,a,E,d,T,u,t,l]);let B=a?ee.createElement("box",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:99998}},...k.map((C,x)=>{let w=G[x];if(!w)return null;let{x:b,y:M}=C.layout,$=w.startsWith(d)&&d.length>0;return ee.createElement("box",{key:C.id,style:{position:"absolute",top:M,left:Math.max(0,b-w.length-2),bg:$?"cyan":r,color:o,paddingX:1,zIndex:99999,...n}},ee.createElement("text",{style:{bold:true,color:o}},w))}),ee.createElement("box",{style:{position:"absolute",bottom:0,left:0,right:0,bg:"blackBright",paddingX:1,zIndex:99999}},ee.createElement("text",{style:{color:"white"}},d?`Jump: ${d}_`:"Press a key to jump \u2022 ESC to cancel"))):null;return ee.createElement(ee.Fragment,null,e,B)}function So(e){let t=useContext(q),[n]=useState(()=>`focus-${Math.random().toString(36).slice(2,9)}`),r=t?t.focusedId===n:false;useEffect(()=>{if(!(!t||!e?.current))return e.current.focusId=n,t.register(n,e.current)},[t,n,e]);let o=useMemo(()=>()=>{t?.requestFocus(n);},[t,n]);return {focused:r,focus:o}}function Ro(e={}){let{disabled:t,onFocus:n,onBlur:r,onKeyPress:o}=e,s=useContext(q),i=useContext(Y),c=useRef(null),l=useRef(null),[a,p]=useState(false),d=useRef(n),S=useRef(r),v=useRef(o);d.current=n,S.current=r,v.current=o;let I=useCallback(u=>{c.current=u,u?l.current=u.focusId??null:l.current=null;},[]);useEffect(()=>{if(!(!s||!l.current||!c.current))return s.register(l.current,c.current)},[s]),useEffect(()=>{!s||!l.current||s.setSkippable(l.current,!!t);},[s,t]),useEffect(()=>{if(!s||!l.current)return;let u=l.current,R=s.focusedId===u;return p(R),s.onFocusChange(P=>{let E=P===u;p(H=>(E&&!H?d.current?.():!E&&H&&S.current?.(),E));})},[s]),useEffect(()=>{if(!i||!l.current||t)return;let u=l.current,R=P=>s?.focusedId!==u?false:v.current?.(P)===true;return i.registerInputHandler(u,R)},[i,s,t]);let f=useCallback(()=>{s&&l.current&&s.requestFocus(l.current);},[s]);return {ref:I,isFocused:a,focus:f,focusId:l.current}}function Io(){let e=useContext(be);if(!e)throw new Error("useApp must be used within a Glyph render tree");return {exit:e.exit,get columns(){return e.columns},get rows(){return e.rows}}}function ko(){let e=useContext(q),t=useContext(oe),[n,r]=useState([]),o=useRef(()=>{}),s=useCallback(()=>{if(!e)return;let c=(e.getActiveElements?.()??e.getRegisteredElements?.()??[]).map(({id:l,node:a})=>({id:l,node:a,layout:t?.getLayout(a)??a.layout,type:a.type}));c.sort((l,a)=>l.layout.y!==a.layout.y?l.layout.y-a.layout.y:l.layout.x-a.layout.x),r(c);},[e,t]);return o.current=s,useEffect(()=>{if(!e)return;s();let i=e.onFocusChange(()=>{s();}),c=setTimeout(s,50);return ()=>{i(),clearTimeout(c);}},[e,t,s]),e?{elements:n,focusedId:e.focusedId,requestFocus:e.requestFocus,focusNext:e.focusNext,focusPrev:e.focusPrev,refresh:()=>o.current()}:null}function Fo(e){let t=[];for(let n of e)switch(n){case "9":t.push({type:"digit",char:n});break;case "a":t.push({type:"letter",char:n});break;case "*":t.push({type:"alphanumeric",char:n});break;default:t.push({type:"literal",char:n});break}return t}function Go(e,t){switch(t){case "digit":return /\d/.test(e);case "letter":return /[a-zA-Z]/.test(e);case "alphanumeric":return /[a-zA-Z0-9]/.test(e);case "literal":return true}}function te(e){let t=typeof e=="string"?{mask:e}:e,{mask:n,placeholder:r="_",showPlaceholder:o=false}=t,s=Fo(n);return (i,c)=>{let l=[];for(let d of i)(d!==r&&!/[\s\-\(\)\/\.\:]/.test(d)||/[a-zA-Z0-9]/.test(d))&&/[a-zA-Z0-9]/.test(d)&&l.push(d);let a="",p=0;for(let d of s)if(d.type==="literal")(p<l.length||o)&&(a+=d.char);else if(p<l.length){let S=l[p];if(Go(S,d.type))a+=S,p++;else {p++;continue}}else o&&(a+=r);return a}}var Lo={usPhone:te("(999) 999-9999"),intlPhone:te("+9 999 999 9999"),dateUS:te("99/99/9999"),dateEU:te("99/99/9999"),dateISO:te("9999-99-99"),time:te("99:99"),timeFull:te("99:99:99"),creditCard:te("9999 9999 9999 9999"),ssn:te("999-99-9999"),zip:te("99999"),zipPlus4:te("99999-9999"),ipv4:te("999.999.999.999"),mac:te("**:**:**:**:**:**")};export{dr as Box,Er as Button,so as Checkbox,ao as DialogHost,ft as FocusScope,xr as Input,go as JumpNav,Ir as Keybind,Ct as List,jr as Menu,Nr as Portal,Wr as Progress,lo as Radio,Ar as ScrollView,oo as Select,Rr as Spacer,zr as Spinner,gr as Text,no as ToastHost,te as createMask,Lo as masks,ar as render,Io as useApp,uo as useDialog,So as useFocus,ko as useFocusRegistry,Ro as useFocusable,Be as useInput,fe as useLayout,eo as useToast};//# sourceMappingURL=index.js.map
15
15
  //# sourceMappingURL=index.js.map