@automagik/genie 0.260202.530 → 0.260202.1833

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/claudio.js +44 -45
  2. package/dist/genie.js +58 -135
  3. package/dist/term.js +134 -67
  4. package/install.sh +43 -7
  5. package/package.json +1 -1
  6. package/src/claudio.ts +31 -21
  7. package/src/commands/launch.ts +12 -68
  8. package/src/genie-commands/doctor.ts +327 -0
  9. package/src/genie-commands/setup.ts +317 -199
  10. package/src/genie-commands/uninstall.ts +176 -0
  11. package/src/genie.ts +24 -44
  12. package/src/lib/claude-settings.ts +22 -64
  13. package/src/lib/genie-config.ts +169 -57
  14. package/src/lib/orchestrator/completion.ts +392 -0
  15. package/src/lib/orchestrator/event-monitor.ts +442 -0
  16. package/src/lib/orchestrator/index.ts +12 -0
  17. package/src/lib/orchestrator/patterns.ts +277 -0
  18. package/src/lib/orchestrator/state-detector.ts +339 -0
  19. package/src/lib/version.ts +1 -1
  20. package/src/lib/worker-registry.ts +229 -0
  21. package/src/term-commands/close.ts +221 -0
  22. package/src/term-commands/exec.ts +28 -6
  23. package/src/term-commands/kill.ts +143 -0
  24. package/src/term-commands/orchestrate.ts +844 -0
  25. package/src/term-commands/read.ts +6 -1
  26. package/src/term-commands/shortcuts.ts +14 -14
  27. package/src/term-commands/work.ts +415 -0
  28. package/src/term-commands/workers.ts +264 -0
  29. package/src/term.ts +201 -3
  30. package/src/types/genie-config.ts +49 -81
  31. package/src/genie-commands/hooks.ts +0 -317
  32. package/src/lib/hook-script.ts +0 -263
  33. package/src/lib/hooks/compose.ts +0 -72
  34. package/src/lib/hooks/index.ts +0 -163
  35. package/src/lib/hooks/presets/audited.ts +0 -191
  36. package/src/lib/hooks/presets/collaborative.ts +0 -143
  37. package/src/lib/hooks/presets/sandboxed.ts +0 -153
  38. package/src/lib/hooks/presets/supervised.ts +0 -66
  39. package/src/lib/hooks/utils/escape.ts +0 -46
package/dist/term.js CHANGED
@@ -1,68 +1,74 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var F0=Object.create;var{getPrototypeOf:D0,defineProperty:m,getOwnPropertyNames:y0}=Object;var P0=Object.prototype.hasOwnProperty;var j0=($,J,q)=>{q=$!=null?F0(D0($)):{};let U=J||!$||!$.__esModule?m(q,"default",{value:$,enumerable:!0}):q;for(let G of y0($))if(!P0.call(U,G))m(U,G,{get:()=>$[G],enumerable:!0});return U};var A=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var R6=($,J)=>{for(var q in J)m($,q,{get:J[q],enumerable:!0,configurable:!0,set:(U)=>J[q]=()=>U})};var f=import.meta.require;var b=A((A0)=>{class r extends Error{constructor($,J,q){super(q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class H1 extends r{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}A0.CommanderError=r;A0.InvalidArgumentError=H1});var v=A((C0)=>{var{InvalidArgumentError:O0}=b();class R1{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,q)=>{if(!this.argChoices.includes(J))throw new O0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,q);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function f0($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}C0.Argument=R1;C0.humanReadableArgName=f0});var s=A((x0)=>{var{humanReadableArgName:b0}=v();class B1{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let J=$.commands.filter((U)=>!U._hidden),q=$._getHelpCommand();if(q&&!q._hidden)J.push(q);if(this.sortSubcommands)J.sort((U,G)=>{return U.name().localeCompare(G.name())});return J}compareOptions($,J){let q=(U)=>{return U.short?U.short.replace(/^-/,""):U.long.replace(/^--/,"")};return q($).localeCompare(q(J))}visibleOptions($){let J=$.options.filter((U)=>!U.hidden),q=$._getHelpOption();if(q&&!q.hidden){let U=q.short&&$._findOption(q.short),G=q.long&&$._findOption(q.long);if(!U&&!G)J.push(q);else if(q.long&&!G)J.push($.createOption(q.long,q.description));else if(q.short&&!U)J.push($.createOption(q.short,q.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let q=$.parent;q;q=q.parent){let U=q.options.filter((G)=>!G.hidden);J.push(...U)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((q)=>b0(q)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((q,U)=>{return Math.max(q,J.subcommandTerm(U).length)},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((q,U)=>{return Math.max(q,J.optionTerm(U).length)},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((q,U)=>{return Math.max(q,J.optionTerm(U).length)},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((q,U)=>{return Math.max(q,J.argumentTerm(U).length)},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let q="";for(let U=$.parent;U;U=U.parent)q=U.name()+" "+q;return q+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((q)=>JSON.stringify(q)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0)return`${$.description} (${J.join(", ")})`;return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((q)=>JSON.stringify(q)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let q=`(${J.join(", ")})`;if($.description)return`${$.description} ${q}`;return q}return $.description}formatHelp($,J){let q=J.padWidth($,J),U=J.helpWidth||80,G=2,X=2;function Q(H,T){if(T){let j=`${H.padEnd(q+2)}${T}`;return J.wrap(j,U-2,q+2)}return H}function Z(H){return H.join(`
4
- `).replace(/^/gm," ".repeat(2))}let _=[`Usage: ${J.commandUsage($)}`,""],Y=J.commandDescription($);if(Y.length>0)_=_.concat([J.wrap(Y,U,0),""]);let S=J.visibleArguments($).map((H)=>{return Q(J.argumentTerm(H),J.argumentDescription(H))});if(S.length>0)_=_.concat(["Arguments:",Z(S),""]);let W=J.visibleOptions($).map((H)=>{return Q(J.optionTerm(H),J.optionDescription(H))});if(W.length>0)_=_.concat(["Options:",Z(W),""]);if(this.showGlobalOptions){let H=J.visibleGlobalOptions($).map((T)=>{return Q(J.optionTerm(T),J.optionDescription(T))});if(H.length>0)_=_.concat(["Global Options:",Z(H),""])}let B=J.visibleCommands($).map((H)=>{return Q(J.subcommandTerm(H),J.subcommandDescription(H))});if(B.length>0)_=_.concat(["Commands:",Z(B),""]);return _.join(`
5
- `)}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}wrap($,J,q,U=40){let X=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if($.match(X))return $;let Q=J-q;if(Q<U)return $;let Z=$.slice(0,q),_=$.slice(q).replace(`\r
3
+ var h1=Object.create;var{getPrototypeOf:g1,defineProperty:w0,getOwnPropertyNames:l1}=Object;var m1=Object.prototype.hasOwnProperty;var xD=(D,F,E)=>{E=D!=null?h1(g1(D)):{};let B=F||!D||!D.__esModule?w0(E,"default",{value:D,enumerable:!0}):E;for(let $ of l1(D))if(!m1.call(B,$))w0(B,$,{get:()=>D[$],enumerable:!0});return B};var m=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var h3=(D,F)=>{for(var E in F)w0(D,E,{get:F[E],enumerable:!0,configurable:!0,set:(B)=>F[E]=()=>B})};var p1=(D,F)=>()=>(D&&(F=D(D=0)),F);var VD=import.meta.require;var Z2=m((c1)=>{class P0 extends Error{constructor(D,F,E){super(E);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=D,this.nestedError=void 0}}class g3 extends P0{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}c1.CommanderError=P0;c1.InvalidArgumentError=g3});var s2=m((a1)=>{var{InvalidArgumentError:n1}=Z2();class l3{constructor(D,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.concat(D)}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,E)=>{if(!this.argChoices.includes(F))throw new n1(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(F,E);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function r1(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}a1.Argument=l3;a1.humanReadableArgName=r1});var I0=m((e1)=>{var{humanReadableArgName:t1}=s2();class m3{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(D){let F=D.commands.filter((B)=>!B._hidden),E=D._getHelpCommand();if(E&&!E._hidden)F.push(E);if(this.sortSubcommands)F.sort((B,$)=>{return B.name().localeCompare($.name())});return F}compareOptions(D,F){let E=(B)=>{return B.short?B.short.replace(/^-/,""):B.long.replace(/^--/,"")};return E(D).localeCompare(E(F))}visibleOptions(D){let F=D.options.filter((B)=>!B.hidden),E=D._getHelpOption();if(E&&!E.hidden){let B=E.short&&D._findOption(E.short),$=E.long&&D._findOption(E.long);if(!B&&!$)F.push(E);else if(E.long&&!$)F.push(D.createOption(E.long,E.description));else if(E.short&&!B)F.push(D.createOption(E.short,E.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let F=[];for(let E=D.parent;E;E=E.parent){let B=E.options.filter(($)=>!$.hidden);F.push(...B)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((F)=>{F.description=F.description||D._argsDescription[F.name()]||""});if(D.registeredArguments.find((F)=>F.description))return D.registeredArguments;return[]}subcommandTerm(D){let F=D.registeredArguments.map((E)=>t1(E)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,F){return F.visibleCommands(D).reduce((E,B)=>{return Math.max(E,F.subcommandTerm(B).length)},0)}longestOptionTermLength(D,F){return F.visibleOptions(D).reduce((E,B)=>{return Math.max(E,F.optionTerm(B).length)},0)}longestGlobalOptionTermLength(D,F){return F.visibleGlobalOptions(D).reduce((E,B)=>{return Math.max(E,F.optionTerm(B).length)},0)}longestArgumentTermLength(D,F){return F.visibleArguments(D).reduce((E,B)=>{return Math.max(E,F.argumentTerm(B).length)},0)}commandUsage(D){let F=D._name;if(D._aliases[0])F=F+"|"+D._aliases[0];let E="";for(let B=D.parent;B;B=B.parent)E=B.name()+" "+E;return E+F+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((E)=>JSON.stringify(E)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)F.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)F.push(`env: ${D.envVar}`);if(F.length>0)return`${D.description} (${F.join(", ")})`;return D.description}argumentDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((E)=>JSON.stringify(E)).join(", ")}`);if(D.defaultValue!==void 0)F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(F.length>0){let E=`(${F.join(", ")})`;if(D.description)return`${D.description} ${E}`;return E}return D.description}formatHelp(D,F){let E=F.padWidth(D,F),B=F.helpWidth||80,$=2,J=2;function X(U,R){if(R){let K=`${U.padEnd(E+2)}${R}`;return F.wrap(K,B-2,E+2)}return U}function Q(U){return U.join(`
4
+ `).replace(/^/gm," ".repeat(2))}let Y=[`Usage: ${F.commandUsage(D)}`,""],q=F.commandDescription(D);if(q.length>0)Y=Y.concat([F.wrap(q,B,0),""]);let _=F.visibleArguments(D).map((U)=>{return X(F.argumentTerm(U),F.argumentDescription(U))});if(_.length>0)Y=Y.concat(["Arguments:",Q(_),""]);let H=F.visibleOptions(D).map((U)=>{return X(F.optionTerm(U),F.optionDescription(U))});if(H.length>0)Y=Y.concat(["Options:",Q(H),""]);if(this.showGlobalOptions){let U=F.visibleGlobalOptions(D).map((R)=>{return X(F.optionTerm(R),F.optionDescription(R))});if(U.length>0)Y=Y.concat(["Global Options:",Q(U),""])}let G=F.visibleCommands(D).map((U)=>{return X(F.subcommandTerm(U),F.subcommandDescription(U))});if(G.length>0)Y=Y.concat(["Commands:",Q(G),""]);return Y.join(`
5
+ `)}padWidth(D,F){return Math.max(F.longestOptionTermLength(D,F),F.longestGlobalOptionTermLength(D,F),F.longestSubcommandTermLength(D,F),F.longestArgumentTermLength(D,F))}wrap(D,F,E,B=40){let J=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if(D.match(J))return D;let X=F-E;if(X<B)return D;let Q=D.slice(0,E),Y=D.slice(E).replace(`\r
6
6
  `,`
7
- `),Y=" ".repeat(q),W=`\\s${"\u200B"}`,B=new RegExp(`
8
- |.{1,${Q-1}}([${W}]|$)|[^${W}]+?([${W}]|$)`,"g"),H=_.match(B)||[];return Z+H.map((T,j)=>{if(T===`
9
- `)return"";return(j>0?Y:"")+T.trimEnd()}).join(`
10
- `)}}x0.Help=B1});var i=A((c0)=>{var{InvalidArgumentError:h0}=b();class K1{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let q=u0($);if(this.short=q.shortFlag,this.long=q.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(J,q)=>{if(!this.argChoices.includes(J))throw new h0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(J,q);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return g0(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class E1{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,q)=>{if(this.positiveOptions.has(q))this.dualOptions.add(q)})}valueFromOption($,J){let q=J.attributeName();if(!this.dualOptions.has(q))return!0;let U=this.negativeOptions.get(q).presetArg,G=U!==void 0?U:!1;return J.negate===(G===$)}}function g0($){return $.split("-").reduce((J,q)=>{return J+q[0].toUpperCase()+q.slice(1)})}function u0($){let J,q,U=$.split(/[ |,]+/);if(U.length>1&&!/^[[<]/.test(U[1]))J=U.shift();if(q=U.shift(),!J&&/^-[^-]$/.test(q))J=q,q=void 0;return{shortFlag:J,longFlag:q}}c0.Option=K1;c0.DualOptions=E1});var z1=A((r0)=>{function p0($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let q=[];for(let U=0;U<=$.length;U++)q[U]=[U];for(let U=0;U<=J.length;U++)q[0][U]=U;for(let U=1;U<=J.length;U++)for(let G=1;G<=$.length;G++){let X=1;if($[G-1]===J[U-1])X=0;else X=1;if(q[G][U]=Math.min(q[G-1][U]+1,q[G][U-1]+1,q[G-1][U-1]+X),G>1&&U>1&&$[G-1]===J[U-2]&&$[G-2]===J[U-1])q[G][U]=Math.min(q[G][U],q[G-2][U-2]+1)}return q[$.length][J.length]}function m0($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let q=$.startsWith("--");if(q)$=$.slice(2),J=J.map((Q)=>Q.slice(2));let U=[],G=3,X=0.4;if(J.forEach((Q)=>{if(Q.length<=1)return;let Z=p0($,Q),_=Math.max($.length,Q.length);if((_-Z)/_>X){if(Z<G)G=Z,U=[Q];else if(Z===G)U.push(Q)}}),U.sort((Q,Z)=>Q.localeCompare(Z)),q)U=U.map((Q)=>`--${Q}`);if(U.length>1)return`
11
- (Did you mean one of ${U.join(", ")}?)`;if(U.length===1)return`
12
- (Did you mean ${U[0]}?)`;return""}r0.suggestSimilar=m0});var T1=A((e0)=>{var i0=f("events").EventEmitter,t=f("child_process"),y=f("path"),o=f("fs"),E=f("process"),{Argument:t0,humanReadableArgName:o0}=v(),{CommanderError:a}=b(),{Help:a0}=s(),{Option:L1,DualOptions:n0}=i(),{suggestSimilar:V1}=z1();class n extends i0{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(J)=>E.stdout.write(J),writeErr:(J)=>E.stderr.write(J),getOutHelpWidth:()=>E.stdout.isTTY?E.stdout.columns:void 0,getErrHelpWidth:()=>E.stderr.isTTY?E.stderr.columns:void 0,outputError:(J,q)=>q(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,q){let U=J,G=q;if(typeof U==="object"&&U!==null)G=U,U=null;G=G||{};let[,X,Q]=$.match(/([^ ]+) *(.*)/),Z=this.createCommand(X);if(U)Z.description(U),Z._executableHandler=!0;if(G.isDefault)this._defaultCommandName=Z._name;if(Z._hidden=!!(G.noHelp||G.hidden),Z._executableFile=G.executableFile||null,Q)Z.arguments(Q);if(this._registerCommand(Z),Z.parent=this,Z.copyInheritedSettings(this),U)return this;return Z}createCommand($){return new n($)}createHelp(){return Object.assign(new a0,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
13
- - specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new t0($,J)}argument($,J,q,U){let G=this.createArgument($,J);if(typeof q==="function")G.default(U).argParser(q);else G.default(q);return this.addArgument(G),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J&&J.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,q,U]=$.match(/([^ ]+) *(.*)/),G=J??"display help for command",X=this.createCommand(q);if(X.helpOption(!1),U)X.arguments(U);if(G)X.description(G);return this._addImplicitHelpCommand=!0,this._helpCommand=X,this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,J){let q=["preSubcommand","preAction","postAction"];if(!q.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
14
- Expecting one of '${q.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,q){if(this._exitCallback)this._exitCallback(new a($,J,q));E.exit($)}action($){let J=(q)=>{let U=this.registeredArguments.length,G=q.slice(0,U);if(this._storeOptionsAsProperties)G[U]=this;else G[U]=this.opts();return G.push(this),$.apply(this,G)};return this._actionHandler=J,this}createOption($,J){return new L1($,J)}_callParseArg($,J,q,U){try{return $.parseArg(J,q)}catch(G){if(G.code==="commander.invalidArgument"){let X=`${U} ${G.message}`;this.error(X,{exitCode:G.exitCode,code:G.code})}throw G}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let q=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${q}'
15
- - already used by option '${J.flags}'`)}this.options.push($)}_registerCommand($){let J=(U)=>{return[U.name()].concat(U.aliases())},q=J($).find((U)=>this._findCommand(U));if(q){let U=J(this._findCommand(q)).join("|"),G=J($).join("|");throw Error(`cannot add command '${G}' as already have command '${U}'`)}this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),q=$.attributeName();if($.negate){let G=$.long.replace(/^--no-/,"--");if(!this._findOption(G))this.setOptionValueWithSource(q,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(q,$.defaultValue,"default");let U=(G,X,Q)=>{if(G==null&&$.presetArg!==void 0)G=$.presetArg;let Z=this.getOptionValue(q);if(G!==null&&$.parseArg)G=this._callParseArg($,G,Z,X);else if(G!==null&&$.variadic)G=$._concatValue(G,Z);if(G==null)if($.negate)G=!1;else if($.isBoolean()||$.optional)G=!0;else G="";this.setOptionValueWithSource(q,G,Q)};if(this.on("option:"+J,(G)=>{let X=`error: option '${$.flags}' argument '${G}' is invalid.`;U(G,X,"cli")}),$.envVar)this.on("optionEnv:"+J,(G)=>{let X=`error: option '${$.flags}' value '${G}' from env '${$.envVar}' is invalid.`;U(G,X,"env")});return this}_optionEx($,J,q,U,G){if(typeof J==="object"&&J instanceof L1)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let X=this.createOption(J,q);if(X.makeOptionMandatory(!!$.mandatory),typeof U==="function")X.default(G).argParser(U);else if(U instanceof RegExp){let Q=U;U=(Z,_)=>{let Y=Q.exec(Z);return Y?Y[0]:_},X.default(G).argParser(U)}else X.default(U);return this.addOption(X)}option($,J,q,U){return this._optionEx({},$,J,q,U)}requiredOption($,J,q,U){return this._optionEx({mandatory:!0},$,J,q,U)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,q){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=q,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((q)=>{if(q.getOptionValueSource($)!==void 0)J=q.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(E.versions?.electron)J.from="electron";let U=E.execArgv??[];if(U.includes("-e")||U.includes("--eval")||U.includes("-p")||U.includes("--print"))J.from="eval"}if($===void 0)$=E.argv;this.rawArgs=$.slice();let q;switch(J.from){case void 0:case"node":this._scriptPath=$[1],q=$.slice(2);break;case"electron":if(E.defaultApp)this._scriptPath=$[1],q=$.slice(2);else q=$.slice(1);break;case"user":q=$.slice(0);break;case"eval":q=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",q}parse($,J){let q=this._prepareUserArgs($,J);return this._parseCommand([],q),this}async parseAsync($,J){let q=this._prepareUserArgs($,J);return await this._parseCommand([],q),this}_executeSubCommand($,J){J=J.slice();let q=!1,U=[".js",".ts",".tsx",".mjs",".cjs"];function G(Y,S){let W=y.resolve(Y,S);if(o.existsSync(W))return W;if(U.includes(y.extname(S)))return;let B=U.find((H)=>o.existsSync(`${W}${H}`));if(B)return`${W}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let X=$._executableFile||`${this._name}-${$._name}`,Q=this._executableDir||"";if(this._scriptPath){let Y;try{Y=o.realpathSync(this._scriptPath)}catch(S){Y=this._scriptPath}Q=y.resolve(y.dirname(Y),Q)}if(Q){let Y=G(Q,X);if(!Y&&!$._executableFile&&this._scriptPath){let S=y.basename(this._scriptPath,y.extname(this._scriptPath));if(S!==this._name)Y=G(Q,`${S}-${$._name}`)}X=Y||X}q=U.includes(y.extname(X));let Z;if(E.platform!=="win32")if(q)J.unshift(X),J=M1(E.execArgv).concat(J),Z=t.spawn(E.argv[0],J,{stdio:"inherit"});else Z=t.spawn(X,J,{stdio:"inherit"});else J.unshift(X),J=M1(E.execArgv).concat(J),Z=t.spawn(E.execPath,J,{stdio:"inherit"});if(!Z.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((S)=>{E.on(S,()=>{if(Z.killed===!1&&Z.exitCode===null)Z.kill(S)})});let _=this._exitCallback;Z.on("close",(Y)=>{if(Y=Y??1,!_)E.exit(Y);else _(new a(Y,"commander.executeSubCommandAsync","(close)"))}),Z.on("error",(Y)=>{if(Y.code==="ENOENT"){let S=Q?`searched for local subcommand relative to directory '${Q}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",W=`'${X}' does not exist
16
- - if '${$._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
7
+ `),q=" ".repeat(E),H=`\\s${"\u200B"}`,G=new RegExp(`
8
+ |.{1,${X-1}}([${H}]|$)|[^${H}]+?([${H}]|$)`,"g"),U=Y.match(G)||[];return Q+U.map((R,K)=>{if(R===`
9
+ `)return"";return(K>0?q:"")+R.trimEnd()}).join(`
10
+ `)}}e1.Help=m3});var u0=m(($F)=>{var{InvalidArgumentError:FF}=Z2();class p3{constructor(D,F){this.flags=D,this.description=F||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let E=BF(D);if(this.short=E.shortFlag,this.long=E.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let F=D;if(typeof D==="string")F={[D]:!0};return this.implied=Object.assign(this.implied||{},F),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_concatValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.concat(D)}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,E)=>{if(!this.argChoices.includes(F))throw new FF(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(F,E);return F},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return EF(this.name().replace(/^no-/,""))}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class c3{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((F)=>{if(F.negate)this.negativeOptions.set(F.attributeName(),F);else this.positiveOptions.set(F.attributeName(),F)}),this.negativeOptions.forEach((F,E)=>{if(this.positiveOptions.has(E))this.dualOptions.add(E)})}valueFromOption(D,F){let E=F.attributeName();if(!this.dualOptions.has(E))return!0;let B=this.negativeOptions.get(E).presetArg,$=B!==void 0?B:!1;return F.negate===($===D)}}function EF(D){return D.split("-").reduce((F,E)=>{return F+E[0].toUpperCase()+E.slice(1)})}function BF(D){let F,E,B=D.split(/[ |,]+/);if(B.length>1&&!/^[[<]/.test(B[1]))F=B.shift();if(E=B.shift(),!F&&/^-[^-]$/.test(E))F=E,E=void 0;return{shortFlag:F,longFlag:E}}$F.Option=p3;$F.DualOptions=c3});var d3=m((qF)=>{function QF(D,F){if(Math.abs(D.length-F.length)>3)return Math.max(D.length,F.length);let E=[];for(let B=0;B<=D.length;B++)E[B]=[B];for(let B=0;B<=F.length;B++)E[0][B]=B;for(let B=1;B<=F.length;B++)for(let $=1;$<=D.length;$++){let J=1;if(D[$-1]===F[B-1])J=0;else J=1;if(E[$][B]=Math.min(E[$-1][B]+1,E[$][B-1]+1,E[$-1][B-1]+J),$>1&&B>1&&D[$-1]===F[B-2]&&D[$-2]===F[B-1])E[$][B]=Math.min(E[$][B],E[$-2][B-2]+1)}return E[D.length][F.length]}function YF(D,F){if(!F||F.length===0)return"";F=Array.from(new Set(F));let E=D.startsWith("--");if(E)D=D.slice(2),F=F.map((X)=>X.slice(2));let B=[],$=3,J=0.4;if(F.forEach((X)=>{if(X.length<=1)return;let Q=QF(D,X),Y=Math.max(D.length,X.length);if((Y-Q)/Y>J){if(Q<$)$=Q,B=[X];else if(Q===$)B.push(X)}}),B.sort((X,Q)=>X.localeCompare(Q)),E)B=B.map((X)=>`--${X}`);if(B.length>1)return`
11
+ (Did you mean one of ${B.join(", ")}?)`;if(B.length===1)return`
12
+ (Did you mean ${B[0]}?)`;return""}qF.suggestSimilar=YF});var a3=m((CF)=>{var HF=VD("events").EventEmitter,f0=VD("child_process"),RD=VD("path"),Z0=VD("fs"),h=VD("process"),{Argument:WF,humanReadableArgName:GF}=s2(),{CommanderError:k0}=Z2(),{Help:AF}=I0(),{Option:i3,DualOptions:UF}=u0(),{suggestSimilar:n3}=d3();class v0 extends HF{constructor(D){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=D||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(F)=>h.stdout.write(F),writeErr:(F)=>h.stderr.write(F),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,outputError:(F,E)=>E(F)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let F=this;F;F=F.parent)D.push(F);return D}command(D,F,E){let B=F,$=E;if(typeof B==="object"&&B!==null)$=B,B=null;$=$||{};let[,J,X]=D.match(/([^ ]+) *(.*)/),Q=this.createCommand(J);if(B)Q.description(B),Q._executableHandler=!0;if($.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!($.noHelp||$.hidden),Q._executableFile=$.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),B)return this;return Q}createCommand(D){return new v0(D)}createHelp(){return Object.assign(new AF,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,D),this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,F){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
13
+ - specify the name in Command constructor or using .name()`);if(F=F||{},F.isDefault)this._defaultCommandName=D._name;if(F.noHelp||F.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,F){return new WF(D,F)}argument(D,F,E,B){let $=this.createArgument(D,F);if(typeof E==="function")$.default(B).argParser(E);else $.default(E);return this.addArgument($),this}arguments(D){return D.trim().split(/ +/).forEach((F)=>{this.argument(F)}),this}addArgument(D){let F=this.registeredArguments.slice(-1)[0];if(F&&F.variadic)throw Error(`only the last argument can be variadic '${F.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,F){if(typeof D==="boolean")return this._addImplicitHelpCommand=D,this;D=D??"help [command]";let[,E,B]=D.match(/([^ ]+) *(.*)/),$=F??"display help for command",J=this.createCommand(E);if(J.helpOption(!1),B)J.arguments(B);if($)J.description($);return this._addImplicitHelpCommand=!0,this._helpCommand=J,this}addHelpCommand(D,F){if(typeof D!=="object")return this.helpCommand(D,F),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,F){let E=["preSubcommand","preAction","postAction"];if(!E.includes(D))throw Error(`Unexpected value for event passed to hook : '${D}'.
14
+ Expecting one of '${E.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(F);else this._lifeCycleHooks[D]=[F];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(F)=>{if(F.code!=="commander.executeSubCommandAsync")throw F};return this}_exit(D,F,E){if(this._exitCallback)this._exitCallback(new k0(D,F,E));h.exit(D)}action(D){let F=(E)=>{let B=this.registeredArguments.length,$=E.slice(0,B);if(this._storeOptionsAsProperties)$[B]=this;else $[B]=this.opts();return $.push(this),D.apply(this,$)};return this._actionHandler=F,this}createOption(D,F){return new i3(D,F)}_callParseArg(D,F,E,B){try{return D.parseArg(F,E)}catch($){if($.code==="commander.invalidArgument"){let J=`${B} ${$.message}`;this.error(J,{exitCode:$.exitCode,code:$.code})}throw $}}_registerOption(D){let F=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(F){let E=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${E}'
15
+ - already used by option '${F.flags}'`)}this.options.push(D)}_registerCommand(D){let F=(B)=>{return[B.name()].concat(B.aliases())},E=F(D).find((B)=>this._findCommand(B));if(E){let B=F(this._findCommand(E)).join("|"),$=F(D).join("|");throw Error(`cannot add command '${$}' as already have command '${B}'`)}this.commands.push(D)}addOption(D){this._registerOption(D);let F=D.name(),E=D.attributeName();if(D.negate){let $=D.long.replace(/^--no-/,"--");if(!this._findOption($))this.setOptionValueWithSource(E,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(E,D.defaultValue,"default");let B=($,J,X)=>{if($==null&&D.presetArg!==void 0)$=D.presetArg;let Q=this.getOptionValue(E);if($!==null&&D.parseArg)$=this._callParseArg(D,$,Q,J);else if($!==null&&D.variadic)$=D._concatValue($,Q);if($==null)if(D.negate)$=!1;else if(D.isBoolean()||D.optional)$=!0;else $="";this.setOptionValueWithSource(E,$,X)};if(this.on("option:"+F,($)=>{let J=`error: option '${D.flags}' argument '${$}' is invalid.`;B($,J,"cli")}),D.envVar)this.on("optionEnv:"+F,($)=>{let J=`error: option '${D.flags}' value '${$}' from env '${D.envVar}' is invalid.`;B($,J,"env")});return this}_optionEx(D,F,E,B,$){if(typeof F==="object"&&F instanceof i3)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let J=this.createOption(F,E);if(J.makeOptionMandatory(!!D.mandatory),typeof B==="function")J.default($).argParser(B);else if(B instanceof RegExp){let X=B;B=(Q,Y)=>{let q=X.exec(Q);return q?q[0]:Y},J.default($).argParser(B)}else J.default(B);return this.addOption(J)}option(D,F,E,B){return this._optionEx({},D,F,E,B)}requiredOption(D,F,E,B){return this._optionEx({mandatory:!0},D,F,E,B)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(D=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,F){return this.setOptionValueWithSource(D,F,void 0)}setOptionValueWithSource(D,F,E){if(this._storeOptionsAsProperties)this[D]=F;else this._optionValues[D]=F;return this._optionValueSources[D]=E,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let F;return this._getCommandAndAncestors().forEach((E)=>{if(E.getOptionValueSource(D)!==void 0)F=E.getOptionValueSource(D)}),F}_prepareUserArgs(D,F){if(D!==void 0&&!Array.isArray(D))throw Error("first parameter to parse must be array or undefined");if(F=F||{},D===void 0&&F.from===void 0){if(h.versions?.electron)F.from="electron";let B=h.execArgv??[];if(B.includes("-e")||B.includes("--eval")||B.includes("-p")||B.includes("--print"))F.from="eval"}if(D===void 0)D=h.argv;this.rawArgs=D.slice();let E;switch(F.from){case void 0:case"node":this._scriptPath=D[1],E=D.slice(2);break;case"electron":if(h.defaultApp)this._scriptPath=D[1],E=D.slice(2);else E=D.slice(1);break;case"user":E=D.slice(0);break;case"eval":E=D.slice(1);break;default:throw Error(`unexpected parse option { from: '${F.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",E}parse(D,F){let E=this._prepareUserArgs(D,F);return this._parseCommand([],E),this}async parseAsync(D,F){let E=this._prepareUserArgs(D,F);return await this._parseCommand([],E),this}_executeSubCommand(D,F){F=F.slice();let E=!1,B=[".js",".ts",".tsx",".mjs",".cjs"];function $(q,_){let H=RD.resolve(q,_);if(Z0.existsSync(H))return H;if(B.includes(RD.extname(_)))return;let G=B.find((U)=>Z0.existsSync(`${H}${U}`));if(G)return`${H}${G}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let J=D._executableFile||`${this._name}-${D._name}`,X=this._executableDir||"";if(this._scriptPath){let q;try{q=Z0.realpathSync(this._scriptPath)}catch(_){q=this._scriptPath}X=RD.resolve(RD.dirname(q),X)}if(X){let q=$(X,J);if(!q&&!D._executableFile&&this._scriptPath){let _=RD.basename(this._scriptPath,RD.extname(this._scriptPath));if(_!==this._name)q=$(X,`${_}-${D._name}`)}J=q||J}E=B.includes(RD.extname(J));let Q;if(h.platform!=="win32")if(E)F.unshift(J),F=r3(h.execArgv).concat(F),Q=f0.spawn(h.argv[0],F,{stdio:"inherit"});else Q=f0.spawn(J,F,{stdio:"inherit"});else F.unshift(J),F=r3(h.execArgv).concat(F),Q=f0.spawn(h.execPath,F,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((_)=>{h.on(_,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(_)})});let Y=this._exitCallback;Q.on("close",(q)=>{if(q=q??1,!Y)h.exit(q);else Y(new k0(q,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(q)=>{if(q.code==="ENOENT"){let _=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",H=`'${J}' does not exist
16
+ - if '${D._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
17
17
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
- - ${S}`;throw Error(W)}else if(Y.code==="EACCES")throw Error(`'${X}' not executable`);if(!_)E.exit(1);else{let S=new a(1,"commander.executeSubCommandAsync","(error)");S.nestedError=Y,_(S)}}),this.runningCommand=Z}_dispatchSubcommand($,J,q){let U=this._findCommand($);if(!U)this.help({error:!0});let G;return G=this._chainOrCallSubCommandHook(G,U,"preSubcommand"),G=this._chainOrCall(G,()=>{if(U._executableHandler)this._executeSubCommand(U,J.concat(q));else return U._parseCommand(J,q)}),G}_dispatchHelpCommand($){if(!$)this.help();let J=this._findCommand($);if(J&&!J._executableHandler)J.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,J)=>{if($.required&&this.args[J]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(q,U,G)=>{let X=U;if(U!==null&&q.parseArg){let Q=`error: command-argument value '${U}' is invalid for argument '${q.name()}'.`;X=this._callParseArg(q,U,G,Q)}return X};this._checkNumberOfArguments();let J=[];this.registeredArguments.forEach((q,U)=>{let G=q.defaultValue;if(q.variadic){if(U<this.args.length){if(G=this.args.slice(U),q.parseArg)G=G.reduce((X,Q)=>{return $(q,Q,X)},q.defaultValue)}else if(G===void 0)G=[]}else if(U<this.args.length){if(G=this.args[U],q.parseArg)G=$(q,G,q.defaultValue)}J[U]=G}),this.processedArgs=J}_chainOrCall($,J){if($&&$.then&&typeof $.then==="function")return $.then(()=>J());return J()}_chainOrCallHooks($,J){let q=$,U=[];if(this._getCommandAndAncestors().reverse().filter((G)=>G._lifeCycleHooks[J]!==void 0).forEach((G)=>{G._lifeCycleHooks[J].forEach((X)=>{U.push({hookedCommand:G,callback:X})})}),J==="postAction")U.reverse();return U.forEach((G)=>{q=this._chainOrCall(q,()=>{return G.callback(G.hookedCommand,this)})}),q}_chainOrCallSubCommandHook($,J,q){let U=$;if(this._lifeCycleHooks[q]!==void 0)this._lifeCycleHooks[q].forEach((G)=>{U=this._chainOrCall(U,()=>{return G(this,J)})});return U}_parseCommand($,J){let q=this.parseOptions(J);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(q.operands),J=q.unknown,this.args=$.concat(J),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),J);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(J),this._dispatchSubcommand(this._defaultCommandName,$,J);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(q.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let U=()=>{if(q.unknown.length>0)this.unknownOption(q.unknown[0])},G=`command:${this.name()}`;if(this._actionHandler){U(),this._processArguments();let X;if(X=this._chainOrCallHooks(X,"preAction"),X=this._chainOrCall(X,()=>this._actionHandler(this.processedArgs)),this.parent)X=this._chainOrCall(X,()=>{this.parent.emit(G,$,J)});return X=this._chainOrCallHooks(X,"postAction"),X}if(this.parent&&this.parent.listenerCount(G))U(),this._processArguments(),this.parent.emit(G,$,J);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,J);if(this.listenerCount("command:*"))this.emit("command:*",$,J);else if(this.commands.length)this.unknownCommand();else U(),this._processArguments()}else if(this.commands.length)U(),this.help({error:!0});else U(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((J)=>J._name===$||J._aliases.includes($))}_findOption($){return this.options.find((J)=>J.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((J)=>{if(J.mandatory&&$.getOptionValue(J.attributeName())===void 0)$.missingMandatoryOptionValue(J)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((q)=>{let U=q.attributeName();if(this.getOptionValue(U)===void 0)return!1;return this.getOptionValueSource(U)!=="default"});$.filter((q)=>q.conflictsWith.length>0).forEach((q)=>{let U=$.find((G)=>q.conflictsWith.includes(G.attributeName()));if(U)this._conflictingOption(q,U)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let J=[],q=[],U=J,G=$.slice();function X(Z){return Z.length>1&&Z[0]==="-"}let Q=null;while(G.length){let Z=G.shift();if(Z==="--"){if(U===q)U.push(Z);U.push(...G);break}if(Q&&!X(Z)){this.emit(`option:${Q.name()}`,Z);continue}if(Q=null,X(Z)){let _=this._findOption(Z);if(_){if(_.required){let Y=G.shift();if(Y===void 0)this.optionMissingArgument(_);this.emit(`option:${_.name()}`,Y)}else if(_.optional){let Y=null;if(G.length>0&&!X(G[0]))Y=G.shift();this.emit(`option:${_.name()}`,Y)}else this.emit(`option:${_.name()}`);Q=_.variadic?_:null;continue}}if(Z.length>2&&Z[0]==="-"&&Z[1]!=="-"){let _=this._findOption(`-${Z[1]}`);if(_){if(_.required||_.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${_.name()}`,Z.slice(2));else this.emit(`option:${_.name()}`),G.unshift(`-${Z.slice(2)}`);continue}}if(/^--[^=]+=/.test(Z)){let _=Z.indexOf("="),Y=this._findOption(Z.slice(0,_));if(Y&&(Y.required||Y.optional)){this.emit(`option:${Y.name()}`,Z.slice(_+1));continue}}if(X(Z))U=q;if((this._enablePositionalOptions||this._passThroughOptions)&&J.length===0&&q.length===0){if(this._findCommand(Z)){if(J.push(Z),G.length>0)q.push(...G);break}else if(this._getHelpCommand()&&Z===this._getHelpCommand().name()){if(J.push(Z),G.length>0)J.push(...G);break}else if(this._defaultCommandName){if(q.push(Z),G.length>0)q.push(...G);break}}if(this._passThroughOptions){if(U.push(Z),G.length>0)U.push(...G);break}U.push(Z)}return{operands:J,unknown:q}}opts(){if(this._storeOptionsAsProperties){let $={},J=this.options.length;for(let q=0;q<J;q++){let U=this.options[q].attributeName();$[U]=U===this._versionOptionName?this._version:this[U]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,J)=>Object.assign($,J.opts()),{})}error($,J){if(this._outputConfiguration.outputError(`${$}
18
+ - ${_}`;throw Error(H)}else if(q.code==="EACCES")throw Error(`'${J}' not executable`);if(!Y)h.exit(1);else{let _=new k0(1,"commander.executeSubCommandAsync","(error)");_.nestedError=q,Y(_)}}),this.runningCommand=Q}_dispatchSubcommand(D,F,E){let B=this._findCommand(D);if(!B)this.help({error:!0});let $;return $=this._chainOrCallSubCommandHook($,B,"preSubcommand"),$=this._chainOrCall($,()=>{if(B._executableHandler)this._executeSubCommand(B,F.concat(E));else return B._parseCommand(F,E)}),$}_dispatchHelpCommand(D){if(!D)this.help();let F=this._findCommand(D);if(F&&!F._executableHandler)F.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,F)=>{if(D.required&&this.args[F]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(E,B,$)=>{let J=B;if(B!==null&&E.parseArg){let X=`error: command-argument value '${B}' is invalid for argument '${E.name()}'.`;J=this._callParseArg(E,B,$,X)}return J};this._checkNumberOfArguments();let F=[];this.registeredArguments.forEach((E,B)=>{let $=E.defaultValue;if(E.variadic){if(B<this.args.length){if($=this.args.slice(B),E.parseArg)$=$.reduce((J,X)=>{return D(E,X,J)},E.defaultValue)}else if($===void 0)$=[]}else if(B<this.args.length){if($=this.args[B],E.parseArg)$=D(E,$,E.defaultValue)}F[B]=$}),this.processedArgs=F}_chainOrCall(D,F){if(D&&D.then&&typeof D.then==="function")return D.then(()=>F());return F()}_chainOrCallHooks(D,F){let E=D,B=[];if(this._getCommandAndAncestors().reverse().filter(($)=>$._lifeCycleHooks[F]!==void 0).forEach(($)=>{$._lifeCycleHooks[F].forEach((J)=>{B.push({hookedCommand:$,callback:J})})}),F==="postAction")B.reverse();return B.forEach(($)=>{E=this._chainOrCall(E,()=>{return $.callback($.hookedCommand,this)})}),E}_chainOrCallSubCommandHook(D,F,E){let B=D;if(this._lifeCycleHooks[E]!==void 0)this._lifeCycleHooks[E].forEach(($)=>{B=this._chainOrCall(B,()=>{return $(this,F)})});return B}_parseCommand(D,F){let E=this.parseOptions(F);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(E.operands),F=E.unknown,this.args=D.concat(F),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),F);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(F),this._dispatchSubcommand(this._defaultCommandName,D,F);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(E.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let B=()=>{if(E.unknown.length>0)this.unknownOption(E.unknown[0])},$=`command:${this.name()}`;if(this._actionHandler){B(),this._processArguments();let J;if(J=this._chainOrCallHooks(J,"preAction"),J=this._chainOrCall(J,()=>this._actionHandler(this.processedArgs)),this.parent)J=this._chainOrCall(J,()=>{this.parent.emit($,D,F)});return J=this._chainOrCallHooks(J,"postAction"),J}if(this.parent&&this.parent.listenerCount($))B(),this._processArguments(),this.parent.emit($,D,F);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,F);if(this.listenerCount("command:*"))this.emit("command:*",D,F);else if(this.commands.length)this.unknownCommand();else B(),this._processArguments()}else if(this.commands.length)B(),this.help({error:!0});else B(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((F)=>F._name===D||F._aliases.includes(D))}_findOption(D){return this.options.find((F)=>F.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((F)=>{if(F.mandatory&&D.getOptionValue(F.attributeName())===void 0)D.missingMandatoryOptionValue(F)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((E)=>{let B=E.attributeName();if(this.getOptionValue(B)===void 0)return!1;return this.getOptionValueSource(B)!=="default"});D.filter((E)=>E.conflictsWith.length>0).forEach((E)=>{let B=D.find(($)=>E.conflictsWith.includes($.attributeName()));if(B)this._conflictingOption(E,B)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let F=[],E=[],B=F,$=D.slice();function J(Q){return Q.length>1&&Q[0]==="-"}let X=null;while($.length){let Q=$.shift();if(Q==="--"){if(B===E)B.push(Q);B.push(...$);break}if(X&&!J(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,J(Q)){let Y=this._findOption(Q);if(Y){if(Y.required){let q=$.shift();if(q===void 0)this.optionMissingArgument(Y);this.emit(`option:${Y.name()}`,q)}else if(Y.optional){let q=null;if($.length>0&&!J($[0]))q=$.shift();this.emit(`option:${Y.name()}`,q)}else this.emit(`option:${Y.name()}`);X=Y.variadic?Y:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let Y=this._findOption(`-${Q[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Q.slice(2));else this.emit(`option:${Y.name()}`),$.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let Y=Q.indexOf("="),q=this._findOption(Q.slice(0,Y));if(q&&(q.required||q.optional)){this.emit(`option:${q.name()}`,Q.slice(Y+1));continue}}if(J(Q))B=E;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&E.length===0){if(this._findCommand(Q)){if(F.push(Q),$.length>0)E.push(...$);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(F.push(Q),$.length>0)F.push(...$);break}else if(this._defaultCommandName){if(E.push(Q),$.length>0)E.push(...$);break}}if(this._passThroughOptions){if(B.push(Q),$.length>0)B.push(...$);break}B.push(Q)}return{operands:F,unknown:E}}opts(){if(this._storeOptionsAsProperties){let D={},F=this.options.length;for(let E=0;E<F;E++){let B=this.options[E].attributeName();D[B]=B===this._versionOptionName?this._version:this[B]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,F)=>Object.assign(D,F.opts()),{})}error(D,F){if(this._outputConfiguration.outputError(`${D}
19
19
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
20
20
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
21
- `),this.outputHelp({error:!0});let q=J||{},U=q.exitCode||1,G=q.code||"commander.error";this._exit(U,G,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in E.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,E.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new n0(this.options),J=(q)=>{return this.getOptionValue(q)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(q))};this.options.filter((q)=>q.implied!==void 0&&J(q.attributeName())&&$.valueFromOption(this.getOptionValue(q.attributeName()),q)).forEach((q)=>{Object.keys(q.implied).filter((U)=>!J(U)).forEach((U)=>{this.setOptionValueWithSource(U,q.implied[U],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let q=(X)=>{let Q=X.attributeName(),Z=this.getOptionValue(Q),_=this.options.find((S)=>S.negate&&Q===S.attributeName()),Y=this.options.find((S)=>!S.negate&&Q===S.attributeName());if(_&&(_.presetArg===void 0&&Z===!1||_.presetArg!==void 0&&Z===_.presetArg))return _;return Y||X},U=(X)=>{let Q=q(X),Z=Q.attributeName();if(this.getOptionValueSource(Z)==="env")return`environment variable '${Q.envVar}'`;return`option '${Q.flags}'`},G=`error: ${U($)} cannot be used with ${U(J)}`;this.error(G,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let U=[],G=this;do{let X=G.createHelp().visibleOptions(G).filter((Q)=>Q.long).map((Q)=>Q.long);U=U.concat(X),G=G.parent}while(G&&!G._enablePositionalOptions);J=V1($,U)}let q=`error: unknown option '${$}'${J}`;this.error(q,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,q=J===1?"":"s",G=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${J} argument${q} but got ${$.length}.`;this.error(G,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let U=[];this.createHelp().visibleCommands(this).forEach((G)=>{if(U.push(G.name()),G.alias())U.push(G.alias())}),J=V1($,U)}let q=`error: unknown command '${$}'${J}`;this.error(q,{code:"commander.unknownCommand"})}version($,J,q){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",q=q||"output the version number";let U=this.createOption(J,q);return this._versionOptionName=U.attributeName(),this._registerOption(U),this.on("option:"+U.name(),()=>{this._outputConfiguration.writeOut(`${$}
22
- `),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let q=this.parent?._findCommand($);if(q){let U=[q.name()].concat(q.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${U}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((q)=>{return o0(q)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=y.basename($,y.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp();if(J.helpWidth===void 0)J.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return J.formatHelp(this,J)}_getHelpContext($){$=$||{};let J={error:!!$.error},q;if(J.error)q=(U)=>this._outputConfiguration.writeErr(U);else q=(U)=>this._outputConfiguration.writeOut(U);return J.write=$.write||q,J.command=this,J}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let q=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let U=this.helpInformation(q);if(J){if(U=J(U),typeof U!=="string"&&!Buffer.isBuffer(U))throw Error("outputHelp callback must return a string or a Buffer")}if(q.write(U),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",q))}helpOption($,J){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",J=J??"display help for command",this._helpOption=this.createOption($,J),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let J=E.exitCode||0;if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let q=["beforeAll","before","after","afterAll"];if(!q.includes($))throw Error(`Unexpected value for position to addHelpText.
23
- Expecting one of '${q.join("', '")}'`);let U=`${$}Help`;return this.on(U,(G)=>{let X;if(typeof J==="function")X=J({error:G.error,command:G.command});else X=J;if(X)G.write(`${X}
24
- `)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((U)=>J.is(U)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function M1($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let q,U="127.0.0.1",G="9229",X;if((X=J.match(/^(--inspect(-brk)?)$/))!==null)q=X[1];else if((X=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(q=X[1],/^\d+$/.test(X[3]))G=X[3];else U=X[3];else if((X=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)q=X[1],U=X[3],G=X[4];if(q&&G!=="0")return`${q}=${U}:${parseInt(G)+1}`;return J})}e0.Command=n});var P1=A((U$)=>{var{Argument:F1}=v(),{Command:e}=T1(),{CommanderError:J$,InvalidArgumentError:D1}=b(),{Help:q$}=s(),{Option:y1}=i();U$.program=new e;U$.createCommand=($)=>new e($);U$.createOption=($,J)=>new y1($,J);U$.createArgument=($,J)=>new F1($,J);U$.Command=e;U$.Option=y1;U$.Argument=F1;U$.Help=q$;U$.CommanderError=J$;U$.InvalidArgumentError=D1;U$.InvalidOptionArgumentError=D1});var j1=j0(P1(),1),{program:F6,createCommand:D6,createArgument:y6,createOption:P6,CommanderError:j6,InvalidArgumentError:A6,InvalidOptionArgumentError:I6,Command:A1,Argument:N6,Option:O6,Help:f6}=j1.default;var I1="0.260202.0530";import{join as u$}from"path";var z=[];for(let $=0;$<256;++$)z.push(($+256).toString(16).slice(1));function N1($,J=0){return(z[$[J+0]]+z[$[J+1]]+z[$[J+2]]+z[$[J+3]]+"-"+z[$[J+4]]+z[$[J+5]]+"-"+z[$[J+6]]+z[$[J+7]]+"-"+z[$[J+8]]+z[$[J+9]]+"-"+z[$[J+10]]+z[$[J+11]]+z[$[J+12]]+z[$[J+13]]+z[$[J+14]]+z[$[J+15]]).toLowerCase()}import{randomFillSync as K$}from"crypto";var g=new Uint8Array(256),h=g.length;function $1(){if(h>g.length-16)K$(g),h=0;return g.slice(h,h+=16)}import{randomUUID as E$}from"crypto";var J1={randomUUID:E$};function z$($,J,q){if(J1.randomUUID&&!J&&!$)return J1.randomUUID();$=$||{};let U=$.random??$.rng?.()??$1();if(U.length<16)throw Error("Random bytes length must be >= 16");if(U[6]=U[6]&15|64,U[8]=U[8]&63|128,J){if(q=q||0,q<0||q+16>J.length)throw RangeError(`UUID byte range ${q}:${q+15} is out of buffer bounds`);for(let G=0;G<16;++G)J[q+G]=U[G];return J}return N1(U)}var u=z$;import{exec as L$}from"child_process";import{promisify as V$}from"util";import{join as M$}from"path";import{mkdirSync as T$,existsSync as F$}from"fs";import{homedir as D$}from"os";var y$=V$(L$);function P$(){let $=M$(D$(),".genie","logs","tmux");if(!F$($))T$($,{recursive:!0});return $}function j$($){return $.filter((J)=>!/^-v+$/.test(J))}function A$(){return process.env.GENIE_TMUX_DEBUG==="1"}async function O1($){let J=typeof $==="string"?$.split(/\s+/).filter(Boolean):$,q=j$(J),U=A$(),G={};if(U)q=["-v",...q],G.cwd=P$();let X=`tmux ${q.join(" ")}`,{stdout:Q}=await y$(X,G);return Q.trim()}var I$={type:"bash"};async function R($){try{return await O1($)}catch(J){throw Error(`Failed to execute tmux command: ${J.message}`)}}async function G1(){try{let J=await R("list-sessions -F '#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}'");if(!J)return[];return J.split(`
25
- `).map((q)=>{let[U,G,X,Q]=q.split(":");return{id:U,name:G,attached:X==="1",windows:parseInt(Q,10)}})}catch($){if($.message.includes("no server running"))return[];throw $}}async function K($){try{return(await G1()).find((q)=>q.name===$)||null}catch(J){return null}}async function L($){try{let q=await R(`list-windows -t '${$}' -F '#{window_id}:#{window_name}:#{?window_active,1,0}'`);if(!q)return[];return q.split(`
26
- `).map((U)=>{let[G,X,Q]=U.split(":");return{id:G,name:X,active:Q==="1",sessionId:$}})}catch(J){if(J.message.includes("no server running")||J.message.includes("session not found"))return[];throw J}}async function M($){try{let q=await R(`list-panes -t '${$}' -F '#{pane_id}:#{pane_title}:#{?pane_active,1,0}'`);if(!q)return[];return q.split(`
27
- `).map((U)=>{let[G,X,Q]=U.split(":");return{id:G,windowId:$,title:X,active:Q==="1"}})}catch(J){if(J.message.includes("no server running")||J.message.includes("window not found"))return[];throw J}}async function I($,J=200,q=!1){try{return await R(`capture-pane -p ${q?"-e":""} -t '${$}' -S -${J} -E -`)}catch(U){if(U.message.includes("no server running")||U.message.includes("pane not found"))return"";throw U}}async function l($){return await R(`new-session -d -s "${$}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),K($)}async function d($,J){let q=await R(`new-window -t '${$}' -n '${J}'`);return(await L($)).find((G)=>G.name===J)||null}async function f1($){await R(`kill-session -t '${$}'`)}async function C1($){await R(`kill-window -t '${$}'`)}async function k1($){await R(`kill-pane -t '${$}'`)}async function w1($,J="vertical",q){let U="split-window";if(J==="horizontal")U+=" -h";else U+=" -v";if(U+=` -t '${$}'`,q!==void 0&&q>0&&q<100)U+=` -p ${q}`;await R(U);let G=await R(`display-message -p -t '${$}' '#{window_id}'`),X=await M(G);return X.length>0?X[X.length-1]:null}var q1=new Map,U1="TMUX_MCP_START",c="TMUX_MCP_DONE_";async function b1($,J,q,U){let G=u(),X;if(q||U)X=J;else{let Q=N$();X=`echo "${U1}"; ${J}; echo "${Q}"`}if(q1.set(G,{id:G,paneId:$,command:J,status:"pending",startTime:new Date,rawMode:q||U}),U)if(["Up","Down","Left","Right","Escape","Tab","Enter","Space","BSpace","Delete","Home","End","PageUp","PageDown","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(X))await R(`send-keys -t '${$}' ${X}`);else for(let Z of X)await R(`send-keys -t '${$}' '${Z.replace(/'/g,"'\\''")}'`);else await R(`send-keys -t '${$}' '${X.replace(/'/g,"'\\''")}' Enter`);return G}async function x1($){let J=q1.get($);if(!J)return null;if(J.status!=="pending")return J;let q=await I(J.paneId,1000);if(J.rawMode)return J.result="Status tracking unavailable for rawMode commands. Use capture-pane to monitor interactive apps instead.",J;let U=q.lastIndexOf(U1),G=q.lastIndexOf(c);if(U===-1||G===-1||G<=U)return J.result="Command output could not be captured properly",J;let X=q.substring(G).split(`
28
- `)[0],Q=new RegExp(`${c}(\\d+)`),Z=X.match(Q);if(Z){let _=parseInt(Z[1],10);J.status=_===0?"completed":"error",J.exitCode=_;let Y=U+U1.length,S=q.substring(Y,G).trim();J.result=S.substring(S.indexOf(`
29
- `)+1).trim(),q1.set($,J)}return J}function N$(){return I$.type==="fish"?`${c}$status`:`${c}$?`}async function v1($,J,q=120000){let U=u().substring(0,8),G=`/tmp/genie-${U}.out`,X=`/tmp/genie-${U}.exit`,Q=`genie-${U}`,_=`{ ${J.replace(/'/g,"'\\''")}; } 2>&1 | tee ${G}; echo \${PIPESTATUS[0]} > ${X}; tmux wait-for -S ${Q}`;await R(`send-keys -t '${$}' '${_.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([R(`wait-for ${Q}`),new Promise((W,B)=>setTimeout(()=>B(Error("Command timed out")),q))])}catch(W){if(W.message==="Command timed out"){try{await R(`wait-for -S ${Q}`)}catch{}return{output:"",exitCode:124}}throw W}let Y="",S=0;try{let{readFile:W,unlink:B}=await import("fs/promises");Y=await W(G,"utf-8"),Y=Y.trim();let H=await W(X,"utf-8");S=parseInt(H.trim(),10)||0,await B(G).catch(()=>{}),await B(X).catch(()=>{})}catch(W){console.error("Failed to read command output:",W)}return{output:Y,exitCode:S}}var{$:P}=globalThis.Bun;import{mkdir as h1,rm as g1,access as X1,readFile as O$,writeFile as f$}from"fs/promises";import{join as C,basename as C$}from"path";function p($){return $.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function k$($){let J=$.match(/^(\d+)([hdwm])$/i);if(!J)throw Error(`Invalid timeframe format: ${$}. Use format like 7d, 2w, 1m, 24h`);let q=parseInt(J[1],10),U=J[2].toLowerCase();return q*{h:3600000,d:86400000,w:604800000,m:2592000000}[U]}class u1{baseDir;repoPath;metadataPath;constructor($){this.baseDir=$.baseDir,this.repoPath=$.repoPath,this.metadataPath=C(this.baseDir,".metadata.json")}async loadMetadata(){try{let $=await O$(this.metadataPath,"utf-8");return JSON.parse($)}catch{return{worktrees:{}}}}async saveMetadata($){await h1(this.baseDir,{recursive:!0}),await f$(this.metadataPath,JSON.stringify($,null,2))}async createWorktree($,J=!1,q){let U=p($),G=C(this.baseDir,U);await h1(this.baseDir,{recursive:!0});try{throw await X1(G),Error(`Worktree already exists at ${G}`)}catch(Z){if(Z.code!=="ENOENT")throw Z}if(J)if(q)await P`git -C ${this.repoPath} worktree add -b ${$} ${G} ${q}`.quiet();else await P`git -C ${this.repoPath} worktree add -b ${$} ${G}`.quiet();else{if(!await this.branchExists($))throw Error(`Branch '${$}' does not exist. Use -b to create a new branch.`);await P`git -C ${this.repoPath} worktree add ${G} ${$}`.quiet()}let X=await this.loadMetadata();X.worktrees[U]={branch:$,createdAt:new Date().toISOString()},await this.saveMetadata(X);let Q=await this.getCommitHash(G);return{path:G,branch:$,commitHash:Q,createdAt:new Date}}async removeWorktree($){let J=p($),q=C(this.baseDir,J);try{await P`git -C ${this.repoPath} worktree remove ${q} --force`.quiet()}catch{try{await g1(q,{recursive:!0,force:!0})}catch{}}try{await X1(q),await g1(q,{recursive:!0,force:!0})}catch{}let U=await this.loadMetadata();delete U.worktrees[J],await this.saveMetadata(U)}async listWorktrees(){let J=(await P`git -C ${this.repoPath} worktree list --porcelain`.quiet()).stdout.toString(),q=[],U={};for(let Q of J.split(`
30
- `))if(Q.startsWith("worktree ")){if(U.path)q.push(U);U={path:Q.slice(9)}}else if(Q.startsWith("HEAD "))U.commitHash=Q.slice(5);else if(Q.startsWith("branch "))U.branch=Q.slice(7).replace("refs/heads/","");if(U.path)q.push(U);let G=q.filter((Q)=>Q.path.startsWith(this.baseDir)),X=await this.loadMetadata();for(let Q of G){let Z=C$(Q.path),_=X.worktrees[Z];if(_)Q.createdAt=new Date(_.createdAt);Q.size=await this.getDiskUsage(Q.path)}return G}async cleanup($,J=!1){let q=k$($),U=Date.now(),G=await this.listWorktrees(),X=[];for(let Q of G)if(Q.createdAt){if(U-Q.createdAt.getTime()>q)X.push(Q)}if(!J)for(let Q of X)await this.removeWorktree(Q.branch);return X}async prune(){await P`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage($){try{let q=(await P`du -sb ${$}`.quiet()).stdout.toString().trim(),U=parseInt(q.split("\t")[0],10);return isNaN(U)?0:U}catch{return 0}}getWorktreePath($){let J=p($);return C(this.baseDir,J)}async worktreeExists($){let J=p($),q=C(this.baseDir,J);try{return await X1(q),!0}catch{return!1}}async branchExists($){try{return await P`git -C ${this.repoPath} rev-parse --verify ${$}`.quiet(),!0}catch{return!1}}async getCommitHash($){return(await P`git -C ${$} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function k($){let J=$?.baseDir||C(process.cwd(),".worktrees"),q=$?.repoPath||process.cwd();return new u1({baseDir:J,repoPath:q})}import{mkdir as w$,readFile as b$,writeFile as x$,access as v$}from"fs/promises";import{join as c1}from"path";import{homedir as h$}from"os";var l1=c1(h$(),".config","term"),Q1=c1(l1,"sessions.json");async function g$(){await w$(l1,{recursive:!0})}async function Z1(){try{await v$(Q1);let $=await b$(Q1,"utf-8");return JSON.parse($)}catch{return{sessions:{}}}}async function d1($){await g$(),await x$(Q1,JSON.stringify($,null,2))}async function p1($,J){let q=await Z1();q.sessions[$]={...J,createdAt:new Date().toISOString()},await d1(q)}async function m1($){return(await Z1()).sessions[$]||null}async function r1($){let J=await Z1();delete J.sessions[$],await d1(J)}async function s1($,J={}){try{if(await K($))console.error(`\u274C Session "${$}" already exists`),process.exit(1);let U=J.workspace||process.cwd(),G;if(J.worktree){if(!J.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let Q=k({baseDir:u$(J.workspace,".worktrees"),repoPath:J.workspace});if(await Q.worktreeExists($))console.error(`\u274C Worktree for "${$}" already exists`),process.exit(1);let _=await Q.createWorktree($,!0);G=_.path,U=_.path,console.log(`\u2705 Worktree created at ${G}`)}if(!await l($))console.error(`\u274C Failed to create session "${$}"`),process.exit(1);if(await R(`send-keys -t '${$}' 'cd ${U}' Enter`),G)await p1($,{worktreePath:G,workspace:J.workspace});if(console.log(`\u2705 Session "${$}" created`),U!==process.cwd())console.log(` Working directory: ${U}`);console.log(`
31
- To attach: term attach ${$}`)}catch(q){console.error(`\u274C Error creating session: ${q.message}`),process.exit(1)}}async function i1($={}){try{let J=await G1();if($.json){console.log(JSON.stringify(J,null,2));return}if(J.length===0){console.log("No tmux sessions found");return}console.log("SESSION ID\t\tNAME\t\t\tWINDOWS\t\tATTACHED"),console.log("\u2500".repeat(80));for(let q of J){let U=q.attached?"yes":"no";console.log(`${q.id} ${q.name} ${q.windows} ${U}`)}}catch(J){console.error(`Error listing sessions: ${J.message}`),process.exit(1)}}import{exec as d$}from"child_process";import{promisify as p$}from"util";var m$=p$(d$);async function t1($){try{if(!await K($))console.error(`\u274C Session "${$}" not found`),process.exit(1);console.log(`\uD83D\uDCCE Attaching to session "${$}"...`),await m$(`tmux attach -t "${$}"`)}catch(J){console.error(`\u274C Error attaching to session: ${J.message}`),process.exit(1)}}import{join as s$}from"path";async function o1($,J={}){try{let q=await K($);if(!q)console.error(`\u274C Session "${$}" not found`),process.exit(1);let U=await m1($);if(await f1(q.id),U?.worktreePath&&U?.workspace&&!J.keepWorktree)await k({baseDir:s$(U.workspace,".worktrees"),repoPath:U.workspace}).removeWorktree($),console.log(`\u2705 Session "${$}" and worktree removed`);else if(U?.worktreePath&&J.keepWorktree)console.log(`\u2705 Session "${$}" removed (worktree kept at ${U.worktreePath})`);else console.log(`\u2705 Session "${$}" removed`);if(U)await r1($)}catch(q){console.error(`\u274C Error removing session: ${q.message}`),process.exit(1)}}function x($){let q=$.split(`
32
- `).filter((U)=>{let G=U.trim();if(G.match(/^TMUX_MCP_START$/))return!1;if(G.match(/^TMUX_MCP_DONE_\d+$/))return!1;if(G.includes("TMUX_MCP_START"))return!1;if(G.includes("TMUX_MCP_DONE_"))return!1;if(U.includes('echo "TMUX_MCP_START"'))return!1;if(U.includes('echo "TMUX_MCP_DONE_'))return!1;if(U.includes("-bash:"))return!1;if(U.includes("warning: setlocale:"))return!1;if(U.includes("cannot change locale"))return!1;if(G==="or directory")return!1;return!0});while(q.length>0&&q[0].trim()==="")q.shift();while(q.length>0&&q[q.length-1].trim()==="")q.pop();return q.join(`
33
- `)}async function a1($,J={}){let q=await K($);if(!q)throw Error(`Session "${$}" not found`);let U=await L(q.id);if(!U||U.length===0)throw Error(`No windows found in session "${$}"`);let G=await M(U[0].id);if(!G||G.length===0)throw Error(`No panes found in session "${$}"`);let X=G[0].id;if(J.range){let _=J.range.split(":");if(_.length===2)J.from=parseInt(_[0],10),J.to=parseInt(_[1],10)}if(J.all){let _=await I(X,1e4);return x(_)}if(J.from!==void 0&&J.to!==void 0){let _=await I(X,1e4),W=x(_).split(`
34
- `).slice(J.from,J.to+1).join(`
35
- `);if(J.reverse)return W.split(`
21
+ `),this.outputHelp({error:!0});let E=F||{},B=E.exitCode||1,$=E.code||"commander.error";this._exit(B,$,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in h.env){let F=D.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,h.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new UF(this.options),F=(E)=>{return this.getOptionValue(E)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(E))};this.options.filter((E)=>E.implied!==void 0&&F(E.attributeName())&&D.valueFromOption(this.getOptionValue(E.attributeName()),E)).forEach((E)=>{Object.keys(E.implied).filter((B)=>!F(B)).forEach((B)=>{this.setOptionValueWithSource(B,E.implied[B],"implied")})})}missingArgument(D){let F=`error: missing required argument '${D}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(D){let F=`error: option '${D.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let F=`error: required option '${D.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,F){let E=(J)=>{let X=J.attributeName(),Q=this.getOptionValue(X),Y=this.options.find((_)=>_.negate&&X===_.attributeName()),q=this.options.find((_)=>!_.negate&&X===_.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return q||J},B=(J)=>{let X=E(J),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},$=`error: ${B(D)} cannot be used with ${B(F)}`;this.error($,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let F="";if(D.startsWith("--")&&this._showSuggestionAfterError){let B=[],$=this;do{let J=$.createHelp().visibleOptions($).filter((X)=>X.long).map((X)=>X.long);B=B.concat(J),$=$.parent}while($&&!$._enablePositionalOptions);F=n3(D,B)}let E=`error: unknown option '${D}'${F}`;this.error(E,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,E=F===1?"":"s",$=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${E} but got ${D.length}.`;this.error($,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],F="";if(this._showSuggestionAfterError){let B=[];this.createHelp().visibleCommands(this).forEach(($)=>{if(B.push($.name()),$.alias())B.push($.alias())}),F=n3(D,B)}let E=`error: unknown command '${D}'${F}`;this.error(E,{code:"commander.unknownCommand"})}version(D,F,E){if(D===void 0)return this._version;this._version=D,F=F||"-V, --version",E=E||"output the version number";let B=this.createOption(F,E);return this._versionOptionName=B.attributeName(),this._registerOption(B),this.on("option:"+B.name(),()=>{this._outputConfiguration.writeOut(`${D}
22
+ `),this._exit(0,"commander.version",D)}),this}description(D,F){if(D===void 0&&F===void 0)return this._description;if(this._description=D,F)this._argsDescription=F;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(D===F._name)throw Error("Command alias can't be the same as its name");let E=this.parent?._findCommand(D);if(E){let B=[E.name()].concat(E.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${B}'`)}return F._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((F)=>this.alias(F)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((E)=>{return GF(E)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}nameFromFilename(D){return this._name=RD.basename(D,RD.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let F=this.createHelp();if(F.helpWidth===void 0)F.helpWidth=D&&D.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return F.formatHelp(this,F)}_getHelpContext(D){D=D||{};let F={error:!!D.error},E;if(F.error)E=(B)=>this._outputConfiguration.writeErr(B);else E=(B)=>this._outputConfiguration.writeOut(B);return F.write=D.write||E,F.command=this,F}outputHelp(D){let F;if(typeof D==="function")F=D,D=void 0;let E=this._getHelpContext(D);this._getCommandAndAncestors().reverse().forEach(($)=>$.emit("beforeAllHelp",E)),this.emit("beforeHelp",E);let B=this.helpInformation(E);if(F){if(B=F(B),typeof B!=="string"&&!Buffer.isBuffer(B))throw Error("outputHelp callback must return a string or a Buffer")}if(E.write(B),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",E),this._getCommandAndAncestors().forEach(($)=>$.emit("afterAllHelp",E))}helpOption(D,F){if(typeof D==="boolean"){if(D)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return D=D??"-h, --help",F=F??"display help for command",this._helpOption=this.createOption(D,F),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this}help(D){this.outputHelp(D);let F=h.exitCode||0;if(F===0&&D&&typeof D!=="function"&&D.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(D,F){let E=["beforeAll","before","after","afterAll"];if(!E.includes(D))throw Error(`Unexpected value for position to addHelpText.
23
+ Expecting one of '${E.join("', '")}'`);let B=`${D}Help`;return this.on(B,($)=>{let J;if(typeof F==="function")J=F({error:$.error,command:$.command});else J=F;if(J)$.write(`${J}
24
+ `)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find((B)=>F.is(B)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function r3(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let E,B="127.0.0.1",$="9229",J;if((J=F.match(/^(--inspect(-brk)?)$/))!==null)E=J[1];else if((J=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(E=J[1],/^\d+$/.test(J[3]))$=J[3];else B=J[3];else if((J=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)E=J[1],B=J[3],$=J[4];if(E&&$!=="0")return`${E}=${B}:${parseInt($)+1}`;return F})}CF.Command=v0});var e3=m((KF)=>{var{Argument:o3}=s2(),{Command:x0}=a3(),{CommanderError:VF,InvalidArgumentError:s3}=Z2(),{Help:RF}=I0(),{Option:t3}=u0();KF.program=new x0;KF.createCommand=(D)=>new x0(D);KF.createOption=(D,F)=>new t3(D,F);KF.createArgument=(D,F)=>new o3(D,F);KF.Command=x0;KF.Option=t3;KF.Argument=o3;KF.Help=RF;KF.CommanderError=VF;KF.InvalidArgumentError=s3;KF.InvalidOptionArgumentError=s3});var oD={};h3(oD,{updateState:()=>T2,update:()=>X9,unregister:()=>rD,register:()=>J3,list:()=>aD,hasWorkerForTask:()=>Y9,getRegistryPath:()=>W9,getElapsedTime:()=>_9,getConfigDir:()=>H9,getByState:()=>q9,get:()=>X3,findByWish:()=>Q9,findByTask:()=>vD,findByPane:()=>Q3});import{mkdir as F9,readFile as E9,writeFile as B9}from"fs/promises";import{join as T6}from"path";import{homedir as $9}from"os";async function J9(){await F9(B3,{recursive:!0})}async function S2(){try{let D=await E9($3,"utf-8");return JSON.parse(D)}catch{return{workers:{},lastUpdated:new Date().toISOString()}}}async function z0(D){await J9(),D.lastUpdated=new Date().toISOString(),await B9($3,JSON.stringify(D,null,2))}async function J3(D){let F=await S2();F.workers[D.id]=D,await z0(F)}async function rD(D){let F=await S2();delete F.workers[D],await z0(F)}async function X3(D){return(await S2()).workers[D]||null}async function aD(){let D=await S2();return Object.values(D.workers)}async function T2(D,F){let E=await S2(),B=E.workers[D];if(B)B.state=F,B.lastStateChange=new Date().toISOString(),await z0(E)}async function X9(D,F){let E=await S2(),B=E.workers[D];if(B){if(Object.assign(B,F),F.state)B.lastStateChange=new Date().toISOString();await z0(E)}}async function Q3(D){let F=await aD(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function vD(D){return(await aD()).find((E)=>E.taskId===D)||null}async function Q9(D){return(await aD()).filter((E)=>E.wishSlug===D)}async function Y9(D){return await vD(D)!==null}async function q9(D){return(await aD()).filter((E)=>E.state===D)}function _9(D){let F=new Date(D.startedAt).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60),J;if($>0)J=`${$}h ${B%60}m`;else if(B>0)J=`${B}m`;else J="<1m";return{ms:E,formatted:J}}function H9(){return B3}function W9(){return $3}var B3,$3;var sD=p1(()=>{B3=T6($9(),".config","term"),$3=T6(B3,"workers.json")});var K0=m((u$,k6)=>{var Z9=VD("tty"),k9=Z9?.WriteStream?.prototype?.hasColors?.()??!1,w=(D,F)=>{if(!k9)return($)=>$;let E=`\x1B[${D}m`,B=`\x1B[${F}m`;return($)=>{let J=$+"",X=J.indexOf(B);if(X===-1)return E+J+B;let Q=E,Y=0,_=(F===22?B:"")+E;while(X!==-1)Q+=J.slice(Y,X)+_,Y=X+B.length,X=J.indexOf(B,Y);return Q+=J.slice(Y)+B,Q}},b={};b.reset=w(0,0);b.bold=w(1,22);b.dim=w(2,22);b.italic=w(3,23);b.underline=w(4,24);b.overline=w(53,55);b.inverse=w(7,27);b.hidden=w(8,28);b.strikethrough=w(9,29);b.black=w(30,39);b.red=w(31,39);b.green=w(32,39);b.yellow=w(33,39);b.blue=w(34,39);b.magenta=w(35,39);b.cyan=w(36,39);b.white=w(37,39);b.gray=w(90,39);b.bgBlack=w(40,49);b.bgRed=w(41,49);b.bgGreen=w(42,49);b.bgYellow=w(43,49);b.bgBlue=w(44,49);b.bgMagenta=w(45,49);b.bgCyan=w(46,49);b.bgWhite=w(47,49);b.bgGray=w(100,49);b.redBright=w(91,39);b.greenBright=w(92,39);b.yellowBright=w(93,39);b.blueBright=w(94,39);b.magentaBright=w(95,39);b.cyanBright=w(96,39);b.whiteBright=w(97,39);b.bgRedBright=w(101,49);b.bgGreenBright=w(102,49);b.bgYellowBright=w(103,49);b.bgBlueBright=w(104,49);b.bgMagentaBright=w(105,49);b.bgCyanBright=w(106,49);b.bgWhiteBright=w(107,49);k6.exports=b});var m6=m((t$,l6)=>{l6.exports=p9;function m9(D){let F={defaultWidth:0,output:process.stdout,tty:VD("tty")};if(!D)return F;return Object.keys(F).forEach(function(E){if(!D[E])D[E]=F[E]}),D}function p9(D){let F=m9(D);if(F.output.getWindowSize)return F.output.getWindowSize()[0]||F.defaultWidth;if(F.tty.getWindowSize)return F.tty.getWindowSize()[1]||F.defaultWidth;if(F.output.columns)return F.output.columns;if(process.env.CLI_WIDTH){let E=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(E)&&E!==0)return E}return F.defaultWidth}});var c6=m((e$,p6)=>{p6.exports=({onlyFirst:D=!1}={})=>{let F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(F,D?void 0:"g")}});var z3=m((DJ,d6)=>{var c9=c6();d6.exports=(D)=>typeof D==="string"?D.replace(c9(),""):D});var n6=m((FJ,V3)=>{var i6=(D)=>{if(Number.isNaN(D))return!1;if(D>=4352&&(D<=4447||D===9001||D===9002||11904<=D&&D<=12871&&D!==12351||12880<=D&&D<=19903||19968<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65131||65281<=D&&D<=65376||65504<=D&&D<=65510||110592<=D&&D<=110593||127488<=D&&D<=127569||131072<=D&&D<=262141))return!0;return!1};V3.exports=i6;V3.exports.default=i6});var a6=m((EJ,r6)=>{r6.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var s6=m((BJ,R3)=>{var d9=z3(),i9=n6(),n9=a6(),o6=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=d9(D),D.length===0)return 0;D=D.replace(n9()," ");let F=0;for(let E=0;E<D.length;E++){let B=D.codePointAt(E);if(B<=31||B>=127&&B<=159)continue;if(B>=768&&B<=879)continue;if(B>65535)E++;F+=i9(B)?2:1}return F};R3.exports=o6;R3.exports.default=o6});var e6=m(($J,t6)=>{t6.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var K3=m((JJ,F1)=>{var n2=e6(),D1={};for(let D of Object.keys(n2))D1[n2[D]]=D;var V={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};F1.exports=V;for(let D of Object.keys(V)){if(!("channels"in V[D]))throw Error("missing channels property: "+D);if(!("labels"in V[D]))throw Error("missing channel labels property: "+D);if(V[D].labels.length!==V[D].channels)throw Error("channel and label counts mismatch: "+D);let{channels:F,labels:E}=V[D];delete V[D].channels,delete V[D].labels,Object.defineProperty(V[D],"channels",{value:F}),Object.defineProperty(V[D],"labels",{value:E})}V.rgb.hsl=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.min(F,E,B),J=Math.max(F,E,B),X=J-$,Q,Y;if(J===$)Q=0;else if(F===J)Q=(E-B)/X;else if(E===J)Q=2+(B-F)/X;else if(B===J)Q=4+(F-E)/X;if(Q=Math.min(Q*60,360),Q<0)Q+=360;let q=($+J)/2;if(J===$)Y=0;else if(q<=0.5)Y=X/(J+$);else Y=X/(2-J-$);return[Q,Y*100,q*100]};V.rgb.hsv=function(D){let F,E,B,$,J,X=D[0]/255,Q=D[1]/255,Y=D[2]/255,q=Math.max(X,Q,Y),_=q-Math.min(X,Q,Y),H=function(G){return(q-G)/6/_+0.5};if(_===0)$=0,J=0;else{if(J=_/q,F=H(X),E=H(Q),B=H(Y),X===q)$=B-E;else if(Q===q)$=0.3333333333333333+F-B;else if(Y===q)$=0.6666666666666666+E-F;if($<0)$+=1;else if($>1)$-=1}return[$*360,J*100,q*100]};V.rgb.hwb=function(D){let F=D[0],E=D[1],B=D[2],$=V.rgb.hsl(D)[0],J=0.00392156862745098*Math.min(F,Math.min(E,B));return B=1-0.00392156862745098*Math.max(F,Math.max(E,B)),[$,J*100,B*100]};V.rgb.cmyk=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.min(1-F,1-E,1-B),J=(1-F-$)/(1-$)||0,X=(1-E-$)/(1-$)||0,Q=(1-B-$)/(1-$)||0;return[J*100,X*100,Q*100,$*100]};function r9(D,F){return(D[0]-F[0])**2+(D[1]-F[1])**2+(D[2]-F[2])**2}V.rgb.keyword=function(D){let F=D1[D];if(F)return F;let E=1/0,B;for(let $ of Object.keys(n2)){let J=n2[$],X=r9(D,J);if(X<E)E=X,B=$}return B};V.keyword.rgb=function(D){return n2[D]};V.rgb.xyz=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255;F=F>0.04045?((F+0.055)/1.055)**2.4:F/12.92,E=E>0.04045?((E+0.055)/1.055)**2.4:E/12.92,B=B>0.04045?((B+0.055)/1.055)**2.4:B/12.92;let $=F*0.4124+E*0.3576+B*0.1805,J=F*0.2126+E*0.7152+B*0.0722,X=F*0.0193+E*0.1192+B*0.9505;return[$*100,J*100,X*100]};V.rgb.lab=function(D){let F=V.rgb.xyz(D),E=F[0],B=F[1],$=F[2];E/=95.047,B/=100,$/=108.883,E=E>0.008856?E**0.3333333333333333:7.787*E+0.13793103448275862,B=B>0.008856?B**0.3333333333333333:7.787*B+0.13793103448275862,$=$>0.008856?$**0.3333333333333333:7.787*$+0.13793103448275862;let J=116*B-16,X=500*(E-B),Q=200*(B-$);return[J,X,Q]};V.hsl.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$,J,X;if(E===0)return X=B*255,[X,X,X];if(B<0.5)$=B*(1+E);else $=B+E-B*E;let Q=2*B-$,Y=[0,0,0];for(let q=0;q<3;q++){if(J=F+0.3333333333333333*-(q-1),J<0)J++;if(J>1)J--;if(6*J<1)X=Q+($-Q)*6*J;else if(2*J<1)X=$;else if(3*J<2)X=Q+($-Q)*(0.6666666666666666-J)*6;else X=Q;Y[q]=X*255}return Y};V.hsl.hsv=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=E,J=Math.max(B,0.01);B*=2,E*=B<=1?B:2-B,$*=J<=1?J:2-J;let X=(B+E)/2,Q=B===0?2*$/(J+$):2*E/(B+E);return[F,Q*100,X*100]};V.hsv.rgb=function(D){let F=D[0]/60,E=D[1]/100,B=D[2]/100,$=Math.floor(F)%6,J=F-Math.floor(F),X=255*B*(1-E),Q=255*B*(1-E*J),Y=255*B*(1-E*(1-J));switch(B*=255,$){case 0:return[B,Y,X];case 1:return[Q,B,X];case 2:return[X,B,Y];case 3:return[X,Q,B];case 4:return[Y,X,B];case 5:return[B,X,Q]}};V.hsv.hsl=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=Math.max(B,0.01),J,X;X=(2-E)*B;let Q=(2-E)*$;return J=E*$,J/=Q<=1?Q:2-Q,J=J||0,X/=2,[F,J*100,X*100]};V.hwb.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$=E+B,J;if($>1)E/=$,B/=$;let X=Math.floor(6*F),Q=1-B;if(J=6*F-X,(X&1)!==0)J=1-J;let Y=E+J*(Q-E),q,_,H;switch(X){default:case 6:case 0:q=Q,_=Y,H=E;break;case 1:q=Y,_=Q,H=E;break;case 2:q=E,_=Q,H=Y;break;case 3:q=E,_=Y,H=Q;break;case 4:q=Y,_=E,H=Q;break;case 5:q=Q,_=E,H=Y;break}return[q*255,_*255,H*255]};V.cmyk.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$=D[3]/100,J=1-Math.min(1,F*(1-$)+$),X=1-Math.min(1,E*(1-$)+$),Q=1-Math.min(1,B*(1-$)+$);return[J*255,X*255,Q*255]};V.xyz.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$,J,X;return $=F*3.2406+E*-1.5372+B*-0.4986,J=F*-0.9689+E*1.8758+B*0.0415,X=F*0.0557+E*-0.204+B*1.057,$=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92,J=J>0.0031308?1.055*J**0.4166666666666667-0.055:J*12.92,X=X>0.0031308?1.055*X**0.4166666666666667-0.055:X*12.92,$=Math.min(Math.max(0,$),1),J=Math.min(Math.max(0,J),1),X=Math.min(Math.max(0,X),1),[$*255,J*255,X*255]};V.xyz.lab=function(D){let F=D[0],E=D[1],B=D[2];F/=95.047,E/=100,B/=108.883,F=F>0.008856?F**0.3333333333333333:7.787*F+0.13793103448275862,E=E>0.008856?E**0.3333333333333333:7.787*E+0.13793103448275862,B=B>0.008856?B**0.3333333333333333:7.787*B+0.13793103448275862;let $=116*E-16,J=500*(F-E),X=200*(E-B);return[$,J,X]};V.lab.xyz=function(D){let F=D[0],E=D[1],B=D[2],$,J,X;J=(F+16)/116,$=E/500+J,X=J-B/200;let Q=J**3,Y=$**3,q=X**3;return J=Q>0.008856?Q:(J-0.13793103448275862)/7.787,$=Y>0.008856?Y:($-0.13793103448275862)/7.787,X=q>0.008856?q:(X-0.13793103448275862)/7.787,$*=95.047,J*=100,X*=108.883,[$,J,X]};V.lab.lch=function(D){let F=D[0],E=D[1],B=D[2],$;if($=Math.atan2(B,E)*360/2/Math.PI,$<0)$+=360;let X=Math.sqrt(E*E+B*B);return[F,X,$]};V.lch.lab=function(D){let F=D[0],E=D[1],$=D[2]/360*2*Math.PI,J=E*Math.cos($),X=E*Math.sin($);return[F,J,X]};V.rgb.ansi16=function(D,F=null){let[E,B,$]=D,J=F===null?V.rgb.hsv(D)[2]:F;if(J=Math.round(J/50),J===0)return 30;let X=30+(Math.round($/255)<<2|Math.round(B/255)<<1|Math.round(E/255));if(J===2)X+=60;return X};V.hsv.ansi16=function(D){return V.rgb.ansi16(V.hsv.rgb(D),D[2])};V.rgb.ansi256=function(D){let F=D[0],E=D[1],B=D[2];if(F===E&&E===B){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(E/255*5)+Math.round(B/255*5)};V.ansi16.rgb=function(D){let F=D%10;if(F===0||F===7){if(D>50)F+=3.5;return F=F/10.5*255,[F,F,F]}let E=(~~(D>50)+1)*0.5,B=(F&1)*E*255,$=(F>>1&1)*E*255,J=(F>>2&1)*E*255;return[B,$,J]};V.ansi256.rgb=function(D){if(D>=232){let J=(D-232)*10+8;return[J,J,J]}D-=16;let F,E=Math.floor(D/36)/5*255,B=Math.floor((F=D%36)/6)/5*255,$=F%6/5*255;return[E,B,$]};V.rgb.hex=function(D){let E=(((Math.round(D[0])&255)<<16)+((Math.round(D[1])&255)<<8)+(Math.round(D[2])&255)).toString(16).toUpperCase();return"000000".substring(E.length)+E};V.hex.rgb=function(D){let F=D.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!F)return[0,0,0];let E=F[0];if(F[0].length===3)E=E.split("").map((Q)=>{return Q+Q}).join("");let B=parseInt(E,16),$=B>>16&255,J=B>>8&255,X=B&255;return[$,J,X]};V.rgb.hcg=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.max(Math.max(F,E),B),J=Math.min(Math.min(F,E),B),X=$-J,Q,Y;if(X<1)Q=J/(1-X);else Q=0;if(X<=0)Y=0;else if($===F)Y=(E-B)/X%6;else if($===E)Y=2+(B-F)/X;else Y=4+(F-E)/X;return Y/=6,Y%=1,[Y*360,X*100,Q*100]};V.hsl.hcg=function(D){let F=D[1]/100,E=D[2]/100,B=E<0.5?2*F*E:2*F*(1-E),$=0;if(B<1)$=(E-0.5*B)/(1-B);return[D[0],B*100,$*100]};V.hsv.hcg=function(D){let F=D[1]/100,E=D[2]/100,B=F*E,$=0;if(B<1)$=(E-B)/(1-B);return[D[0],B*100,$*100]};V.hcg.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100;if(E===0)return[B*255,B*255,B*255];let $=[0,0,0],J=F%1*6,X=J%1,Q=1-X,Y=0;switch(Math.floor(J)){case 0:$[0]=1,$[1]=X,$[2]=0;break;case 1:$[0]=Q,$[1]=1,$[2]=0;break;case 2:$[0]=0,$[1]=1,$[2]=X;break;case 3:$[0]=0,$[1]=Q,$[2]=1;break;case 4:$[0]=X,$[1]=0,$[2]=1;break;default:$[0]=1,$[1]=0,$[2]=Q}return Y=(1-E)*B,[(E*$[0]+Y)*255,(E*$[1]+Y)*255,(E*$[2]+Y)*255]};V.hcg.hsv=function(D){let F=D[1]/100,E=D[2]/100,B=F+E*(1-F),$=0;if(B>0)$=F/B;return[D[0],$*100,B*100]};V.hcg.hsl=function(D){let F=D[1]/100,B=D[2]/100*(1-F)+0.5*F,$=0;if(B>0&&B<0.5)$=F/(2*B);else if(B>=0.5&&B<1)$=F/(2*(1-B));return[D[0],$*100,B*100]};V.hcg.hwb=function(D){let F=D[1]/100,E=D[2]/100,B=F+E*(1-F);return[D[0],(B-F)*100,(1-B)*100]};V.hwb.hcg=function(D){let F=D[1]/100,B=1-D[2]/100,$=B-F,J=0;if($<1)J=(B-$)/(1-$);return[D[0],$*100,J*100]};V.apple.rgb=function(D){return[D[0]/65535*255,D[1]/65535*255,D[2]/65535*255]};V.rgb.apple=function(D){return[D[0]/255*65535,D[1]/255*65535,D[2]/255*65535]};V.gray.rgb=function(D){return[D[0]/100*255,D[0]/100*255,D[0]/100*255]};V.gray.hsl=function(D){return[0,0,D[0]]};V.gray.hsv=V.gray.hsl;V.gray.hwb=function(D){return[0,100,D[0]]};V.gray.cmyk=function(D){return[0,0,0,D[0]]};V.gray.lab=function(D){return[D[0],0,0]};V.gray.hex=function(D){let F=Math.round(D[0]/100*255)&255,B=((F<<16)+(F<<8)+F).toString(16).toUpperCase();return"000000".substring(B.length)+B};V.rgb.gray=function(D){return[(D[0]+D[1]+D[2])/3/255*100]}});var B1=m((XJ,E1)=>{var L0=K3();function a9(){let D={},F=Object.keys(L0);for(let E=F.length,B=0;B<E;B++)D[F[B]]={distance:-1,parent:null};return D}function o9(D){let F=a9(),E=[D];F[D].distance=0;while(E.length){let B=E.pop(),$=Object.keys(L0[B]);for(let J=$.length,X=0;X<J;X++){let Q=$[X],Y=F[Q];if(Y.distance===-1)Y.distance=F[B].distance+1,Y.parent=B,E.unshift(Q)}}return F}function s9(D,F){return function(E){return F(D(E))}}function t9(D,F){let E=[F[D].parent,D],B=L0[F[D].parent][D],$=F[D].parent;while(F[$].parent)E.unshift(F[$].parent),B=s9(L0[F[$].parent][$],B),$=F[$].parent;return B.conversion=E,B}E1.exports=function(D){let F=o9(D),E={},B=Object.keys(F);for(let $=B.length,J=0;J<$;J++){let X=B[J];if(F[X].parent===null)continue;E[X]=t9(X,F)}return E}});var J1=m((QJ,$1)=>{var j3=K3(),e9=B1(),P2={},D4=Object.keys(j3);function F4(D){let F=function(...E){let B=E[0];if(B===void 0||B===null)return B;if(B.length>1)E=B;return D(E)};if("conversion"in D)F.conversion=D.conversion;return F}function E4(D){let F=function(...E){let B=E[0];if(B===void 0||B===null)return B;if(B.length>1)E=B;let $=D(E);if(typeof $==="object")for(let J=$.length,X=0;X<J;X++)$[X]=Math.round($[X]);return $};if("conversion"in D)F.conversion=D.conversion;return F}D4.forEach((D)=>{P2[D]={},Object.defineProperty(P2[D],"channels",{value:j3[D].channels}),Object.defineProperty(P2[D],"labels",{value:j3[D].labels});let F=e9(D);Object.keys(F).forEach((B)=>{let $=F[B];P2[D][B]=E4($),P2[D][B].raw=F4($)})});$1.exports=P2});var H1=m((YJ,_1)=>{var X1=(D,F)=>(...E)=>{return`\x1B[${D(...E)+F}m`},Q1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};5;${B}m`},Y1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};2;${B[0]};${B[1]};${B[2]}m`},M0=(D)=>D,q1=(D,F,E)=>[D,F,E],I2=(D,F,E)=>{Object.defineProperty(D,F,{get:()=>{let B=E();return Object.defineProperty(D,F,{value:B,enumerable:!0,configurable:!0}),B},enumerable:!0,configurable:!0})},L3,u2=(D,F,E,B)=>{if(L3===void 0)L3=J1();let $=B?10:0,J={};for(let[X,Q]of Object.entries(L3)){let Y=X==="ansi16"?"ansi":X;if(X===F)J[Y]=D(E,$);else if(typeof Q==="object")J[Y]=D(Q[F],$)}return J};function B4(){let D=new Map,F={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};F.color.gray=F.color.blackBright,F.bgColor.bgGray=F.bgColor.bgBlackBright,F.color.grey=F.color.blackBright,F.bgColor.bgGrey=F.bgColor.bgBlackBright;for(let[E,B]of Object.entries(F)){for(let[$,J]of Object.entries(B))F[$]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},B[$]=F[$],D.set(J[0],J[1]);Object.defineProperty(F,E,{value:B,enumerable:!1})}return Object.defineProperty(F,"codes",{value:D,enumerable:!1}),F.color.close="\x1B[39m",F.bgColor.close="\x1B[49m",I2(F.color,"ansi",()=>u2(X1,"ansi16",M0,!1)),I2(F.color,"ansi256",()=>u2(Q1,"ansi256",M0,!1)),I2(F.color,"ansi16m",()=>u2(Y1,"rgb",q1,!1)),I2(F.bgColor,"ansi",()=>u2(X1,"ansi16",M0,!0)),I2(F.bgColor,"ansi256",()=>u2(Q1,"ansi256",M0,!0)),I2(F.bgColor,"ansi16m",()=>u2(Y1,"rgb",q1,!0)),F}Object.defineProperty(_1,"exports",{enumerable:!0,get:B4})});var A1=m((qJ,G1)=>{var r2=s6(),$4=z3(),J4=H1(),O3=new Set(["\x1B","\x9B"]),W1=(D)=>`${O3.values().next().value}[${D}m`,X4=(D)=>D.split(" ").map((F)=>r2(F)),M3=(D,F,E)=>{let B=[...F],$=!1,J=r2($4(D[D.length-1]));for(let[X,Q]of B.entries()){let Y=r2(Q);if(J+Y<=E)D[D.length-1]+=Q;else D.push(Q),J=0;if(O3.has(Q))$=!0;else if($&&Q==="m"){$=!1;continue}if($)continue;if(J+=Y,J===E&&X<B.length-1)D.push(""),J=0}if(!J&&D[D.length-1].length>0&&D.length>1)D[D.length-2]+=D.pop()},Q4=(D)=>{let F=D.split(" "),E=F.length;while(E>0){if(r2(F[E-1])>0)break;E--}if(E===F.length)return D;return F.slice(0,E).join(" ")+F.slice(E).join("")},Y4=(D,F,E={})=>{if(E.trim!==!1&&D.trim()==="")return"";let B="",$="",J,X=X4(D),Q=[""];for(let[Y,q]of D.split(" ").entries()){if(E.trim!==!1)Q[Q.length-1]=Q[Q.length-1].trimLeft();let _=r2(Q[Q.length-1]);if(Y!==0){if(_>=F&&(E.wordWrap===!1||E.trim===!1))Q.push(""),_=0;if(_>0||E.trim===!1)Q[Q.length-1]+=" ",_++}if(E.hard&&X[Y]>F){let H=F-_,G=1+Math.floor((X[Y]-H-1)/F);if(Math.floor((X[Y]-1)/F)<G)Q.push("");M3(Q,q,F);continue}if(_+X[Y]>F&&_>0&&X[Y]>0){if(E.wordWrap===!1&&_<F){M3(Q,q,F);continue}Q.push("")}if(_+X[Y]>F&&E.wordWrap===!1){M3(Q,q,F);continue}Q[Q.length-1]+=q}if(E.trim!==!1)Q=Q.map(Q4);B=Q.join(`
25
+ `);for(let[Y,q]of[...B].entries()){if($+=q,O3.has(q)){let H=parseFloat(/\d[^m]*/.exec(B.slice(Y,Y+4)));J=H===39?null:H}let _=J4.codes.get(Number(J));if(J&&_){if(B[Y+1]===`
26
+ `)$+=W1(_);else if(q===`
27
+ `)$+=W1(J)}}return $};G1.exports=(D,F,E)=>{return String(D).normalize().replace(/\r\n/g,`
28
+ `).split(`
29
+ `).map((B)=>Y4(B,F,E)).join(`
30
+ `)}});var R1=m((UJ,V1)=>{var _4=VD("stream");class z1 extends _4{#E=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#E!==null)return this.#E;return this.#F("isTTY",!1)}set isTTY(D){this.#E=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}V1.exports=z1});var D8=xD(e3(),1),{program:n4,createCommand:r4,createArgument:a4,createOption:o4,CommanderError:s4,InvalidArgumentError:t4,InvalidOptionArgumentError:e4,Command:F8,Argument:DE,Option:FE,Help:EE}=D8.default;var E8="0.260202.1833";import{join as B5}from"path";var i=[];for(let D=0;D<256;++D)i.push((D+256).toString(16).slice(1));function B8(D,F=0){return(i[D[F+0]]+i[D[F+1]]+i[D[F+2]]+i[D[F+3]]+"-"+i[D[F+4]]+i[D[F+5]]+"-"+i[D[F+6]]+i[D[F+7]]+"-"+i[D[F+8]]+i[D[F+9]]+"-"+i[D[F+10]]+i[D[F+11]]+i[D[F+12]]+i[D[F+13]]+i[D[F+14]]+i[D[F+15]]).toLowerCase()}import{randomFillSync as uF}from"crypto";var e2=new Uint8Array(256),t2=e2.length;function y0(){if(t2>e2.length-16)uF(e2),t2=0;return e2.slice(t2,t2+=16)}import{randomUUID as fF}from"crypto";var h0={randomUUID:fF};function ZF(D,F,E){if(h0.randomUUID&&!F&&!D)return h0.randomUUID();D=D||{};let B=D.random??D.rng?.()??y0();if(B.length<16)throw Error("Random bytes length must be >= 16");if(B[6]=B[6]&15|64,B[8]=B[8]&63|128,F){if(E=E||0,E<0||E+16>F.length)throw RangeError(`UUID byte range ${E}:${E+15} is out of buffer bounds`);for(let $=0;$<16;++$)F[E+$]=B[$];return F}return B8(B)}var D0=ZF;import{exec as kF}from"child_process";import{promisify as vF}from"util";import{join as xF}from"path";import{mkdirSync as yF,existsSync as hF}from"fs";import{homedir as gF}from"os";var lF=vF(kF);function mF(){let D=xF(gF(),".genie","logs","tmux");if(!hF(D))yF(D,{recursive:!0});return D}function pF(D){return D.filter((F)=>!/^-v+$/.test(F))}function cF(){return process.env.GENIE_TMUX_DEBUG==="1"}async function $8(D){let F=typeof D==="string"?D.split(/\s+/).filter(Boolean):D,E=pF(F),B=cF(),$={};if(B)E=["-v",...E],$.cwd=mF();let J=`tmux ${E.join(" ")}`,{stdout:X}=await lF(J,$);return X.trim()}var dF={type:"bash"};async function S(D){try{return await $8(D)}catch(F){throw Error(`Failed to execute tmux command: ${F.message}`)}}async function m0(){try{let F=await S("list-sessions -F '#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}'");if(!F)return[];return F.split(`
31
+ `).map((E)=>{let[B,$,J,X]=E.split(":");return{id:B,name:$,attached:J==="1",windows:parseInt(X,10)}})}catch(D){if(D.message.includes("no server running"))return[];throw D}}async function Z(D){try{return(await m0()).find((E)=>E.name===D)||null}catch(F){return null}}async function v(D){try{let E=await S(`list-windows -t '${D}' -F '#{window_id}:#{window_name}:#{?window_active,1,0}'`);if(!E)return[];return E.split(`
32
+ `).map((B)=>{let[$,J,X]=B.split(":");return{id:$,name:J,active:X==="1",sessionId:D}})}catch(F){if(F.message.includes("no server running")||F.message.includes("session not found"))return[];throw F}}async function g(D){try{let E=await S(`list-panes -t '${D}' -F '#{pane_id}:#{pane_title}:#{?pane_active,1,0}'`);if(!E)return[];return E.split(`
33
+ `).map((B)=>{let[$,J,X]=B.split(":");return{id:$,windowId:D,title:J,active:X==="1"}})}catch(F){if(F.message.includes("no server running")||F.message.includes("window not found"))return[];throw F}}async function p(D,F=200,E=!1){try{return await S(`capture-pane -p ${E?"-e":""} -t '${D}' -S -${F} -E -`)}catch(B){if(B.message.includes("no server running")||B.message.includes("pane not found"))return"";throw B}}async function yD(D){return await S(`new-session -d -s "${D}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),Z(D)}async function E0(D,F){let E=await S(`new-window -t '${D}' -n '${F}'`);return(await v(D)).find(($)=>$.name===F)||null}async function B0(D){await S(`kill-session -t '${D}'`)}async function J8(D){await S(`kill-window -t '${D}'`)}async function $2(D){await S(`kill-pane -t '${D}'`)}async function $0(D,F="vertical",E){let B="split-window";if(F==="horizontal")B+=" -h";else B+=" -v";if(B+=` -t '${D}'`,E!==void 0&&E>0&&E<100)B+=` -p ${E}`;await S(B);let $=await S(`display-message -p -t '${D}' '#{window_id}'`),J=await g($);return J.length>0?J[J.length-1]:null}var g0=new Map,l0="TMUX_MCP_START",F0="TMUX_MCP_DONE_";async function e(D,F,E,B){let $=D0(),J;if(E||B)J=F;else{let X=iF();J=`echo "${l0}"; ${F}; echo "${X}"`}if(g0.set($,{id:$,paneId:D,command:F,status:"pending",startTime:new Date,rawMode:E||B}),B)if(["Up","Down","Left","Right","Escape","Tab","Enter","Space","BSpace","Delete","Home","End","PageUp","PageDown","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(J))await S(`send-keys -t '${D}' ${J}`);else for(let Q of J)await S(`send-keys -t '${D}' '${Q.replace(/'/g,"'\\''")}'`);else await S(`send-keys -t '${D}' '${J.replace(/'/g,"'\\''")}' Enter`);return $}async function X8(D){let F=g0.get(D);if(!F)return null;if(F.status!=="pending")return F;let E=await p(F.paneId,1000);if(F.rawMode)return F.result="Status tracking unavailable for rawMode commands. Use capture-pane to monitor interactive apps instead.",F;let B=E.lastIndexOf(l0),$=E.lastIndexOf(F0);if(B===-1||$===-1||$<=B)return F.result="Command output could not be captured properly",F;let J=E.substring($).split(`
34
+ `)[0],X=new RegExp(`${F0}(\\d+)`),Q=J.match(X);if(Q){let Y=parseInt(Q[1],10);F.status=Y===0?"completed":"error",F.exitCode=Y;let q=B+l0.length,_=E.substring(q,$).trim();F.result=_.substring(_.indexOf(`
35
+ `)+1).trim(),g0.set(D,F)}return F}function iF(){return dF.type==="fish"?`${F0}$status`:`${F0}$?`}async function Q8(D,F,E=120000){let B=D0().substring(0,8),$=`/tmp/genie-${B}.out`,J=`/tmp/genie-${B}.exit`,X=`genie-${B}`,Y=`{ ${F.replace(/'/g,"'\\''")}; } 2>&1 | tee ${$}; echo \${PIPESTATUS[0]} > ${J}; tmux wait-for -S ${X}`;await S(`send-keys -t '${D}' '${Y.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([S(`wait-for ${X}`),new Promise((H,G)=>setTimeout(()=>G(Error("Command timed out")),E))])}catch(H){if(H.message==="Command timed out"){try{await S(`wait-for -S ${X}`)}catch{}return{output:"",exitCode:124}}throw H}let q="",_=0;try{let{readFile:H,unlink:G}=await import("fs/promises");q=await H($,"utf-8"),q=q.trim();let U=await H(J,"utf-8");_=parseInt(U.trim(),10)||0,await G($).catch(()=>{}),await G(J).catch(()=>{})}catch(H){console.error("Failed to read command output:",H)}return{output:q,exitCode:_}}var{$:KD}=globalThis.Bun;import{mkdir as Y8,rm as q8,access as p0,readFile as nF,writeFile as rF}from"fs/promises";import{join as J2,basename as aF}from"path";function J0(D){return D.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function oF(D){let F=D.match(/^(\d+)([hdwm])$/i);if(!F)throw Error(`Invalid timeframe format: ${D}. Use format like 7d, 2w, 1m, 24h`);let E=parseInt(F[1],10),B=F[2].toLowerCase();return E*{h:3600000,d:86400000,w:604800000,m:2592000000}[B]}class PD{baseDir;repoPath;metadataPath;constructor(D){this.baseDir=D.baseDir,this.repoPath=D.repoPath,this.metadataPath=J2(this.baseDir,".metadata.json")}async loadMetadata(){try{let D=await nF(this.metadataPath,"utf-8");return JSON.parse(D)}catch{return{worktrees:{}}}}async saveMetadata(D){await Y8(this.baseDir,{recursive:!0}),await rF(this.metadataPath,JSON.stringify(D,null,2))}async createWorktree(D,F=!1,E){let B=J0(D),$=J2(this.baseDir,B);await Y8(this.baseDir,{recursive:!0});try{throw await p0($),Error(`Worktree already exists at ${$}`)}catch(Q){if(Q.code!=="ENOENT")throw Q}if(F)if(E)await KD`git -C ${this.repoPath} worktree add -b ${D} ${$} ${E}`.quiet();else await KD`git -C ${this.repoPath} worktree add -b ${D} ${$}`.quiet();else{if(!await this.branchExists(D))throw Error(`Branch '${D}' does not exist. Use -b to create a new branch.`);await KD`git -C ${this.repoPath} worktree add ${$} ${D}`.quiet()}let J=await this.loadMetadata();J.worktrees[B]={branch:D,createdAt:new Date().toISOString()},await this.saveMetadata(J);let X=await this.getCommitHash($);return{path:$,branch:D,commitHash:X,createdAt:new Date}}async removeWorktree(D){let F=J0(D),E=J2(this.baseDir,F);try{await KD`git -C ${this.repoPath} worktree remove ${E} --force`.quiet()}catch{try{await q8(E,{recursive:!0,force:!0})}catch{}}try{await p0(E),await q8(E,{recursive:!0,force:!0})}catch{}let B=await this.loadMetadata();delete B.worktrees[F],await this.saveMetadata(B)}async listWorktrees(){let F=(await KD`git -C ${this.repoPath} worktree list --porcelain`.quiet()).stdout.toString(),E=[],B={};for(let X of F.split(`
36
+ `))if(X.startsWith("worktree ")){if(B.path)E.push(B);B={path:X.slice(9)}}else if(X.startsWith("HEAD "))B.commitHash=X.slice(5);else if(X.startsWith("branch "))B.branch=X.slice(7).replace("refs/heads/","");if(B.path)E.push(B);let $=E.filter((X)=>X.path.startsWith(this.baseDir)),J=await this.loadMetadata();for(let X of $){let Q=aF(X.path),Y=J.worktrees[Q];if(Y)X.createdAt=new Date(Y.createdAt);X.size=await this.getDiskUsage(X.path)}return $}async cleanup(D,F=!1){let E=oF(D),B=Date.now(),$=await this.listWorktrees(),J=[];for(let X of $)if(X.createdAt){if(B-X.createdAt.getTime()>E)J.push(X)}if(!F)for(let X of J)await this.removeWorktree(X.branch);return J}async prune(){await KD`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage(D){try{let E=(await KD`du -sb ${D}`.quiet()).stdout.toString().trim(),B=parseInt(E.split("\t")[0],10);return isNaN(B)?0:B}catch{return 0}}getWorktreePath(D){let F=J0(D);return J2(this.baseDir,F)}async worktreeExists(D){let F=J0(D),E=J2(this.baseDir,F);try{return await p0(E),!0}catch{return!1}}async branchExists(D){try{return await KD`git -C ${this.repoPath} rev-parse --verify ${D}`.quiet(),!0}catch{return!1}}async getCommitHash(D){return(await KD`git -C ${D} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function X2(D){let F=D?.baseDir||J2(process.cwd(),".worktrees"),E=D?.repoPath||process.cwd();return new PD({baseDir:F,repoPath:E})}import{mkdir as sF,readFile as tF,writeFile as eF,access as D5}from"fs/promises";import{join as _8}from"path";import{homedir as F5}from"os";var H8=_8(F5(),".config","term"),c0=_8(H8,"sessions.json");async function E5(){await sF(H8,{recursive:!0})}async function d0(){try{await D5(c0);let D=await tF(c0,"utf-8");return JSON.parse(D)}catch{return{sessions:{}}}}async function W8(D){await E5(),await eF(c0,JSON.stringify(D,null,2))}async function G8(D,F){let E=await d0();E.sessions[D]={...F,createdAt:new Date().toISOString()},await W8(E)}async function A8(D){return(await d0()).sessions[D]||null}async function U8(D){let F=await d0();delete F.sessions[D],await W8(F)}async function C8(D,F={}){try{if(await Z(D))console.error(`\u274C Session "${D}" already exists`),process.exit(1);let B=F.workspace||process.cwd(),$;if(F.worktree){if(!F.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let X=X2({baseDir:B5(F.workspace,".worktrees"),repoPath:F.workspace});if(await X.worktreeExists(D))console.error(`\u274C Worktree for "${D}" already exists`),process.exit(1);let Y=await X.createWorktree(D,!0);$=Y.path,B=Y.path,console.log(`\u2705 Worktree created at ${$}`)}if(!await yD(D))console.error(`\u274C Failed to create session "${D}"`),process.exit(1);if(await S(`send-keys -t '${D}' 'cd ${B}' Enter`),$)await G8(D,{worktreePath:$,workspace:F.workspace});if(console.log(`\u2705 Session "${D}" created`),B!==process.cwd())console.log(` Working directory: ${B}`);console.log(`
37
+ To attach: term attach ${D}`)}catch(E){console.error(`\u274C Error creating session: ${E.message}`),process.exit(1)}}async function z8(D={}){try{let F=await m0();if(D.json){console.log(JSON.stringify(F,null,2));return}if(F.length===0){console.log("No tmux sessions found");return}console.log("SESSION ID\t\tNAME\t\t\tWINDOWS\t\tATTACHED"),console.log("\u2500".repeat(80));for(let E of F){let B=E.attached?"yes":"no";console.log(`${E.id} ${E.name} ${E.windows} ${B}`)}}catch(F){console.error(`Error listing sessions: ${F.message}`),process.exit(1)}}import{exec as X5}from"child_process";import{promisify as Q5}from"util";var Y5=Q5(X5);async function V8(D){try{if(!await Z(D))console.error(`\u274C Session "${D}" not found`),process.exit(1);console.log(`\uD83D\uDCCE Attaching to session "${D}"...`),await Y5(`tmux attach -t "${D}"`)}catch(F){console.error(`\u274C Error attaching to session: ${F.message}`),process.exit(1)}}import{join as _5}from"path";async function R8(D,F={}){try{let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await A8(D);if(await B0(E.id),B?.worktreePath&&B?.workspace&&!F.keepWorktree)await X2({baseDir:_5(B.workspace,".worktrees"),repoPath:B.workspace}).removeWorktree(D),console.log(`\u2705 Session "${D}" and worktree removed`);else if(B?.worktreePath&&F.keepWorktree)console.log(`\u2705 Session "${D}" removed (worktree kept at ${B.worktreePath})`);else console.log(`\u2705 Session "${D}" removed`);if(B)await U8(D)}catch(E){console.error(`\u274C Error removing session: ${E.message}`),process.exit(1)}}function k2(D){let E=D.split(`
38
+ `).filter((B)=>{let $=B.trim();if($.match(/^TMUX_MCP_START$/))return!1;if($.match(/^TMUX_MCP_DONE_\d+$/))return!1;if($.includes("TMUX_MCP_START"))return!1;if($.includes("TMUX_MCP_DONE_"))return!1;if(B.includes('echo "TMUX_MCP_START"'))return!1;if(B.includes('echo "TMUX_MCP_DONE_'))return!1;if(B.includes("-bash:"))return!1;if(B.includes("warning: setlocale:"))return!1;if(B.includes("cannot change locale"))return!1;if($==="or directory")return!1;return!0});while(E.length>0&&E[0].trim()==="")E.shift();while(E.length>0&&E[E.length-1].trim()==="")E.pop();return E.join(`
39
+ `)}async function K8(D,F={}){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await v(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await g(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let J=$[0].id;if(F.range){let Y=F.range.split(":");if(Y.length===2)F.from=parseInt(Y[0],10),F.to=parseInt(Y[1],10)}if(F.all){let Y=await p(J,1e4);return k2(Y)}if(F.from!==void 0&&F.to!==void 0){let Y=await p(J,1e4),H=k2(Y).split(`
40
+ `).slice(F.from,F.to+1).join(`
41
+ `);if(F.reverse)return H.split(`
36
42
  `).reverse().join(`
37
- `);return W}if(J.search||J.grep){let _=J.search||J.grep,Y=await I(X,1e4),W=x(Y).split(`
38
- `);try{let B=new RegExp(_,"i"),H=W.filter((T)=>B.test(T));if(J.reverse)return H.reverse().join(`
39
- `);return H.join(`
40
- `)}catch(B){throw Error(`Invalid regex pattern: ${B.message}`)}}let Q=J.lines||100,Z=await I(X,Q);if(Z=x(Z),J.reverse)Z=Z.split(`
43
+ `);return H}if(F.search||F.grep){let Y=F.search||F.grep,q=await p(J,1e4),H=k2(q).split(`
44
+ `);try{let G=new RegExp(Y,"i"),U=H.filter((R)=>G.test(R));if(F.reverse)return U.reverse().join(`
45
+ `);return U.join(`
46
+ `)}catch(G){throw Error(`Invalid regex pattern: ${G.message}`)}}let X=F.lines||100,Q=await p(J,X);if(Q=k2(Q),F.reverse)Q=Q.split(`
41
47
  `).reverse().join(`
42
- `);return Z}async function n1($,J){let q=await K($);if(!q)throw Error(`Session "${$}" not found`);let U=await L(q.id);if(!U||U.length===0)throw Error(`No windows found in session "${$}"`);let G=await M(U[0].id);if(!G||G.length===0)throw Error(`No panes found in session "${$}"`);let X=G[0].id,Q="",Z=!0,_=setInterval(async()=>{if(!Z){clearInterval(_);return}try{let Y=await I(X,100),S=x(Y);if(S!==Q){let W=S.split(`
43
- `),B=Q.split(`
44
- `),H=B.length>0?B.length-1:0;W.slice(H).forEach((j)=>{if(j&&j!==B[B.length-1])J(j)}),Q=S}}catch(Y){clearInterval(_),Z=!1}},500);return()=>{Z=!1,clearInterval(_)}}async function e1($,J){try{let q={lines:J.lines?parseInt(J.lines,10):100,from:J.from?parseInt(J.from,10):void 0,to:J.to?parseInt(J.to,10):void 0,range:J.range,search:J.search,grep:J.grep,follow:J.follow,all:J.all,reverse:J.reverse};if(J.follow){console.log(`Following session "${$}" (Ctrl+C to stop)...`),console.log("");let G=await n1($,(X)=>{console.log(X)});process.on("SIGINT",()=>{G(),console.log(`
45
- Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let U=await a1($,q);if(J.json){let G=U.split(`
46
- `);console.log(JSON.stringify({session:$,lineCount:G.length,content:G},null,2));return}console.log(U)}catch(q){console.error(`Error reading session logs: ${q.message}`),process.exit(1)}}async function $0($,J){let[q,U]=$.includes(":")?$.split(":"):[$,"shell"];try{let G=await K(q);if(!G){if(console.error(`Session "${q}" not found, creating...`),G=await l(q),!G)console.error(`Failed to create session "${q}"`),process.exit(1)}let Q=(await L(G.id)).find((S)=>S.name===U);if(!Q){if(console.error(`Window "${U}" not found, creating...`),Q=await d(G.id,U),!Q)console.error(`Failed to create window "${U}"`),process.exit(1)}let Z=await M(Q.id);if(!Z||Z.length===0)console.error(`No panes found in window "${U}"`),process.exit(1);let{output:_,exitCode:Y}=await v1(Z[0].id,J);if(_)console.log(_);process.exit(Y)}catch(G){console.error(`Error: ${G.message}`),process.exit(1)}}async function J0($,J){try{let q=await K($);if(!q)console.error(`\u274C Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(!U||U.length===0)console.error(`\u274C No windows found in session "${$}"`),process.exit(1);let G=await M(U[0].id);if(!G||G.length===0)console.error(`\u274C No panes found in session "${$}"`),process.exit(1);let X=G[0].id;await b1(X,J,!1,!0),console.log(`\u2705 Keys sent to session "${$}"`)}catch(q){console.error(`\u274C Error sending keys: ${q.message}`),process.exit(1)}}import{join as e$}from"path";async function q0($,J,q={}){try{let U=await K($);if(!U)console.error(`\u274C Session "${$}" not found`),process.exit(1);let G=await L(U.id);if(!G||G.length===0)console.error(`\u274C No windows found in session "${$}"`),process.exit(1);let X=await M(G[0].id);if(!X||X.length===0)console.error(`\u274C No panes found in session "${$}"`),process.exit(1);let Q=X[0].id,Z=J==="h"?"horizontal":"vertical",_;if(q.worktree){if(!q.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let S=k({baseDir:e$(q.workspace,".worktrees"),repoPath:q.workspace});if(!await S.worktreeExists(q.worktree)){let B=await S.createWorktree(q.worktree,!0);console.log(`\u2705 Worktree created at ${B.path}`)}_=S.getWorktreePath(q.worktree)}else if(q.workspace)_=q.workspace;let Y=await w1(Q,Z);if(!Y)console.error("\u274C Failed to split pane"),process.exit(1);if(_&&Y)await R(`send-keys -t '${Y.id}' 'cd ${_}' Enter`);if(console.log(`\u2705 Pane split ${Z}ly in session "${$}"`),_)console.log(` Working directory: ${_}`)}catch(U){console.error(`\u274C Error splitting pane: ${U.message}`),process.exit(1)}}async function U0($,J){await R(`set-hook -g ${$} '${J.replace(/'/g,"'\\''")}'`)}async function G0($){await R(`set-hook -gu ${$}`)}async function X0(){let $=["after-bind-key","after-capture-pane","after-copy-mode","after-display-message","after-display-panes","after-kill-pane","after-list-buffers","after-list-clients","after-list-keys","after-list-panes","after-list-sessions","after-list-windows","after-load-buffer","after-lock-server","after-new-session","after-new-window","after-paste-buffer","after-pipe-pane","after-queue","after-refresh-client","after-rename-session","after-rename-window","after-resize-pane","after-resize-window","after-save-buffer","after-select-layout","after-select-pane","after-select-window","after-send-keys","after-set-buffer","after-set-environment","after-set-option","after-show-environment","after-show-messages","after-show-options","after-split-window","after-unbind-key","alert-activity","alert-bell","alert-silence","client-attached","client-detached","client-resized","client-session-changed","pane-died","pane-exited","pane-focus-in","pane-focus-out","pane-mode-changed","pane-set-clipboard","session-closed","session-created","session-renamed","session-window-changed","window-linked","window-pane-changed","window-renamed","window-unlinked"],J=[];for(let q of $)try{let U=await R(`show-hooks -g ${q}`);if(U.trim()){let G=U.trim().split(" ");if(G.length>=2)J.push({event:G[0],command:G.slice(1).join(" ")})}}catch(U){continue}return J}async function Q0($,J){try{await U0($,J),console.log(`\u2705 Hook set: ${$} \u2192 ${J}`)}catch(q){console.error(`\u274C Error setting hook: ${q.message}`),process.exit(1)}}async function Z0(){try{let $=await X0();if($.length===0){console.log("No hooks configured");return}console.log("EVENT\t\t\t\tCOMMAND"),console.log("\u2500".repeat(80));for(let J of $)console.log(`${J.event} ${J.command}`)}catch($){console.error(`\u274C Error listing hooks: ${$.message}`),process.exit(1)}}async function _0($){try{await G0($),console.log(`\u2705 Hook removed: ${$}`)}catch(J){console.error(`\u274C Error removing hook: ${J.message}`),process.exit(1)}}async function Y0($,J={}){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(J.json){console.log(JSON.stringify(U,null,2));return}if(U.length===0){console.log("No windows found");return}console.log("WINDOW ID\t\tNAME\t\t\tACTIVE"),console.log("\u2500".repeat(60));for(let G of U){let X=G.active?"yes":"no";console.log(`${G.id} ${G.name} ${X}`)}}catch(q){console.error(`Error listing windows: ${q.message}`),process.exit(1)}}async function S0($,J){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await d(q.id,J);if(U)console.log(`Window created: ${U.id}`);else console.error("Failed to create window"),process.exit(1)}catch(q){console.error(`Error creating window: ${q.message}`),process.exit(1)}}async function W0($){try{await C1($),console.log(`Window removed: ${$}`)}catch(J){console.error(`Error removing window: ${J.message}`),process.exit(1)}}async function H0($,J={}){try{let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id);if(U.length===0){if(J.json)console.log("[]");else console.log("No panes found");return}let G=[];for(let X of U){let Q=await M(X.id);for(let Z of Q)G.push({id:Z.id,windowId:X.id,windowName:X.name,title:Z.title,active:Z.active})}if(J.json){console.log(JSON.stringify(G,null,2));return}if(G.length===0){console.log("No panes found");return}console.log("PANE ID\t\tWINDOW\t\t\tTITLE\t\t\tACTIVE"),console.log("\u2500".repeat(80));for(let X of G){let Q=X.active?"yes":"no",Z=X.title||"-";console.log(`${X.id} ${X.windowName} ${Z} ${Q}`)}}catch(q){console.error(`Error listing panes: ${q.message}`),process.exit(1)}}async function R0($){try{await k1($),console.log(`Pane removed: ${$}`)}catch(J){console.error(`Error removing pane: ${J.message}`),process.exit(1)}}async function B0($,J={}){try{if(J.command){await X6(J.command,J.json);return}let q=await K($);if(!q)console.error(`Session "${$}" not found`),process.exit(1);let U=await L(q.id),G=0;for(let Z of U){let _=await M(Z.id);G+=_.length}let X="idle",Q={session:q.name,id:q.id,attached:q.attached,windows:U.length,panes:G,state:X};if(J.json){console.log(JSON.stringify(Q,null,2));return}console.log(`Session: ${Q.session}`),console.log(`ID: ${Q.id}`),console.log(`Attached: ${Q.attached?"yes":"no"}`),console.log(`Windows: ${Q.windows}`),console.log(`Panes: ${Q.panes}`),console.log(`State: ${Q.state}`)}catch(q){console.error(`Error getting status: ${q.message}`),process.exit(1)}}async function X6($,J){try{let q=await x1($);if(!q)console.error(`Command "${$}" not found`),process.exit(1);let U={id:q.id,paneId:q.paneId,command:q.command,status:q.status,exitCode:q.exitCode,startTime:q.startTime.toISOString(),result:q.result};if(J){console.log(JSON.stringify(U,null,2));return}if(console.log(`Command: ${U.id}`),console.log(`Status: ${U.status}`),console.log(`Exit Code: ${U.exitCode??"N/A"}`),console.log(`Start Time: ${U.startTime}`),U.result)console.log(`
48
+ `);return Q}async function j8(D,F){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await v(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await g(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let J=$[0].id,X="",Q=!0,Y=setInterval(async()=>{if(!Q){clearInterval(Y);return}try{let q=await p(J,100),_=k2(q);if(_!==X){let H=_.split(`
49
+ `),G=X.split(`
50
+ `),U=G.length>0?G.length-1:0;H.slice(U).forEach((K)=>{if(K&&K!==G[G.length-1])F(K)}),X=_}}catch(q){clearInterval(Y),Q=!1}},500);return()=>{Q=!1,clearInterval(Y)}}import{existsSync as H0,mkdirSync as w7,readFileSync as Z8,writeFileSync as P7}from"fs";import{homedir as k8}from"os";import{join as v8}from"path";var u={};h3(u,{void:()=>o5,util:()=>I,unknown:()=>r5,union:()=>D7,undefined:()=>d5,tuple:()=>B7,transformer:()=>G7,symbol:()=>c5,string:()=>P8,strictObject:()=>e5,setErrorMap:()=>U5,set:()=>X7,record:()=>$7,quotelessJson:()=>G5,promise:()=>W7,preprocess:()=>C7,pipeline:()=>z7,ostring:()=>V7,optional:()=>A7,onumber:()=>R7,oboolean:()=>K7,objectUtil:()=>i0,object:()=>t5,number:()=>I8,nullable:()=>U7,null:()=>i5,never:()=>a5,nativeEnum:()=>H7,nan:()=>l5,map:()=>J7,makeIssue:()=>v2,literal:()=>q7,lazy:()=>Y7,late:()=>h5,isValid:()=>ID,isDirty:()=>Q0,isAsync:()=>Y2,isAborted:()=>X0,intersection:()=>E7,instanceof:()=>g5,getParsedType:()=>WD,getErrorMap:()=>Q2,function:()=>Q7,enum:()=>_7,effect:()=>G7,discriminatedUnion:()=>F7,defaultErrorMap:()=>jD,datetimeRegex:()=>T8,date:()=>p5,custom:()=>w8,coerce:()=>j7,boolean:()=>u8,bigint:()=>m5,array:()=>s5,any:()=>n5,addIssueToContext:()=>C,ZodVoid:()=>y2,ZodUnknown:()=>uD,ZodUnion:()=>A2,ZodUndefined:()=>W2,ZodType:()=>P,ZodTuple:()=>AD,ZodTransformer:()=>YD,ZodSymbol:()=>x2,ZodString:()=>$D,ZodSet:()=>mD,ZodSchema:()=>P,ZodRecord:()=>h2,ZodReadonly:()=>j2,ZodPromise:()=>pD,ZodPipeline:()=>m2,ZodParsedType:()=>A,ZodOptional:()=>XD,ZodObject:()=>y,ZodNumber:()=>fD,ZodNullable:()=>MD,ZodNull:()=>G2,ZodNever:()=>GD,ZodNativeEnum:()=>V2,ZodNaN:()=>l2,ZodMap:()=>g2,ZodLiteral:()=>z2,ZodLazy:()=>C2,ZodIssueCode:()=>W,ZodIntersection:()=>U2,ZodFunction:()=>_2,ZodFirstPartyTypeKind:()=>M,ZodError:()=>s,ZodEnum:()=>kD,ZodEffects:()=>YD,ZodDiscriminatedUnion:()=>Y0,ZodDefault:()=>R2,ZodDate:()=>gD,ZodCatch:()=>K2,ZodBranded:()=>q0,ZodBoolean:()=>H2,ZodBigInt:()=>ZD,ZodArray:()=>JD,ZodAny:()=>lD,Schema:()=>P,ParseStatus:()=>n,OK:()=>a,NEVER:()=>L7,INVALID:()=>j,EMPTY_PATH:()=>C5,DIRTY:()=>hD,BRAND:()=>y5});var I;(function(D){D.assertEqual=($)=>{};function F($){}D.assertIs=F;function E($){throw Error()}D.assertNever=E,D.arrayToEnum=($)=>{let J={};for(let X of $)J[X]=X;return J},D.getValidEnumValues=($)=>{let J=D.objectKeys($).filter((Q)=>typeof $[$[Q]]!=="number"),X={};for(let Q of J)X[Q]=$[Q];return D.objectValues(X)},D.objectValues=($)=>{return D.objectKeys($).map(function(J){return $[J]})},D.objectKeys=typeof Object.keys==="function"?($)=>Object.keys($):($)=>{let J=[];for(let X in $)if(Object.prototype.hasOwnProperty.call($,X))J.push(X);return J},D.find=($,J)=>{for(let X of $)if(J(X))return X;return},D.isInteger=typeof Number.isInteger==="function"?($)=>Number.isInteger($):($)=>typeof $==="number"&&Number.isFinite($)&&Math.floor($)===$;function B($,J=" | "){return $.map((X)=>typeof X==="string"?`'${X}'`:X).join(J)}D.joinValues=B,D.jsonStringifyReplacer=($,J)=>{if(typeof J==="bigint")return J.toString();return J}})(I||(I={}));var i0;(function(D){D.mergeShapes=(F,E)=>{return{...F,...E}}})(i0||(i0={}));var A=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),WD=(D)=>{switch(typeof D){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(D)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":if(Array.isArray(D))return A.array;if(D===null)return A.null;if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return A.promise;if(typeof Map<"u"&&D instanceof Map)return A.map;if(typeof Set<"u"&&D instanceof Set)return A.set;if(typeof Date<"u"&&D instanceof Date)return A.date;return A.object;default:return A.unknown}};var W=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),G5=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")};class s extends Error{get errors(){return this.issues}constructor(D){super();this.issues=[],this.addIssue=(E)=>{this.issues=[...this.issues,E]},this.addIssues=(E=[])=>{this.issues=[...this.issues,...E]};let F=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,F);else this.__proto__=F;this.name="ZodError",this.issues=D}format(D){let F=D||function($){return $.message},E={_errors:[]},B=($)=>{for(let J of $.issues)if(J.code==="invalid_union")J.unionErrors.map(B);else if(J.code==="invalid_return_type")B(J.returnTypeError);else if(J.code==="invalid_arguments")B(J.argumentsError);else if(J.path.length===0)E._errors.push(F(J));else{let X=E,Q=0;while(Q<J.path.length){let Y=J.path[Q];if(Q!==J.path.length-1)X[Y]=X[Y]||{_errors:[]};else X[Y]=X[Y]||{_errors:[]},X[Y]._errors.push(F(J));X=X[Y],Q++}}};return B(this),E}static assert(D){if(!(D instanceof s))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(D=(F)=>F.message){let F={},E=[];for(let B of this.issues)if(B.path.length>0){let $=B.path[0];F[$]=F[$]||[],F[$].push(D(B))}else E.push(D(B));return{formErrors:E,fieldErrors:F}}get formErrors(){return this.flatten()}}s.create=(D)=>{return new s(D)};var A5=(D,F)=>{let E;switch(D.code){case W.invalid_type:if(D.received===A.undefined)E="Required";else E=`Expected ${D.expected}, received ${D.received}`;break;case W.invalid_literal:E=`Invalid literal value, expected ${JSON.stringify(D.expected,I.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:E=`Unrecognized key(s) in object: ${I.joinValues(D.keys,", ")}`;break;case W.invalid_union:E="Invalid input";break;case W.invalid_union_discriminator:E=`Invalid discriminator value. Expected ${I.joinValues(D.options)}`;break;case W.invalid_enum_value:E=`Invalid enum value. Expected ${I.joinValues(D.options)}, received '${D.received}'`;break;case W.invalid_arguments:E="Invalid function arguments";break;case W.invalid_return_type:E="Invalid function return type";break;case W.invalid_date:E="Invalid date";break;case W.invalid_string:if(typeof D.validation==="object")if("includes"in D.validation){if(E=`Invalid input: must include "${D.validation.includes}"`,typeof D.validation.position==="number")E=`${E} at one or more positions greater than or equal to ${D.validation.position}`}else if("startsWith"in D.validation)E=`Invalid input: must start with "${D.validation.startsWith}"`;else if("endsWith"in D.validation)E=`Invalid input: must end with "${D.validation.endsWith}"`;else I.assertNever(D.validation);else if(D.validation!=="regex")E=`Invalid ${D.validation}`;else E="Invalid";break;case W.too_small:if(D.type==="array")E=`Array must contain ${D.exact?"exactly":D.inclusive?"at least":"more than"} ${D.minimum} element(s)`;else if(D.type==="string")E=`String must contain ${D.exact?"exactly":D.inclusive?"at least":"over"} ${D.minimum} character(s)`;else if(D.type==="number")E=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="bigint")E=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="date")E=`Date must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(D.minimum))}`;else E="Invalid input";break;case W.too_big:if(D.type==="array")E=`Array must contain ${D.exact?"exactly":D.inclusive?"at most":"less than"} ${D.maximum} element(s)`;else if(D.type==="string")E=`String must contain ${D.exact?"exactly":D.inclusive?"at most":"under"} ${D.maximum} character(s)`;else if(D.type==="number")E=`Number must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="bigint")E=`BigInt must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="date")E=`Date must be ${D.exact?"exactly":D.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(D.maximum))}`;else E="Invalid input";break;case W.custom:E="Invalid input";break;case W.invalid_intersection_types:E="Intersection results could not be merged";break;case W.not_multiple_of:E=`Number must be a multiple of ${D.multipleOf}`;break;case W.not_finite:E="Number must be finite";break;default:E=F.defaultError,I.assertNever(D)}return{message:E}},jD=A5;var L8=jD;function U5(D){L8=D}function Q2(){return L8}var v2=(D)=>{let{data:F,path:E,errorMaps:B,issueData:$}=D,J=[...E,...$.path||[]],X={...$,path:J};if($.message!==void 0)return{...$,path:J,message:$.message};let Q="",Y=B.filter((q)=>!!q).slice().reverse();for(let q of Y)Q=q(X,{data:F,defaultError:Q}).message;return{...$,path:J,message:Q}},C5=[];function C(D,F){let E=Q2(),B=v2({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,E,E===jD?void 0:jD].filter(($)=>!!$)});D.common.issues.push(B)}class n{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(D,F){let E=[];for(let B of F){if(B.status==="aborted")return j;if(B.status==="dirty")D.dirty();E.push(B.value)}return{status:D.value,value:E}}static async mergeObjectAsync(D,F){let E=[];for(let B of F){let $=await B.key,J=await B.value;E.push({key:$,value:J})}return n.mergeObjectSync(D,E)}static mergeObjectSync(D,F){let E={};for(let B of F){let{key:$,value:J}=B;if($.status==="aborted")return j;if(J.status==="aborted")return j;if($.status==="dirty")D.dirty();if(J.status==="dirty")D.dirty();if($.value!=="__proto__"&&(typeof J.value<"u"||B.alwaysSet))E[$.value]=J.value}return{status:D.value,value:E}}}var j=Object.freeze({status:"aborted"}),hD=(D)=>({status:"dirty",value:D}),a=(D)=>({status:"valid",value:D}),X0=(D)=>D.status==="aborted",Q0=(D)=>D.status==="dirty",ID=(D)=>D.status==="valid",Y2=(D)=>typeof Promise<"u"&&D instanceof Promise;var z;(function(D){D.errToObj=(F)=>typeof F==="string"?{message:F}:F||{},D.toString=(F)=>typeof F==="string"?F:F?.message})(z||(z={}));class QD{constructor(D,F,E,B){this._cachedPath=[],this.parent=D,this.data=F,this._path=E,this._key=B}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var M8=(D,F)=>{if(ID(F))return{success:!0,data:F.value};else{if(!D.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let E=new s(D.common.issues);return this._error=E,this._error}}}};function T(D){if(!D)return{};let{errorMap:F,invalid_type_error:E,required_error:B,description:$}=D;if(F&&(E||B))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(F)return{errorMap:F,description:$};return{errorMap:(X,Q)=>{let{message:Y}=D;if(X.code==="invalid_enum_value")return{message:Y??Q.defaultError};if(typeof Q.data>"u")return{message:Y??B??Q.defaultError};if(X.code!=="invalid_type")return{message:Q.defaultError};return{message:Y??E??Q.defaultError}},description:$}}class P{get description(){return this._def.description}_getType(D){return WD(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:WD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}_processInputParams(D){return{status:new n,ctx:{common:D.parent.common,data:D.data,parsedType:WD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(Y2(F))throw Error("Synchronous parse encountered promise.");return F}_parseAsync(D){let F=this._parse(D);return Promise.resolve(F)}parse(D,F){let E=this.safeParse(D,F);if(E.success)return E.data;throw E.error}safeParse(D,F){let E={common:{issues:[],async:F?.async??!1,contextualErrorMap:F?.errorMap},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)},B=this._parseSync({data:D,path:E.path,parent:E});return M8(E,B)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)};if(!this["~standard"].async)try{let E=this._parseSync({data:D,path:[],parent:F});return ID(E)?{value:E.value}:{issues:F.common.issues}}catch(E){if(E?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;F.common={issues:[],async:!0}}return this._parseAsync({data:D,path:[],parent:F}).then((E)=>ID(E)?{value:E.value}:{issues:F.common.issues})}async parseAsync(D,F){let E=await this.safeParseAsync(D,F);if(E.success)return E.data;throw E.error}async safeParseAsync(D,F){let E={common:{issues:[],contextualErrorMap:F?.errorMap,async:!0},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)},B=this._parse({data:D,path:E.path,parent:E}),$=await(Y2(B)?B:Promise.resolve(B));return M8(E,$)}refine(D,F){let E=(B)=>{if(typeof F==="string"||typeof F>"u")return{message:F};else if(typeof F==="function")return F(B);else return F};return this._refinement((B,$)=>{let J=D(B),X=()=>$.addIssue({code:W.custom,...E(B)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Q)=>{if(!Q)return X(),!1;else return!0});if(!J)return X(),!1;else return!0})}refinement(D,F){return this._refinement((E,B)=>{if(!D(E))return B.addIssue(typeof F==="function"?F(E,B):F),!1;else return!0})}_refinement(D){return new YD({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:D}})}superRefine(D){return this._refinement(D)}constructor(D){this.spa=this.safeParseAsync,this._def=D,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(F)=>this["~validate"](F)}}optional(){return XD.create(this,this._def)}nullable(){return MD.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return JD.create(this)}promise(){return pD.create(this,this._def)}or(D){return A2.create([this,D],this._def)}and(D){return U2.create(this,D,this._def)}transform(D){return new YD({...T(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new R2({...T(this._def),innerType:this,defaultValue:F,typeName:M.ZodDefault})}brand(){return new q0({typeName:M.ZodBranded,type:this,...T(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new K2({...T(this._def),innerType:this,catchValue:F,typeName:M.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return m2.create(this,D)}readonly(){return j2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var z5=/^c[^\s-]{8,}$/i,V5=/^[0-9a-z]+$/,R5=/^[0-9A-HJKMNP-TV-Z]{26}$/i,K5=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,j5=/^[a-z0-9_-]{21}$/i,L5=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,M5=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,O5=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",n0,S5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,T5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,b5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,w5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,P5=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I5=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,N8="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",u5=new RegExp(`^${N8}$`);function S8(D){let F="[0-5]\\d";if(D.precision)F=`${F}\\.\\d{${D.precision}}`;else if(D.precision==null)F=`${F}(\\.\\d+)?`;let E=D.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${F})${E}`}function f5(D){return new RegExp(`^${S8(D)}$`)}function T8(D){let F=`${N8}T${S8(D)}`,E=[];if(E.push(D.local?"Z?":"Z"),D.offset)E.push("([+-]\\d{2}:?\\d{2})");return F=`${F}(${E.join("|")})`,new RegExp(`^${F}$`)}function Z5(D,F){if((F==="v4"||!F)&&S5.test(D))return!0;if((F==="v6"||!F)&&b5.test(D))return!0;return!1}function k5(D,F){if(!L5.test(D))return!1;try{let[E]=D.split(".");if(!E)return!1;let B=E.replace(/-/g,"+").replace(/_/g,"/").padEnd(E.length+(4-E.length%4)%4,"="),$=JSON.parse(atob(B));if(typeof $!=="object"||$===null)return!1;if("typ"in $&&$?.typ!=="JWT")return!1;if(!$.alg)return!1;if(F&&$.alg!==F)return!1;return!0}catch{return!1}}function v5(D,F){if((F==="v4"||!F)&&T5.test(D))return!0;if((F==="v6"||!F)&&w5.test(D))return!0;return!1}class $D extends P{_parse(D){if(this._def.coerce)D.data=String(D.data);if(this._getType(D)!==A.string){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.string,received:$.parsedType}),j}let E=new n,B=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(D.data.length<$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),E.dirty()}else if($.kind==="max"){if(D.data.length>$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),E.dirty()}else if($.kind==="length"){let J=D.data.length>$.value,X=D.data.length<$.value;if(J||X){if(B=this._getOrReturnCtx(D,B),J)C(B,{code:W.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});else if(X)C(B,{code:W.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});E.dirty()}}else if($.kind==="email"){if(!O5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"email",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="emoji"){if(!n0)n0=new RegExp(N5,"u");if(!n0.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"emoji",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="uuid"){if(!K5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"uuid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="nanoid"){if(!j5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"nanoid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cuid"){if(!z5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"cuid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cuid2"){if(!V5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"cuid2",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="ulid"){if(!R5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"ulid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="url")try{new URL(D.data)}catch{B=this._getOrReturnCtx(D,B),C(B,{validation:"url",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="regex"){if($.regex.lastIndex=0,!$.regex.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"regex",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="trim")D.data=D.data.trim();else if($.kind==="includes"){if(!D.data.includes($.value,$.position))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{includes:$.value,position:$.position},message:$.message}),E.dirty()}else if($.kind==="toLowerCase")D.data=D.data.toLowerCase();else if($.kind==="toUpperCase")D.data=D.data.toUpperCase();else if($.kind==="startsWith"){if(!D.data.startsWith($.value))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{startsWith:$.value},message:$.message}),E.dirty()}else if($.kind==="endsWith"){if(!D.data.endsWith($.value))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{endsWith:$.value},message:$.message}),E.dirty()}else if($.kind==="datetime"){if(!T8($).test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"datetime",message:$.message}),E.dirty()}else if($.kind==="date"){if(!u5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"date",message:$.message}),E.dirty()}else if($.kind==="time"){if(!f5($).test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"time",message:$.message}),E.dirty()}else if($.kind==="duration"){if(!M5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"duration",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="ip"){if(!Z5(D.data,$.version))B=this._getOrReturnCtx(D,B),C(B,{validation:"ip",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="jwt"){if(!k5(D.data,$.alg))B=this._getOrReturnCtx(D,B),C(B,{validation:"jwt",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cidr"){if(!v5(D.data,$.version))B=this._getOrReturnCtx(D,B),C(B,{validation:"cidr",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="base64"){if(!P5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"base64",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="base64url"){if(!I5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"base64url",code:W.invalid_string,message:$.message}),E.dirty()}else I.assertNever($);return{status:E.value,value:D.data}}_regex(D,F,E){return this.refinement((B)=>D.test(B),{validation:F,code:W.invalid_string,...z.errToObj(E)})}_addCheck(D){return new $D({...this._def,checks:[...this._def.checks,D]})}email(D){return this._addCheck({kind:"email",...z.errToObj(D)})}url(D){return this._addCheck({kind:"url",...z.errToObj(D)})}emoji(D){return this._addCheck({kind:"emoji",...z.errToObj(D)})}uuid(D){return this._addCheck({kind:"uuid",...z.errToObj(D)})}nanoid(D){return this._addCheck({kind:"nanoid",...z.errToObj(D)})}cuid(D){return this._addCheck({kind:"cuid",...z.errToObj(D)})}cuid2(D){return this._addCheck({kind:"cuid2",...z.errToObj(D)})}ulid(D){return this._addCheck({kind:"ulid",...z.errToObj(D)})}base64(D){return this._addCheck({kind:"base64",...z.errToObj(D)})}base64url(D){return this._addCheck({kind:"base64url",...z.errToObj(D)})}jwt(D){return this._addCheck({kind:"jwt",...z.errToObj(D)})}ip(D){return this._addCheck({kind:"ip",...z.errToObj(D)})}cidr(D){return this._addCheck({kind:"cidr",...z.errToObj(D)})}datetime(D){if(typeof D==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:D});return this._addCheck({kind:"datetime",precision:typeof D?.precision>"u"?null:D?.precision,offset:D?.offset??!1,local:D?.local??!1,...z.errToObj(D?.message)})}date(D){return this._addCheck({kind:"date",message:D})}time(D){if(typeof D==="string")return this._addCheck({kind:"time",precision:null,message:D});return this._addCheck({kind:"time",precision:typeof D?.precision>"u"?null:D?.precision,...z.errToObj(D?.message)})}duration(D){return this._addCheck({kind:"duration",...z.errToObj(D)})}regex(D,F){return this._addCheck({kind:"regex",regex:D,...z.errToObj(F)})}includes(D,F){return this._addCheck({kind:"includes",value:D,position:F?.position,...z.errToObj(F?.message)})}startsWith(D,F){return this._addCheck({kind:"startsWith",value:D,...z.errToObj(F)})}endsWith(D,F){return this._addCheck({kind:"endsWith",value:D,...z.errToObj(F)})}min(D,F){return this._addCheck({kind:"min",value:D,...z.errToObj(F)})}max(D,F){return this._addCheck({kind:"max",value:D,...z.errToObj(F)})}length(D,F){return this._addCheck({kind:"length",value:D,...z.errToObj(F)})}nonempty(D){return this.min(1,z.errToObj(D))}trim(){return new $D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((D)=>D.kind==="datetime")}get isDate(){return!!this._def.checks.find((D)=>D.kind==="date")}get isTime(){return!!this._def.checks.find((D)=>D.kind==="time")}get isDuration(){return!!this._def.checks.find((D)=>D.kind==="duration")}get isEmail(){return!!this._def.checks.find((D)=>D.kind==="email")}get isURL(){return!!this._def.checks.find((D)=>D.kind==="url")}get isEmoji(){return!!this._def.checks.find((D)=>D.kind==="emoji")}get isUUID(){return!!this._def.checks.find((D)=>D.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((D)=>D.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((D)=>D.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((D)=>D.kind==="cuid2")}get isULID(){return!!this._def.checks.find((D)=>D.kind==="ulid")}get isIP(){return!!this._def.checks.find((D)=>D.kind==="ip")}get isCIDR(){return!!this._def.checks.find((D)=>D.kind==="cidr")}get isBase64(){return!!this._def.checks.find((D)=>D.kind==="base64")}get isBase64url(){return!!this._def.checks.find((D)=>D.kind==="base64url")}get minLength(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxLength(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}}$D.create=(D)=>{return new $D({checks:[],typeName:M.ZodString,coerce:D?.coerce??!1,...T(D)})};function x5(D,F){let E=(D.toString().split(".")[1]||"").length,B=(F.toString().split(".")[1]||"").length,$=E>B?E:B,J=Number.parseInt(D.toFixed($).replace(".","")),X=Number.parseInt(F.toFixed($).replace(".",""));return J%X/10**$}class fD extends P{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(D){if(this._def.coerce)D.data=Number(D.data);if(this._getType(D)!==A.number){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.number,received:$.parsedType}),j}let E=void 0,B=new n;for(let $ of this._def.checks)if($.kind==="int"){if(!I.isInteger(D.data))E=this._getOrReturnCtx(D,E),C(E,{code:W.invalid_type,expected:"integer",received:"float",message:$.message}),B.dirty()}else if($.kind==="min"){if($.inclusive?D.data<$.value:D.data<=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_small,minimum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),B.dirty()}else if($.kind==="max"){if($.inclusive?D.data>$.value:D.data>=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_big,maximum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),B.dirty()}else if($.kind==="multipleOf"){if(x5(D.data,$.value)!==0)E=this._getOrReturnCtx(D,E),C(E,{code:W.not_multiple_of,multipleOf:$.value,message:$.message}),B.dirty()}else if($.kind==="finite"){if(!Number.isFinite(D.data))E=this._getOrReturnCtx(D,E),C(E,{code:W.not_finite,message:$.message}),B.dirty()}else I.assertNever($);return{status:B.value,value:D.data}}gte(D,F){return this.setLimit("min",D,!0,z.toString(F))}gt(D,F){return this.setLimit("min",D,!1,z.toString(F))}lte(D,F){return this.setLimit("max",D,!0,z.toString(F))}lt(D,F){return this.setLimit("max",D,!1,z.toString(F))}setLimit(D,F,E,B){return new fD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:z.toString(B)}]})}_addCheck(D){return new fD({...this._def,checks:[...this._def.checks,D]})}int(D){return this._addCheck({kind:"int",message:z.toString(D)})}positive(D){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(D)})}negative(D){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:z.toString(F)})}finite(D){return this._addCheck({kind:"finite",message:z.toString(D)})}safe(D){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(D)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(D)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}get isInt(){return!!this._def.checks.find((D)=>D.kind==="int"||D.kind==="multipleOf"&&I.isInteger(D.value))}get isFinite(){let D=null,F=null;for(let E of this._def.checks)if(E.kind==="finite"||E.kind==="int"||E.kind==="multipleOf")return!0;else if(E.kind==="min"){if(F===null||E.value>F)F=E.value}else if(E.kind==="max"){if(D===null||E.value<D)D=E.value}return Number.isFinite(F)&&Number.isFinite(D)}}fD.create=(D)=>{return new fD({checks:[],typeName:M.ZodNumber,coerce:D?.coerce||!1,...T(D)})};class ZD extends P{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(D){if(this._def.coerce)try{D.data=BigInt(D.data)}catch{return this._getInvalidInput(D)}if(this._getType(D)!==A.bigint)return this._getInvalidInput(D);let E=void 0,B=new n;for(let $ of this._def.checks)if($.kind==="min"){if($.inclusive?D.data<$.value:D.data<=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_small,type:"bigint",minimum:$.value,inclusive:$.inclusive,message:$.message}),B.dirty()}else if($.kind==="max"){if($.inclusive?D.data>$.value:D.data>=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_big,type:"bigint",maximum:$.value,inclusive:$.inclusive,message:$.message}),B.dirty()}else if($.kind==="multipleOf"){if(D.data%$.value!==BigInt(0))E=this._getOrReturnCtx(D,E),C(E,{code:W.not_multiple_of,multipleOf:$.value,message:$.message}),B.dirty()}else I.assertNever($);return{status:B.value,value:D.data}}_getInvalidInput(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:A.bigint,received:F.parsedType}),j}gte(D,F){return this.setLimit("min",D,!0,z.toString(F))}gt(D,F){return this.setLimit("min",D,!1,z.toString(F))}lte(D,F){return this.setLimit("max",D,!0,z.toString(F))}lt(D,F){return this.setLimit("max",D,!1,z.toString(F))}setLimit(D,F,E,B){return new ZD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:z.toString(B)}]})}_addCheck(D){return new ZD({...this._def,checks:[...this._def.checks,D]})}positive(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(D)})}negative(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:z.toString(F)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}}ZD.create=(D)=>{return new ZD({checks:[],typeName:M.ZodBigInt,coerce:D?.coerce??!1,...T(D)})};class H2 extends P{_parse(D){if(this._def.coerce)D.data=Boolean(D.data);if(this._getType(D)!==A.boolean){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.boolean,received:E.parsedType}),j}return a(D.data)}}H2.create=(D)=>{return new H2({typeName:M.ZodBoolean,coerce:D?.coerce||!1,...T(D)})};class gD extends P{_parse(D){if(this._def.coerce)D.data=new Date(D.data);if(this._getType(D)!==A.date){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.date,received:$.parsedType}),j}if(Number.isNaN(D.data.getTime())){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_date}),j}let E=new n,B=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(D.data.getTime()<$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_small,message:$.message,inclusive:!0,exact:!1,minimum:$.value,type:"date"}),E.dirty()}else if($.kind==="max"){if(D.data.getTime()>$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_big,message:$.message,inclusive:!0,exact:!1,maximum:$.value,type:"date"}),E.dirty()}else I.assertNever($);return{status:E.value,value:new Date(D.data.getTime())}}_addCheck(D){return new gD({...this._def,checks:[...this._def.checks,D]})}min(D,F){return this._addCheck({kind:"min",value:D.getTime(),message:z.toString(F)})}max(D,F){return this._addCheck({kind:"max",value:D.getTime(),message:z.toString(F)})}get minDate(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D!=null?new Date(D):null}get maxDate(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D!=null?new Date(D):null}}gD.create=(D)=>{return new gD({checks:[],coerce:D?.coerce||!1,typeName:M.ZodDate,...T(D)})};class x2 extends P{_parse(D){if(this._getType(D)!==A.symbol){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.symbol,received:E.parsedType}),j}return a(D.data)}}x2.create=(D)=>{return new x2({typeName:M.ZodSymbol,...T(D)})};class W2 extends P{_parse(D){if(this._getType(D)!==A.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.undefined,received:E.parsedType}),j}return a(D.data)}}W2.create=(D)=>{return new W2({typeName:M.ZodUndefined,...T(D)})};class G2 extends P{_parse(D){if(this._getType(D)!==A.null){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.null,received:E.parsedType}),j}return a(D.data)}}G2.create=(D)=>{return new G2({typeName:M.ZodNull,...T(D)})};class lD extends P{constructor(){super(...arguments);this._any=!0}_parse(D){return a(D.data)}}lD.create=(D)=>{return new lD({typeName:M.ZodAny,...T(D)})};class uD extends P{constructor(){super(...arguments);this._unknown=!0}_parse(D){return a(D.data)}}uD.create=(D)=>{return new uD({typeName:M.ZodUnknown,...T(D)})};class GD extends P{_parse(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:A.never,received:F.parsedType}),j}}GD.create=(D)=>{return new GD({typeName:M.ZodNever,...T(D)})};class y2 extends P{_parse(D){if(this._getType(D)!==A.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.void,received:E.parsedType}),j}return a(D.data)}}y2.create=(D)=>{return new y2({typeName:M.ZodVoid,...T(D)})};class JD extends P{_parse(D){let{ctx:F,status:E}=this._processInputParams(D),B=this._def;if(F.parsedType!==A.array)return C(F,{code:W.invalid_type,expected:A.array,received:F.parsedType}),j;if(B.exactLength!==null){let J=F.data.length>B.exactLength.value,X=F.data.length<B.exactLength.value;if(J||X)C(F,{code:J?W.too_big:W.too_small,minimum:X?B.exactLength.value:void 0,maximum:J?B.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:B.exactLength.message}),E.dirty()}if(B.minLength!==null){if(F.data.length<B.minLength.value)C(F,{code:W.too_small,minimum:B.minLength.value,type:"array",inclusive:!0,exact:!1,message:B.minLength.message}),E.dirty()}if(B.maxLength!==null){if(F.data.length>B.maxLength.value)C(F,{code:W.too_big,maximum:B.maxLength.value,type:"array",inclusive:!0,exact:!1,message:B.maxLength.message}),E.dirty()}if(F.common.async)return Promise.all([...F.data].map((J,X)=>{return B.type._parseAsync(new QD(F,J,F.path,X))})).then((J)=>{return n.mergeArray(E,J)});let $=[...F.data].map((J,X)=>{return B.type._parseSync(new QD(F,J,F.path,X))});return n.mergeArray(E,$)}get element(){return this._def.type}min(D,F){return new JD({...this._def,minLength:{value:D,message:z.toString(F)}})}max(D,F){return new JD({...this._def,maxLength:{value:D,message:z.toString(F)}})}length(D,F){return new JD({...this._def,exactLength:{value:D,message:z.toString(F)}})}nonempty(D){return this.min(1,D)}}JD.create=(D,F)=>{return new JD({type:D,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...T(F)})};function q2(D){if(D instanceof y){let F={};for(let E in D.shape){let B=D.shape[E];F[E]=XD.create(q2(B))}return new y({...D._def,shape:()=>F})}else if(D instanceof JD)return new JD({...D._def,type:q2(D.element)});else if(D instanceof XD)return XD.create(q2(D.unwrap()));else if(D instanceof MD)return MD.create(q2(D.unwrap()));else if(D instanceof AD)return AD.create(D.items.map((F)=>q2(F)));else return D}class y extends P{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let D=this._def.shape(),F=I.objectKeys(D);return this._cached={shape:D,keys:F},this._cached}_parse(D){if(this._getType(D)!==A.object){let Y=this._getOrReturnCtx(D);return C(Y,{code:W.invalid_type,expected:A.object,received:Y.parsedType}),j}let{status:E,ctx:B}=this._processInputParams(D),{shape:$,keys:J}=this._getCached(),X=[];if(!(this._def.catchall instanceof GD&&this._def.unknownKeys==="strip")){for(let Y in B.data)if(!J.includes(Y))X.push(Y)}let Q=[];for(let Y of J){let q=$[Y],_=B.data[Y];Q.push({key:{status:"valid",value:Y},value:q._parse(new QD(B,_,B.path,Y)),alwaysSet:Y in B.data})}if(this._def.catchall instanceof GD){let Y=this._def.unknownKeys;if(Y==="passthrough")for(let q of X)Q.push({key:{status:"valid",value:q},value:{status:"valid",value:B.data[q]}});else if(Y==="strict"){if(X.length>0)C(B,{code:W.unrecognized_keys,keys:X}),E.dirty()}else if(Y==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let Y=this._def.catchall;for(let q of X){let _=B.data[q];Q.push({key:{status:"valid",value:q},value:Y._parse(new QD(B,_,B.path,q)),alwaysSet:q in B.data})}}if(B.common.async)return Promise.resolve().then(async()=>{let Y=[];for(let q of Q){let _=await q.key,H=await q.value;Y.push({key:_,value:H,alwaysSet:q.alwaysSet})}return Y}).then((Y)=>{return n.mergeObjectSync(E,Y)});else return n.mergeObjectSync(E,Q)}get shape(){return this._def.shape()}strict(D){return z.errToObj,new y({...this._def,unknownKeys:"strict",...D!==void 0?{errorMap:(F,E)=>{let B=this._def.errorMap?.(F,E).message??E.defaultError;if(F.code==="unrecognized_keys")return{message:z.errToObj(D).message??B};return{message:B}}}:{}})}strip(){return new y({...this._def,unknownKeys:"strip"})}passthrough(){return new y({...this._def,unknownKeys:"passthrough"})}extend(D){return new y({...this._def,shape:()=>({...this._def.shape(),...D})})}merge(D){return new y({unknownKeys:D._def.unknownKeys,catchall:D._def.catchall,shape:()=>({...this._def.shape(),...D._def.shape()}),typeName:M.ZodObject})}setKey(D,F){return this.augment({[D]:F})}catchall(D){return new y({...this._def,catchall:D})}pick(D){let F={};for(let E of I.objectKeys(D))if(D[E]&&this.shape[E])F[E]=this.shape[E];return new y({...this._def,shape:()=>F})}omit(D){let F={};for(let E of I.objectKeys(this.shape))if(!D[E])F[E]=this.shape[E];return new y({...this._def,shape:()=>F})}deepPartial(){return q2(this)}partial(D){let F={};for(let E of I.objectKeys(this.shape)){let B=this.shape[E];if(D&&!D[E])F[E]=B;else F[E]=B.optional()}return new y({...this._def,shape:()=>F})}required(D){let F={};for(let E of I.objectKeys(this.shape))if(D&&!D[E])F[E]=this.shape[E];else{let $=this.shape[E];while($ instanceof XD)$=$._def.innerType;F[E]=$}return new y({...this._def,shape:()=>F})}keyof(){return b8(I.objectKeys(this.shape))}}y.create=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strip",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};y.strictCreate=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strict",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};y.lazycreate=(D,F)=>{return new y({shape:D,unknownKeys:"strip",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};class A2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=this._def.options;function B($){for(let X of $)if(X.result.status==="valid")return X.result;for(let X of $)if(X.result.status==="dirty")return F.common.issues.push(...X.ctx.common.issues),X.result;let J=$.map((X)=>new s(X.ctx.common.issues));return C(F,{code:W.invalid_union,unionErrors:J}),j}if(F.common.async)return Promise.all(E.map(async($)=>{let J={...F,common:{...F.common,issues:[]},parent:null};return{result:await $._parseAsync({data:F.data,path:F.path,parent:J}),ctx:J}})).then(B);else{let $=void 0,J=[];for(let Q of E){let Y={...F,common:{...F.common,issues:[]},parent:null},q=Q._parseSync({data:F.data,path:F.path,parent:Y});if(q.status==="valid")return q;else if(q.status==="dirty"&&!$)$={result:q,ctx:Y};if(Y.common.issues.length)J.push(Y.common.issues)}if($)return F.common.issues.push(...$.ctx.common.issues),$.result;let X=J.map((Q)=>new s(Q));return C(F,{code:W.invalid_union,unionErrors:X}),j}}get options(){return this._def.options}}A2.create=(D,F)=>{return new A2({options:D,typeName:M.ZodUnion,...T(F)})};var LD=(D)=>{if(D instanceof C2)return LD(D.schema);else if(D instanceof YD)return LD(D.innerType());else if(D instanceof z2)return[D.value];else if(D instanceof kD)return D.options;else if(D instanceof V2)return I.objectValues(D.enum);else if(D instanceof R2)return LD(D._def.innerType);else if(D instanceof W2)return[void 0];else if(D instanceof G2)return[null];else if(D instanceof XD)return[void 0,...LD(D.unwrap())];else if(D instanceof MD)return[null,...LD(D.unwrap())];else if(D instanceof q0)return LD(D.unwrap());else if(D instanceof j2)return LD(D.unwrap());else if(D instanceof K2)return LD(D._def.innerType);else return[]};class Y0 extends P{_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.object)return C(F,{code:W.invalid_type,expected:A.object,received:F.parsedType}),j;let E=this.discriminator,B=F.data[E],$=this.optionsMap.get(B);if(!$)return C(F,{code:W.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[E]}),j;if(F.common.async)return $._parseAsync({data:F.data,path:F.path,parent:F});else return $._parseSync({data:F.data,path:F.path,parent:F})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(D,F,E){let B=new Map;for(let $ of F){let J=LD($.shape[D]);if(!J.length)throw Error(`A discriminator value for key \`${D}\` could not be extracted from all schema options`);for(let X of J){if(B.has(X))throw Error(`Discriminator property ${String(D)} has duplicate value ${String(X)}`);B.set(X,$)}}return new Y0({typeName:M.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:B,...T(E)})}}function r0(D,F){let E=WD(D),B=WD(F);if(D===F)return{valid:!0,data:D};else if(E===A.object&&B===A.object){let $=I.objectKeys(F),J=I.objectKeys(D).filter((Q)=>$.indexOf(Q)!==-1),X={...D,...F};for(let Q of J){let Y=r0(D[Q],F[Q]);if(!Y.valid)return{valid:!1};X[Q]=Y.data}return{valid:!0,data:X}}else if(E===A.array&&B===A.array){if(D.length!==F.length)return{valid:!1};let $=[];for(let J=0;J<D.length;J++){let X=D[J],Q=F[J],Y=r0(X,Q);if(!Y.valid)return{valid:!1};$.push(Y.data)}return{valid:!0,data:$}}else if(E===A.date&&B===A.date&&+D===+F)return{valid:!0,data:D};else return{valid:!1}}class U2 extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=($,J)=>{if(X0($)||X0(J))return j;let X=r0($.value,J.value);if(!X.valid)return C(E,{code:W.invalid_intersection_types}),j;if(Q0($)||Q0(J))F.dirty();return{status:F.value,value:X.data}};if(E.common.async)return Promise.all([this._def.left._parseAsync({data:E.data,path:E.path,parent:E}),this._def.right._parseAsync({data:E.data,path:E.path,parent:E})]).then(([$,J])=>B($,J));else return B(this._def.left._parseSync({data:E.data,path:E.path,parent:E}),this._def.right._parseSync({data:E.data,path:E.path,parent:E}))}}U2.create=(D,F,E)=>{return new U2({left:D,right:F,typeName:M.ZodIntersection,...T(E)})};class AD extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.array)return C(E,{code:W.invalid_type,expected:A.array,received:E.parsedType}),j;if(E.data.length<this._def.items.length)return C(E,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;if(!this._def.rest&&E.data.length>this._def.items.length)C(E,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F.dirty();let $=[...E.data].map((J,X)=>{let Q=this._def.items[X]||this._def.rest;if(!Q)return null;return Q._parse(new QD(E,J,E.path,X))}).filter((J)=>!!J);if(E.common.async)return Promise.all($).then((J)=>{return n.mergeArray(F,J)});else return n.mergeArray(F,$)}get items(){return this._def.items}rest(D){return new AD({...this._def,rest:D})}}AD.create=(D,F)=>{if(!Array.isArray(D))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new AD({items:D,typeName:M.ZodTuple,rest:null,...T(F)})};class h2 extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.object)return C(E,{code:W.invalid_type,expected:A.object,received:E.parsedType}),j;let B=[],$=this._def.keyType,J=this._def.valueType;for(let X in E.data)B.push({key:$._parse(new QD(E,X,E.path,X)),value:J._parse(new QD(E,E.data[X],E.path,X)),alwaysSet:X in E.data});if(E.common.async)return n.mergeObjectAsync(F,B);else return n.mergeObjectSync(F,B)}get element(){return this._def.valueType}static create(D,F,E){if(F instanceof P)return new h2({keyType:D,valueType:F,typeName:M.ZodRecord,...T(E)});return new h2({keyType:$D.create(),valueType:D,typeName:M.ZodRecord,...T(F)})}}class g2 extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.map)return C(E,{code:W.invalid_type,expected:A.map,received:E.parsedType}),j;let B=this._def.keyType,$=this._def.valueType,J=[...E.data.entries()].map(([X,Q],Y)=>{return{key:B._parse(new QD(E,X,E.path,[Y,"key"])),value:$._parse(new QD(E,Q,E.path,[Y,"value"]))}});if(E.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let Q of J){let Y=await Q.key,q=await Q.value;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();X.set(Y.value,q.value)}return{status:F.value,value:X}})}else{let X=new Map;for(let Q of J){let{key:Y,value:q}=Q;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();X.set(Y.value,q.value)}return{status:F.value,value:X}}}}g2.create=(D,F,E)=>{return new g2({valueType:F,keyType:D,typeName:M.ZodMap,...T(E)})};class mD extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.set)return C(E,{code:W.invalid_type,expected:A.set,received:E.parsedType}),j;let B=this._def;if(B.minSize!==null){if(E.data.size<B.minSize.value)C(E,{code:W.too_small,minimum:B.minSize.value,type:"set",inclusive:!0,exact:!1,message:B.minSize.message}),F.dirty()}if(B.maxSize!==null){if(E.data.size>B.maxSize.value)C(E,{code:W.too_big,maximum:B.maxSize.value,type:"set",inclusive:!0,exact:!1,message:B.maxSize.message}),F.dirty()}let $=this._def.valueType;function J(Q){let Y=new Set;for(let q of Q){if(q.status==="aborted")return j;if(q.status==="dirty")F.dirty();Y.add(q.value)}return{status:F.value,value:Y}}let X=[...E.data.values()].map((Q,Y)=>$._parse(new QD(E,Q,E.path,Y)));if(E.common.async)return Promise.all(X).then((Q)=>J(Q));else return J(X)}min(D,F){return new mD({...this._def,minSize:{value:D,message:z.toString(F)}})}max(D,F){return new mD({...this._def,maxSize:{value:D,message:z.toString(F)}})}size(D,F){return this.min(D,F).max(D,F)}nonempty(D){return this.min(1,D)}}mD.create=(D,F)=>{return new mD({valueType:D,minSize:null,maxSize:null,typeName:M.ZodSet,...T(F)})};class _2 extends P{constructor(){super(...arguments);this.validate=this.implement}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.function)return C(F,{code:W.invalid_type,expected:A.function,received:F.parsedType}),j;function E(X,Q){return v2({data:X,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,Q2(),jD].filter((Y)=>!!Y),issueData:{code:W.invalid_arguments,argumentsError:Q}})}function B(X,Q){return v2({data:X,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,Q2(),jD].filter((Y)=>!!Y),issueData:{code:W.invalid_return_type,returnTypeError:Q}})}let $={errorMap:F.common.contextualErrorMap},J=F.data;if(this._def.returns instanceof pD){let X=this;return a(async function(...Q){let Y=new s([]),q=await X._def.args.parseAsync(Q,$).catch((G)=>{throw Y.addIssue(E(Q,G)),Y}),_=await Reflect.apply(J,this,q);return await X._def.returns._def.type.parseAsync(_,$).catch((G)=>{throw Y.addIssue(B(_,G)),Y})})}else{let X=this;return a(function(...Q){let Y=X._def.args.safeParse(Q,$);if(!Y.success)throw new s([E(Q,Y.error)]);let q=Reflect.apply(J,this,Y.data),_=X._def.returns.safeParse(q,$);if(!_.success)throw new s([B(q,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new _2({...this._def,args:AD.create(D).rest(uD.create())})}returns(D){return new _2({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,E){return new _2({args:D?D:AD.create([]).rest(uD.create()),returns:F||uD.create(),typeName:M.ZodFunction,...T(E)})}}class C2 extends P{get schema(){return this._def.getter()}_parse(D){let{ctx:F}=this._processInputParams(D);return this._def.getter()._parse({data:F.data,path:F.path,parent:F})}}C2.create=(D,F)=>{return new C2({getter:D,typeName:M.ZodLazy,...T(F)})};class z2 extends P{_parse(D){if(D.data!==this._def.value){let F=this._getOrReturnCtx(D);return C(F,{received:F.data,code:W.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:D.data}}get value(){return this._def.value}}z2.create=(D,F)=>{return new z2({value:D,typeName:M.ZodLiteral,...T(F)})};function b8(D,F){return new kD({values:D,typeName:M.ZodEnum,...T(F)})}class kD extends P{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{expected:I.joinValues(E),received:F.parsedType,code:W.invalid_type}),j}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(D.data)){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{received:F.data,code:W.invalid_enum_value,options:E}),j}return a(D.data)}get options(){return this._def.values}get enum(){let D={};for(let F of this._def.values)D[F]=F;return D}get Values(){let D={};for(let F of this._def.values)D[F]=F;return D}get Enum(){let D={};for(let F of this._def.values)D[F]=F;return D}extract(D,F=this._def){return kD.create(D,{...this._def,...F})}exclude(D,F=this._def){return kD.create(this.options.filter((E)=>!D.includes(E)),{...this._def,...F})}}kD.create=b8;class V2 extends P{_parse(D){let F=I.getValidEnumValues(this._def.values),E=this._getOrReturnCtx(D);if(E.parsedType!==A.string&&E.parsedType!==A.number){let B=I.objectValues(F);return C(E,{expected:I.joinValues(B),received:E.parsedType,code:W.invalid_type}),j}if(!this._cache)this._cache=new Set(I.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let B=I.objectValues(F);return C(E,{received:E.data,code:W.invalid_enum_value,options:B}),j}return a(D.data)}get enum(){return this._def.values}}V2.create=(D,F)=>{return new V2({values:D,typeName:M.ZodNativeEnum,...T(F)})};class pD extends P{unwrap(){return this._def.type}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.promise&&F.common.async===!1)return C(F,{code:W.invalid_type,expected:A.promise,received:F.parsedType}),j;let E=F.parsedType===A.promise?F.data:Promise.resolve(F.data);return a(E.then((B)=>{return this._def.type.parseAsync(B,{path:F.path,errorMap:F.common.contextualErrorMap})}))}}pD.create=(D,F)=>{return new pD({type:D,typeName:M.ZodPromise,...T(F)})};class YD extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=this._def.effect||null,$={addIssue:(J)=>{if(C(E,J),J.fatal)F.abort();else F.dirty()},get path(){return E.path}};if($.addIssue=$.addIssue.bind($),B.type==="preprocess"){let J=B.transform(E.data,$);if(E.common.async)return Promise.resolve(J).then(async(X)=>{if(F.value==="aborted")return j;let Q=await this._def.schema._parseAsync({data:X,path:E.path,parent:E});if(Q.status==="aborted")return j;if(Q.status==="dirty")return hD(Q.value);if(F.value==="dirty")return hD(Q.value);return Q});else{if(F.value==="aborted")return j;let X=this._def.schema._parseSync({data:J,path:E.path,parent:E});if(X.status==="aborted")return j;if(X.status==="dirty")return hD(X.value);if(F.value==="dirty")return hD(X.value);return X}}if(B.type==="refinement"){let J=(X)=>{let Q=B.refinement(X,$);if(E.common.async)return Promise.resolve(Q);if(Q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(E.common.async===!1){let X=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(X.status==="aborted")return j;if(X.status==="dirty")F.dirty();return J(X.value),{status:F.value,value:X.value}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((X)=>{if(X.status==="aborted")return j;if(X.status==="dirty")F.dirty();return J(X.value).then(()=>{return{status:F.value,value:X.value}})})}if(B.type==="transform")if(E.common.async===!1){let J=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(!ID(J))return j;let X=B.transform(J.value,$);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:F.value,value:X}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((J)=>{if(!ID(J))return j;return Promise.resolve(B.transform(J.value,$)).then((X)=>({status:F.value,value:X}))});I.assertNever(B)}}YD.create=(D,F,E)=>{return new YD({schema:D,typeName:M.ZodEffects,effect:F,...T(E)})};YD.createWithPreprocess=(D,F,E)=>{return new YD({schema:F,effect:{type:"preprocess",transform:D},typeName:M.ZodEffects,...T(E)})};class XD extends P{_parse(D){if(this._getType(D)===A.undefined)return a(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}XD.create=(D,F)=>{return new XD({innerType:D,typeName:M.ZodOptional,...T(F)})};class MD extends P{_parse(D){if(this._getType(D)===A.null)return a(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}MD.create=(D,F)=>{return new MD({innerType:D,typeName:M.ZodNullable,...T(F)})};class R2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=F.data;if(F.parsedType===A.undefined)E=this._def.defaultValue();return this._def.innerType._parse({data:E,path:F.path,parent:F})}removeDefault(){return this._def.innerType}}R2.create=(D,F)=>{return new R2({innerType:D,typeName:M.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...T(F)})};class K2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E={...F,common:{...F.common,issues:[]}},B=this._def.innerType._parse({data:E.data,path:E.path,parent:{...E}});if(Y2(B))return B.then(($)=>{return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new s(E.common.issues)},input:E.data})}});else return{status:"valid",value:B.status==="valid"?B.value:this._def.catchValue({get error(){return new s(E.common.issues)},input:E.data})}}removeCatch(){return this._def.innerType}}K2.create=(D,F)=>{return new K2({innerType:D,typeName:M.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...T(F)})};class l2 extends P{_parse(D){if(this._getType(D)!==A.nan){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.nan,received:E.parsedType}),j}return{status:"valid",value:D.data}}}l2.create=(D)=>{return new l2({typeName:M.ZodNaN,...T(D)})};var y5=Symbol("zod_brand");class q0 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=F.data;return this._def.type._parse({data:E,path:F.path,parent:F})}unwrap(){return this._def.type}}class m2 extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.common.async)return(async()=>{let $=await this._def.in._parseAsync({data:E.data,path:E.path,parent:E});if($.status==="aborted")return j;if($.status==="dirty")return F.dirty(),hD($.value);else return this._def.out._parseAsync({data:$.value,path:E.path,parent:E})})();else{let B=this._def.in._parseSync({data:E.data,path:E.path,parent:E});if(B.status==="aborted")return j;if(B.status==="dirty")return F.dirty(),{status:"dirty",value:B.value};else return this._def.out._parseSync({data:B.value,path:E.path,parent:E})}}static create(D,F){return new m2({in:D,out:F,typeName:M.ZodPipeline})}}class j2 extends P{_parse(D){let F=this._def.innerType._parse(D),E=(B)=>{if(ID(B))B.value=Object.freeze(B.value);return B};return Y2(F)?F.then((B)=>E(B)):E(F)}unwrap(){return this._def.innerType}}j2.create=(D,F)=>{return new j2({innerType:D,typeName:M.ZodReadonly,...T(F)})};function O8(D,F){let E=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof E==="string"?{message:E}:E}function w8(D,F={},E){if(D)return lD.create().superRefine((B,$)=>{let J=D(B);if(J instanceof Promise)return J.then((X)=>{if(!X){let Q=O8(F,B),Y=Q.fatal??E??!0;$.addIssue({code:"custom",...Q,fatal:Y})}});if(!J){let X=O8(F,B),Q=X.fatal??E??!0;$.addIssue({code:"custom",...X,fatal:Q})}return});return lD.create()}var h5={object:y.lazycreate},M;(function(D){D.ZodString="ZodString",D.ZodNumber="ZodNumber",D.ZodNaN="ZodNaN",D.ZodBigInt="ZodBigInt",D.ZodBoolean="ZodBoolean",D.ZodDate="ZodDate",D.ZodSymbol="ZodSymbol",D.ZodUndefined="ZodUndefined",D.ZodNull="ZodNull",D.ZodAny="ZodAny",D.ZodUnknown="ZodUnknown",D.ZodNever="ZodNever",D.ZodVoid="ZodVoid",D.ZodArray="ZodArray",D.ZodObject="ZodObject",D.ZodUnion="ZodUnion",D.ZodDiscriminatedUnion="ZodDiscriminatedUnion",D.ZodIntersection="ZodIntersection",D.ZodTuple="ZodTuple",D.ZodRecord="ZodRecord",D.ZodMap="ZodMap",D.ZodSet="ZodSet",D.ZodFunction="ZodFunction",D.ZodLazy="ZodLazy",D.ZodLiteral="ZodLiteral",D.ZodEnum="ZodEnum",D.ZodEffects="ZodEffects",D.ZodNativeEnum="ZodNativeEnum",D.ZodOptional="ZodOptional",D.ZodNullable="ZodNullable",D.ZodDefault="ZodDefault",D.ZodCatch="ZodCatch",D.ZodPromise="ZodPromise",D.ZodBranded="ZodBranded",D.ZodPipeline="ZodPipeline",D.ZodReadonly="ZodReadonly"})(M||(M={}));var g5=(D,F={message:`Input not instance of ${D.name}`})=>w8((E)=>E instanceof D,F),P8=$D.create,I8=fD.create,l5=l2.create,m5=ZD.create,u8=H2.create,p5=gD.create,c5=x2.create,d5=W2.create,i5=G2.create,n5=lD.create,r5=uD.create,a5=GD.create,o5=y2.create,s5=JD.create,t5=y.create,e5=y.strictCreate,D7=A2.create,F7=Y0.create,E7=U2.create,B7=AD.create,$7=h2.create,J7=g2.create,X7=mD.create,Q7=_2.create,Y7=C2.create,q7=z2.create,_7=kD.create,H7=V2.create,W7=pD.create,G7=YD.create,A7=XD.create,U7=MD.create,C7=YD.createWithPreprocess,z7=m2.create,V7=()=>P8().optional(),R7=()=>I8().optional(),K7=()=>u8().optional(),j7={string:(D)=>$D.create({...D,coerce:!0}),number:(D)=>fD.create({...D,coerce:!0}),boolean:(D)=>H2.create({...D,coerce:!0}),bigint:(D)=>ZD.create({...D,coerce:!0}),date:(D)=>gD.create({...D,coerce:!0})};var L7=j;var M7=u.object({name:u.string().default("genie"),defaultWindow:u.string().default("shell"),autoCreate:u.boolean().default(!0)}),O7=u.object({execTimeout:u.number().default(120000),readLines:u.number().default(100),worktreeBase:u.string().default(".worktrees")}),N7=u.object({tmuxDebug:u.boolean().default(!1),verbose:u.boolean().default(!1)}),S7=u.object({preference:u.enum(["auto","zsh","bash","fish"]).default("auto")}),T7=u.object({tmuxInstalled:u.boolean().default(!1),shellInstalled:u.boolean().default(!1)}),b7=u.object({enabled:u.boolean().default(!1)}),qD=u.object({version:u.number().default(2),session:M7.default({}),terminal:O7.default({}),logging:N7.default({}),shell:S7.default({}),shortcuts:T7.default({}),claudio:b7.optional(),installMethod:u.enum(["source","npm","bun"]).optional(),setupComplete:u.boolean().default(!1),lastSetupAt:u.string().optional()}),f8=u.object({session:u.object({name:u.string().default("genie"),defaultWindow:u.string().default("shell")}).default({}),logging:u.object({tmuxDebug:u.boolean().default(!1)}).default({}),installMethod:u.enum(["source","npm","bun"]).optional()});var _0=v8(k8(),".genie"),cD=v8(_0,"config.json"),a0=2;function NB(){return _0}function SB(){return cD}function I7(){return H0(cD)}function u7(){if(!H0(_0))w7(_0,{recursive:!0})}function x8(D){let F=f8.safeParse(D);if(F.success){let E=F.data;return qD.parse({version:a0,session:{name:E.session.name,defaultWindow:E.session.defaultWindow,autoCreate:!0},terminal:{execTimeout:120000,readLines:100,worktreeBase:".worktrees"},logging:{tmuxDebug:E.logging.tmuxDebug,verbose:!1},shell:{preference:"auto"},shortcuts:{tmuxInstalled:!1,shellInstalled:!1},installMethod:E.installMethod,setupComplete:!1})}return qD.parse({})}async function y8(){if(!H0(cD))return qD.parse({});try{let D=Z8(cD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<a0){let E=x8(F);return await W0(E),E}return qD.parse(F)}catch(D){return console.warn(`Warning: Invalid genie config, using defaults: ${D.message}`),qD.parse({})}}async function W0(D){u7();try{let F=qD.parse(D),E=JSON.stringify(F,null,2);P7(cD,E,"utf-8")}catch(F){throw Error(`Failed to save genie config: ${F.message}`)}}function f7(){return qD.parse({})}function h8(){if(!H0(cD))return qD.parse({});try{let D=Z8(cD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<a0)return x8(F);return qD.parse(F)}catch{return qD.parse({})}}function TB(D){let F=k8();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}function G0(){return h8().terminal}function bB(){if(!I7())return!1;return h8().setupComplete??!1}async function wB(){let D=await y8();D.setupComplete=!0,D.lastSetupAt=new Date().toISOString(),await W0(D)}async function PB(){let D=f7();await W0(D)}async function IB(D){let F=await y8();F.shortcuts={...F.shortcuts,...D},await W0(F)}async function g8(D,F){try{let B=G0().readLines,$={lines:F.lines?parseInt(F.lines,10):B,from:F.from?parseInt(F.from,10):void 0,to:F.to?parseInt(F.to,10):void 0,range:F.range,search:F.search,grep:F.grep,follow:F.follow,all:F.all,reverse:F.reverse};if(F.follow){console.log(`Following session "${D}" (Ctrl+C to stop)...`),console.log("");let X=await j8(D,(Q)=>{console.log(Q)});process.on("SIGINT",()=>{X(),console.log(`
51
+ Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let J=await K8(D,$);if(F.json){let X=J.split(`
52
+ `);console.log(JSON.stringify({session:D,lineCount:X.length,content:X},null,2));return}console.log(J)}catch(E){console.error(`Error reading session logs: ${E.message}`),process.exit(1)}}async function l8(D,F,E={}){let[B,$]=D.includes(":")?D.split(":"):[D,"shell"];try{let J=await Z(B);if(!J){if(!E.quiet)console.error(`Session "${B}" not found, creating...`);if(J=await yD(B),!J)console.error(`Failed to create session "${B}"`),process.exit(1)}let Q=(await v(J.id)).find((U)=>U.name===$);if(!Q){if(!E.quiet)console.error(`Window "${$}" not found, creating...`);if(Q=await E0(J.id,$),!Q)console.error(`Failed to create window "${$}"`),process.exit(1)}let Y=await g(Q.id);if(!Y||Y.length===0)console.error(`No panes found in window "${$}"`),process.exit(1);let q=G0(),_=E.timeout??q.execTimeout,{output:H,exitCode:G}=await Q8(Y[0].id,F,_);if(H&&!E.quiet)console.log(H);process.exit(G)}catch(J){console.error(`Error: ${J.message}`),process.exit(1)}}async function m8(D,F){try{let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await g(B[0].id);if(!$||$.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let J=$[0].id;await e(J,F,!1,!0),console.log(`\u2705 Keys sent to session "${D}"`)}catch(E){console.error(`\u274C Error sending keys: ${E.message}`),process.exit(1)}}import{join as x7}from"path";async function p8(D,F,E={}){try{let B=await Z(D);if(!B)console.error(`\u274C Session "${D}" not found`),process.exit(1);let $=await v(B.id);if(!$||$.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let J=await g($[0].id);if(!J||J.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let X=J[0].id,Q=F==="h"?"horizontal":"vertical",Y;if(E.worktree){if(!E.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let _=X2({baseDir:x7(E.workspace,".worktrees"),repoPath:E.workspace});if(!await _.worktreeExists(E.worktree)){let G=await _.createWorktree(E.worktree,!0);console.log(`\u2705 Worktree created at ${G.path}`)}Y=_.getWorktreePath(E.worktree)}else if(E.workspace)Y=E.workspace;let q=await $0(X,Q);if(!q)console.error("\u274C Failed to split pane"),process.exit(1);if(Y&&q)await S(`send-keys -t '${q.id}' 'cd ${Y}' Enter`);if(console.log(`\u2705 Pane split ${Q}ly in session "${D}"`),Y)console.log(` Working directory: ${Y}`)}catch(B){console.error(`\u274C Error splitting pane: ${B.message}`),process.exit(1)}}async function c8(D,F){await S(`set-hook -g ${D} '${F.replace(/'/g,"'\\''")}'`)}async function d8(D){await S(`set-hook -gu ${D}`)}async function i8(){let D=["after-bind-key","after-capture-pane","after-copy-mode","after-display-message","after-display-panes","after-kill-pane","after-list-buffers","after-list-clients","after-list-keys","after-list-panes","after-list-sessions","after-list-windows","after-load-buffer","after-lock-server","after-new-session","after-new-window","after-paste-buffer","after-pipe-pane","after-queue","after-refresh-client","after-rename-session","after-rename-window","after-resize-pane","after-resize-window","after-save-buffer","after-select-layout","after-select-pane","after-select-window","after-send-keys","after-set-buffer","after-set-environment","after-set-option","after-show-environment","after-show-messages","after-show-options","after-split-window","after-unbind-key","alert-activity","alert-bell","alert-silence","client-attached","client-detached","client-resized","client-session-changed","pane-died","pane-exited","pane-focus-in","pane-focus-out","pane-mode-changed","pane-set-clipboard","session-closed","session-created","session-renamed","session-window-changed","window-linked","window-pane-changed","window-renamed","window-unlinked"],F=[];for(let E of D)try{let B=await S(`show-hooks -g ${E}`);if(B.trim()){let $=B.trim().split(" ");if($.length>=2)F.push({event:$[0],command:$.slice(1).join(" ")})}}catch(B){continue}return F}async function n8(D,F){try{await c8(D,F),console.log(`\u2705 Hook set: ${D} \u2192 ${F}`)}catch(E){console.error(`\u274C Error setting hook: ${E.message}`),process.exit(1)}}async function r8(){try{let D=await i8();if(D.length===0){console.log("No hooks configured");return}console.log("EVENT\t\t\t\tCOMMAND"),console.log("\u2500".repeat(80));for(let F of D)console.log(`${F.event} ${F.command}`)}catch(D){console.error(`\u274C Error listing hooks: ${D.message}`),process.exit(1)}}async function a8(D){try{await d8(D),console.log(`\u2705 Hook removed: ${D}`)}catch(F){console.error(`\u274C Error removing hook: ${F.message}`),process.exit(1)}}async function o8(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(F.json){console.log(JSON.stringify(B,null,2));return}if(B.length===0){console.log("No windows found");return}console.log("WINDOW ID\t\tNAME\t\t\tACTIVE"),console.log("\u2500".repeat(60));for(let $ of B){let J=$.active?"yes":"no";console.log(`${$.id} ${$.name} ${J}`)}}catch(E){console.error(`Error listing windows: ${E.message}`),process.exit(1)}}async function s8(D,F){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await E0(E.id,F);if(B)console.log(`Window created: ${B.id}`);else console.error("Failed to create window"),process.exit(1)}catch(E){console.error(`Error creating window: ${E.message}`),process.exit(1)}}async function t8(D){try{await J8(D),console.log(`Window removed: ${D}`)}catch(F){console.error(`Error removing window: ${F.message}`),process.exit(1)}}async function e8(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(B.length===0){if(F.json)console.log("[]");else console.log("No panes found");return}let $=[];for(let J of B){let X=await g(J.id);for(let Q of X)$.push({id:Q.id,windowId:J.id,windowName:J.name,title:Q.title,active:Q.active})}if(F.json){console.log(JSON.stringify($,null,2));return}if($.length===0){console.log("No panes found");return}console.log("PANE ID\t\tWINDOW\t\t\tTITLE\t\t\tACTIVE"),console.log("\u2500".repeat(80));for(let J of $){let X=J.active?"yes":"no",Q=J.title||"-";console.log(`${J.id} ${J.windowName} ${Q} ${X}`)}}catch(E){console.error(`Error listing panes: ${E.message}`),process.exit(1)}}async function D6(D){try{await $2(D),console.log(`Pane removed: ${D}`)}catch(F){console.error(`Error removing pane: ${F.message}`),process.exit(1)}}async function F6(D,F={}){try{if(F.command){await p7(F.command,F.json);return}let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id),$=0;for(let Q of B){let Y=await g(Q.id);$+=Y.length}let J="idle",X={session:E.name,id:E.id,attached:E.attached,windows:B.length,panes:$,state:J};if(F.json){console.log(JSON.stringify(X,null,2));return}console.log(`Session: ${X.session}`),console.log(`ID: ${X.id}`),console.log(`Attached: ${X.attached?"yes":"no"}`),console.log(`Windows: ${X.windows}`),console.log(`Panes: ${X.panes}`),console.log(`State: ${X.state}`)}catch(E){console.error(`Error getting status: ${E.message}`),process.exit(1)}}async function p7(D,F){try{let E=await X8(D);if(!E)console.error(`Command "${D}" not found`),process.exit(1);let B={id:E.id,paneId:E.paneId,command:E.command,status:E.status,exitCode:E.exitCode,startTime:E.startTime.toISOString(),result:E.result};if(F){console.log(JSON.stringify(B,null,2));return}if(console.log(`Command: ${B.id}`),console.log(`Status: ${B.status}`),console.log(`Exit Code: ${B.exitCode??"N/A"}`),console.log(`Start Time: ${B.startTime}`),B.result)console.log(`
47
53
  Output:
48
- ${U.result}`)}catch(q){console.error(`Error getting command status: ${q.message}`),process.exit(1)}}import{homedir as K0}from"os";import{join as D}from"path";import{existsSync as N,readFileSync as E0,writeFileSync as Z6,mkdirSync as _6,appendFileSync as _1}from"fs";import*as z0 from"readline";function L0(){return`# Warp-like keyboard shortcuts (generated by genie-cli)
54
+ ${B.result}`)}catch(E){console.error(`Error getting command status: ${E.message}`),process.exit(1)}}import{homedir as E6}from"os";import{join as _D}from"path";import{existsSync as dD,readFileSync as B6,writeFileSync as d7,mkdirSync as i7,appendFileSync as o0}from"fs";import*as $6 from"readline";function J6(){return`# Warp-like keyboard shortcuts (generated by genie-cli)
49
55
  # To use: add to ~/.tmux.conf or source this file
50
56
 
51
57
  # Ctrl+T: New window (tab) in current session
52
- bind-key -n C-t new-window
58
+ bind-key -n C-t new-window -c "#{pane_current_path}"
53
59
 
54
60
  # Ctrl+S: Vertical split (requires stty -ixon in shell rc)
55
- bind-key -n C-s split-window -v
61
+ bind-key -n C-s split-window -v -c "#{pane_current_path}"
56
62
 
57
- # Ctrl+H: Horizontal split
58
- bind-key -n C-h split-window -h
59
- `}function V0(){return`# Warp-like extra keys (generated by genie-cli)
63
+ # Ctrl+Shift+S: Horizontal split
64
+ bind-key -n C-S split-window -h -c "#{pane_current_path}"
65
+ `}function X6(){return`# Warp-like extra keys (generated by genie-cli)
60
66
  # To use: add to ~/.termux/termux.properties
61
67
 
62
68
  # Extra keys row with F-keys for shortcuts
63
69
  # F1=New Tab, F2=VSplit, F3=HSplit
64
70
  extra-keys = [['ESC','TAB','CTRL','ALT','F1','F2','F3']]
65
- `}function Y6(){return`# Warp-like shortcuts (generated by genie-cli)
71
+ `}function n7(){return`# Warp-like shortcuts (generated by genie-cli)
66
72
  # To use: add to ~/.bashrc or ~/.zshrc
67
73
 
68
74
  # Disable Ctrl+S flow control (required for Ctrl+S to work in tmux)
@@ -73,7 +79,7 @@ genie-new-tab() {
73
79
  local session
74
80
  session=$(tmux display-message -p '#S' 2>/dev/null)
75
81
  if [ -n "$session" ]; then
76
- tmux new-window
82
+ tmux new-window -c "#{pane_current_path}"
77
83
  else
78
84
  echo "Not in a tmux session"
79
85
  fi
@@ -81,7 +87,7 @@ genie-new-tab() {
81
87
 
82
88
  genie-vsplit() {
83
89
  if tmux display-message -p '#S' >/dev/null 2>&1; then
84
- tmux split-window -v
90
+ tmux split-window -v -c "#{pane_current_path}"
85
91
  else
86
92
  echo "Not in a tmux session"
87
93
  fi
@@ -89,7 +95,7 @@ genie-vsplit() {
89
95
 
90
96
  genie-hsplit() {
91
97
  if tmux display-message -p '#S' >/dev/null 2>&1; then
92
- tmux split-window -h
98
+ tmux split-window -h -c "#{pane_current_path}"
93
99
  else
94
100
  echo "Not in a tmux session"
95
101
  fi
@@ -99,16 +105,16 @@ genie-hsplit() {
99
105
  bind -x '"eOP":"genie-new-tab"' 2>/dev/null # F1
100
106
  bind -x '"eOQ":"genie-vsplit"' 2>/dev/null # F2
101
107
  bind -x '"eOR":"genie-hsplit"' 2>/dev/null # F3
102
- `}function S6(){console.log(`
108
+ `}function r7(){console.log(`
103
109
  Warp-like Terminal Shortcuts for tmux + Termux
104
110
 
105
- \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
106
- \u2502 Shortcut \u2502 Action \u2502
107
- \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524
108
- \u2502 Ctrl+T \u2502 New tab (window) in current session \u2502
109
- \u2502 Ctrl+S \u2502 Vertical split in current session \u2502
110
- \u2502 Ctrl+H \u2502 Horizontal split in current session \u2502
111
- \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
111
+ \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
112
+ \u2502 Shortcut \u2502 Action \u2502
113
+ \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524
114
+ \u2502 Ctrl+T \u2502 New tab (window) in current session \u2502
115
+ \u2502 Ctrl+S \u2502 Vertical split in current session \u2502
116
+ \u2502 Ctrl+Shift+S \u2502 Horizontal split in current session \u2502
117
+ \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
112
118
 
113
119
  Termux Extra Keys (F1-F3):
114
120
  F1 \u2192 New tab F2 \u2192 Vertical split
@@ -118,19 +124,80 @@ Commands:
118
124
  term shortcuts --tmux Output tmux.conf snippet
119
125
  term shortcuts --termux Output termux.properties snippet
120
126
  term shortcuts --install Install to config files
121
- `)}async function w($){let J=z0.createInterface({input:process.stdin,output:process.stdout});return new Promise((q)=>{J.question($,(U)=>{J.close(),q(U.trim().toLowerCase())})})}function O($,J){if(!N($))return!1;return E0($,"utf-8").includes(J)}async function W6(){let $=K0(),J="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
122
- `);let q=D($,".tmux.conf");if(O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await w(`Add shortcuts to ${q}? [Y/n] `)!=="n"){let _=`
123
- `+L0();_1(q,_),console.log(`\u2705 Added to ${q}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let U=N(D($,".zshrc"))?D($,".zshrc"):D($,".bashrc");if(O(U,"generated by genie-cli"))console.log(`\u2713 ${U} already has genie shortcuts`);else if(await w(`Add shell functions to ${U}? [Y/n] `)!=="n"){let _=`
124
- `+Y6();_1(U,_),console.log(`\u2705 Added to ${U}`)}else console.log(`\u23ED\uFE0F Skipped ${U}`);let G=D($,".termux"),X=D(G,"termux.properties"),Q=N(G)||process.env.TERMUX_VERSION;if(Q)if(O(X,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await w(`Add extra keys to ${X}? [Y/n] `)!=="n"){if(!N(G))_6(G,{recursive:!0});let _=`
125
- `+V0();_1(X,_),console.log(`\u2705 Added to ${X}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
127
+ `)}async function L2(D){let F=$6.createInterface({input:process.stdin,output:process.stdout});return new Promise((E)=>{F.question(D,(B)=>{F.close(),E(B.trim().toLowerCase())})})}function iD(D,F){if(!dD(D))return!1;return B6(D,"utf-8").includes(F)}async function a7(){let D=E6(),F="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
128
+ `);let E=_D(D,".tmux.conf");if(iD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await L2(`Add shortcuts to ${E}? [Y/n] `)!=="n"){let Y=`
129
+ `+J6();o0(E,Y),console.log(`\u2705 Added to ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=dD(_D(D,".zshrc"))?_D(D,".zshrc"):_D(D,".bashrc");if(iD(B,"generated by genie-cli"))console.log(`\u2713 ${B} already has genie shortcuts`);else if(await L2(`Add shell functions to ${B}? [Y/n] `)!=="n"){let Y=`
130
+ `+n7();o0(B,Y),console.log(`\u2705 Added to ${B}`)}else console.log(`\u23ED\uFE0F Skipped ${B}`);let $=_D(D,".termux"),J=_D($,"termux.properties"),X=dD($)||process.env.TERMUX_VERSION;if(X)if(iD(J,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await L2(`Add extra keys to ${J}? [Y/n] `)!=="n"){if(!dD($))i7($,{recursive:!0});let Y=`
131
+ `+X6();o0(J,Y),console.log(`\u2705 Added to ${J}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
126
132
  \u2705 Installation complete!`),console.log(`
127
- Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Q)console.log(" 3. Reload Termux: termux-reload-settings")}function D8($){return O($,"generated by genie-cli")}function Y1($,J){if(!N($))return!1;let q=E0($,"utf-8");if(!q.includes(J))return!1;let U=q.split(`
128
- `),G=[],X=!1,Q=-1;for(let _=0;_<U.length;_++){let Y=U[_];if(Y.includes(J)&&!X){if(X=!0,Q===-1&&G.length>0&&G[G.length-1].trim()==="")G.pop();continue}if(X){if(Y.trim()===""&&_+1<U.length&&!U[_+1].includes("genie")){X=!1;continue}if(!(Y.includes("genie")||Y.includes("Ctrl+")||Y.includes("split-window")||Y.includes("new-window")||Y.includes("stty -ixon")||Y.includes("Warp-like")||Y.includes("bind-key -n")||Y.includes("extra-keys")||Y.includes("F1=")||Y.includes("bind -x")||Y.startsWith("#")&&U[_-1]?.includes("genie"))&&Y.trim()!=="")X=!1,G.push(Y);continue}G.push(Y)}while(G.length>0&&G[G.length-1].trim()==="")G.pop();let Z=G.length>0?G.join(`
133
+ Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),X)console.log(" 3. Reload Termux: termux-reload-settings")}function lB(D){return iD(D,"generated by genie-cli")}function s0(D,F){if(!dD(D))return!1;let E=B6(D,"utf-8");if(!E.includes(F))return!1;let B=E.split(`
134
+ `),$=[],J=!1,X=-1;for(let Y=0;Y<B.length;Y++){let q=B[Y];if(q.includes(F)&&!J){if(J=!0,X===-1&&$.length>0&&$[$.length-1].trim()==="")$.pop();continue}if(J){if(q.trim()===""&&Y+1<B.length&&!B[Y+1].includes("genie")){J=!1;continue}if(!(q.includes("genie")||q.includes("Ctrl+")||q.includes("split-window")||q.includes("new-window")||q.includes("stty -ixon")||q.includes("Warp-like")||q.includes("bind-key -n")||q.includes("extra-keys")||q.includes("F1=")||q.includes("bind -x")||q.startsWith("#")&&B[Y-1]?.includes("genie"))&&q.trim()!=="")J=!1,$.push(q);continue}$.push(q)}while($.length>0&&$[$.length-1].trim()==="")$.pop();let Q=$.length>0?$.join(`
129
135
  `)+`
130
- `:"";return Z6($,Z),!0}async function y8(){let $=K0(),J="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
131
- `);let q=D($,".tmux.conf");if(!O(q,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await w(`Remove shortcuts from ${q}? [Y/n] `)!=="n"){if(Y1(q,"generated by genie-cli"))console.log(`\u2705 Removed from ${q}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let U=D($,".zshrc"),G=D($,".bashrc");for(let _ of[U,G]){if(!N(_))continue;if(!O(_,"generated by genie-cli"))console.log(`\u2713 ${_} has no genie shortcuts`);else if(await w(`Remove shell functions from ${_}? [Y/n] `)!=="n"){if(Y1(_,"generated by genie-cli"))console.log(`\u2705 Removed from ${_}`)}else console.log(`\u23ED\uFE0F Skipped ${_}`)}let X=D($,".termux"),Q=D(X,"termux.properties"),Z=N(X)||process.env.TERMUX_VERSION;if(Z)if(!O(Q,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await w(`Remove extra keys from ${Q}? [Y/n] `)!=="n"){if(Y1(Q,"generated by genie-cli"))console.log(`\u2705 Removed from ${Q}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
136
+ `:"";return d7(D,Q),!0}async function mB(){let D=E6(),F="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
137
+ `);let E=_D(D,".tmux.conf");if(!iD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await L2(`Remove shortcuts from ${E}? [Y/n] `)!=="n"){if(s0(E,"generated by genie-cli"))console.log(`\u2705 Removed from ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=_D(D,".zshrc"),$=_D(D,".bashrc");for(let Y of[B,$]){if(!dD(Y))continue;if(!iD(Y,"generated by genie-cli"))console.log(`\u2713 ${Y} has no genie shortcuts`);else if(await L2(`Remove shell functions from ${Y}? [Y/n] `)!=="n"){if(s0(Y,"generated by genie-cli"))console.log(`\u2705 Removed from ${Y}`)}else console.log(`\u23ED\uFE0F Skipped ${Y}`)}let J=_D(D,".termux"),X=_D(J,"termux.properties"),Q=dD(J)||process.env.TERMUX_VERSION;if(Q)if(!iD(X,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await L2(`Remove extra keys from ${X}? [Y/n] `)!=="n"){if(s0(X,"generated by genie-cli"))console.log(`\u2705 Removed from ${X}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
132
138
  \u2705 Uninstallation complete!`),console.log(`
133
- Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Z)console.log(" 3. Reload Termux: termux-reload-settings")}async function M0($){if($.tmux)console.log(L0());else if($.termux)console.log(V0());else if($.install)await W6();else S6()}var V=new A1;V.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
139
+ Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Q)console.log(" 3. Reload Termux: termux-reload-settings")}async function Q6(D){if(D.tmux)console.log(J6());else if(D.termux)console.log(X6());else if(D.install)await a7();else r7()}var M2=[{type:"bash_permission",pattern:/Allow (?:Bash|bash|command|shell).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"file_permission",pattern:/Allow (?:Edit|Write|Read|file|reading|writing|editing).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"mcp_permission",pattern:/Allow (?:MCP|mcp|tool).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"generic_permission",pattern:/^(?:Allow|Confirm|Approve)\s+(?:this|the|once|always)?\s*(?:\w+)?\s*\?\s*(?:\[([YyNn])\/([YyNn])\])?/im,extract:(D)=>({default:D[1]||"y"})},{type:"claude_code_yes_no",pattern:/(?:Yes|No)\s*$/m},{type:"claude_code_permission_block",pattern:/(?:Allow|Run|Execute)\s+(?:once|always)/i}],A0=[{type:"numbered_options",pattern:/\[(\d+)\]\s+(.+?)(?=\[(\d+)\]|$)/g,extract:(D)=>({number:D[1],option:D[2].trim()})},{type:"lettered_options",pattern:/\(([a-z])\)\s+(.+?)(?=\([a-z]\)|$)/gi,extract:(D)=>({letter:D[1],option:D[2].trim()})},{type:"yes_no_question",pattern:/\?\s*\[([YyNn])\/([YyNn])\]\s*$/,extract:(D)=>({default:D[1]})},{type:"claude_code_numbered_options",pattern:/(?:\u276F|>)?\s*(\d+)\.\s+(.+?)(?:\n|$)/g,extract:(D)=>({number:D[1],option:D[2].trim()})},{type:"claude_code_plan_approval",pattern:/Would you like to proceed\?/i}],Y6=[{type:"error",pattern:/(?:^|\n)\s*(?:Error|ERROR|error):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"failed",pattern:/(?:^|\n)\s*(?:Failed|FAILED|failed):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"exception",pattern:/(?:^|\n)\s*(?:Exception|EXCEPTION|Uncaught|Unhandled):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"api_error",pattern:/(?:API|api)\s+(?:error|Error|ERROR):\s*(.+)/,extract:(D)=>({message:D[1]})}],q6=[{type:"checkmark",pattern:/[\u2713\u2714\u2611\uFE0E]/},{type:"success_message",pattern:/(?:Successfully|Completed|Done|Finished|Created|Updated|Saved)/i},{type:"task_complete",pattern:/(?:task|operation|process)\s+(?:complete|completed|finished|done)/i}],_6=[{type:"thinking",pattern:/(?:Thinking|thinking|Processing|processing)\.\.\./},{type:"spinner",pattern:/[\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F\u28FE\u28FD\u28FB\u28BF\u287F\u28DF\u28EF\u28F7]/},{type:"loading",pattern:/(?:Loading|loading|Working|working)\.\.\./},{type:"claude_code_working",pattern:/[\uD83D\uDEE0\uFE0F\uD83D\uDD27\u2699\uFE0F]\s*(?:Read|Edit|Write|Bash|Glob|Grep|Task)/},{type:"claude_code_streaming",pattern:/\u258C$/},{type:"claude_code_propagating",pattern:/Propagating\u2026/}],H6=[{type:"claude_prompt",pattern:/(?:^|\n)\s*>\s*$/},{type:"claude_code_prompt",pattern:/\u276F\s*(?!\d\.)/},{type:"claude_code_input_line",pattern:/\u276F\s*.+\n\u2500+\n/},{type:"idle_indicator",pattern:/\|\s*idle\s*$/i},{type:"input_prompt",pattern:/(?:^|\n)(?:Enter|Input|Type|Provide).*:\s*$/i}],W6=[{type:"run_command",pattern:/(?:Run|Running|Executing)\s+(?:command|bash):\s*(.+)/i,extract:(D)=>({command:D[1]})},{type:"read_file",pattern:/(?:Read|Reading)\s+(?:file):\s*(.+)/i,extract:(D)=>({file:D[1]})},{type:"write_file",pattern:/(?:Write|Writing|Edit|Editing)\s+(?:file|to):\s*(.+)/i,extract:(D)=>({file:D[1]})},{type:"search",pattern:/(?:Search|Searching|Grep|Glob)(?:ing)?:\s*(.+)/i,extract:(D)=>({query:D[1]})}],s7=[{type:"claude_plan_file",pattern:/(~\/\.claude\/plans\/[\w-]+\.md|\/[^\s]+\/\.claude\/plans\/[\w-]+\.md)/,extract:(D)=>({path:D[1]})}];function DD(D){return D.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function G6(D){let F=DD(D),E=O2(F,s7);if(E?.extracted?.path){let B=E.extracted.path;if(B.startsWith("~"))B=B.replace("~",process.env.HOME||"");return B}return null}function p2(D,F){let E=DD(D),B=[];for(let $ of F){let J=new RegExp($.pattern.source,$.pattern.flags||"g"),X;while((X=J.exec(E))!==null)if(B.push({type:$.type,match:X,extracted:$.extract?$.extract(X):void 0}),!$.pattern.flags?.includes("g"))break}return B}function c2(D,F){return p2(D,F).length>0}function O2(D,F){let E=p2(D,F);return E.length>0?E[0]:null}function FD(D,F={}){let{linesToAnalyze:E=50,minConfidence:B=0.3}=F,$=D.split(`
140
+ `),J=$.slice(-E).join(`
141
+ `),X=DD(J),Y={timestamp:Date.now(),rawOutput:J},q=O2(X,M2);if(q)return{...Y,type:"permission",detail:q.type.replace("_permission",""),confidence:0.9};let _=c2(X,A0.filter((c)=>c.type==="claude_code_plan_approval")),H=$.slice(-15).join(`
142
+ `),G=DD(H),U=p2(G,A0);if(U.length>0||_){let c=U.filter((r)=>r.type==="claude_code_numbered_options"&&r.extracted?.option).map((r)=>r.extracted.option);if(c.length>=2||_)return{...Y,type:"question",options:c.length>0?c:void 0,detail:_?"plan_approval":void 0,confidence:0.85};let t=U.filter((r)=>r.extracted?.option&&r.type!=="claude_code_numbered_options").map((r)=>r.extracted.option);if(t.length>=2)return{...Y,type:"question",options:t,confidence:0.85}}let R=U.find((c)=>c.type==="yes_no_question");if(R)return{...Y,type:"question",options:["Yes","No"],detail:`default: ${R.extracted?.default||"y"}`,confidence:0.85};let K=O2(X,Y6);if(K)return{...Y,type:"error",detail:K.extracted?.message||K.match[0],confidence:0.8};let O=O2(X,W6);if(O)return{...Y,type:"tool_use",detail:`${O.type}: ${O.extracted?.command||O.extracted?.file||O.extracted?.query||""}`,confidence:0.75};if(c2(X,_6))return{...Y,type:"working",confidence:0.7};if(c2(X,q6))return{...Y,type:"complete",confidence:0.6};let L=$.slice(-5).join(`
143
+ `),N=DD(L);if(c2(N,H6))return{...Y,type:"idle",confidence:0.7};let f=N.trim();if(f.endsWith(">")||f.match(/>\s*$/))return{...Y,type:"idle",detail:"prompt detected",confidence:0.65};return{...Y,type:"unknown",confidence:B}}function A6(D,F){let E=FD(D),B=FD(F);if(E.type==="permission"||E.type==="question")return{complete:!1,reason:`awaiting ${E.type}`,confidence:0.95};if(E.type==="error")return{complete:!0,reason:"error detected",confidence:0.8};if(E.type==="idle")return{complete:!0,reason:"idle prompt detected",confidence:E.confidence};if(E.type==="complete")return{complete:!0,reason:"completion marker detected",confidence:E.confidence};if(B.type==="working"&&E.type!=="working")return{complete:!0,reason:"work finished",confidence:0.6};if(E.type==="working"||E.type==="tool_use")return{complete:!1,reason:"still working",confidence:0.7};return{complete:!1,reason:"unknown state",confidence:0.3}}function U6(D){let F=DD(D),E=O2(F,M2);if(!E)return null;let B=F.split(`
144
+ `),$=B.findIndex((Q)=>Q.match(M2[0].pattern)||Q.match(M2[1].pattern)||Q.match(M2[2].pattern)),J,X;if($>0){let Q=B.slice(Math.max(0,$-5),$).join(`
145
+ `),Y=Q.match(/(?:Command|command|Bash|bash):\s*(.+)/);if(Y)J=Y[1].trim();let q=Q.match(/(?:File|file|Path|path):\s*(.+)/);if(q)X=q[1].trim()}return{type:E.type.replace("_permission",""),command:J,file:X}}function t0(D){let F=DD(D),E=p2(F,A0),B=[];for(let $ of E)if($.extracted?.option)B.push($.extracted.option);return B}import{EventEmitter as t7}from"events";class UD extends t7{sessionName;paneId=null;explicitPaneId=null;options;pollTimer=null;lastOutput="";lastOutputTime=Date.now();lastState=null;running=!1;constructor(D,F={}){super();this.sessionName=D,this.explicitPaneId=F.paneId||null,this.options={pollIntervalMs:F.pollIntervalMs??500,captureLines:F.captureLines??30,silenceThresholdMs:F.silenceThresholdMs??3000}}async start(){if(this.running)return;if(this.explicitPaneId)this.paneId=this.explicitPaneId.startsWith("%")?this.explicitPaneId:`%${this.explicitPaneId}`;else{let D=await Z(this.sessionName);if(!D)throw Error(`Session "${this.sessionName}" not found`);let F=await v(D.id);if(!F||F.length===0)throw Error(`No windows found in session "${this.sessionName}"`);let E=await g(F[0].id);if(!E||E.length===0)throw Error(`No panes found in session "${this.sessionName}"`);this.paneId=E[0].id}this.running=!0,this.lastOutputTime=Date.now(),await this.poll(),this.pollTimer=setInterval(()=>this.poll(),this.options.pollIntervalMs),this.emit("started",{sessionName:this.sessionName,paneId:this.paneId})}stop(){if(this.pollTimer)clearInterval(this.pollTimer),this.pollTimer=null;this.running=!1,this.emit("stopped")}isRunning(){return this.running}getCurrentState(){return this.lastState}getSilenceMs(){return Date.now()-this.lastOutputTime}async poll(){if(!this.paneId||!this.running)return;try{let D=await p(this.paneId,this.options.captureLines),F=Date.now();if(D!==this.lastOutput){let E=this.getNewContent(this.lastOutput,D);if(E)this.lastOutputTime=F,this.emitEvent({type:"output",output:E,timestamp:F}),this.emitEvent({type:"activity",timestamp:F});let B=FD(D);if(this.lastState&&B.type!==this.lastState.type){if(this.emitEvent({type:"state_change",state:B,timestamp:F}),B.type==="permission")this.emitEvent({type:"permission",state:B,timestamp:F});else if(B.type==="question")this.emitEvent({type:"question",state:B,timestamp:F});else if(B.type==="error")this.emitEvent({type:"error",state:B,timestamp:F});let $=A6(D,this.lastOutput);if($.complete&&$.confidence>0.6)this.emitEvent({type:"complete",state:B,timestamp:F})}this.lastState=B,this.lastOutput=D}else{let E=F-this.lastOutputTime;if(E>=this.options.silenceThresholdMs&&E%this.options.silenceThresholdMs<this.options.pollIntervalMs)this.emitEvent({type:"silence",silenceMs:E,timestamp:F})}}catch(D){this.emit("poll_error",D)}}getNewContent(D,F){if(D===F)return null;if(!D)return F;let E=D.split(`
146
+ `),B=F.split(`
147
+ `),$=E[E.length-1],J=B.lastIndexOf($);if(J>=0&&J<B.length-1)return B.slice(J+1).join(`
148
+ `);let X=new Set(E),Q=B.filter((Y)=>!X.has(Y));return Q.length>0?Q.join(`
149
+ `):null}emitEvent(D){this.emit(D.type,D),this.emit("event",D)}}async function C6(D,F,E=120000){return new Promise((B,$)=>{let X=Date.now(),Q=setTimeout(()=>{_(),$(Error("Timeout waiting for silence"))},E),Y=()=>{X=Date.now()},q=setInterval(()=>{if(Date.now()-X>=F)_(),B()},100),_=()=>{clearTimeout(Q),clearInterval(q),D.off("activity",Y)};D.on("activity",Y)})}async function z6(D,F={}){let{silenceMs:E=3000,timeoutMs:B=120000,requireIdle:$=!0}=F;return new Promise((J,X)=>{let Q=setTimeout(()=>{U(),X(Error("Timeout waiting for completion"))},B),Y=Date.now(),q=null,_=(R)=>{if(R.state)U(),J({state:R.state,reason:"complete event"})},H=()=>{Y=Date.now()},G=(R)=>{if(R.state?.type==="permission"||R.state?.type==="question")return;if($&&R.state?.type==="idle")U(),J({state:R.state,reason:"idle state"});if(R.state?.type==="error")U(),J({state:R.state,reason:"error"})},U=()=>{if(clearTimeout(Q),q)clearInterval(q);D.off("complete",_),D.off("activity",H),D.off("state_change",G)};q=setInterval(()=>{let R=Date.now()-Y,K=D.getCurrentState();if(R>=E){if(K&&(K.type==="idle"||K.type==="complete"||K.type==="error"))U(),J({state:K,reason:`silence (${R}ms)`});else if(!$)U(),J({state:K||{type:"unknown",timestamp:Date.now(),rawOutput:"",confidence:0},reason:`silence (${R}ms) - non-idle`})}},500),D.on("complete",_),D.on("activity",H),D.on("state_change",G)})}function nD(D){let F={name:`silence-${D}ms`,totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:`silence-${D}ms`,description:`Detect completion when no output for ${D}ms`,metrics:F,async detect(E,B=120000){let $=Date.now();try{await C6(E,D,B);let J=Date.now()-$;return{complete:!0,state:E.getCurrentState()||void 0,reason:`silence for ${D}ms`,latencyMs:J,method:this.name}}catch(J){return{complete:!1,reason:J instanceof Error?J.message:"unknown error",latencyMs:Date.now()-$,method:this.name}}},recordResult(E,B,$){if(F.totalRuns++,F.avgLatencyMs=(F.avgLatencyMs*(F.totalRuns-1)+E)/F.totalRuns,F.minLatencyMs=Math.min(F.minLatencyMs,E),F.maxLatencyMs=Math.max(F.maxLatencyMs,E),!B)if($)F.falsePositives++;else F.falseNegatives++;F.successRate=(F.totalRuns-F.falsePositives-F.falseNegatives)/F.totalRuns}}}function U0(){let D={name:"state-detection",totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:"state-detection",description:"Detect completion when idle state is detected",metrics:D,async detect(F,E=120000){let B=Date.now();try{let $=await z6(F,{timeoutMs:E,requireIdle:!0,silenceMs:2000}),J=Date.now()-B;return{complete:!0,state:$.state,reason:$.reason,latencyMs:J,method:this.name}}catch($){return{complete:!1,reason:$ instanceof Error?$.message:"unknown error",latencyMs:Date.now()-B,method:this.name}}},recordResult(F,E,B){if(D.totalRuns++,D.avgLatencyMs=(D.avgLatencyMs*(D.totalRuns-1)+F)/D.totalRuns,D.minLatencyMs=Math.min(D.minLatencyMs,F),D.maxLatencyMs=Math.max(D.maxLatencyMs,F),!E)if(B)D.falsePositives++;else D.falseNegatives++;D.successRate=(D.totalRuns-D.falsePositives-D.falseNegatives)/D.totalRuns}}}function e0(D,F,E={}){let{primaryTimeoutMs:B=30000,fallbackTimeoutMs:$=90000}=E,J={name:`hybrid(${D.name},${F.name})`,totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:J.name,description:`Try ${D.name} first, fall back to ${F.name}`,metrics:J,async detect(X,Q=120000){let Y=Date.now(),q=await D.detect(X,Math.min(B,Q));if(q.complete)return{...q,method:this.name,reason:`primary(${q.reason})`};let _=Q-(Date.now()-Y);if(_<=0)return{complete:!1,reason:"timeout after primary method",latencyMs:Date.now()-Y,method:this.name};let H=await F.detect(X,Math.min($,_));return{...H,method:this.name,reason:`fallback(${H.reason})`,latencyMs:Date.now()-Y}},recordResult(X,Q,Y){if(J.totalRuns++,J.avgLatencyMs=(J.avgLatencyMs*(J.totalRuns-1)+X)/J.totalRuns,J.minLatencyMs=Math.min(J.minLatencyMs,X),J.maxLatencyMs=Math.max(J.maxLatencyMs,X),!Q)if(Y)J.falsePositives++;else J.falseNegatives++;J.successRate=(J.totalRuns-J.falsePositives-J.falseNegatives)/J.totalRuns}}}function C0(){return e0(U0(),nD(5000),{primaryTimeoutMs:30000,fallbackTimeoutMs:90000})}var d2={"silence-3s":()=>nD(3000),"silence-5s":()=>nD(5000),"silence-10s":()=>nD(1e4),"state-detection":()=>U0(),hybrid:()=>C0(),"aggressive-hybrid":()=>e0(U0(),nD(2000),{primaryTimeoutMs:1e4,fallbackTimeoutMs:30000}),"conservative-hybrid":()=>e0(U0(),nD(1e4),{primaryTimeoutMs:60000,fallbackTimeoutMs:120000})};function D3(D){if(D in d2)return d2[D]();let F=D.match(/^silence-(\d+)(ms|s)?$/);if(F){let E=parseInt(F[1],10),$=(F[2]||"ms")==="s"?E*1000:E;return nD($)}return C0()}async function N2(D,F){let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);if(F){let J=F.startsWith("%")?F:`%${F}`;return{session:E,paneId:J}}let B=await v(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await g(B[0].id);if(!$||$.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);return{session:E,paneId:$[0].id}}function V6(D){let F=`${D.type}`;if(D.detail)F+=` (${D.detail})`;if(D.options&&D.options.length>0)F+=`
150
+ Options: ${D.options.join(", ")}`;return F+=` [confidence: ${(D.confidence*100).toFixed(0)}%]`,F}function R6(D){let F=new Date(D.timestamp).toISOString().split("T")[1].split(".")[0];switch(D.type){case"output":return`[${F}] OUTPUT: ${(D.output||"").substring(0,100).replace(/\n/g,"\\n")}`;case"state_change":return`[${F}] STATE: ${D.state?.type||"unknown"}${D.state?.detail?` (${D.state.detail})`:""}`;case"silence":return`[${F}] SILENCE: ${D.silenceMs}ms`;case"activity":return`[${F}] ACTIVITY`;case"permission":return`[${F}] PERMISSION: ${D.state?.detail||"unknown"}`;case"question":return`[${F}] QUESTION: ${D.state?.options?.join(", ")||"unknown"}`;case"error":return`[${F}] ERROR: ${D.state?.detail||"unknown"}`;case"complete":return`[${F}] COMPLETE`;default:return`[${F}] ${D.type}`}}async function K6(D,F={}){try{let E=await Z(D);if(!E){if(E=await yD(D),!E)console.error(`\u274C Failed to create session "${D}"`),process.exit(1);console.log(`\u2705 Created session "${D}"`)}else console.log(`\u2139\uFE0F Session "${D}" already exists`);let B;if(F.pane)B=F.pane.startsWith("%")?F.pane:`%${F.pane}`;else{let J=await v(E.id);B=(await g(J[0].id))[0].id}let $=F.command||"claude";if(await e(B,$,!1,!1),console.log(`\u2705 Started "${$}" in session "${D}"`),F.monitor){console.log("\u2139\uFE0F Starting event monitor...");let J=new UD(D,{pollIntervalMs:500,paneId:F.pane});J.on("event",(X)=>{if(F.json)console.log(JSON.stringify(X));else console.log(R6(X))}),J.on("poll_error",(X)=>{console.error(`\u26A0\uFE0F Poll error: ${X.message}`)}),await J.start(),console.log("\u2705 Monitor active. Press Ctrl+C to stop."),process.on("SIGINT",()=>{J.stop(),console.log(`
151
+ \u2705 Monitor stopped.`),process.exit(0)}),await new Promise(()=>{})}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function j6(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane);if(await e(B,F,!1,!1),E.noWait){console.log(`\u2705 Message sent to session "${D}"`);return}let $=new UD(D,{pollIntervalMs:250,paneId:E.pane});await $.start();let J=E.method?D3(E.method):C0(),X=E.timeout||120000;console.log(`\u2139\uFE0F Waiting for completion using "${J.name}"...`);try{let Q=await J.detect($,X);if($.stop(),E.json)console.log(JSON.stringify(Q,null,2));else if(console.log(`\u2705 Completion detected: ${Q.reason}`),console.log(` Latency: ${Q.latencyMs}ms`),Q.state)console.log(` State: ${V6(Q.state)}`);let Y=await p(B,100);console.log(`
152
+ --- Response ---`),console.log(DD(Y).trim())}catch(Q){$.stop(),console.error(`\u274C Completion detection failed: ${Q.message}`),process.exit(1)}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}async function L6(D,F={}){try{let{paneId:E}=await N2(D,F.pane),B=await p(E,100),$=FD(B),J=null,X=[],Q=null;if($.type==="permission")J=U6(B);else if($.type==="question"){if(X=t0(B),$.detail==="plan_approval")Q=G6(B)}if(F.json)console.log(JSON.stringify({session:D,state:$.type,detail:$.detail,confidence:$.confidence,timestamp:$.timestamp,permissionDetails:J,questionOptions:X,planFile:Q},null,2));else{if(console.log(`Session: ${D}`),console.log(`State: ${$.type}`),$.detail)console.log(`Detail: ${$.detail}`);if(console.log(`Confidence: ${($.confidence*100).toFixed(0)}%`),J){if(console.log(`
153
+ Permission Request:`),console.log(` Type: ${J.type}`),J.command)console.log(` Command: ${J.command}`);if(J.file)console.log(` File: ${J.file}`)}if(X.length>0)console.log(`
154
+ Question Options:`),X.forEach((_,H)=>{console.log(` [${H+1}] ${_}`)});if(Q)console.log(`
155
+ Plan File: ${Q}`);let q=DD(B).trim().split(`
156
+ `).slice(-5);console.log(`
157
+ Last output:`),q.forEach((_)=>console.log(` ${_}`))}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function M6(D,F={}){try{let E=new UD(D,{pollIntervalMs:F.poll||500,paneId:F.pane});E.on("event",($)=>{if(F.json)console.log(JSON.stringify($));else console.log(R6($))}),E.on("poll_error",($)=>{console.error(`\u26A0\uFE0F Poll error: ${$.message}`)}),await E.start(),console.log(`\u2705 Watching session "${D}". Press Ctrl+C to stop.`);let B=E.getCurrentState();if(B)console.log(`Initial state: ${V6(B)}`);process.on("SIGINT",()=>{E.stop(),console.log(`
158
+ \u2705 Watch stopped.`),process.exit(0)}),await new Promise(()=>{})}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function F3(D,F={}){try{let{paneId:E}=await N2(D,F.pane),B=await p(E,50),$=FD(B);if($.type!=="permission"&&!F.auto){console.log(`\u2139\uFE0F No permission request pending (state: ${$.type})`);return}if(F.deny)await S(`send-keys -t '${E}' Down`),await CD(100);if(await S(`send-keys -t '${E}' Enter`),console.log(`\u2705 ${F.deny?"Denied":"Approved"} permission in session "${D}"`),F.auto){console.log("\u2139\uFE0F Auto-approve mode enabled. Press Ctrl+C to stop.");let J=new UD(D,{pollIntervalMs:250,paneId:F.pane});J.on("permission",async(X)=>{try{let{paneId:Q}=await N2(D,F.pane),Y=F.deny?"n":"y";await e(Q,Y,!1,!0),console.log(`\u2705 Auto-${F.deny?"denied":"approved"}: ${X.state?.detail||"unknown"}`)}catch(Q){console.error(`\u26A0\uFE0F Auto-approve failed: ${Q.message}`)}}),await J.start(),process.on("SIGINT",()=>{J.stop(),console.log(`
159
+ \u2705 Auto-approve stopped.`),process.exit(0)}),await new Promise(()=>{})}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function E3(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane),$=await p(B,50),J=FD($);if(J.type!=="question"){console.log(`\u2139\uFE0F No question pending (state: ${J.type})`);return}if(F.startsWith("text:")){let X=F.slice(5);await S(`send-keys -t '${B}' End`),await CD(100),await S(`send-keys -t '${B}' Enter`),await CD(100),await S(`send-keys -t '${B}' ${e7(X)}`),await CD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Sent feedback: "${X.substring(0,50)}${X.length>50?"...":""}"`)}else if(/^\d+$/.test(F)){let X=parseInt(F,10),Y=DD($).split(`
160
+ `),q=1;for(let H=0;H<Y.length;H++)if(Y[H].match(/^\s*\u276F\s*\d+\./)){let G=Y[H].match(/\u276F\s*(\d+)\./);if(G)q=parseInt(G[1],10);break}let _=X-q;if(_>0)for(let H=0;H<_;H++)await S(`send-keys -t '${B}' Down`),await CD(50);else if(_<0)for(let H=0;H<Math.abs(_);H++)await S(`send-keys -t '${B}' Up`),await CD(50);await CD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Selected option ${X} in session "${D}"`)}else await S(`send-keys -t '${B}' '${F}'`),console.log(`\u2705 Sent '${F}' to session "${D}"`)}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}function e7(D){return`"${D.replace(/"/g,"\\\"").replace(/\$/g,"\\$")}"`}function CD(D){return new Promise((F)=>setTimeout(F,D))}async function O6(D,F={}){let E=F.runs||1,B=F.task||'echo "Hello, World!"';console.log(`\uD83E\uDDEA Experiment: Testing "${D}" method`),console.log(` Runs: ${E}`),console.log(` Task: ${B}`),console.log("");let $=D3(D),J=[],X=`orc-experiment-${Date.now()}`,Q=await yD(X);if(!Q)console.error("\u274C Failed to create test session"),process.exit(1);try{let Y=await v(Q.id),_=(await g(Y[0].id))[0].id;for(let O=0;O<E;O++){console.log(`
161
+ Run ${O+1}/${E}...`),await e(_,"clear",!1,!1),await new Promise((f)=>setTimeout(f,500));let L=new UD(X,{pollIntervalMs:100});await L.start(),await e(_,B,!1,!1);let N=await $.detect(L,30000);if(L.stop(),J.push({run:O+1,latencyMs:N.latencyMs,complete:N.complete,reason:N.reason}),console.log(` Complete: ${N.complete}`),console.log(` Latency: ${N.latencyMs}ms`),console.log(` Reason: ${N.reason}`),O<E-1)await new Promise((f)=>setTimeout(f,1000))}let H=J.filter((O)=>O.complete),G=H.reduce((O,L)=>O+L.latencyMs,0)/H.length||0,U=Math.min(...H.map((O)=>O.latencyMs))||0,R=Math.max(...H.map((O)=>O.latencyMs))||0,K={method:D,totalRuns:E,successfulRuns:H.length,successRate:H.length/E*100,avgLatencyMs:Math.round(G),minLatencyMs:U,maxLatencyMs:R,results:J};if(console.log(`
162
+ --- Summary ---`),F.json)console.log(JSON.stringify(K,null,2));else console.log(`Method: ${K.method}`),console.log(`Success Rate: ${K.successRate.toFixed(1)}%`),console.log(`Avg Latency: ${K.avgLatencyMs}ms`),console.log(`Min Latency: ${K.minLatencyMs}ms`),console.log(`Max Latency: ${K.maxLatencyMs}ms`)}finally{await B0(Q.id),console.log(`
163
+ \u2705 Cleaned up test session`)}}async function N6(){console.log("Available completion methods:"),console.log("");for(let D of Object.keys(d2)){let F=d2[D]();console.log(` ${D}`),console.log(` ${F.description}`),console.log("")}console.log("Custom methods:"),console.log(" silence-Xms - Silence timeout (e.g., silence-2000ms)"),console.log(" silence-Xs - Silence timeout (e.g., silence-5s)")}async function S6(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane),$=E.timeout||300000;await e(B,F,!1,!1),console.log(`\u2705 Sent task: "${F.substring(0,50)}${F.length>50?"...":""}"`);let J=new UD(D,{pollIntervalMs:250,paneId:E.pane});await J.start();let X=Date.now();console.log(`\u2139\uFE0F Monitoring for completion...${E.autoApprove?" (auto-approve enabled)":""}`);let Q=null,Y=async()=>{let H=await p(B,30),G=FD(H);if(G.type!==Q){let U=((Date.now()-X)/1000).toFixed(1);console.log(`[${U}s] State: ${G.type}${G.detail?` (${G.detail})`:""}`),Q=G.type}if(G.type==="permission"&&E.autoApprove)return console.log(" \u21B3 Auto-approving permission..."),await S(`send-keys -t '${B}' Enter`),await CD(200),!1;if(G.type==="question"){if(G.detail==="plan_approval"&&E.autoApprove)return console.log(" \u21B3 Auto-approving plan..."),await S(`send-keys -t '${B}' Enter`),await CD(200),!1;console.log("\u26A0\uFE0F Question requires manual input");let U=t0(H);if(U.length>0)console.log(" Options:"),U.forEach((R,K)=>console.log(` [${K+1}] ${R}`));return!0}if(G.type==="idle"){let U=((Date.now()-X)/1000).toFixed(1);return console.log(`\u2705 Task complete (${U}s)`),!0}if(G.type==="error")return console.log("\u274C Task encountered error"),!0;return!1},q=500,_=Math.ceil($/q);for(let H=0;H<_;H++){if(await Y())break;if(Date.now()-X>$){console.log(`\u26A0\uFE0F Timeout after ${$/1000}s`);break}await CD(q)}if(J.stop(),E.json){let H=await p(B,30),G=FD(H);console.log(JSON.stringify({session:D,state:G.type,detail:G.detail,elapsedMs:Date.now()-X},null,2))}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}var{$:G9}=globalThis.Bun;sD();import{join as A9}from"path";import{homedir as U9}from"os";var C9=A9(U9(),".local","share","term","worktrees");async function Y3(D){try{return{stdout:(await G9`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function b6(D){let{stdout:F,exitCode:E}=await Y3(["show",D,"--json"]);if(E!==0||!F)return null;try{let B=JSON.parse(F);return{id:B.id,title:B.title||B.description?.substring(0,50)||"Untitled",status:B.status,blockedBy:B.blockedBy||[]}}catch{return null}}async function z9(){let{stdout:D,exitCode:F}=await Y3(["ready","--json"]);if(F!==0||!D)return null;try{let E=JSON.parse(D);if(Array.isArray(E)&&E.length>0){let B=E[0];return{id:B.id,title:B.title||B.description?.substring(0,50)||"Untitled",status:B.status,blockedBy:B.blockedBy||[]}}return null}catch{let E=D.split(`
164
+ `).filter((B)=>B.trim());if(E.length>0){let B=E[0].match(/^(bd-\d+)/);if(B)return b6(B[1])}return null}}async function V9(D){let{exitCode:F}=await Y3(["update",D,"--status","in_progress"]);return F===0}async function R9(){try{return(await S("display-message -p '#{session_name}'")).trim()||null}catch{return null}}async function K9(D,F){try{let E=new PD({baseDir:C9,repoPath:F});if(await E.worktreeExists(D))return console.log(`\u2139\uFE0F Worktree for ${D} already exists`),E.getWorktreePath(D);return(await E.createWorktree(D,!0)).path}catch(E){return console.error(`\u26A0\uFE0F Failed to create worktree: ${E.message}`),null}}async function j9(D,F){try{let E=await Z(D);if(!E)return console.error(`\u274C Session "${D}" not found`),null;let B=await v(E.id);if(!B||B.length===0)return console.error(`\u274C No windows in session "${D}"`),null;let $=await g(B[0].id);if(!$||$.length===0)return console.error(`\u274C No panes in session "${D}"`),null;let J=await $0($[0].id,"horizontal",50,F);if(!J)return console.error("\u274C Failed to create new pane"),null;return{paneId:J.id}}catch(E){return console.error(`\u274C Error spawning worker pane: ${E.message}`),null}}function L9(D,F,E){let B=new UD(F,{pollIntervalMs:1000,paneId:E});B.on("state_change",async($)=>{if(!$.state)return;let J;switch($.state.type){case"working":case"tool_use":J="working";break;case"idle":J="idle";break;case"permission":J="permission";break;case"question":J="question";break;case"error":J="error";break;case"complete":J="done";break;default:return}try{await T2(D,J)}catch{}}),B.on("poll_error",()=>{rD(D).catch(()=>{}),B.stop()}),B.start().catch(()=>{})}async function w6(D,F={}){try{let E=process.cwd(),B=null;if(D==="next"){if(console.log("\uD83D\uDD0D Finding next ready issue..."),B=await z9(),!B){console.log("\u2139\uFE0F No ready issues. Run `bd ready` to see the queue.");return}console.log(`\uD83D\uDCCB Found: ${B.id} - "${B.title}"`)}else if(D==="wish")console.error("\u274C `term work wish` is not yet implemented. Coming in Phase 1.5."),process.exit(1);else if(B=await b6(D),!B)console.error(`\u274C Issue "${D}" not found. Run \`bd list\` to see issues.`),process.exit(1);let $=B.id,J=await vD($);if(J)console.error(`\u274C ${$} already has a worker (pane ${J.paneId})`),console.log(` Run \`term kill ${J.id}\` first, or work on a different issue.`),process.exit(1);let X=F.session||await R9();if(!X)console.error("\u274C Not in a tmux session. Attach to a session first or use --session."),process.exit(1);if(console.log(`\uD83D\uDCDD Claiming ${$}...`),!await V9($))console.error(`\u274C Failed to claim ${$}. Check \`bd show ${$}\`.`),process.exit(1);let Y=E,q=null;if(!F.noWorktree)if(console.log(`\uD83C\uDF33 Creating worktree for ${$}...`),q=await K9($,E),q)Y=q,console.log(` Created: ${q}`);else console.log("\u26A0\uFE0F Worktree creation failed. Using shared repo.");console.log("\uD83D\uDE80 Spawning worker pane...");let _=await j9(X,Y);if(!_)process.exit(1);let{paneId:H}=_,G={id:$,paneId:H,session:X,worktree:q,taskId:$,taskTitle:B.title,startedAt:new Date().toISOString(),state:"spawning",lastStateChange:new Date().toISOString(),repoPath:E};await J3(G),await e(H,"claude",!1,!1),await new Promise((R)=>setTimeout(R,2000));let U=F.prompt||`Work on beads issue ${$}: "${B.title}"
165
+
166
+ Read the issue details with: bd show ${$}
167
+
168
+ When you're done, commit your changes and let me know.`;if(await e(H,U,!1,!1),await T2($,"working"),L9($,X,H),F.focus!==!1)await S(`select-pane -t '${H}'`);if(console.log(`
169
+ \u2705 Worker started for ${$}`),console.log(` Pane: ${H}`),console.log(` Session: ${X}`),q)console.log(` Worktree: ${q}`);console.log(`
170
+ Commands:`),console.log(" term workers - Check worker status"),console.log(` term approve ${$} - Approve permissions`),console.log(` term close ${$} - Close issue when done`),console.log(` term kill ${$} - Force kill worker`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var{$:P6}=globalThis.Bun;sD();async function O9(D){try{return await p(D,1),!0}catch{return!1}}async function N9(D){try{let F=await p(D,30),E=FD(F);switch(E.type){case"working":case"tool_use":return"working";case"idle":return"idle";case"permission":return"\u26A0\uFE0F perm";case"question":return"\u26A0\uFE0F question";case"error":return"\u274C error";case"complete":return"\u2705 done";default:return E.type}}catch{return"unknown"}}async function S9(){let D=[],F=[];try{let B=(await P6`bd ready --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)D.push(`${J.id}`)}catch{let $=B.split(`
171
+ `).filter((J)=>J.trim());for(let J of $){let X=J.match(/^(bd-\d+)/);if(X)D.push(X[1])}}}catch{}try{let B=(await P6`bd list --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)if(J.blockedBy&&J.blockedBy.length>0)F.push(`${J.id} (blocked by ${J.blockedBy.join(", ")})`)}catch{}}catch{}return{ready:D,blocked:F}}function T9(D){let F=new Date(D).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60);if($>0)return`${$}h ${B%60}m`;else if(B>0)return`${B}m`;return"<1m"}async function I6(D={}){try{let F=await aD(),E=[];for(let Q of F){let Y=await O9(Q.paneId),q=Q.state;if(Y){q=await N9(Q.paneId);let _=b9(q);if(_&&_!==Q.state)await T2(Q.id,_)}else q="\uD83D\uDC80 dead";E.push({name:Q.id,pane:Q.paneId,task:Q.taskTitle?`"${Q.taskTitle.substring(0,25)}${Q.taskTitle.length>25?"...":""}"`:Q.taskId,state:q,time:T9(Q.startedAt),alive:Y})}let B=await S9(),$=F.filter((Q)=>E.find((Y)=>Y.name===Q.id&&Y.alive)).map((Q)=>Q.taskId),J=B.ready.filter((Q)=>!$.includes(Q));if(D.json){console.log(JSON.stringify({workers:E,queue:{ready:J,blocked:B.blocked}},null,2));return}if(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 WORKERS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2524"),console.log("\u2502 Name \u2502 Pane \u2502 Task \u2502 State \u2502Time\u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2524"),E.length===0)console.log("\u2502 (no workers) \u2502");else for(let Q of E){let Y=Q.name.padEnd(8).substring(0,8),q=Q.pane.padEnd(8).substring(0,8),_=Q.task.padEnd(25).substring(0,25),H=Q.state.padEnd(8).substring(0,8),G=Q.time.padStart(4).substring(0,4);console.log(`\u2502 ${Y} \u2502 ${q} \u2502 ${_} \u2502 ${H} \u2502${G}\u2502`)}if(console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"),B.blocked.length>0)console.log(`
172
+ Blocked: ${B.blocked.slice(0,5).join(", ")}${B.blocked.length>5?"...":""}`);if(J.length>0)console.log(`Ready: ${J.slice(0,5).join(", ")}${J.length>5?"...":""}`);else if(E.length>0)console.log(`
173
+ Ready: (none - all assigned or blocked)`);let X=E.filter((Q)=>!Q.alive);if(X.length>0)console.log(`
174
+ \u26A0\uFE0F ${X.length} dead worker(s) detected. Run \`term kill <name>\` to clean up.`)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}function b9(D){if(D==="working")return"working";if(D==="idle")return"idle";if(D==="\u26A0\uFE0F perm")return"permission";if(D==="\u26A0\uFE0F question")return"question";if(D==="\u274C error")return"error";if(D==="\u2705 done")return"done";return null}var{$:T0}=globalThis.Bun;var i2=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",V0=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n";var q3=(D)=>D.name==="backspace",tD=(D)=>D.name==="tab";var OD=(D)=>D.name==="enter"||D.name==="return";class _3 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class H3 extends Error{name="CancelPromptError";message="Prompt was canceled"}class R0 extends Error{name="ExitPromptError"}class W3 extends Error{name="HookError"}class G3 extends Error{name="ValidationError"}import{AsyncResource as f9}from"async_hooks";import{AsyncLocalStorage as P9,AsyncResource as I9}from"async_hooks";var u6=new P9;function u9(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function f6(D,F){let E=u9(D);return u6.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function eD(){let D=u6.getStore();if(!D)throw new W3("[Inquirer] Hook functions can only be called from within a prompt");return D}function A3(){return eD().rl}function U3(D){let F=(...E)=>{let B=eD(),$=!1,J=B.handleChange;B.handleChange=()=>{$=!0};let X=D(...E);if($)J();return B.handleChange=J,X};return I9.bind(F)}function b2(D){let F=eD(),{index:E}=F,B={get(){return F.hooks[E]},set(J){F.hooks[E]=J},initialized:E in F.hooks},$=D(B);return F.index++,$}function Z6(){eD().handleChange()}var D2={queue(D){let F=eD(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(A3());if(B!=null&&typeof B!=="function")throw new G3("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=eD();U3(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=eD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function x(D){return b2((F)=>{let E=f9.bind(function(J){if(F.get()!==J)F.set(J),Z6()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function ND(D,F){b2((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((J,X)=>!Object.is(J,B[X])))D2.queue(D);E.set(F)})}var ED=xD(K0(),1);import zD from"process";function v9(){if(zD.platform!=="win32")return zD.env.TERM!=="linux";return Boolean(zD.env.WT_SESSION)||Boolean(zD.env.TERMINUS_SUBLIME)||zD.env.ConEmuTask==="{cmd::Cmder}"||zD.env.TERM_PROGRAM==="Terminus-Sublime"||zD.env.TERM_PROGRAM==="vscode"||zD.env.TERM==="xterm-256color"||zD.env.TERM==="alacritty"||zD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var v6={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},x6={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},x9={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},y9={...v6,...x6},h9={...v6,...x9},g9=v9(),l9=g9?y9:h9,w2=l9,Z$=Object.entries(x6);var y6={prefix:{idle:ED.default.blue("?"),done:ED.default.green(w2.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>ED.default.yellow(D))},style:{answer:ED.default.cyan,message:ED.default.bold,error:(D)=>ED.default.red(`> ${D}`),defaultAnswer:(D)=>ED.default.dim(`(${D})`),help:ED.default.dim,highlight:ED.default.cyan,key:(D)=>ED.default.cyan(ED.default.bold(`<${D}>`))}};function h6(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function g6(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let J=F[B];F[B]=h6(J)&&h6($)?g6(J,$):$}return F}function HD(...D){let F=[y6,...D.filter((E)=>E!=null)];return g6(...F)}function SD({status:D="idle",theme:F}){let[E,B]=x(!1),[$,J]=x(0),{prefix:X,spinner:Q}=HD(F);if(ND(()=>{if(D==="loading"){let q,_=-1,H=setTimeout(()=>{B(!0),q=setInterval(()=>{_=_+1,J(_%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(H),clearInterval(q)}}else B(!1)},[D]),E)return Q.frames[$];return typeof X==="string"?X:X[D==="loading"?"idle":D]??X.idle}function C3(D,F){return b2((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,J)=>$!==F[J])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function j0(D){return x({current:D})[0]}function TD(D){let F=j0(D);F.current=D,ND((E)=>{let B=!1,$=U3((J,X)=>{if(B)return;F.current(X,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var U1=xD(m6(),1),C1=xD(A1(),1);function a2(D,F){return D.split(`
175
+ `).flatMap((E)=>C1.default(E,F,{trim:!1,hard:!0}).split(`
176
+ `).map((B)=>B.trimEnd())).join(`
177
+ `)}function O0(){return U1.default({defaultWidth:80,output:A3().output})}function q4({active:D,renderedItems:F,pageSize:E,loop:B}){let $=j0({lastPointer:D,lastActive:void 0}),{lastPointer:J,lastActive:X}=$.current,Q=Math.floor(E/2),Y=F.reduce((H,G)=>H+G.length,0),q=F.slice(0,D).reduce((H,G)=>H+G.length,0),_=q;if(Y>E)if(B){if(_=J,X!=null&&X<D&&D-X<E)_=Math.min(Q,Math.abs(D-X)===1?Math.min(J+(F[X]?.length??0),Math.max(q,J)):J+D-X)}else{let H=F.slice(D).reduce((G,U)=>G+U.length,0);_=H<E-Q?E-H:Math.min(q,Q)}return $.current.lastPointer=_,$.current.lastActive=D,_}function N3({items:D,active:F,renderItem:E,pageSize:B,loop:$=!0}){let J=O0(),X=(L)=>(L%D.length+D.length)%D.length,Q=D.map((L,N)=>{if(L==null)return[];return a2(E({item:L,index:N,isActive:N===F}),J).split(`
178
+ `)}),Y=Q.reduce((L,N)=>L+N.length,0),q=(L)=>Q[L]??[],_=q4({active:F,renderedItems:Q,pageSize:B,loop:$}),H=q(F).slice(0,B),G=_+H.length<=B?_:B-H.length,U=Array.from({length:B});U.splice(G,H.length,...H);let R=new Set([F]),K=G+H.length,O=X(F+1);while(K<B&&!R.has(O)&&($&&Y>B?O!==F:O>F)){let N=q(O).slice(0,B-K);U.splice(K,N.length,...N),R.add(O),K+=N.length,O=X(O+1)}K=G-1,O=X(F-1);while(K>=0&&!R.has(O)&&($&&Y>B?O!==F:O<F)){let L=q(O),N=L.slice(Math.max(0,L.length-K-1));U.splice(K-N.length+1,N.length,...N),R.add(O),K-=N.length,O=X(O-1)}return U.filter((L)=>typeof L==="string").join(`
179
+ `)}var w1=xD(R1(),1);import*as b1 from"readline";import{AsyncResource as C4}from"async_hooks";var F2=[];F2.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")F2.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")F2.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var N0=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",S3=Symbol.for("signal-exit emitter"),T3=globalThis,H4=Object.defineProperty.bind(Object);class K1{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(T3[S3])return T3[S3];H4(T3,S3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let E=this.listeners[D],B=E.indexOf(F);if(B===-1)return;if(B===0&&E.length===1)E.length=0;else E.splice(B,1)}emit(D,F,E){if(this.emitted[D])return!1;this.emitted[D]=!0;let B=!1;for(let $ of this.listeners[D])B=$(F,E)===!0||B;if(D==="exit")B=this.emit("afterExit",F,E)||B;return B}}class w3{}var W4=(D)=>{return{onExit(F,E){return D.onExit(F,E)},load(){return D.load()},unload(){return D.unload()}}};class j1 extends w3{onExit(){return()=>{}}load(){}unload(){}}class L1 extends w3{#E=b3.platform==="win32"?"SIGINT":"SIGHUP";#F=new K1;#D;#J;#X;#$={};#B=!1;constructor(D){super();this.#D=D,this.#$={};for(let F of F2)this.#$[F]=()=>{let E=this.#D.listeners(F),{count:B}=this.#F,$=D;if(typeof $.__signal_exit_emitter__==="object"&&typeof $.__signal_exit_emitter__.count==="number")B+=$.__signal_exit_emitter__.count;if(E.length===B){this.unload();let J=this.#F.emit("exit",null,F),X=F==="SIGHUP"?this.#E:F;if(!J)D.kill(D.pid,X)}};this.#X=D.reallyExit,this.#J=D.emit}onExit(D,F){if(!N0(this.#D))return()=>{};if(this.#B===!1)this.load();let E=F?.alwaysLast?"afterExit":"exit";return this.#F.on(E,D),()=>{if(this.#F.removeListener(E,D),this.#F.listeners.exit.length===0&&this.#F.listeners.afterExit.length===0)this.unload()}}load(){if(this.#B)return;this.#B=!0,this.#F.count+=1;for(let D of F2)try{let F=this.#$[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#Y(D,...F)},this.#D.reallyExit=(D)=>{return this.#Q(D)}}unload(){if(!this.#B)return;this.#B=!1,F2.forEach((D)=>{let F=this.#$[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(E){}}),this.#D.emit=this.#J,this.#D.reallyExit=this.#X,this.#F.count-=1}#Q(D){if(!N0(this.#D))return 0;return this.#D.exitCode=D||0,this.#F.emit("exit",this.#D.exitCode,null),this.#X.call(this.#D,this.#D.exitCode)}#Y(D,...F){let E=this.#J;if(D==="exit"&&N0(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let B=E.call(this.#D,D,...F);return this.#F.emit("exit",this.#D.exitCode,null),B}else return E.call(this.#D,D,...F)}}var b3=globalThis.process,{onExit:M1,load:VJ,unload:RJ}=W4(N0(b3)?new L1(b3):new j1);import{stripVTControlCharacters as A4}from"util";var G4="\x1B[G",N1="\x1B[?25l",S1="\x1B[?25h",P3=(D=1)=>D>0?`\x1B[${D}A`:"",I3=(D=1)=>D>0?`\x1B[${D}B`:"",u3=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},O1="\x1B[2K",f3=(D)=>D>0?(O1+P3(1)).repeat(D-1)+O1+G4:"";var T1=(D)=>D.split(`
180
+ `).length,U4=(D)=>D.split(`
181
+ `).pop()??"";class S0{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(D){this.rl=D,this.cursorPos=D.getCursorPos()}write(D){this.rl.output.unmute(),this.rl.output.write(D),this.rl.output.mute()}render(D,F=""){let E=U4(D),B=A4(E),$=B;if(this.rl.line.length>0)$=$.slice(0,-this.rl.line.length);this.rl.setPrompt($),this.cursorPos=this.rl.getCursorPos();let J=O0();if(D=a2(D,J),F=a2(F,J),B.length%J===0)D+=`
182
+ `;let X=D+(F?`
183
+ `+F:""),Y=Math.floor(B.length/J)-this.cursorPos.rows+(F?T1(F):0);if(Y>0)X+=P3(Y);X+=u3(this.cursorPos.cols),this.write(I3(this.extraLinesUnderPrompt)+f3(this.height)+X),this.extraLinesUnderPrompt=Y,this.height=T1(X)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(u3(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=I3(this.extraLinesUnderPrompt);F+=D?f3(this.height):`
184
+ `,F+=S1,this.write(F),this.rl.close()}}class Z3 extends Promise{static withResolver(){let D,F;return{promise:new Promise((B,$)=>{D=B,F=$}),resolve:D,reject:F}}}function z4(){let D=Error.prepareStackTrace,F=[];try{Error.prepareStackTrace=(E,B)=>{let $=B.slice(1);return F=$,$},Error().stack}catch{return F}return Error.prepareStackTrace=D,F}function bD(D){let F=z4();return(B,$={})=>{let{input:J=process.stdin,signal:X}=$,Q=new Set,Y=new w1.default;Y.pipe($.output??process.stdout);let q=b1.createInterface({terminal:!0,input:J,output:Y}),_=new S0(q),{promise:H,resolve:G,reject:U}=Z3.withResolver(),R=()=>U(new H3);if(X){let L=()=>U(new _3({cause:X.reason}));if(X.aborted)return L(),Object.assign(H,{cancel:R});X.addEventListener("abort",L),Q.add(()=>X.removeEventListener("abort",L))}Q.add(M1((L,N)=>{U(new R0(`User force closed the prompt with ${L} ${N}`))}));let K=()=>U(new R0("User force closed the prompt with SIGINT"));q.on("SIGINT",K),Q.add(()=>q.removeListener("SIGINT",K));let O=()=>_.checkCursorPos();return q.input.on("keypress",O),Q.add(()=>q.input.removeListener("keypress",O)),f6(q,(L)=>{let N=C4.bind(()=>D2.clearAll());return q.on("close",N),Q.add(()=>q.removeListener("close",N)),L(()=>{try{let f=D(B,(r)=>{setImmediate(()=>G(r))});if(f===void 0){let r=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
185
+ at ${r}`)}let[c,t]=typeof f==="string"?[f]:f;_.render(c,t),D2.run()}catch(f){U(f)}}),Object.assign(H.then((f)=>{return D2.clearAll(),f},(f)=>{throw D2.clearAll(),f}).finally(()=>{Q.forEach((f)=>f()),_.done({clearContent:Boolean($.clearPromptOnDone)}),Y.end()}).then(()=>H),{cancel:R})})}}var P1=xD(K0(),1);class f2{separator=P1.default.dim(Array.from({length:15}).join(w2.line));type="separator";constructor(D){if(D)this.separator=D}static isSeparator(D){return Boolean(D&&typeof D==="object"&&"type"in D&&D.type==="separator")}}function I1(D,F){let E=F!==!1;if(/^(y|yes)/i.test(D))E=!0;else if(/^(n|no)/i.test(D))E=!1;return E}function u1(D){return D?"Yes":"No"}var o2=bD((D,F)=>{let{transformer:E=u1}=D,[B,$]=x("idle"),[J,X]=x(""),Q=HD(D.theme),Y=SD({status:B,theme:Q});TD((G,U)=>{if(B!=="idle")return;if(OD(G)){let R=I1(J,D.default);X(E(R)),$("done"),F(R)}else if(tD(G)){let R=u1(!I1(J,D.default));U.clearLine(0),U.write(R),X(R)}else X(U.line)});let q=J,_="";if(B==="done")q=Q.style.answer(J);else _=` ${Q.style.defaultAnswer(D.default===!1?"y/N":"Y/n")}`;let H=Q.style.message(D.message,B);return`${Y} ${H}${_} ${q}`});var V4={validationFailureMode:"keep"},R4=bD((D,F)=>{let{prefill:E="tab"}=D,B=HD(V4,D.theme),[$,J]=x("idle"),[X="",Q]=x(D.default),[Y,q]=x(),[_,H]=x(""),G=SD({status:$,theme:B});async function U(N){let{required:f,pattern:c,patternError:t="Invalid input"}=D;if(f&&!N)return"You must provide a value";if(c&&!c.test(N))return t;if(typeof D.validate==="function")return await D.validate(N)||"You must provide a valid value";return!0}TD(async(N,f)=>{if($!=="idle")return;if(OD(N)){let c=_||X;J("loading");let t=await U(c);if(t===!0)H(c),J("done"),F(c);else{if(B.validationFailureMode==="clear")H("");else f.write(_);q(t),J("idle")}}else if(q3(N)&&!_)Q(void 0);else if(tD(N)&&!_)Q(void 0),f.clearLine(0),f.write(X),H(X);else H(f.line),q(void 0)}),ND((N)=>{if(E==="editable"&&X)N.write(X),H(X)},[]);let R=B.style.message(D.message,$),K=_;if(typeof D.transformer==="function")K=D.transformer(_,{isFinal:$==="done"});else if($==="done")K=B.style.answer(_);let O;if(X&&$!=="done"&&!_)O=B.style.defaultAnswer(X);let L="";if(Y)L=B.style.error(Y);return[[G,R,O,K].filter((N)=>N!==void 0).join(" "),L]});var K4=bD((D,F)=>{let{validate:E=()=>!0}=D,B=HD(D.theme),[$,J]=x("idle"),[X,Q]=x(),[Y,q]=x(""),_=SD({status:$,theme:B});TD(async(K,O)=>{if($!=="idle")return;if(OD(K)){let L=Y;J("loading");let N=await E(L);if(N===!0)q(L),J("done"),F(L);else O.write(Y),Q(N||"You must provide a valid value"),J("idle")}else q(O.line),Q(void 0)});let H=B.style.message(D.message,$),G="",U;if(D.mask)G=(typeof D.mask==="string"?D.mask:"*").repeat(Y.length);else if($!=="done")U=`${B.style.help("[input is masked]")}${N1}`;if($==="done")G=B.style.answer(G);let R="";if(X)R=B.style.error(X);return[[_,H,D.mask?G:U].join(" "),R]});var E2=xD(K0(),1);var j4={icon:{cursor:w2.pointer},style:{disabled:(D)=>E2.default.dim(`- ${D}`),searchTerm:(D)=>E2.default.cyan(D),description:(D)=>E2.default.cyan(D),keysHelpTip:(D)=>D.map(([F,E])=>`${E2.default.bold(F)} ${E2.default.dim(E)}`).join(E2.default.dim(" \u2022 "))},helpMode:"always"};function k3(D){return!f2.isSeparator(D)&&!D.disabled}function L4(D){return D.map((F)=>{if(f2.isSeparator(F))return F;if(typeof F==="string")return{value:F,name:F,short:F,disabled:!1};let E=F.name??String(F.value),B={value:F.value,name:E,short:F.short??E,disabled:F.disabled??!1};if(F.description)B.description=F.description;return B})}var M4=bD((D,F)=>{let{pageSize:E=7,validate:B=()=>!0}=D,$=HD(j4,D.theme),[J,X]=x("loading"),[Q,Y]=x(""),[q,_]=x([]),[H,G]=x(),U=SD({status:J,theme:$}),R=C3(()=>{let k=q.findIndex(k3),o=q.findLastIndex(k3);return{first:k,last:o}},[q]),[K=R.first,O]=x();ND(()=>{let k=new AbortController;return X("loading"),G(void 0),(async()=>{try{let BD=await D.source(Q||void 0,{signal:k.signal});if(!k.signal.aborted)O(void 0),G(void 0),_(L4(BD)),X("idle")}catch(BD){if(!k.signal.aborted&&BD instanceof Error)G(BD.message)}})(),()=>{k.abort()}},[Q]);let L=q[K];TD(async(k,o)=>{if(OD(k))if(L){X("loading");let BD=await B(L.value);if(X("idle"),BD===!0)X("done"),F(L.value);else if(L.name===Q)G(BD||"You must provide a valid value");else o.write(L.name),Y(L.name)}else o.write(Q);else if(tD(k)&&L)o.clearLine(0),o.write(L.name),Y(L.name);else if(J!=="loading"&&(i2(k)||V0(k))){if(o.clearLine(0),i2(k)&&K!==R.first||V0(k)&&K!==R.last){let BD=i2(k)?-1:1,B2=K;do B2=(B2+BD+q.length)%q.length;while(!k3(q[B2]));O(B2)}}else Y(o.line)});let N=$.style.message(D.message,J),f;if($.helpMode!=="never")if(D.instructions){let{pager:k,navigation:o}=D.instructions;f=$.style.help(q.length>E?k:o)}else f=$.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]);let c=N3({items:q,active:K,renderItem({item:k,isActive:o}){if(f2.isSeparator(k))return` ${k.separator}`;if(k.disabled){let b0=typeof k.disabled==="string"?k.disabled:"(disabled)";return $.style.disabled(`${k.name} ${b0}`)}let BD=o?$.style.highlight:(b0)=>b0,B2=o?$.icon.cursor:" ";return BD(`${B2} ${k.name}`)},pageSize:E,loop:!1}),t;if(H)t=$.style.error(H);else if(q.length===0&&Q!==""&&J==="idle")t=$.style.error("No results found");let r;if(J==="done"&&L)return[U,N,$.style.answer(L.short)].filter(Boolean).join(" ").trimEnd();else r=$.style.searchTerm(Q);let y3=L?.description,x1=[U,N,r].filter(Boolean).join(" ").trimEnd(),y1=[t??c," ",y3?$.style.description(y3):"",f].filter(Boolean).join(`
186
+ `).trimEnd();return[x1,y1]});sD();import{join as O4}from"path";import{homedir as N4}from"os";var S4=O4(N4(),".local","share","term","worktrees");async function f1(D){try{return{stdout:(await T0`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function T4(D){let{exitCode:F}=await f1(["close",D]);return F===0}async function b4(){let{exitCode:D}=await f1(["sync"]);return D===0}async function w4(D,F){try{let B=(await T0`git -C ${D} branch --show-current`.quiet()).stdout.toString().trim();if(B===F)return console.log(`\u26A0\uFE0F Already on branch ${F}. Skipping merge.`),!0;return console.log(` Switching to ${B}...`),await T0`git -C ${D} checkout ${B}`.quiet(),console.log(` Merging ${F}...`),await T0`git -C ${D} merge ${F} --no-edit`.quiet(),!0}catch(E){return console.error(`\u26A0\uFE0F Merge failed: ${E.message}`),!1}}async function P4(D,F){try{let E=new PD({baseDir:S4,repoPath:F});if(await E.worktreeExists(D))return await E.removeWorktree(D),!0;return!0}catch(E){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${E.message}`),!1}}async function I4(D){try{return await $2(D),!0}catch{return!1}}async function Z1(D,F={}){try{let E=await vD(D);if(!E)console.log(`\u2139\uFE0F No active worker for ${D}. Closing issue only.`);if(!F.yes){if(!await o2({message:`Close ${D}${E?` and kill worker (pane ${E.paneId})`:""}?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDCDD Closing ${D}...`),!await T4(D))console.error(`\u274C Failed to close ${D}. Check \`bd show ${D}\`.`);else console.log(" \u2705 Issue closed");if(!F.noSync)if(console.log("\uD83D\uDD04 Syncing beads..."),await b4())console.log(" \u2705 Synced to git");else console.log(" \u26A0\uFE0F Sync failed (non-fatal)");if(E?.worktree&&!F.keepWorktree){if(F.merge){if(console.log("\uD83D\uDD00 Merging changes..."),await w4(E.repoPath,D))console.log(" \u2705 Merged to main")}if(console.log("\uD83C\uDF33 Removing worktree..."),await P4(D,E.repoPath))console.log(" \u2705 Worktree removed")}if(E)console.log("\uD83D\uDC80 Killing worker pane..."),await I4(E.paneId),console.log(" \u2705 Pane killed"),await rD(E.id),console.log(" \u2705 Worker unregistered");console.log(`
187
+ \u2705 ${D} closed successfully`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}sD();import{join as f4}from"path";import{homedir as Z4}from"os";var k4=f4(Z4(),".local","share","term","worktrees");async function v4(D){try{return await $2(D),!0}catch{return!1}}async function x4(D,F){try{let E=new PD({baseDir:k4,repoPath:F});if(await E.worktreeExists(D))return await E.removeWorktree(D),!0;return!0}catch(E){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${E.message}`),!1}}async function k1(D,F={}){try{let E=await X3(D);if(!E)E=await Q3(D);if(!E)E=await vD(D);if(!E)console.error(`\u274C Worker "${D}" not found.`),console.log(" Run `term workers` to see active workers."),process.exit(1);if(!F.yes){if(!await o2({message:`Kill worker ${E.id} (pane ${E.paneId})?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDC80 Killing worker pane ${E.paneId}...`),await v4(E.paneId))console.log(" \u2705 Pane killed");else console.log(" \u2139\uFE0F Pane already gone");if(E.worktree&&!F.keepWorktree){if(console.log("\uD83C\uDF33 Removing worktree..."),await x4(E.taskId,E.repoPath))console.log(" \u2705 Worktree removed")}await rD(E.id),console.log(" \u2705 Worker unregistered"),console.log(`
188
+ \u26A0\uFE0F Task ${E.taskId} is still in_progress in beads.`),console.log(` Run \`bd update ${E.taskId} --status open\` to reopen,`),console.log(` or \`term work ${E.taskId}\` to start a new worker.`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var l=new F8;l.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
189
+
190
+ Collaborative Usage:
191
+ AI runs: term exec genie:shell '<command>'
192
+ Human watches: tmux attach -t genie
193
+ AI reads: term read genie
134
194
 
135
195
  Workflow: new \u2192 exec \u2192 read \u2192 rm
136
- Full control: window new/ls/rm, pane ls/rm, split, status`).version(I1);V.command("new <name>").description("Create a new tmux session").option("-d, --workspace <path>","Working directory for the session").option("-w, --worktree","Create git worktree in .worktrees/<name>/").action(async($,J)=>{await s1($,J)});V.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async($)=>{await i1($)});V.command("attach <name>").description("Attach to a tmux session").action(async($)=>{await t1($)});V.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async($,J)=>{await o1($,J)});V.command("read <session>").description("Read logs from a tmux session").option("-n, --lines <number>","Number of lines to read (default: 100)","100").option("--from <line>","Start line number").option("--to <line>","End line number").option("--range <range>","Line range (e.g., 100:200)").option("--search <pattern>","Search for pattern").option("--grep <pattern>","Regex search pattern").option("-f, --follow","Follow mode (live tail)").option("--all","Export entire scrollback buffer").option("--reverse","Reverse chronological (newest first)").option("--json","Output as JSON").action(async($,J)=>{await e1($,J)});V.command("exec <session> <command...>").description("Execute command in a tmux session").action(async($,J)=>{await $0($,J.join(" "))});V.command("send <session> <keys>").description("Send raw keys to a tmux session").action(async($,J)=>{await J0($,J)});V.command("split <session> [direction]").description("Split pane in a tmux session (h=horizontal, v=vertical)").option("-d, --workspace <path>","Working directory for the new pane").option("-w, --worktree <branch>","Create git worktree in .worktrees/<branch>/").action(async($,J,q)=>{await q0($,J,q)});V.command("status <session>").description("Check session state (idle/busy, pane count)").option("--command <id>","Check specific command status").option("--json","Output as JSON").action(async($,J)=>{await B0($,J)});var S1=V.command("window").description("Manage tmux windows");S1.command("new <session> <name>").description("Create a new window in session").action(async($,J)=>{await S0($,J)});S1.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async($,J)=>{await Y0($,J)});S1.command("rm <window-id>").description("Remove window by ID").action(async($)=>{await W0($)});var T0=V.command("pane").description("Manage tmux panes");T0.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async($,J)=>{await H0($,J)});T0.command("rm <pane-id>").description("Remove pane by ID").action(async($)=>{await R0($)});var W1=V.command("hook").description("Manage tmux hooks");W1.command("set <event> <command>").description("Set a tmux hook").action(async($,J)=>{await Q0($,J)});W1.command("list").description("List all tmux hooks").action(async()=>{await Z0()});W1.command("rm <event>").description("Remove a tmux hook").action(async($)=>{await _0($)});V.command("shortcuts").description("Warp-like keyboard shortcuts for tmux/Termux").option("--tmux","Output tmux.conf snippet").option("--termux","Output termux.properties snippet").option("--install","Install to config files (interactive)").action(async($)=>{await M0($)});V.parse();
196
+ Full control: window new/ls/rm, pane ls/rm, split, status
197
+
198
+ Worker Orchestration:
199
+ term work <bd-id> - Spawn worker bound to beads issue
200
+ term work next - Work on next ready issue
201
+ term workers - List all workers and states
202
+ term close <bd-id> - Close issue, cleanup worker
203
+ term kill <worker> - Force kill a stuck worker`).version(E8);l.command("new <name>").description("Create a new tmux session").option("-d, --workspace <path>","Working directory for the session").option("-w, --worktree","Create git worktree in .worktrees/<name>/").action(async(D,F)=>{await C8(D,F)});l.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async(D)=>{await z8(D)});l.command("attach <name>").description("Attach to a tmux session").action(async(D)=>{await V8(D)});l.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async(D,F)=>{await R8(D,F)});l.command("read <session>").description("Read logs from a tmux session").option("-n, --lines <number>","Number of lines to read (default: 100)","100").option("--from <line>","Start line number").option("--to <line>","End line number").option("--range <range>","Line range (e.g., 100:200)").option("--search <pattern>","Search for pattern").option("--grep <pattern>","Regex search pattern").option("-f, --follow","Follow mode (live tail)").option("--all","Export entire scrollback buffer").option("--reverse","Reverse chronological (newest first)").option("--json","Output as JSON").action(async(D,F)=>{await g8(D,F)});l.command("exec <session> <command...>").description("Execute command in a tmux session").option("-q, --quiet","Suppress stdout output").option("-t, --timeout <ms>","Timeout in milliseconds (default: 120000)").action(async(D,F,E)=>{await l8(D,F.join(" "),{quiet:E.quiet,timeout:E.timeout?parseInt(E.timeout,10):void 0})});l.command("send <session> <keys>").description("Send raw keys to a tmux session").action(async(D,F)=>{await m8(D,F)});l.command("split <session> [direction]").description("Split pane in a tmux session (h=horizontal, v=vertical)").option("-d, --workspace <path>","Working directory for the new pane").option("-w, --worktree <branch>","Create git worktree in .worktrees/<branch>/").action(async(D,F,E)=>{await p8(D,F,E)});l.command("status <session>").description("Check session state (idle/busy, pane count)").option("--command <id>","Check specific command status").option("--json","Output as JSON").action(async(D,F)=>{await F6(D,F)});var v3=l.command("window").description("Manage tmux windows");v3.command("new <session> <name>").description("Create a new window in session").action(async(D,F)=>{await s8(D,F)});v3.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async(D,F)=>{await o8(D,F)});v3.command("rm <window-id>").description("Remove window by ID").action(async(D)=>{await t8(D)});var v1=l.command("pane").description("Manage tmux panes");v1.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async(D,F)=>{await e8(D,F)});v1.command("rm <pane-id>").description("Remove pane by ID").action(async(D)=>{await D6(D)});var x3=l.command("hook").description("Manage tmux hooks");x3.command("set <event> <command>").description("Set a tmux hook").action(async(D,F)=>{await n8(D,F)});x3.command("list").description("List all tmux hooks").action(async()=>{await r8()});x3.command("rm <event>").description("Remove a tmux hook").action(async(D)=>{await a8(D)});l.command("shortcuts").description("Warp-like keyboard shortcuts for tmux/Termux").option("--tmux","Output tmux.conf snippet").option("--termux","Output termux.properties snippet").option("--install","Install to config files (interactive)").action(async(D)=>{await Q6(D)});l.command("work <target>").description('Spawn worker bound to beads issue (target: bd-id, "next", or "wish")').option("--no-worktree","Use shared repo instead of worktree").option("-s, --session <name>","Target tmux session").option("--no-focus","Don't focus the worker pane").option("-p, --prompt <message>","Custom initial prompt").action(async(D,F)=>{await w6(D,F)});l.command("workers").description("List all workers and their states").option("--json","Output as JSON").option("-w, --watch","Live updates (coming soon)").action(async(D)=>{if(D.watch)console.log("\u2139\uFE0F --watch mode coming in Phase 1.5");await I6(D)});l.command("close <task-id>").description("Close beads issue and cleanup worker").option("--no-sync","Skip bd sync").option("--keep-worktree","Don't remove the worktree").option("--merge","Merge worktree changes to main branch").option("-y, --yes","Skip confirmation").action(async(D,F)=>{await Z1(D,F)});l.command("kill <worker>").description("Force kill a worker").option("-y, --yes","Skip confirmation").option("--keep-worktree","Don't remove the worktree").action(async(D,F)=>{await k1(D,F)});l.command("approve <worker>").description("Approve pending permission request for a worker").option("--deny","Deny instead of approve").action(async(D,F)=>{let E=await Promise.resolve().then(() => (sD(),oD)),B=await E.get(D);if(!B)B=await E.findByTask(D);if(!B)console.error(`\u274C Worker "${D}" not found. Run \`term workers\` to see workers.`),process.exit(1);await F3(B.session,{pane:B.paneId,deny:F.deny})});l.command("answer <worker> <choice>").description('Answer a question for a worker (use "text:..." for text input)').action(async(D,F)=>{let E=await Promise.resolve().then(() => (sD(),oD)),B=await E.get(D);if(!B)B=await E.findByTask(D);if(!B)console.error(`\u274C Worker "${D}" not found. Run \`term workers\` to see workers.`),process.exit(1);await E3(B.session,F,{pane:B.paneId})});var wD=l.command("orc").description("Orchestrate Claude Code sessions");wD.command("start <session>").description("Start Claude Code in a session with optional monitoring").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").option("-m, --monitor","Enable real-time event monitoring").option("-c, --command <cmd>","Command to run instead of claude").option("--json","Output events as JSON").action(async(D,F)=>{await K6(D,F)});wD.command("send <session> <message>").description("Send message to Claude and track completion").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--method <name>","Completion detection method").option("-t, --timeout <ms>","Timeout in milliseconds").option("--no-wait","Send without waiting for completion").option("--json","Output as JSON").action(async(D,F,E)=>{await j6(D,F,E)});wD.command("status <session>").description("Show current Claude state and details").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--json","Output as JSON").action(async(D,F)=>{await L6(D,F)});wD.command("watch <session>").description("Watch session events in real-time").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--json","Output events as JSON").option("-p, --poll <ms>","Poll interval in milliseconds").action(async(D,F)=>{await M6(D,F)});wD.command("approve <session>").description("Approve pending permission request").option("-p, --pane <id>","Specific pane ID to target").option("--auto","Auto-approve all future permissions (dangerous!)").option("--deny","Deny instead of approve").action(async(D,F)=>{await F3(D,F)});wD.command("answer <session> <choice>").description('Answer a question with the given choice (use "text:..." to send feedback)').option("-p, --pane <id>","Specific pane ID to target").action(async(D,F,E)=>{await E3(D,F,E)});wD.command("experiment <method>").description("Test a completion detection method").option("-n, --runs <number>","Number of test runs").option("--task <command>","Test command to run").option("--json","Output as JSON").action(async(D,F)=>{await O6(D,F)});wD.command("methods").description("List available completion detection methods").action(async()=>{await N6()});wD.command("run <session> <message>").description("Send task and auto-approve until idle (fire-and-forget)").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").option("-a, --auto-approve","Auto-approve permissions and plans").option("-t, --timeout <ms>","Timeout in milliseconds (default: 300000)").option("--json","Output final state as JSON").action(async(D,F,E)=>{await S6(D,F,E)});l.parse();