@nick-skriabin/glyph 0.1.46 → 0.1.48

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
@@ -717,23 +717,36 @@ render(<App />, { useNativeCursor: false });
717
717
 
718
718
  ## Examples
719
719
 
720
+ Interactive examples are included in the repo. Each demonstrates different components and patterns:
721
+
722
+ | Example | Description | Source |
723
+ |---------|-------------|--------|
724
+ | **basic-layout** | Flexbox layout fundamentals | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/basic-layout) |
725
+ | **modal-input** | Modal dialogs, input focus trapping | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/modal-input) |
726
+ | **scrollview-demo** | Scrollable content with keyboard navigation | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/scrollview-demo) |
727
+ | **list-demo** | Keyboard-navigable lists | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/list-demo) |
728
+ | **menu-demo** | Styled menus with icons | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/menu-demo) |
729
+ | **select-demo** | Dropdown select with search | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/select-demo) |
730
+ | **forms-demo** | Checkbox and Radio inputs | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/forms-demo) |
731
+ | **masked-input** | Input masks (phone, credit card, SSN) | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/masked-input) |
732
+ | **dialog-demo** | Alert and Confirm dialogs | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/dialog-demo) |
733
+ | **jump-nav** | Quick navigation with keyboard hints | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/jump-nav) |
734
+ | **showcase** | Progress bars, Spinners, Toasts | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/showcase) |
735
+ | **dashboard** | Full task manager (all components) | [View →](https://github.com/nick-skriabin/glyph/tree/main/examples/dashboard) |
736
+
737
+ ### Running Examples Locally
738
+
720
739
  ```bash
721
740
  # Clone and install
722
- git clone <repo-url> && cd glyph
723
- pnpm install && pnpm build
724
-
725
- # Run examples
726
- pnpm --filter basic-layout dev # Flexbox layout demo
727
- pnpm --filter modal-input dev # Modal, input, focus trapping
728
- pnpm --filter scrollview-demo dev # Scrollable content
729
- pnpm --filter list-demo dev # Keyboard-navigable list
730
- pnpm --filter menu-demo dev # Styled menu
731
- pnpm --filter select-demo dev # Dropdown select with search
732
- pnpm --filter forms-demo dev # Checkbox and Radio inputs
733
- pnpm --filter masked-input dev # Input masks (phone, credit card, etc.)
734
- pnpm --filter dialog-demo dev # Alert and Confirm dialogs
735
- pnpm --filter dashboard dev # Full task manager (all components)
736
- pnpm --filter showcase dev # Progress, Spinner, Toasts
741
+ git clone https://github.com/nick-skriabin/glyph.git && cd glyph
742
+ bun install && bun run build
743
+
744
+ # Run any example
745
+ bun run --filter <example-name> dev
746
+
747
+ # e.g.
748
+ bun run --filter dashboard dev
749
+ bun run --filter jump-nav dev
737
750
  ```
738
751
 
739
752
  ---
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import te,{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 Bt(){return `glyph-focus-${Hn++}`}function Lt(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?Bt():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 Lt(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),u=parseInt(c[2]??"0",10);i={name:At(u),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),u=parseInt(c[1]??"1",10);i={name:At(l),sequence:s},qe(i,u);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 ke=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,u){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:u});}fillRect(t,n,r,o,s,i,c){for(let l=n;l<n+o;l++)for(let u=t;u<t+r;u++)this.setChar(u,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
2
  `);if(n===MeasureMode.Undefined||r==="none"){let l=0;for(let u of o){let f=ue(u);f>l&&(l=f);}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 u=ue(l);u>c&&(c=u);}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],u=c===e.length,f=l===" ";if(u||f){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 m of s){let S=ue(m);o+S>t&&r.length>0&&(n.push(r),r="",o=0),r+=m,o+=S;}s="",i=0;}f&&(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:u,innerWidth:f,innerHeight:m}=e.layout,S=e.style;if(i<=0||c<=0)return;let v=_e(e).bg;if(S.bg)for(let p=s;p<s+c;p++)for(let h=o;h<o+i;h++)Xe(h,p,n)&&t.setChar(h,p," ",void 0,S.bg);let a=S.border?qt(S.border):null;if(a&&i>=2&&c>=2){let p=S.borderColor,h=v;ie(t,n,o,s,a.topLeft,p,h);for(let I=o+1;I<o+i-1;I++)ie(t,n,I,s,a.horizontal,p,h);ie(t,n,o+i-1,s,a.topRight,p,h),ie(t,n,o,s+c-1,a.bottomLeft,p,h);for(let I=o+1;I<o+i-1;I++)ie(t,n,I,s+c-1,a.horizontal,p,h);ie(t,n,o+i-1,s+c-1,a.bottomRight,p,h);for(let I=s+1;I<s+c-1;I++)ie(t,n,o,I,a.vertical,p,h),ie(t,n,o+i-1,I,a.vertical,p,h);}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,u,f){Xe(n,r,t)&&e.setChar(n,r,o,s,i,c,l,u,f);}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 u=Ut(c.color,c.bg),f=e.style.wrap??"wrap",m=e.style.textAlign??"left",S=l.split(`
3
3
  `),R=ce(S,s,f);for(let v=0;v<R.length&&v<i;v++){let a=R[v],p=ue(a),h=0;m==="center"?h=Math.max(0,Math.floor((s-p)/2)):m==="right"&&(h=Math.max(0,s-p));let I=0;for(let P of a){let j=ue(P);j>0&&ie(t,n,r+h+I,o+v,P,u,c.bg,c.bold,c.dim,c.italic,c.underline),I+=j;}}}function Qn(e,t,n,r={}){let{cursorInfo:o,useNativeCursor:s}=r,{innerX:i,innerY:c,innerWidth:l,innerHeight:u}=e.layout;if(l<=0||u<=0)return;let f=e.props.value??e.props.defaultValue??"",m=e.props.placeholder??"",S=f||m,R=!f&&!!m,v=e.props.multiline??false,a=_e(e),p=Ut(a.color,a.bg),h=a.bg?ze(a.bg)?"blackBright":"whiteBright":"blackBright",I=R?h:p??a.color??e.style.color,P=R?h:I,j=R?true:a.dim,K=o&&o.nodeId===e.focusId,E;if(v&&!R){let G=e.style.wrap??"wrap",T=S.split(`
4
- `),M=ce(T,l,G),b=0,y=0;if(K){let x=o.position,V=0,z=x,O=0;for(let J=0;J<T.length;J++){let B=T[J].length;if(x<=O+B){V=J,z=x-O;break}O+=B+1;}let W=0;for(let J=0;J<V;J++)W+=ce([T[J]],l,G).length;let Y=ce([T[V]],l,G),X=0,_=0;for(let J=0;J<Y.length;J++){let B=Y[J];if(z<=X+B.length){_=J;break}X+=B.length;}b=W+_,y=ue(T[V].slice(X,X+(z-X)));}let C=Math.max(0,b-u+1);for(let x=0;x<u;x++){let V=C+x;if(V>=M.length)break;let z=M[V],O=0;for(let W of z){if(O>=l)break;let Y=ue(W);Y>0&&ie(t,n,i+O,c+x,W,P,a.bg,a.bold,j,a.italic,a.underline),O+=Y;}}if(K){let x=b-C;if(x>=0&&x<u){let V=Math.min(y,l-1),z=i+V,O=c+x;if(Xe(z,O,n)&&z<i+l)if(s)E={cursorPosition:{x:z,y:O,bg:a.bg}};else {let W=t.get(z,O),Y=W?.ch&&W.ch!==" "?W.ch:"\u258C",X=a.bg??"black",_=a.color??"white";t.setChar(z,O,Y,X,_,W?.bold,W?.dim,W?.italic,false);}}}}else {let G=0;for(let T of S){if(G>=l)break;let M=ue(T);M>0&&ie(t,n,i+G,c,T,P,a.bg,a.bold,j,a.italic,a.underline),G+=M;}if(K){let T=Math.min(o.position,l-1),M=i+T;if(Xe(M,c,n)&&M<i+l)if(s)E={cursorPosition:{x:M,y:c,bg:a.bg}};else {let b=t.get(M,c),y=b?.ch&&b.ch!==" "?b.ch:"\u258C",C=a.bg??"black",x=a.color??"white";t.setChar(M,c,y,C,x,b?.bold,b?.dim,b?.italic,false);}}}return E}var er="\x1B",me=`${er}[`;function tr(e,t){return `${me}${t+1};${e+1}H`}function nr(e){let t=`${me}0m`;return e.bold&&(t+=`${me}1m`),e.dim&&(t+=`${me}2m`),e.italic&&(t+=`${me}3m`),e.underline&&(t+=`${me}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 u=t.get(l,c);if(!n){let m=e.get(l,c);if(m&&t.cellsEqual(u,m))continue}(s!==c||o!==l)&&(r+=tr(l,c));let f=nr(u);f!==i&&(r+=f,i=f),r+=u.ch,o=l+1,s=c;}return r.length>0&&(r+=`${me}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,u=e.style.border&&e.style.border!=="none"?1:0,f=r.getComputedPadding(Edge.Top),m=r.getComputedPadding(Edge.Right),S=r.getComputedPadding(Edge.Bottom),R=r.getComputedPadding(Edge.Left),v=s+u+R,a=i+u+f,p=Math.max(0,c-u*2-R-m),h=Math.max(0,l-u*2-f-S);e.layout={x:s,y:i,width:c,height:l,innerX:v,innerY:a,innerWidth:p,innerHeight:h};for(let I of e.children)I.hidden||!I.yogaNode||sn(I,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 Z=createContext(null),q=createContext(null),oe=createContext(null),Ce=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(g=>{_t(g),f=true,x();});let l=new ke(i.columns,i.rows),u=new ke(i.columns,i.rows),f=true,m=new Set,S=new Set,R=new Map,v={subscribe(g){return m.add(g),()=>m.delete(g)},subscribePriority(g){return S.add(g),()=>S.delete(g)},registerInputHandler(g,L){return R.set(g,L),()=>R.delete(g)}},a=null,p=new Map,h=[],I=new Set,P=[],j=new Set;function K(g){if(a!==g){a=g,x();for(let L of j)L(a);}}function E(){let g=[...h];if(P.length>0){let L=P[P.length-1];g=g.filter(N=>L.has(N));}return g=g.filter(L=>!I.has(L)),g.sort((L,N)=>{let w=p.get(L),k=p.get(N);if(!w||!k)return 0;let F=w.layout,$=k.layout;return F.y!==$.y?F.y-$.y:F.x-$.x}),g}let G={get focusedId(){return a},register(g,L){if(p.set(g,L),h.includes(g)||h.push(g),P.length>0&&P[P.length-1].add(g),a===null){let N=E();N.length>0&&K(N[0]);}return ()=>{p.delete(g);let N=h.indexOf(g);if(N!==-1&&h.splice(N,1),a===g){let w=E();K(w[0]??null);}}},requestFocus(g){K(g);},focusNext(){let g=E();if(g.length===0)return;let N=((a?g.indexOf(a):-1)+1)%g.length;K(g[N]);},focusPrev(){let g=E();if(g.length===0)return;let N=((a?g.indexOf(a):0)-1+g.length)%g.length;K(g[N]);},setSkippable(g,L){if(L){if(I.add(g),a===g){let N=E();N.length>0&&K(N[0]);}}else I.delete(g);},trapIds:null,pushTrap(g){return P.push(g),()=>{let L=P.indexOf(g);L!==-1&&P.splice(L,1);}},onFocusChange(g){return j.add(g),()=>{j.delete(g);}},getRegisteredElements(){let g=[];for(let L of h){if(I.has(L))continue;let N=p.get(L);N&&g.push({id:L,node:N});}return g},getActiveElements(){let g=E(),L=[];for(let N of g){if(I.has(N))continue;let w=p.get(N);w&&L.push({id:N,node:w});}return L}},T=new Map,M={getLayout(g){return g.layout},subscribe(g,L){return T.has(g)||T.set(g,new Set),T.get(g).add(L),()=>{let N=T.get(g);N&&(N.delete(L),N.size===0&&T.delete(g));}}},b={registerNode(){},unregisterNode(){},scheduleRender:x,exit(g){le.exit(g);},get columns(){return i.columns},get rows(){return i.rows}},y={type:"root",children:[],onCommit(){x();}},C=false;function x(){C||(C=true,queueMicrotask(()=>{C=false,V();}));}function V(){let g=i.columns,L=i.rows;(u.width!==g||u.height!==L)&&(u.resize(g,L),l.resize(g,L),f=true),ln(y.children,g,L),z(y.children);let N;if(a){let F=p.get(a);F?.type==="input"&&(N={nodeId:a,position:F.props.cursorPosition??F.props.value?.length??0});}let w=Jt(y.children,u,{cursorInfo:N,useNativeCursor:s}),k=Zt(l,u,f);if(k.length>0&&i.write(k),s)if(w.cursorPosition){let F=$t(w.cursorPosition.bg);i.setCursorColor(F),i.moveCursor(w.cursorPosition.x,w.cursorPosition.y),c||(i.showCursor(),c=true);}else c&&(i.hideCursor(),c=false);for(let F=0;F<u.cells.length;F++)l.cells[F]={...u.cells[F]};f=false;}function z(g){for(let L of g){let N=T.get(L);if(N)for(let w of N)w(L.layout);z(L.children);}}let O=i.onData(g=>{let L=jt(g);for(let N of L){if(N.ctrl&&N.name==="c"){le.exit();return}if(N.ctrl&&N.name==="z"){i.suspend(),process.kill(0,"SIGSTOP");return}if(N.name==="tab"&&!N.ctrl&&!N.alt){N.shift?G.focusPrev():G.focusNext();continue}let w=false;for(let k of S)if(k(N)){w=true;break}if(!w&&a){let k=R.get(a);k&&(w=k(N));}if(!w)for(let k of m)k(N);}}),W=i.onResize(()=>{f=true,x();}),Y=()=>{i.resume(),f=true,x();};process.on("SIGCONT",Y);let X=te.createElement(Ce.Provider,{value:b},te.createElement(Z.Provider,{value:v},te.createElement(q.Provider,{value:G},te.createElement(oe.Provider,{value:M},e)))),_=g=>{o&&console.error("Uncaught error:",g);},J=g=>{o&&console.error("Error caught by boundary:",g);},B=g=>{o&&console.error("Recoverable error:",g);},se=Ie.createContainer(y,0,null,false,null,"",_,J,B,null);Ie.updateContainer(X,se,null,null);let le={unmount(){Ie.updateContainer(null,se,null,null),O(),W(),process.off("SIGCONT",Y),i.cleanup();},exit(g){le.unmount(),process.exit(g??0);}};return le}var pr=forwardRef(function({children:t,style:n,focusable:r},o){return te.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 te.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(`
4
+ `),M=ce(T,l,G),b=0,y=0;if(K){let x=o.position,V=0,z=x,O=0;for(let J=0;J<T.length;J++){let B=T[J].length;if(x<=O+B){V=J,z=x-O;break}O+=B+1;}let W=0;for(let J=0;J<V;J++)W+=ce([T[J]],l,G).length;let Y=ce([T[V]],l,G),X=0,_=0;for(let J=0;J<Y.length;J++){let B=Y[J];if(z<=X+B.length){_=J;break}X+=B.length;}b=W+_,y=ue(T[V].slice(X,X+(z-X)));}let C=Math.max(0,b-u+1);for(let x=0;x<u;x++){let V=C+x;if(V>=M.length)break;let z=M[V],O=0;for(let W of z){if(O>=l)break;let Y=ue(W);Y>0&&ie(t,n,i+O,c+x,W,P,a.bg,a.bold,j,a.italic,a.underline),O+=Y;}}if(K){let x=b-C;if(x>=0&&x<u){let V=Math.min(y,l-1),z=i+V,O=c+x;if(Xe(z,O,n)&&z<i+l)if(s)E={cursorPosition:{x:z,y:O,bg:a.bg}};else {let W=t.get(z,O),Y=W?.ch&&W.ch!==" "?W.ch:"\u258C",X=a.bg??"black",_=a.color??"white";t.setChar(z,O,Y,X,_,W?.bold,W?.dim,W?.italic,false);}}}}else {let G=0;for(let T of S){if(G>=l)break;let M=ue(T);M>0&&ie(t,n,i+G,c,T,P,a.bg,a.bold,j,a.italic,a.underline),G+=M;}if(K){let T=Math.min(o.position,l-1),M=i+T;if(Xe(M,c,n)&&M<i+l)if(s)E={cursorPosition:{x:M,y:c,bg:a.bg}};else {let b=t.get(M,c),y=b?.ch&&b.ch!==" "?b.ch:"\u258C",C=a.bg??"black",x=a.color??"white";t.setChar(M,c,y,C,x,b?.bold,b?.dim,b?.italic,false);}}}return E}var er="\x1B",me=`${er}[`;function tr(e,t){return `${me}${t+1};${e+1}H`}function nr(e){let t=`${me}0m`;return e.bold&&(t+=`${me}1m`),e.dim&&(t+=`${me}2m`),e.italic&&(t+=`${me}3m`),e.underline&&(t+=`${me}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 u=t.get(l,c);if(!n){let m=e.get(l,c);if(m&&t.cellsEqual(u,m))continue}(s!==c||o!==l)&&(r+=tr(l,c));let f=nr(u);f!==i&&(r+=f,i=f),r+=u.ch,o=l+1,s=c;}return r.length>0&&(r+=`${me}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,u=e.style.border&&e.style.border!=="none"?1:0,f=r.getComputedPadding(Edge.Top),m=r.getComputedPadding(Edge.Right),S=r.getComputedPadding(Edge.Bottom),R=r.getComputedPadding(Edge.Left),v=s+u+R,a=i+u+f,p=Math.max(0,c-u*2-R-m),h=Math.max(0,l-u*2-f-S);e.layout={x:s,y:i,width:c,height:l,innerX:v,innerY:a,innerWidth:p,innerHeight:h};for(let I of e.children)I.hidden||!I.yogaNode||sn(I,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 Z=createContext(null),q=createContext(null),oe=createContext(null),Ce=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(g=>{_t(g),f=true,x();});let l=new ke(i.columns,i.rows),u=new ke(i.columns,i.rows),f=true,m=new Set,S=new Set,R=new Map,v={subscribe(g){return m.add(g),()=>m.delete(g)},subscribePriority(g){return S.add(g),()=>S.delete(g)},registerInputHandler(g,L){return R.set(g,L),()=>R.delete(g)}},a=null,p=new Map,h=[],I=new Set,P=[],j=new Set;function K(g){if(a!==g){a=g,x();for(let L of j)L(a);}}function E(){let g=[...h];if(P.length>0){let L=P[P.length-1];g=g.filter(N=>L.has(N));}return g=g.filter(L=>!I.has(L)),g.sort((L,N)=>{let w=p.get(L),k=p.get(N);if(!w||!k)return 0;let F=w.layout,$=k.layout;return F.y!==$.y?F.y-$.y:F.x-$.x}),g}let G={get focusedId(){return a},register(g,L){if(p.set(g,L),h.includes(g)||h.push(g),P.length>0&&P[P.length-1].add(g),a===null){let N=E();N.length>0&&K(N[0]);}return ()=>{p.delete(g);let N=h.indexOf(g);if(N!==-1&&h.splice(N,1),a===g){let w=E();K(w[0]??null);}}},requestFocus(g){K(g);},focusNext(){let g=E();if(g.length===0)return;let N=((a?g.indexOf(a):-1)+1)%g.length;K(g[N]);},focusPrev(){let g=E();if(g.length===0)return;let N=((a?g.indexOf(a):0)-1+g.length)%g.length;K(g[N]);},setSkippable(g,L){if(L){if(I.add(g),a===g){let N=E();N.length>0&&K(N[0]);}}else I.delete(g);},trapIds:null,pushTrap(g){return P.push(g),()=>{let L=P.indexOf(g);L!==-1&&P.splice(L,1);}},onFocusChange(g){return j.add(g),()=>{j.delete(g);}},getRegisteredElements(){let g=[];for(let L of h){if(I.has(L))continue;let N=p.get(L);N&&g.push({id:L,node:N});}return g},getActiveElements(){let g=E(),L=[];for(let N of g){if(I.has(N))continue;let w=p.get(N);w&&L.push({id:N,node:w});}return L}},T=new Map,M={getLayout(g){return g.layout},subscribe(g,L){return T.has(g)||T.set(g,new Set),T.get(g).add(L),()=>{let N=T.get(g);N&&(N.delete(L),N.size===0&&T.delete(g));}}},b={registerNode(){},unregisterNode(){},scheduleRender:x,exit(g){le.exit(g);},get columns(){return i.columns},get rows(){return i.rows}},y={type:"root",children:[],onCommit(){x();}},C=false;function x(){C||(C=true,queueMicrotask(()=>{C=false,V();}));}function V(){let g=i.columns,L=i.rows;(u.width!==g||u.height!==L)&&(u.resize(g,L),l.resize(g,L),f=true),ln(y.children,g,L),z(y.children);let N;if(a){let F=p.get(a);F?.type==="input"&&(N={nodeId:a,position:F.props.cursorPosition??F.props.value?.length??0});}let w=Jt(y.children,u,{cursorInfo:N,useNativeCursor:s}),k=Zt(l,u,f);if(k.length>0&&i.write(k),s)if(w.cursorPosition){let F=$t(w.cursorPosition.bg);i.setCursorColor(F),i.moveCursor(w.cursorPosition.x,w.cursorPosition.y),c||(i.showCursor(),c=true);}else c&&(i.hideCursor(),c=false);for(let F=0;F<u.cells.length;F++)l.cells[F]={...u.cells[F]};f=false;}function z(g){for(let L of g){let N=T.get(L);if(N)for(let w of N)w(L.layout);z(L.children);}}let O=i.onData(g=>{let L=jt(g);for(let N of L){if(N.ctrl&&N.name==="c"){le.exit();return}if(N.ctrl&&N.name==="z"){i.suspend(),process.kill(0,"SIGSTOP");return}let w=false;for(let k of S)if(k(N)){w=true;break}if(!w&&a){let k=R.get(a);k&&(w=k(N));}if(!w&&N.name==="tab"&&!N.ctrl&&!N.alt){N.shift?G.focusPrev():G.focusNext();continue}if(!w)for(let k of m)k(N);}}),W=i.onResize(()=>{f=true,x();}),Y=()=>{i.resume(),f=true,x();};process.on("SIGCONT",Y);let X=te.createElement(Ce.Provider,{value:b},te.createElement(Z.Provider,{value:v},te.createElement(q.Provider,{value:G},te.createElement(oe.Provider,{value:M},e)))),_=g=>{o&&console.error("Uncaught error:",g);},J=g=>{o&&console.error("Error caught by boundary:",g);},B=g=>{o&&console.error("Recoverable error:",g);},se=Ie.createContainer(y,0,null,false,null,"",_,J,B,null);Ie.updateContainer(X,se,null,null);let le={unmount(){Ie.updateContainer(null,se,null,null),O(),W(),process.off("SIGCONT",Y),i.cleanup();},exit(g){le.unmount(),process.exit(g??0);}};return le}var pr=forwardRef(function({children:t,style:n,focusable:r},o){return te.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 te.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 u=ce([l],n,"wrap"),f=0;for(let m of u)o.push({text:m,logicalOffset:s+f}),f+=m.length;s+=l.length+1;}let i=0;for(let l=0;l<o.length;l++){let u=o[l],f=u.text.length,m=l+1<o.length&&o[l+1].logicalOffset!==u.logicalOffset+f,S=f+(m?1:0);if(t<i+f||l===o.length-1)return {visualLine:l,visualCol:Math.min(t-i,f),totalVisualLines:o.length,lineStartOffset:i,lineLength:f};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 f of o){let m=ce([f],r,"wrap"),S=0;for(let R of m)s.push({text:R,startOffset:i+S}),S+=R.length;i+=f.length+1;}let c=Math.max(0,Math.min(t,s.length-1)),l=s[c],u=Math.min(n,l.text.length);return l.startOffset+u}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 Be(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:u,autoFocus:f,type:m="text"}=e,[S,R]=useState(n),[v,a]=useState(n.length),[p,h]=useState(0),[I,P]=useState(false),[j,K]=useState(false),E=useContext(Z),G=useContext(q),T=useContext(oe),M=useRef(null),b=useRef(null),y=t!==void 0,C=y?t:S;useEffect(()=>{if(!T||!M.current)return;let _=T.getLayout(M.current);return h(_.innerWidth),T.subscribe(M.current,J=>{h(J.innerWidth);})},[T]);let x=useRef(C),V=useRef(v),z=useRef(C),O=useRef(v);useEffect(()=>{C!==z.current&&(x.current=C,z.current=C,V.current>C.length&&(V.current=C.length,O.current=C.length,a(C.length)));},[C]),useEffect(()=>{v!==O.current&&(V.current=v,O.current=v);},[v]);let W=useRef({isControlled:y,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:u??false,innerWidth:p,type:m});W.current={isControlled:y,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:u??false,innerWidth:p,type:m},useEffect(()=>{if(!(!G||!b.current||!M.current))return G.register(b.current,M.current)},[G,j]);let Y=useRef(false);useEffect(()=>{if(!j){Y.current=false;return}if(f&&!Y.current&&G&&b.current){Y.current=true;let _=b.current,J=setTimeout(()=>{G.requestFocus(_);},0);return ()=>clearTimeout(J)}},[f,G,j]),useEffect(()=>{if(!G||!b.current)return;let _=b.current;return P(G.focusedId===_),G.onFocusChange(J=>{P(J===_);})},[G,j]),useEffect(()=>{if(!E||!b.current)return;let _=b.current,J=B=>{let{isControlled:se,onChange:le,onKeyPress:g,onBeforeChange:L,multiline:N}=W.current;if(g?.(B)===true)return true;let w=x.current,k=V.current;if(B.name==="escape")return false;let F=(d,A)=>{let H=d,Q=A;if(L){let U=L(d,w);if(U===false)return;typeof U=="string"&&(H=U,Q=U.length);}x.current=H,V.current=Q,z.current=H,O.current=Q,se||R(H),le?.(H),a(Q);},$=d=>{V.current=d,O.current=d,a(d);};if(B.name==="return"){if(N){let d=w.slice(0,k)+`
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 Be(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:u,autoFocus:f,type:m="text"}=e,[S,R]=useState(n),[v,a]=useState(n.length),[p,h]=useState(0),[I,P]=useState(false),[j,K]=useState(false),E=useContext(Z),G=useContext(q),T=useContext(oe),M=useRef(null),b=useRef(null),y=t!==void 0,C=y?t:S;useEffect(()=>{if(!T||!M.current)return;let _=T.getLayout(M.current);return h(_.innerWidth),T.subscribe(M.current,J=>{h(J.innerWidth);})},[T]);let x=useRef(C),V=useRef(v),z=useRef(C),O=useRef(v);useEffect(()=>{C!==z.current&&(x.current=C,z.current=C,V.current=C.length,O.current=C.length,a(C.length));},[C]),useEffect(()=>{v!==O.current&&(V.current=v,O.current=v);},[v]);let W=useRef({isControlled:y,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:u??false,innerWidth:p,type:m});W.current={isControlled:y,onChange:r,onKeyPress:o,onBeforeChange:s,multiline:u??false,innerWidth:p,type:m},useEffect(()=>{if(!(!G||!b.current||!M.current))return G.register(b.current,M.current)},[G,j]);let Y=useRef(false);useEffect(()=>{if(!j){Y.current=false;return}if(f&&!Y.current&&G&&b.current){Y.current=true;let _=b.current,J=setTimeout(()=>{G.requestFocus(_);},0);return ()=>clearTimeout(J)}},[f,G,j]),useEffect(()=>{if(!G||!b.current)return;let _=b.current;return P(G.focusedId===_),G.onFocusChange(J=>{P(J===_);})},[G,j]),useEffect(()=>{if(!E||!b.current)return;let _=b.current,J=B=>{let{isControlled:se,onChange:le,onKeyPress:g,onBeforeChange:L,multiline:N}=W.current;if(g?.(B)===true)return true;let w=x.current,k=V.current;if(B.name==="escape")return false;let F=(d,A)=>{let H=d,Q=A;if(L){let U=L(d,w);if(U===false)return;typeof U=="string"&&(H=U,Q=U.length);}x.current=H,V.current=Q,z.current=H,O.current=Q,se||R(H),le?.(H),a(Q);},$=d=>{V.current=d,O.current=d,a(d);};if(B.name==="return"){if(N){let d=w.slice(0,k)+`
8
8
  `+w.slice(k);return F(d,k+1),true}return false}if(B.ctrl){if(B.name==="w"){if(k>0){let d=k;for(;d>0&&w[d-1]===" ";)d--;for(;d>0&&w[d-1]!==" "&&(!N||w[d-1]!==`
9
9
  `);)d--;let A=w.slice(0,d)+w.slice(k);F(A,d);}return true}if(B.name==="a"){if(N){let{line:d,lines:A}=Ge(w,k);$(Be(A,d,0));}else $(0);return true}if(B.name==="e"){if(N){let{line:d,lines:A}=Ge(w,k);$(Be(A,d,A[d].length));}else $(w.length);return true}if(B.name==="k"){if(N){let{line:d,lines:A}=Ge(w,k),H=Be(A,d,A[d].length);if(k<H){let Q=w.slice(0,k)+w.slice(H);F(Q,k);}}else if(k<w.length){let d=w.slice(0,k);F(d,k);}return true}return false}if(B.alt){if(B.name==="left"||B.name==="b"){let d=k;for(;d>0&&w[d-1]===" ";)d--;for(;d>0&&w[d-1]!==" "&&w[d-1]!==`
10
10
  `;)d--;return $(d),true}if(B.name==="right"||B.name==="f"){let d=k;for(;d<w.length&&w[d]!==" "&&w[d]!==`