@automagik/genie 0.260202.1607 → 0.260202.1901
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.beads/README.md +81 -0
- package/.beads/config.yaml +67 -0
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +0 -0
- package/.beads/metadata.json +4 -0
- package/.gitattributes +3 -0
- package/AGENTS.md +40 -0
- package/dist/claudio.js +5 -5
- package/dist/genie.js +6 -6
- package/dist/term.js +116 -53
- package/package.json +1 -1
- package/src/lib/beads-registry.ts +546 -0
- package/src/lib/orchestrator/completion.ts +392 -0
- package/src/lib/orchestrator/event-monitor.ts +442 -0
- package/src/lib/orchestrator/index.ts +12 -0
- package/src/lib/orchestrator/patterns.ts +277 -0
- package/src/lib/orchestrator/state-detector.ts +339 -0
- package/src/lib/tmux.ts +15 -1
- package/src/lib/version.ts +1 -1
- package/src/lib/worker-registry.ts +229 -0
- package/src/term-commands/close.ts +256 -0
- package/src/term-commands/daemon.ts +176 -0
- package/src/term-commands/kill.ts +186 -0
- package/src/term-commands/orchestrate.ts +844 -0
- package/src/term-commands/split.ts +8 -7
- package/src/term-commands/work.ts +497 -0
- package/src/term-commands/workers.ts +298 -0
- package/src/term.ts +227 -1
package/dist/term.js
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`).replace(/^/gm," ".repeat(2))}let
|
|
5
|
-
`)}padWidth(
|
|
3
|
+
var RF=Object.create;var{getPrototypeOf:KF,defineProperty:d0,getOwnPropertyNames:jF}=Object;var LF=Object.prototype.hasOwnProperty;var mD=(D,F,E)=>{E=D!=null?RF(KF(D)):{};let B=F||!D||!D.__esModule?d0(E,"default",{value:D,enumerable:!0}):E;for(let $ of jF(D))if(!LF.call(B,$))d0(B,$,{get:()=>D[$],enumerable:!0});return B};var m=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var Y8=(D,F)=>{for(var E in F)d0(D,E,{get:F[E],enumerable:!0,configurable:!0,set:(B)=>F[E]=()=>B})};var MF=(D,F)=>()=>(D&&(F=D(D=0)),F);var RD=import.meta.require;var m2=m((OF)=>{class i0 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 q8 extends i0{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}OF.CommanderError=i0;OF.InvalidArgumentError=q8});var H0=m((PF)=>{var{InvalidArgumentError:TF}=m2();class H8{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 TF(`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 bF(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}PF.Argument=H8;PF.humanReadableArgName=bF});var n0=m((uF)=>{var{humanReadableArgName:IF}=H0();class _8{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)=>IF(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,X=2;function Q(A,z){if(z){let K=`${A.padEnd(E+2)}${z}`;return F.wrap(K,B-2,E+2)}return A}function J(A){return A.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 H=F.visibleArguments(D).map((A)=>{return Q(F.argumentTerm(A),F.argumentDescription(A))});if(H.length>0)Y=Y.concat(["Arguments:",J(H),""]);let _=F.visibleOptions(D).map((A)=>{return Q(F.optionTerm(A),F.optionDescription(A))});if(_.length>0)Y=Y.concat(["Options:",J(_),""]);if(this.showGlobalOptions){let A=F.visibleGlobalOptions(D).map((z)=>{return Q(F.optionTerm(z),F.optionDescription(z))});if(A.length>0)Y=Y.concat(["Global Options:",J(A),""])}let G=F.visibleCommands(D).map((A)=>{return Q(F.subcommandTerm(A),F.subcommandDescription(A))});if(G.length>0)Y=Y.concat(["Commands:",J(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 X=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if(D.match(X))return D;let Q=F-E;if(Q<B)return D;let J=D.slice(0,E),Y=D.slice(E).replace(`\r
|
|
6
6
|
`,`
|
|
7
|
-
`),
|
|
8
|
-
|.{1,${
|
|
9
|
-
`)return"";return(
|
|
10
|
-
`)}}
|
|
11
|
-
(Did you mean one of ${
|
|
12
|
-
(Did you mean ${
|
|
13
|
-
- specify the name in Command constructor or using .name()`);if(
|
|
14
|
-
Expecting one of '${
|
|
15
|
-
- already used by option '${
|
|
16
|
-
- if '${
|
|
7
|
+
`),q=" ".repeat(E),_=`\\s${"\u200B"}`,G=new RegExp(`
|
|
8
|
+
|.{1,${Q-1}}([${_}]|$)|[^${_}]+?([${_}]|$)`,"g"),A=Y.match(G)||[];return J+A.map((z,K)=>{if(z===`
|
|
9
|
+
`)return"";return(K>0?q:"")+z.trimEnd()}).join(`
|
|
10
|
+
`)}}uF.Help=_8});var r0=m((yF)=>{var{InvalidArgumentError:vF}=m2();class W8{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=xF(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 vF(`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 kF(this.name().replace(/^no-/,""))}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class G8{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 kF(D){return D.split("-").reduce((F,E)=>{return F+E[0].toUpperCase()+E.slice(1)})}function xF(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}}yF.Option=W8;yF.DualOptions=G8});var U8=m((pF)=>{function lF(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 X=1;if(D[$-1]===F[B-1])X=0;else X=1;if(E[$][B]=Math.min(E[$-1][B]+1,E[$][B-1]+1,E[$-1][B-1]+X),$>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 mF(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((Q)=>Q.slice(2));let B=[],$=3,X=0.4;if(F.forEach((Q)=>{if(Q.length<=1)return;let J=lF(D,Q),Y=Math.max(D.length,Q.length);if((Y-J)/Y>X){if(J<$)$=J,B=[Q];else if(J===$)B.push(Q)}}),B.sort((Q,J)=>Q.localeCompare(J)),E)B=B.map((Q)=>`--${Q}`);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""}pF.suggestSimilar=mF});var V8=m((oF)=>{var dF=RD("events").EventEmitter,a0=RD("child_process"),KD=RD("path"),o0=RD("fs"),g=RD("process"),{Argument:iF,humanReadableArgName:nF}=H0(),{CommanderError:s0}=m2(),{Help:rF}=n0(),{Option:A8,DualOptions:aF}=r0(),{suggestSimilar:C8}=U8();class t0 extends dF{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)=>g.stdout.write(F),writeErr:(F)=>g.stderr.write(F),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.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[,X,Q]=D.match(/([^ ]+) *(.*)/),J=this.createCommand(X);if(B)J.description(B),J._executableHandler=!0;if($.isDefault)this._defaultCommandName=J._name;if(J._hidden=!!($.noHelp||$.hidden),J._executableFile=$.executableFile||null,Q)J.arguments(Q);if(this._registerCommand(J),J.parent=this,J.copyInheritedSettings(this),B)return this;return J}createCommand(D){return new t0(D)}createHelp(){return Object.assign(new rF,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 iF(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",X=this.createCommand(E);if(X.helpOption(!1),B)X.arguments(B);if($)X.description($);return this._addImplicitHelpCommand=!0,this._helpCommand=X,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 s0(D,F,E));g.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 A8(D,F)}_callParseArg(D,F,E,B){try{return D.parseArg(F,E)}catch($){if($.code==="commander.invalidArgument"){let X=`${B} ${$.message}`;this.error(X,{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=($,X,Q)=>{if($==null&&D.presetArg!==void 0)$=D.presetArg;let J=this.getOptionValue(E);if($!==null&&D.parseArg)$=this._callParseArg(D,$,J,X);else if($!==null&&D.variadic)$=D._concatValue($,J);if($==null)if(D.negate)$=!1;else if(D.isBoolean()||D.optional)$=!0;else $="";this.setOptionValueWithSource(E,$,Q)};if(this.on("option:"+F,($)=>{let X=`error: option '${D.flags}' argument '${$}' is invalid.`;B($,X,"cli")}),D.envVar)this.on("optionEnv:"+F,($)=>{let X=`error: option '${D.flags}' value '${$}' from env '${D.envVar}' is invalid.`;B($,X,"env")});return this}_optionEx(D,F,E,B,$){if(typeof F==="object"&&F instanceof A8)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let X=this.createOption(F,E);if(X.makeOptionMandatory(!!D.mandatory),typeof B==="function")X.default($).argParser(B);else if(B instanceof RegExp){let Q=B;B=(J,Y)=>{let q=Q.exec(J);return q?q[0]:Y},X.default($).argParser(B)}else X.default(B);return this.addOption(X)}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(g.versions?.electron)F.from="electron";let B=g.execArgv??[];if(B.includes("-e")||B.includes("--eval")||B.includes("-p")||B.includes("--print"))F.from="eval"}if(D===void 0)D=g.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(g.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,H){let _=KD.resolve(q,H);if(o0.existsSync(_))return _;if(B.includes(KD.extname(H)))return;let G=B.find((A)=>o0.existsSync(`${_}${A}`));if(G)return`${_}${G}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let X=D._executableFile||`${this._name}-${D._name}`,Q=this._executableDir||"";if(this._scriptPath){let q;try{q=o0.realpathSync(this._scriptPath)}catch(H){q=this._scriptPath}Q=KD.resolve(KD.dirname(q),Q)}if(Q){let q=$(Q,X);if(!q&&!D._executableFile&&this._scriptPath){let H=KD.basename(this._scriptPath,KD.extname(this._scriptPath));if(H!==this._name)q=$(Q,`${H}-${D._name}`)}X=q||X}E=B.includes(KD.extname(X));let J;if(g.platform!=="win32")if(E)F.unshift(X),F=z8(g.execArgv).concat(F),J=a0.spawn(g.argv[0],F,{stdio:"inherit"});else J=a0.spawn(X,F,{stdio:"inherit"});else F.unshift(X),F=z8(g.execArgv).concat(F),J=a0.spawn(g.execPath,F,{stdio:"inherit"});if(!J.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((H)=>{g.on(H,()=>{if(J.killed===!1&&J.exitCode===null)J.kill(H)})});let Y=this._exitCallback;J.on("close",(q)=>{if(q=q??1,!Y)g.exit(q);else Y(new s0(q,"commander.executeSubCommandAsync","(close)"))}),J.on("error",(q)=>{if(q.code==="ENOENT"){let H=Q?`searched for local subcommand relative to directory '${Q}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${X}' 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
|
-
- ${
|
|
18
|
+
- ${H}`;throw Error(_)}else if(q.code==="EACCES")throw Error(`'${X}' not executable`);if(!Y)g.exit(1);else{let H=new s0(1,"commander.executeSubCommandAsync","(error)");H.nestedError=q,Y(H)}}),this.runningCommand=J}_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 X=B;if(B!==null&&E.parseArg){let Q=`error: command-argument value '${B}' is invalid for argument '${E.name()}'.`;X=this._callParseArg(E,B,$,Q)}return X};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((X,Q)=>{return D(E,Q,X)},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((X)=>{B.push({hookedCommand:$,callback:X})})}),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 X;if(X=this._chainOrCallHooks(X,"preAction"),X=this._chainOrCall(X,()=>this._actionHandler(this.processedArgs)),this.parent)X=this._chainOrCall(X,()=>{this.parent.emit($,D,F)});return X=this._chainOrCallHooks(X,"postAction"),X}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 X(J){return J.length>1&&J[0]==="-"}let Q=null;while($.length){let J=$.shift();if(J==="--"){if(B===E)B.push(J);B.push(...$);break}if(Q&&!X(J)){this.emit(`option:${Q.name()}`,J);continue}if(Q=null,X(J)){let Y=this._findOption(J);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&&!X($[0]))q=$.shift();this.emit(`option:${Y.name()}`,q)}else this.emit(`option:${Y.name()}`);Q=Y.variadic?Y:null;continue}}if(J.length>2&&J[0]==="-"&&J[1]!=="-"){let Y=this._findOption(`-${J[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,J.slice(2));else this.emit(`option:${Y.name()}`),$.unshift(`-${J.slice(2)}`);continue}}if(/^--[^=]+=/.test(J)){let Y=J.indexOf("="),q=this._findOption(J.slice(0,Y));if(q&&(q.required||q.optional)){this.emit(`option:${q.name()}`,J.slice(Y+1));continue}}if(X(J))B=E;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&E.length===0){if(this._findCommand(J)){if(F.push(J),$.length>0)E.push(...$);break}else if(this._getHelpCommand()&&J===this._getHelpCommand().name()){if(F.push(J),$.length>0)F.push(...$);break}else if(this._defaultCommandName){if(E.push(J),$.length>0)E.push(...$);break}}if(this._passThroughOptions){if(B.push(J),$.length>0)B.push(...$);break}B.push(J)}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
|
|
22
|
-
`),this._exit(0,"commander.version"
|
|
23
|
-
Expecting one of '${
|
|
24
|
-
`)}),this}_outputHelpIfRequested($){let q=this._getHelpOption();if(q&&$.find((X)=>q.is(X)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Z1($){return $.map((q)=>{if(!q.startsWith("--inspect"))return q;let J,X="127.0.0.1",Q="9229",W;if((W=q.match(/^(--inspect(-brk)?)$/))!==null)J=W[1];else if((W=q.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=W[1],/^\d+$/.test(W[3]))Q=W[3];else X=W[3];else if((W=q.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=W[1],X=W[3],Q=W[4];if(J&&Q!=="0")return`${J}=${X}:${parseInt(Q)+1}`;return q})}y6.Command=M1});var m1=Q$((g6)=>{var{Argument:g1}=m$(),{Command:z1}=x1(),{CommanderError:Z6,InvalidArgumentError:l1}=T$(),{Help:x6}=Y1(),{Option:u1}=H1();g6.program=new z1;g6.createCommand=($)=>new z1($);g6.createOption=($,q)=>new u1($,q);g6.createArgument=($,q)=>new g1($,q);g6.Command=z1;g6.Option=u1;g6.Argument=g1;g6.Help=x6;g6.CommanderError=Z6;g6.InvalidArgumentError=l1;g6.InvalidOptionArgumentError=l1});var c1=H6(m1(),1),{program:wJ,createCommand:OJ,createArgument:NJ,createOption:bJ,CommanderError:vJ,InvalidArgumentError:fJ,InvalidOptionArgumentError:PJ,Command:p1,Argument:kJ,Option:IJ,Help:TJ}=c1.default;var d1="0.260202.1607";import{join as A8}from"path";var v=[];for(let $=0;$<256;++$)v.push(($+256).toString(16).slice(1));function r1($,q=0){return(v[$[q+0]]+v[$[q+1]]+v[$[q+2]]+v[$[q+3]]+"-"+v[$[q+4]]+v[$[q+5]]+"-"+v[$[q+6]]+v[$[q+7]]+"-"+v[$[q+8]]+v[$[q+9]]+"-"+v[$[q+10]]+v[$[q+11]]+v[$[q+12]]+v[$[q+13]]+v[$[q+14]]+v[$[q+15]]).toLowerCase()}import{randomFillSync as a6}from"crypto";var p$=new Uint8Array(256),c$=p$.length;function U1(){if(c$>p$.length-16)a6(p$),c$=0;return p$.slice(c$,c$+=16)}import{randomUUID as t6}from"crypto";var R1={randomUUID:t6};function e6($,q,J){if(R1.randomUUID&&!q&&!$)return R1.randomUUID();$=$||{};let X=$.random??$.rng?.()??U1();if(X.length<16)throw Error("Random bytes length must be >= 16");if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,q){if(J=J||0,J<0||J+16>q.length)throw RangeError(`UUID byte range ${J}:${J+15} is out of buffer bounds`);for(let Q=0;Q<16;++Q)q[J+Q]=X[Q];return q}return r1(X)}var d$=e6;import{exec as $8}from"child_process";import{promisify as q8}from"util";import{join as J8}from"path";import{mkdirSync as X8,existsSync as Q8}from"fs";import{homedir as W8}from"os";var Y8=q8($8);function H8(){let $=J8(W8(),".genie","logs","tmux");if(!Q8($))X8($,{recursive:!0});return $}function _8($){return $.filter((q)=>!/^-v+$/.test(q))}function B8(){return process.env.GENIE_TMUX_DEBUG==="1"}async function i1($){let q=typeof $==="string"?$.split(/\s+/).filter(Boolean):$,J=_8(q),X=B8(),Q={};if(X)J=["-v",...J],Q.cwd=H8();let W=`tmux ${J.join(" ")}`,{stdout:Y}=await Y8(W,Q);return Y.trim()}var G8={type:"bash"};async function w($){try{return await i1($)}catch(q){throw Error(`Failed to execute tmux command: ${q.message}`)}}async function E1(){try{let q=await w("list-sessions -F '#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}'");if(!q)return[];return q.split(`
|
|
25
|
-
`)
|
|
26
|
-
`)
|
|
27
|
-
`)
|
|
28
|
-
`)
|
|
29
|
-
`)
|
|
30
|
-
`))
|
|
31
|
-
|
|
32
|
-
`).
|
|
33
|
-
`)}async function
|
|
34
|
-
`).
|
|
35
|
-
`);if(q.
|
|
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 g.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()}`,g.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new aF(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=(X)=>{let Q=X.attributeName(),J=this.getOptionValue(Q),Y=this.options.find((H)=>H.negate&&Q===H.attributeName()),q=this.options.find((H)=>!H.negate&&Q===H.attributeName());if(Y&&(Y.presetArg===void 0&&J===!1||Y.presetArg!==void 0&&J===Y.presetArg))return Y;return q||X},B=(X)=>{let Q=E(X),J=Q.attributeName();if(this.getOptionValueSource(J)==="env")return`environment variable '${Q.envVar}'`;return`option '${Q.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 X=$.createHelp().visibleOptions($).filter((Q)=>Q.long).map((Q)=>Q.long);B=B.concat(X),$=$.parent}while($&&!$._enablePositionalOptions);F=C8(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=C8(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 nF(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=KD.basename(D,KD.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=g.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 X;if(typeof F==="function")X=F({error:$.error,command:$.command});else X=F;if(X)$.write(`${X}
|
|
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 z8(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let E,B="127.0.0.1",$="9229",X;if((X=F.match(/^(--inspect(-brk)?)$/))!==null)E=X[1];else if((X=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(E=X[1],/^\d+$/.test(X[3]))$=X[3];else B=X[3];else if((X=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)E=X[1],B=X[3],$=X[4];if(E&&$!=="0")return`${E}=${B}:${parseInt($)+1}`;return F})}oF.Command=t0});var L8=m((D5)=>{var{Argument:R8}=H0(),{Command:e0}=V8(),{CommanderError:tF,InvalidArgumentError:K8}=m2(),{Help:eF}=n0(),{Option:j8}=r0();D5.program=new e0;D5.createCommand=(D)=>new e0(D);D5.createOption=(D,F)=>new j8(D,F);D5.createArgument=(D,F)=>new R8(D,F);D5.Command=e0;D5.Option=j8;D5.Argument=R8;D5.Help=eF;D5.CommanderError=tF;D5.InvalidArgumentError=K8;D5.InvalidOptionArgumentError=K8});var D2={};Y8(D2,{updateState:()=>Z2,update:()=>l9,unregister:()=>eD,register:()=>j3,list:()=>ND,hasWorkerForTask:()=>p9,getRegistryPath:()=>n9,getElapsedTime:()=>d9,getConfigDir:()=>i9,getByState:()=>c9,get:()=>L3,findByWish:()=>m9,findByTask:()=>yD,findByPane:()=>M3});import{mkdir as k9,readFile as x9,writeFile as y9}from"fs/promises";import{join as o6}from"path";import{homedir as h9}from"os";async function g9(){await k9(R3,{recursive:!0})}async function u2(){try{let D=await x9(K3,"utf-8");return JSON.parse(D)}catch{return{workers:{},lastUpdated:new Date().toISOString()}}}async function f0(D){await g9(),D.lastUpdated=new Date().toISOString(),await y9(K3,JSON.stringify(D,null,2))}async function j3(D){let F=await u2();F.workers[D.id]=D,await f0(F)}async function eD(D){let F=await u2();delete F.workers[D],await f0(F)}async function L3(D){return(await u2()).workers[D]||null}async function ND(){let D=await u2();return Object.values(D.workers)}async function Z2(D,F){let E=await u2(),B=E.workers[D];if(B)B.state=F,B.lastStateChange=new Date().toISOString(),await f0(E)}async function l9(D,F){let E=await u2(),B=E.workers[D];if(B){if(Object.assign(B,F),F.state)B.lastStateChange=new Date().toISOString();await f0(E)}}async function M3(D){let F=await ND(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function yD(D){return(await ND()).find((E)=>E.taskId===D)||null}async function m9(D){return(await ND()).filter((E)=>E.wishSlug===D)}async function p9(D){return await yD(D)!==null}async function c9(D){return(await ND()).filter((E)=>E.state===D)}function d9(D){let F=new Date(D.startedAt).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60),X;if($>0)X=`${$}h ${B%60}m`;else if(B>0)X=`${B}m`;else X="<1m";return{ms:E,formatted:X}}function i9(){return R3}function n9(){return K3}var R3,K3;var F2=MF(()=>{R3=o6(h9(),".config","term"),K3=o6(R3,"workers.json")});var v0=m((KX,_1)=>{var K4=RD("tty"),j4=K4?.WriteStream?.prototype?.hasColors?.()??!1,P=(D,F)=>{if(!j4)return($)=>$;let E=`\x1B[${D}m`,B=`\x1B[${F}m`;return($)=>{let X=$+"",Q=X.indexOf(B);if(Q===-1)return E+X+B;let J=E,Y=0,H=(F===22?B:"")+E;while(Q!==-1)J+=X.slice(Y,Q)+H,Y=Q+B.length,Q=X.indexOf(B,Y);return J+=X.slice(Y)+B,J}},b={};b.reset=P(0,0);b.bold=P(1,22);b.dim=P(2,22);b.italic=P(3,23);b.underline=P(4,24);b.overline=P(53,55);b.inverse=P(7,27);b.hidden=P(8,28);b.strikethrough=P(9,29);b.black=P(30,39);b.red=P(31,39);b.green=P(32,39);b.yellow=P(33,39);b.blue=P(34,39);b.magenta=P(35,39);b.cyan=P(36,39);b.white=P(37,39);b.gray=P(90,39);b.bgBlack=P(40,49);b.bgRed=P(41,49);b.bgGreen=P(42,49);b.bgYellow=P(43,49);b.bgBlue=P(44,49);b.bgMagenta=P(45,49);b.bgCyan=P(46,49);b.bgWhite=P(47,49);b.bgGray=P(100,49);b.redBright=P(91,39);b.greenBright=P(92,39);b.yellowBright=P(93,39);b.blueBright=P(94,39);b.magentaBright=P(95,39);b.cyanBright=P(96,39);b.whiteBright=P(97,39);b.bgRedBright=P(101,49);b.bgGreenBright=P(102,49);b.bgYellowBright=P(103,49);b.bgBlueBright=P(104,49);b.bgMagentaBright=P(105,49);b.bgCyanBright=P(106,49);b.bgWhiteBright=P(107,49);_1.exports=b});var V1=m((gX,z1)=>{z1.exports=P4;function b4(D){let F={defaultWidth:0,output:process.stdout,tty:RD("tty")};if(!D)return F;return Object.keys(F).forEach(function(E){if(!D[E])D[E]=F[E]}),D}function P4(D){let F=b4(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 K1=m((lX,R1)=>{R1.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 h3=m((mX,j1)=>{var f4=K1();j1.exports=(D)=>typeof D==="string"?D.replace(f4(),""):D});var M1=m((pX,g3)=>{var L1=(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};g3.exports=L1;g3.exports.default=L1});var N1=m((cX,O1)=>{O1.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 T1=m((dX,l3)=>{var w4=h3(),I4=M1(),u4=N1(),S1=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=w4(D),D.length===0)return 0;D=D.replace(u4()," ");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+=I4(B)?2:1}return F};l3.exports=S1;l3.exports.default=S1});var P1=m((iX,b1)=>{b1.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 m3=m((nX,w1)=>{var X0=P1(),f1={};for(let D of Object.keys(X0))f1[X0[D]]=D;var R={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"]}};w1.exports=R;for(let D of Object.keys(R)){if(!("channels"in R[D]))throw Error("missing channels property: "+D);if(!("labels"in R[D]))throw Error("missing channel labels property: "+D);if(R[D].labels.length!==R[D].channels)throw Error("channel and label counts mismatch: "+D);let{channels:F,labels:E}=R[D];delete R[D].channels,delete R[D].labels,Object.defineProperty(R[D],"channels",{value:F}),Object.defineProperty(R[D],"labels",{value:E})}R.rgb.hsl=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.min(F,E,B),X=Math.max(F,E,B),Q=X-$,J,Y;if(X===$)J=0;else if(F===X)J=(E-B)/Q;else if(E===X)J=2+(B-F)/Q;else if(B===X)J=4+(F-E)/Q;if(J=Math.min(J*60,360),J<0)J+=360;let q=($+X)/2;if(X===$)Y=0;else if(q<=0.5)Y=Q/(X+$);else Y=Q/(2-X-$);return[J,Y*100,q*100]};R.rgb.hsv=function(D){let F,E,B,$,X,Q=D[0]/255,J=D[1]/255,Y=D[2]/255,q=Math.max(Q,J,Y),H=q-Math.min(Q,J,Y),_=function(G){return(q-G)/6/H+0.5};if(H===0)$=0,X=0;else{if(X=H/q,F=_(Q),E=_(J),B=_(Y),Q===q)$=B-E;else if(J===q)$=0.3333333333333333+F-B;else if(Y===q)$=0.6666666666666666+E-F;if($<0)$+=1;else if($>1)$-=1}return[$*360,X*100,q*100]};R.rgb.hwb=function(D){let F=D[0],E=D[1],B=D[2],$=R.rgb.hsl(D)[0],X=0.00392156862745098*Math.min(F,Math.min(E,B));return B=1-0.00392156862745098*Math.max(F,Math.max(E,B)),[$,X*100,B*100]};R.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),X=(1-F-$)/(1-$)||0,Q=(1-E-$)/(1-$)||0,J=(1-B-$)/(1-$)||0;return[X*100,Q*100,J*100,$*100]};function Z4(D,F){return(D[0]-F[0])**2+(D[1]-F[1])**2+(D[2]-F[2])**2}R.rgb.keyword=function(D){let F=f1[D];if(F)return F;let E=1/0,B;for(let $ of Object.keys(X0)){let X=X0[$],Q=Z4(D,X);if(Q<E)E=Q,B=$}return B};R.keyword.rgb=function(D){return X0[D]};R.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,X=F*0.2126+E*0.7152+B*0.0722,Q=F*0.0193+E*0.1192+B*0.9505;return[$*100,X*100,Q*100]};R.rgb.lab=function(D){let F=R.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 X=116*B-16,Q=500*(E-B),J=200*(B-$);return[X,Q,J]};R.hsl.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$,X,Q;if(E===0)return Q=B*255,[Q,Q,Q];if(B<0.5)$=B*(1+E);else $=B+E-B*E;let J=2*B-$,Y=[0,0,0];for(let q=0;q<3;q++){if(X=F+0.3333333333333333*-(q-1),X<0)X++;if(X>1)X--;if(6*X<1)Q=J+($-J)*6*X;else if(2*X<1)Q=$;else if(3*X<2)Q=J+($-J)*(0.6666666666666666-X)*6;else Q=J;Y[q]=Q*255}return Y};R.hsl.hsv=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=E,X=Math.max(B,0.01);B*=2,E*=B<=1?B:2-B,$*=X<=1?X:2-X;let Q=(B+E)/2,J=B===0?2*$/(X+$):2*E/(B+E);return[F,J*100,Q*100]};R.hsv.rgb=function(D){let F=D[0]/60,E=D[1]/100,B=D[2]/100,$=Math.floor(F)%6,X=F-Math.floor(F),Q=255*B*(1-E),J=255*B*(1-E*X),Y=255*B*(1-E*(1-X));switch(B*=255,$){case 0:return[B,Y,Q];case 1:return[J,B,Q];case 2:return[Q,B,Y];case 3:return[Q,J,B];case 4:return[Y,Q,B];case 5:return[B,Q,J]}};R.hsv.hsl=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=Math.max(B,0.01),X,Q;Q=(2-E)*B;let J=(2-E)*$;return X=E*$,X/=J<=1?J:2-J,X=X||0,Q/=2,[F,X*100,Q*100]};R.hwb.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$=E+B,X;if($>1)E/=$,B/=$;let Q=Math.floor(6*F),J=1-B;if(X=6*F-Q,(Q&1)!==0)X=1-X;let Y=E+X*(J-E),q,H,_;switch(Q){default:case 6:case 0:q=J,H=Y,_=E;break;case 1:q=Y,H=J,_=E;break;case 2:q=E,H=J,_=Y;break;case 3:q=E,H=Y,_=J;break;case 4:q=Y,H=E,_=J;break;case 5:q=J,H=E,_=Y;break}return[q*255,H*255,_*255]};R.cmyk.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$=D[3]/100,X=1-Math.min(1,F*(1-$)+$),Q=1-Math.min(1,E*(1-$)+$),J=1-Math.min(1,B*(1-$)+$);return[X*255,Q*255,J*255]};R.xyz.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$,X,Q;return $=F*3.2406+E*-1.5372+B*-0.4986,X=F*-0.9689+E*1.8758+B*0.0415,Q=F*0.0557+E*-0.204+B*1.057,$=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92,X=X>0.0031308?1.055*X**0.4166666666666667-0.055:X*12.92,Q=Q>0.0031308?1.055*Q**0.4166666666666667-0.055:Q*12.92,$=Math.min(Math.max(0,$),1),X=Math.min(Math.max(0,X),1),Q=Math.min(Math.max(0,Q),1),[$*255,X*255,Q*255]};R.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,X=500*(F-E),Q=200*(E-B);return[$,X,Q]};R.lab.xyz=function(D){let F=D[0],E=D[1],B=D[2],$,X,Q;X=(F+16)/116,$=E/500+X,Q=X-B/200;let J=X**3,Y=$**3,q=Q**3;return X=J>0.008856?J:(X-0.13793103448275862)/7.787,$=Y>0.008856?Y:($-0.13793103448275862)/7.787,Q=q>0.008856?q:(Q-0.13793103448275862)/7.787,$*=95.047,X*=100,Q*=108.883,[$,X,Q]};R.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 Q=Math.sqrt(E*E+B*B);return[F,Q,$]};R.lch.lab=function(D){let F=D[0],E=D[1],$=D[2]/360*2*Math.PI,X=E*Math.cos($),Q=E*Math.sin($);return[F,X,Q]};R.rgb.ansi16=function(D,F=null){let[E,B,$]=D,X=F===null?R.rgb.hsv(D)[2]:F;if(X=Math.round(X/50),X===0)return 30;let Q=30+(Math.round($/255)<<2|Math.round(B/255)<<1|Math.round(E/255));if(X===2)Q+=60;return Q};R.hsv.ansi16=function(D){return R.rgb.ansi16(R.hsv.rgb(D),D[2])};R.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)};R.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,X=(F>>2&1)*E*255;return[B,$,X]};R.ansi256.rgb=function(D){if(D>=232){let X=(D-232)*10+8;return[X,X,X]}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,$]};R.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};R.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((J)=>{return J+J}).join("");let B=parseInt(E,16),$=B>>16&255,X=B>>8&255,Q=B&255;return[$,X,Q]};R.rgb.hcg=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.max(Math.max(F,E),B),X=Math.min(Math.min(F,E),B),Q=$-X,J,Y;if(Q<1)J=X/(1-Q);else J=0;if(Q<=0)Y=0;else if($===F)Y=(E-B)/Q%6;else if($===E)Y=2+(B-F)/Q;else Y=4+(F-E)/Q;return Y/=6,Y%=1,[Y*360,Q*100,J*100]};R.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]};R.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]};R.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],X=F%1*6,Q=X%1,J=1-Q,Y=0;switch(Math.floor(X)){case 0:$[0]=1,$[1]=Q,$[2]=0;break;case 1:$[0]=J,$[1]=1,$[2]=0;break;case 2:$[0]=0,$[1]=1,$[2]=Q;break;case 3:$[0]=0,$[1]=J,$[2]=1;break;case 4:$[0]=Q,$[1]=0,$[2]=1;break;default:$[0]=1,$[1]=0,$[2]=J}return Y=(1-E)*B,[(E*$[0]+Y)*255,(E*$[1]+Y)*255,(E*$[2]+Y)*255]};R.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]};R.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]};R.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]};R.hwb.hcg=function(D){let F=D[1]/100,B=1-D[2]/100,$=B-F,X=0;if($<1)X=(B-$)/(1-$);return[D[0],$*100,X*100]};R.apple.rgb=function(D){return[D[0]/65535*255,D[1]/65535*255,D[2]/65535*255]};R.rgb.apple=function(D){return[D[0]/255*65535,D[1]/255*65535,D[2]/255*65535]};R.gray.rgb=function(D){return[D[0]/100*255,D[0]/100*255,D[0]/100*255]};R.gray.hsl=function(D){return[0,0,D[0]]};R.gray.hsv=R.gray.hsl;R.gray.hwb=function(D){return[0,100,D[0]]};R.gray.cmyk=function(D){return[0,0,0,D[0]]};R.gray.lab=function(D){return[D[0],0,0]};R.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};R.rgb.gray=function(D){return[(D[0]+D[1]+D[2])/3/255*100]}});var u1=m((rX,I1)=>{var x0=m3();function v4(){let D={},F=Object.keys(x0);for(let E=F.length,B=0;B<E;B++)D[F[B]]={distance:-1,parent:null};return D}function k4(D){let F=v4(),E=[D];F[D].distance=0;while(E.length){let B=E.pop(),$=Object.keys(x0[B]);for(let X=$.length,Q=0;Q<X;Q++){let J=$[Q],Y=F[J];if(Y.distance===-1)Y.distance=F[B].distance+1,Y.parent=B,E.unshift(J)}}return F}function x4(D,F){return function(E){return F(D(E))}}function y4(D,F){let E=[F[D].parent,D],B=x0[F[D].parent][D],$=F[D].parent;while(F[$].parent)E.unshift(F[$].parent),B=x4(x0[F[$].parent][$],B),$=F[$].parent;return B.conversion=E,B}I1.exports=function(D){let F=k4(D),E={},B=Object.keys(F);for(let $=B.length,X=0;X<$;X++){let Q=B[X];if(F[Q].parent===null)continue;E[Q]=y4(Q,F)}return E}});var v1=m((aX,Z1)=>{var p3=m3(),h4=u1(),y2={},g4=Object.keys(p3);function l4(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 m4(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 X=$.length,Q=0;Q<X;Q++)$[Q]=Math.round($[Q]);return $};if("conversion"in D)F.conversion=D.conversion;return F}g4.forEach((D)=>{y2[D]={},Object.defineProperty(y2[D],"channels",{value:p3[D].channels}),Object.defineProperty(y2[D],"labels",{value:p3[D].labels});let F=h4(D);Object.keys(F).forEach((B)=>{let $=F[B];y2[D][B]=m4($),y2[D][B].raw=l4($)})});Z1.exports=y2});var l1=m((oX,g1)=>{var k1=(D,F)=>(...E)=>{return`\x1B[${D(...E)+F}m`},x1=(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`},y0=(D)=>D,h1=(D,F,E)=>[D,F,E],h2=(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})},c3,g2=(D,F,E,B)=>{if(c3===void 0)c3=v1();let $=B?10:0,X={};for(let[Q,J]of Object.entries(c3)){let Y=Q==="ansi16"?"ansi":Q;if(Q===F)X[Y]=D(E,$);else if(typeof J==="object")X[Y]=D(J[F],$)}return X};function p4(){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[$,X]of Object.entries(B))F[$]={open:`\x1B[${X[0]}m`,close:`\x1B[${X[1]}m`},B[$]=F[$],D.set(X[0],X[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",h2(F.color,"ansi",()=>g2(k1,"ansi16",y0,!1)),h2(F.color,"ansi256",()=>g2(x1,"ansi256",y0,!1)),h2(F.color,"ansi16m",()=>g2(y1,"rgb",h1,!1)),h2(F.bgColor,"ansi",()=>g2(k1,"ansi16",y0,!0)),h2(F.bgColor,"ansi256",()=>g2(x1,"ansi256",y0,!0)),h2(F.bgColor,"ansi16m",()=>g2(y1,"rgb",h1,!0)),F}Object.defineProperty(g1,"exports",{enumerable:!0,get:p4})});var c1=m((sX,p1)=>{var Q0=T1(),c4=h3(),d4=l1(),i3=new Set(["\x1B","\x9B"]),m1=(D)=>`${i3.values().next().value}[${D}m`,i4=(D)=>D.split(" ").map((F)=>Q0(F)),d3=(D,F,E)=>{let B=[...F],$=!1,X=Q0(c4(D[D.length-1]));for(let[Q,J]of B.entries()){let Y=Q0(J);if(X+Y<=E)D[D.length-1]+=J;else D.push(J),X=0;if(i3.has(J))$=!0;else if($&&J==="m"){$=!1;continue}if($)continue;if(X+=Y,X===E&&Q<B.length-1)D.push(""),X=0}if(!X&&D[D.length-1].length>0&&D.length>1)D[D.length-2]+=D.pop()},n4=(D)=>{let F=D.split(" "),E=F.length;while(E>0){if(Q0(F[E-1])>0)break;E--}if(E===F.length)return D;return F.slice(0,E).join(" ")+F.slice(E).join("")},r4=(D,F,E={})=>{if(E.trim!==!1&&D.trim()==="")return"";let B="",$="",X,Q=i4(D),J=[""];for(let[Y,q]of D.split(" ").entries()){if(E.trim!==!1)J[J.length-1]=J[J.length-1].trimLeft();let H=Q0(J[J.length-1]);if(Y!==0){if(H>=F&&(E.wordWrap===!1||E.trim===!1))J.push(""),H=0;if(H>0||E.trim===!1)J[J.length-1]+=" ",H++}if(E.hard&&Q[Y]>F){let _=F-H,G=1+Math.floor((Q[Y]-_-1)/F);if(Math.floor((Q[Y]-1)/F)<G)J.push("");d3(J,q,F);continue}if(H+Q[Y]>F&&H>0&&Q[Y]>0){if(E.wordWrap===!1&&H<F){d3(J,q,F);continue}J.push("")}if(H+Q[Y]>F&&E.wordWrap===!1){d3(J,q,F);continue}J[J.length-1]+=q}if(E.trim!==!1)J=J.map(n4);B=J.join(`
|
|
25
|
+
`);for(let[Y,q]of[...B].entries()){if($+=q,i3.has(q)){let _=parseFloat(/\d[^m]*/.exec(B.slice(Y,Y+4)));X=_===39?null:_}let H=d4.codes.get(Number(X));if(X&&H){if(B[Y+1]===`
|
|
26
|
+
`)$+=m1(H);else if(q===`
|
|
27
|
+
`)$+=m1(X)}}return $};p1.exports=(D,F,E)=>{return String(D).normalize().replace(/\r\n/g,`
|
|
28
|
+
`).split(`
|
|
29
|
+
`).map((B)=>r4(B,F,E)).join(`
|
|
30
|
+
`)}});var a1=m((BQ,r1)=>{var o4=RD("stream");class n1 extends o4{#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)}}r1.exports=n1});var M8=mD(L8(),1),{program:ZE,createCommand:vE,createArgument:kE,createOption:xE,CommanderError:yE,InvalidArgumentError:hE,InvalidOptionArgumentError:gE,Command:O8,Argument:lE,Option:mE,Help:pE}=M8.default;var N8="0.260202.1901";import{join as y5}from"path";var i=[];for(let D=0;D<256;++D)i.push((D+256).toString(16).slice(1));function S8(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 W5}from"crypto";var W0=new Uint8Array(256),_0=W0.length;function D3(){if(_0>W0.length-16)W5(W0),_0=0;return W0.slice(_0,_0+=16)}import{randomUUID as G5}from"crypto";var F3={randomUUID:G5};function U5(D,F,E){if(F3.randomUUID&&!F&&!D)return F3.randomUUID();D=D||{};let B=D.random??D.rng?.()??D3();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 S8(B)}var G0=U5;import{exec as A5}from"child_process";import{promisify as C5}from"util";import{join as z5}from"path";import{mkdirSync as V5,existsSync as R5}from"fs";import{homedir as K5}from"os";var j5=C5(A5);function L5(){let D=z5(K5(),".genie","logs","tmux");if(!R5(D))V5(D,{recursive:!0});return D}function M5(D){return D.filter((F)=>!/^-v+$/.test(F))}function O5(){return process.env.GENIE_TMUX_DEBUG==="1"}async function T8(D){let F=typeof D==="string"?D.split(/\s+/).filter(Boolean):D,E=M5(F),B=O5(),$={};if(B)E=["-v",...E],$.cwd=L5();let X=`tmux ${E.join(" ")}`,{stdout:Q}=await j5(X,$);return Q.trim()}var N5={type:"bash"};async function S(D){try{return await T8(D)}catch(F){throw Error(`Failed to execute tmux command: ${F.message}`)}}async function $3(){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,$,X,Q]=E.split(":");return{id:B,name:$,attached:X==="1",windows:parseInt(Q,10)}})}catch(D){if(D.message.includes("no server running"))return[];throw D}}async function Z(D){try{return(await $3()).find((E)=>E.name===D)||null}catch(F){return null}}async function k(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[$,X,Q]=B.split(":");return{id:$,name:X,active:Q==="1",sessionId:D}})}catch(F){if(F.message.includes("no server running")||F.message.includes("session not found"))return[];throw F}}async function l(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[$,X,Q]=B.split(":");return{id:$,windowId:D,title:X,active:Q==="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 pD(D){return await S(`new-session -d -s "${D}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),Z(D)}async function A0(D,F){let E=await S(`new-window -t '${D}' -n '${F}'`);return(await k(D)).find(($)=>$.name===F)||null}async function C0(D){await S(`kill-session -t '${D}'`)}async function b8(D){await S(`kill-window -t '${D}'`)}async function _2(D){await S(`kill-pane -t '${D}'`)}function S5(D){return D.replace(/'/g,"'\\''")}async function z0(D,F="vertical",E,B){let $="split-window";if(F==="horizontal")$+=" -h";else $+=" -v";if($+=` -t '${D}'`,E!==void 0&&E>0&&E<100)$+=` -p ${E}`;if(B)$+=` -c '${S5(B)}'`;await S($);let X=await S(`display-message -p -t '${D}' '#{window_id}'`),Q=await l(X);return Q.length>0?Q[Q.length-1]:null}var E3=new Map,B3="TMUX_MCP_START",U0="TMUX_MCP_DONE_";async function DD(D,F,E,B){let $=G0(),X;if(E||B)X=F;else{let Q=T5();X=`echo "${B3}"; ${F}; echo "${Q}"`}if(E3.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(X))await S(`send-keys -t '${D}' ${X}`);else for(let J of X)await S(`send-keys -t '${D}' '${J.replace(/'/g,"'\\''")}'`);else await S(`send-keys -t '${D}' '${X.replace(/'/g,"'\\''")}' Enter`);return $}async function P8(D){let F=E3.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(B3),$=E.lastIndexOf(U0);if(B===-1||$===-1||$<=B)return F.result="Command output could not be captured properly",F;let X=E.substring($).split(`
|
|
34
|
+
`)[0],Q=new RegExp(`${U0}(\\d+)`),J=X.match(Q);if(J){let Y=parseInt(J[1],10);F.status=Y===0?"completed":"error",F.exitCode=Y;let q=B+B3.length,H=E.substring(q,$).trim();F.result=H.substring(H.indexOf(`
|
|
35
|
+
`)+1).trim(),E3.set(D,F)}return F}function T5(){return N5.type==="fish"?`${U0}$status`:`${U0}$?`}async function f8(D,F,E=120000){let B=G0().substring(0,8),$=`/tmp/genie-${B}.out`,X=`/tmp/genie-${B}.exit`,Q=`genie-${B}`,Y=`{ ${F.replace(/'/g,"'\\''")}; } 2>&1 | tee ${$}; echo \${PIPESTATUS[0]} > ${X}; tmux wait-for -S ${Q}`;await S(`send-keys -t '${D}' '${Y.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([S(`wait-for ${Q}`),new Promise((_,G)=>setTimeout(()=>G(Error("Command timed out")),E))])}catch(_){if(_.message==="Command timed out"){try{await S(`wait-for -S ${Q}`)}catch{}return{output:"",exitCode:124}}throw _}let q="",H=0;try{let{readFile:_,unlink:G}=await import("fs/promises");q=await _($,"utf-8"),q=q.trim();let A=await _(X,"utf-8");H=parseInt(A.trim(),10)||0,await G($).catch(()=>{}),await G(X).catch(()=>{})}catch(_){console.error("Failed to read command output:",_)}return{output:q,exitCode:H}}var{$:jD}=globalThis.Bun;import{mkdir as w8,rm as I8,access as X3,readFile as b5,writeFile as P5}from"fs/promises";import{join as W2,basename as f5}from"path";function V0(D){return D.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function w5(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 ID{baseDir;repoPath;metadataPath;constructor(D){this.baseDir=D.baseDir,this.repoPath=D.repoPath,this.metadataPath=W2(this.baseDir,".metadata.json")}async loadMetadata(){try{let D=await b5(this.metadataPath,"utf-8");return JSON.parse(D)}catch{return{worktrees:{}}}}async saveMetadata(D){await w8(this.baseDir,{recursive:!0}),await P5(this.metadataPath,JSON.stringify(D,null,2))}async createWorktree(D,F=!1,E){let B=V0(D),$=W2(this.baseDir,B);await w8(this.baseDir,{recursive:!0});try{throw await X3($),Error(`Worktree already exists at ${$}`)}catch(J){if(J.code!=="ENOENT")throw J}if(F)if(E)await jD`git -C ${this.repoPath} worktree add -b ${D} ${$} ${E}`.quiet();else await jD`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 jD`git -C ${this.repoPath} worktree add ${$} ${D}`.quiet()}let X=await this.loadMetadata();X.worktrees[B]={branch:D,createdAt:new Date().toISOString()},await this.saveMetadata(X);let Q=await this.getCommitHash($);return{path:$,branch:D,commitHash:Q,createdAt:new Date}}async removeWorktree(D){let F=V0(D),E=W2(this.baseDir,F);try{await jD`git -C ${this.repoPath} worktree remove ${E} --force`.quiet()}catch{try{await I8(E,{recursive:!0,force:!0})}catch{}}try{await X3(E),await I8(E,{recursive:!0,force:!0})}catch{}let B=await this.loadMetadata();delete B.worktrees[F],await this.saveMetadata(B)}async listWorktrees(){let F=(await jD`git -C ${this.repoPath} worktree list --porcelain`.quiet()).stdout.toString(),E=[],B={};for(let Q of F.split(`
|
|
36
|
+
`))if(Q.startsWith("worktree ")){if(B.path)E.push(B);B={path:Q.slice(9)}}else if(Q.startsWith("HEAD "))B.commitHash=Q.slice(5);else if(Q.startsWith("branch "))B.branch=Q.slice(7).replace("refs/heads/","");if(B.path)E.push(B);let $=E.filter((Q)=>Q.path.startsWith(this.baseDir)),X=await this.loadMetadata();for(let Q of $){let J=f5(Q.path),Y=X.worktrees[J];if(Y)Q.createdAt=new Date(Y.createdAt);Q.size=await this.getDiskUsage(Q.path)}return $}async cleanup(D,F=!1){let E=w5(D),B=Date.now(),$=await this.listWorktrees(),X=[];for(let Q of $)if(Q.createdAt){if(B-Q.createdAt.getTime()>E)X.push(Q)}if(!F)for(let Q of X)await this.removeWorktree(Q.branch);return X}async prune(){await jD`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage(D){try{let E=(await jD`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=V0(D);return W2(this.baseDir,F)}async worktreeExists(D){let F=V0(D),E=W2(this.baseDir,F);try{return await X3(E),!0}catch{return!1}}async branchExists(D){try{return await jD`git -C ${this.repoPath} rev-parse --verify ${D}`.quiet(),!0}catch{return!1}}async getCommitHash(D){return(await jD`git -C ${D} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function G2(D){let F=D?.baseDir||W2(process.cwd(),".worktrees"),E=D?.repoPath||process.cwd();return new ID({baseDir:F,repoPath:E})}import{mkdir as I5,readFile as u5,writeFile as Z5,access as v5}from"fs/promises";import{join as u8}from"path";import{homedir as k5}from"os";var Z8=u8(k5(),".config","term"),Q3=u8(Z8,"sessions.json");async function x5(){await I5(Z8,{recursive:!0})}async function J3(){try{await v5(Q3);let D=await u5(Q3,"utf-8");return JSON.parse(D)}catch{return{sessions:{}}}}async function v8(D){await x5(),await Z5(Q3,JSON.stringify(D,null,2))}async function k8(D,F){let E=await J3();E.sessions[D]={...F,createdAt:new Date().toISOString()},await v8(E)}async function x8(D){return(await J3()).sessions[D]||null}async function y8(D){let F=await J3();delete F.sessions[D],await v8(F)}async function h8(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 Q=G2({baseDir:y5(F.workspace,".worktrees"),repoPath:F.workspace});if(await Q.worktreeExists(D))console.error(`\u274C Worktree for "${D}" already exists`),process.exit(1);let Y=await Q.createWorktree(D,!0);$=Y.path,B=Y.path,console.log(`\u2705 Worktree created at ${$}`)}if(!await pD(D))console.error(`\u274C Failed to create session "${D}"`),process.exit(1);if(await S(`send-keys -t '${D}' 'cd ${B}' Enter`),$)await k8(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 g8(D={}){try{let F=await $3();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 l5}from"child_process";import{promisify as m5}from"util";var p5=m5(l5);async function l8(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 p5(`tmux attach -t "${D}"`)}catch(F){console.error(`\u274C Error attaching to session: ${F.message}`),process.exit(1)}}import{join as d5}from"path";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 x8(D);if(await C0(E.id),B?.worktreePath&&B?.workspace&&!F.keepWorktree)await G2({baseDir:d5(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 y8(D)}catch(E){console.error(`\u274C Error removing session: ${E.message}`),process.exit(1)}}function p2(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 p8(D,F={}){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await k(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await l(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let X=$[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(X,1e4);return p2(Y)}if(F.from!==void 0&&F.to!==void 0){let Y=await p(X,1e4),_=p2(Y).split(`
|
|
40
|
+
`).slice(F.from,F.to+1).join(`
|
|
41
|
+
`);if(F.reverse)return _.split(`
|
|
36
42
|
`).reverse().join(`
|
|
37
|
-
`);return
|
|
38
|
-
`);try{let
|
|
39
|
-
`);return
|
|
40
|
-
`)}catch(
|
|
43
|
+
`);return _}if(F.search||F.grep){let Y=F.search||F.grep,q=await p(X,1e4),_=p2(q).split(`
|
|
44
|
+
`);try{let G=new RegExp(Y,"i"),A=_.filter((z)=>G.test(z));if(F.reverse)return A.reverse().join(`
|
|
45
|
+
`);return A.join(`
|
|
46
|
+
`)}catch(G){throw Error(`Invalid regex pattern: ${G.message}`)}}let Q=F.lines||100,J=await p(X,Q);if(J=p2(J),F.reverse)J=J.split(`
|
|
41
47
|
`).reverse().join(`
|
|
42
|
-
`);return
|
|
43
|
-
`),
|
|
44
|
-
`),F=A.length>0?A.length-1:0;K.slice(F).forEach((X$)=>{if(X$&&X$!==A[A.length-1])q(X$)}),Y=R}}catch(B){clearInterval(_),H=!1}},500);return()=>{H=!1,clearInterval(_)}}import{existsSync as q1,mkdirSync as nq,readFileSync as v0,writeFileSync as oq}from"fs";import{homedir as f0}from"os";import{join as P0}from"path";var D={};_6(D,{void:()=>Sq,util:()=>L,unknown:()=>Uq,union:()=>Lq,undefined:()=>Gq,tuple:()=>Aq,transformer:()=>Iq,symbol:()=>Bq,string:()=>w0,strictObject:()=>jq,setErrorMap:()=>C8,set:()=>Oq,record:()=>Fq,quotelessJson:()=>I8,promise:()=>kq,preprocess:()=>yq,pipeline:()=>hq,ostring:()=>Zq,optional:()=>Tq,onumber:()=>xq,oboolean:()=>gq,objectUtil:()=>D1,object:()=>Eq,number:()=>O0,nullable:()=>Cq,null:()=>Mq,never:()=>Rq,nativeEnum:()=>Pq,nan:()=>Yq,map:()=>wq,makeIssue:()=>y$,literal:()=>vq,lazy:()=>bq,late:()=>Qq,isValid:()=>t,isDirty:()=>a$,isAsync:()=>j$,isAborted:()=>s$,intersection:()=>Dq,instanceof:()=>Wq,getParsedType:()=>p,getErrorMap:()=>E$,function:()=>Nq,enum:()=>fq,effect:()=>Iq,discriminatedUnion:()=>Kq,defaultErrorMap:()=>o,datetimeRegex:()=>D0,date:()=>_q,custom:()=>F0,coerce:()=>lq,boolean:()=>N0,bigint:()=>Hq,array:()=>Vq,any:()=>zq,addIssueToContext:()=>z,ZodVoid:()=>Z$,ZodUnknown:()=>e,ZodUnion:()=>w$,ZodUndefined:()=>A$,ZodType:()=>j,ZodTuple:()=>r,ZodTransformer:()=>u,ZodSymbol:()=>h$,ZodString:()=>Z,ZodSet:()=>B$,ZodSchema:()=>j,ZodRecord:()=>x$,ZodReadonly:()=>k$,ZodPromise:()=>G$,ZodPipeline:()=>u$,ZodParsedType:()=>M,ZodOptional:()=>g,ZodObject:()=>N,ZodNumber:()=>$$,ZodNullable:()=>a,ZodNull:()=>F$,ZodNever:()=>d,ZodNativeEnum:()=>v$,ZodNaN:()=>l$,ZodMap:()=>g$,ZodLiteral:()=>b$,ZodLazy:()=>N$,ZodIssueCode:()=>G,ZodIntersection:()=>O$,ZodFunction:()=>K$,ZodFirstPartyTypeKind:()=>V,ZodError:()=>C,ZodEnum:()=>J$,ZodEffects:()=>u,ZodDiscriminatedUnion:()=>t$,ZodDefault:()=>f$,ZodDate:()=>H$,ZodCatch:()=>P$,ZodBranded:()=>e$,ZodBoolean:()=>D$,ZodBigInt:()=>q$,ZodArray:()=>x,ZodAny:()=>_$,Schema:()=>j,ParseStatus:()=>f,OK:()=>k,NEVER:()=>uq,INVALID:()=>S,EMPTY_PATH:()=>y8,DIRTY:()=>Y$,BRAND:()=>Xq});var L;(function($){$.assertEqual=(Q)=>{};function q(Q){}$.assertIs=q;function J(Q){throw Error()}$.assertNever=J,$.arrayToEnum=(Q)=>{let W={};for(let Y of Q)W[Y]=Y;return W},$.getValidEnumValues=(Q)=>{let W=$.objectKeys(Q).filter((H)=>typeof Q[Q[H]]!=="number"),Y={};for(let H of W)Y[H]=Q[H];return $.objectValues(Y)},$.objectValues=(Q)=>{return $.objectKeys(Q).map(function(W){return Q[W]})},$.objectKeys=typeof Object.keys==="function"?(Q)=>Object.keys(Q):(Q)=>{let W=[];for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))W.push(Y);return W},$.find=(Q,W)=>{for(let Y of Q)if(W(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(Q)=>Number.isInteger(Q):(Q)=>typeof Q==="number"&&Number.isFinite(Q)&&Math.floor(Q)===Q;function X(Q,W=" | "){return Q.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(W)}$.joinValues=X,$.jsonStringifyReplacer=(Q,W)=>{if(typeof W==="bigint")return W.toString();return W}})(L||(L={}));var D1;(function($){$.mergeShapes=(q,J)=>{return{...q,...J}}})(D1||(D1={}));var M=L.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p=($)=>{switch(typeof $){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN($)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":if(Array.isArray($))return M.array;if($===null)return M.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return M.promise;if(typeof Map<"u"&&$ instanceof Map)return M.map;if(typeof Set<"u"&&$ instanceof Set)return M.set;if(typeof Date<"u"&&$ instanceof Date)return M.date;return M.object;default:return M.unknown}};var G=L.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"]),I8=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class C extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(J)=>{this.issues=[...this.issues,J]},this.addIssues=(J=[])=>{this.issues=[...this.issues,...J]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(Q){return Q.message},J={_errors:[]},X=(Q)=>{for(let W of Q.issues)if(W.code==="invalid_union")W.unionErrors.map(X);else if(W.code==="invalid_return_type")X(W.returnTypeError);else if(W.code==="invalid_arguments")X(W.argumentsError);else if(W.path.length===0)J._errors.push(q(W));else{let Y=J,H=0;while(H<W.path.length){let _=W.path[H];if(H!==W.path.length-1)Y[_]=Y[_]||{_errors:[]};else Y[_]=Y[_]||{_errors:[]},Y[_]._errors.push(q(W));Y=Y[_],H++}}};return X(this),J}static assert($){if(!($ instanceof C))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},J=[];for(let X of this.issues)if(X.path.length>0){let Q=X.path[0];q[Q]=q[Q]||[],q[Q].push($(X))}else J.push($(X));return{formErrors:J,fieldErrors:q}}get formErrors(){return this.flatten()}}C.create=($)=>{return new C($)};var T8=($,q)=>{let J;switch($.code){case G.invalid_type:if($.received===M.undefined)J="Required";else J=`Expected ${$.expected}, received ${$.received}`;break;case G.invalid_literal:J=`Invalid literal value, expected ${JSON.stringify($.expected,L.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:J=`Unrecognized key(s) in object: ${L.joinValues($.keys,", ")}`;break;case G.invalid_union:J="Invalid input";break;case G.invalid_union_discriminator:J=`Invalid discriminator value. Expected ${L.joinValues($.options)}`;break;case G.invalid_enum_value:J=`Invalid enum value. Expected ${L.joinValues($.options)}, received '${$.received}'`;break;case G.invalid_arguments:J="Invalid function arguments";break;case G.invalid_return_type:J="Invalid function return type";break;case G.invalid_date:J="Invalid date";break;case G.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(J=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")J=`${J} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)J=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)J=`Invalid input: must end with "${$.validation.endsWith}"`;else L.assertNever($.validation);else if($.validation!=="regex")J=`Invalid ${$.validation}`;else J="Invalid";break;case G.too_small:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else J="Invalid input";break;case G.too_big:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")J=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else J="Invalid input";break;case G.custom:J="Invalid input";break;case G.invalid_intersection_types:J="Intersection results could not be merged";break;case G.not_multiple_of:J=`Number must be a multiple of ${$.multipleOf}`;break;case G.not_finite:J="Number must be finite";break;default:J=q.defaultError,L.assertNever($)}return{message:J}},o=T8;var V0=o;function C8($){V0=$}function E$(){return V0}var y$=($)=>{let{data:q,path:J,errorMaps:X,issueData:Q}=$,W=[...J,...Q.path||[]],Y={...Q,path:W};if(Q.message!==void 0)return{...Q,path:W,message:Q.message};let H="",_=X.filter((B)=>!!B).slice().reverse();for(let B of _)H=B(Y,{data:q,defaultError:H}).message;return{...Q,path:W,message:H}},y8=[];function z($,q){let J=E$(),X=y$({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,J,J===o?void 0:o].filter((Q)=>!!Q)});$.common.issues.push(X)}class f{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let J=[];for(let X of q){if(X.status==="aborted")return S;if(X.status==="dirty")$.dirty();J.push(X.value)}return{status:$.value,value:J}}static async mergeObjectAsync($,q){let J=[];for(let X of q){let Q=await X.key,W=await X.value;J.push({key:Q,value:W})}return f.mergeObjectSync($,J)}static mergeObjectSync($,q){let J={};for(let X of q){let{key:Q,value:W}=X;if(Q.status==="aborted")return S;if(W.status==="aborted")return S;if(Q.status==="dirty")$.dirty();if(W.status==="dirty")$.dirty();if(Q.value!=="__proto__"&&(typeof W.value<"u"||X.alwaysSet))J[Q.value]=W.value}return{status:$.value,value:J}}}var S=Object.freeze({status:"aborted"}),Y$=($)=>({status:"dirty",value:$}),k=($)=>({status:"valid",value:$}),s$=($)=>$.status==="aborted",a$=($)=>$.status==="dirty",t=($)=>$.status==="valid",j$=($)=>typeof Promise<"u"&&$ instanceof Promise;var U;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(U||(U={}));class l{constructor($,q,J,X){this._cachedPath=[],this.parent=$,this.data=q,this._path=J,this._key=X}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 E0=($,q)=>{if(t(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let J=new C($.common.issues);return this._error=J,this._error}}}};function E($){if(!$)return{};let{errorMap:q,invalid_type_error:J,required_error:X,description:Q}=$;if(q&&(J||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:Q};return{errorMap:(Y,H)=>{let{message:_}=$;if(Y.code==="invalid_enum_value")return{message:_??H.defaultError};if(typeof H.data>"u")return{message:_??X??H.defaultError};if(Y.code!=="invalid_type")return{message:H.defaultError};return{message:_??J??H.defaultError}},description:Q}}class j{get description(){return this._def.description}_getType($){return p($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:p($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new f,ctx:{common:$.parent.common,data:$.data,parsedType:p($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(j$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let J=this.safeParse($,q);if(J.success)return J.data;throw J.error}safeParse($,q){let J={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)},X=this._parseSync({data:$,path:J.path,parent:J});return E0(J,X)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)};if(!this["~standard"].async)try{let J=this._parseSync({data:$,path:[],parent:q});return t(J)?{value:J.value}:{issues:q.common.issues}}catch(J){if(J?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((J)=>t(J)?{value:J.value}:{issues:q.common.issues})}async parseAsync($,q){let J=await this.safeParseAsync($,q);if(J.success)return J.data;throw J.error}async safeParseAsync($,q){let J={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)},X=this._parse({data:$,path:J.path,parent:J}),Q=await(j$(X)?X:Promise.resolve(X));return E0(J,Q)}refine($,q){let J=(X)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(X);else return q};return this._refinement((X,Q)=>{let W=$(X),Y=()=>Q.addIssue({code:G.custom,...J(X)});if(typeof Promise<"u"&&W instanceof Promise)return W.then((H)=>{if(!H)return Y(),!1;else return!0});if(!W)return Y(),!1;else return!0})}refinement($,q){return this._refinement((J,X)=>{if(!$(J))return X.addIssue(typeof q==="function"?q(J,X):q),!1;else return!0})}_refinement($){return new u({schema:this,typeName:V.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(q)=>this["~validate"](q)}}optional(){return g.create(this,this._def)}nullable(){return a.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return x.create(this)}promise(){return G$.create(this,this._def)}or($){return w$.create([this,$],this._def)}and($){return O$.create(this,$,this._def)}transform($){return new u({...E(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new f$({...E(this._def),innerType:this,defaultValue:q,typeName:V.ZodDefault})}brand(){return new e$({typeName:V.ZodBranded,type:this,...E(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new P$({...E(this._def),innerType:this,catchValue:q,typeName:V.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return u$.create(this,$)}readonly(){return k$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var h8=/^c[^\s-]{8,}$/i,Z8=/^[0-9a-z]+$/,x8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,g8=/^[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,l8=/^[a-z0-9_-]{21}$/i,u8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,m8=/^[-+]?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)?)??$/,c8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,p8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",A1,d8=/^(?:(?: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])$/,r8=/^(?:(?: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])$/,i8=/^(([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]))$/,n8=/^(([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])$/,o8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,s8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,L0="((\\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])))",a8=new RegExp(`^${L0}$`);function K0($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let J=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${J}`}function t8($){return new RegExp(`^${K0($)}$`)}function D0($){let q=`${L0}T${K0($)}`,J=[];if(J.push($.local?"Z?":"Z"),$.offset)J.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${J.join("|")})`,new RegExp(`^${q}$`)}function e8($,q){if((q==="v4"||!q)&&d8.test($))return!0;if((q==="v6"||!q)&&i8.test($))return!0;return!1}function $q($,q){if(!u8.test($))return!1;try{let[J]=$.split(".");if(!J)return!1;let X=J.replace(/-/g,"+").replace(/_/g,"/").padEnd(J.length+(4-J.length%4)%4,"="),Q=JSON.parse(atob(X));if(typeof Q!=="object"||Q===null)return!1;if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(q&&Q.alg!==q)return!1;return!0}catch{return!1}}function qq($,q){if((q==="v4"||!q)&&r8.test($))return!0;if((q==="v6"||!q)&&n8.test($))return!0;return!1}class Z extends j{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==M.string){let Q=this._getOrReturnCtx($);return z(Q,{code:G.invalid_type,expected:M.string,received:Q.parsedType}),S}let J=new f,X=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.length<Q.value)X=this._getOrReturnCtx($,X),z(X,{code:G.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),J.dirty()}else if(Q.kind==="max"){if($.data.length>Q.value)X=this._getOrReturnCtx($,X),z(X,{code:G.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),J.dirty()}else if(Q.kind==="length"){let W=$.data.length>Q.value,Y=$.data.length<Q.value;if(W||Y){if(X=this._getOrReturnCtx($,X),W)z(X,{code:G.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});else if(Y)z(X,{code:G.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});J.dirty()}}else if(Q.kind==="email"){if(!c8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"email",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="emoji"){if(!A1)A1=new RegExp(p8,"u");if(!A1.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"emoji",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="uuid"){if(!g8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"uuid",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="nanoid"){if(!l8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"nanoid",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="cuid"){if(!h8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"cuid",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="cuid2"){if(!Z8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"cuid2",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="ulid"){if(!x8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"ulid",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="url")try{new URL($.data)}catch{X=this._getOrReturnCtx($,X),z(X,{validation:"url",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="regex"){if(Q.regex.lastIndex=0,!Q.regex.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"regex",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="trim")$.data=$.data.trim();else if(Q.kind==="includes"){if(!$.data.includes(Q.value,Q.position))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:{includes:Q.value,position:Q.position},message:Q.message}),J.dirty()}else if(Q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Q.kind==="startsWith"){if(!$.data.startsWith(Q.value))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:{startsWith:Q.value},message:Q.message}),J.dirty()}else if(Q.kind==="endsWith"){if(!$.data.endsWith(Q.value))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:{endsWith:Q.value},message:Q.message}),J.dirty()}else if(Q.kind==="datetime"){if(!D0(Q).test($.data))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:"datetime",message:Q.message}),J.dirty()}else if(Q.kind==="date"){if(!a8.test($.data))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:"date",message:Q.message}),J.dirty()}else if(Q.kind==="time"){if(!t8(Q).test($.data))X=this._getOrReturnCtx($,X),z(X,{code:G.invalid_string,validation:"time",message:Q.message}),J.dirty()}else if(Q.kind==="duration"){if(!m8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"duration",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="ip"){if(!e8($.data,Q.version))X=this._getOrReturnCtx($,X),z(X,{validation:"ip",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="jwt"){if(!$q($.data,Q.alg))X=this._getOrReturnCtx($,X),z(X,{validation:"jwt",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="cidr"){if(!qq($.data,Q.version))X=this._getOrReturnCtx($,X),z(X,{validation:"cidr",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="base64"){if(!o8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"base64",code:G.invalid_string,message:Q.message}),J.dirty()}else if(Q.kind==="base64url"){if(!s8.test($.data))X=this._getOrReturnCtx($,X),z(X,{validation:"base64url",code:G.invalid_string,message:Q.message}),J.dirty()}else L.assertNever(Q);return{status:J.value,value:$.data}}_regex($,q,J){return this.refinement((X)=>$.test(X),{validation:q,code:G.invalid_string,...U.errToObj(J)})}_addCheck($){return new Z({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...U.errToObj($)})}url($){return this._addCheck({kind:"url",...U.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...U.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...U.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...U.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...U.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...U.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...U.errToObj($)})}base64($){return this._addCheck({kind:"base64",...U.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...U.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...U.errToObj($)})}ip($){return this._addCheck({kind:"ip",...U.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...U.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...U.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...U.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...U.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...U.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...U.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...U.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...U.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...U.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...U.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...U.errToObj(q)})}nonempty($){return this.min(1,U.errToObj($))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}Z.create=($)=>{return new Z({checks:[],typeName:V.ZodString,coerce:$?.coerce??!1,...E($)})};function Jq($,q){let J=($.toString().split(".")[1]||"").length,X=(q.toString().split(".")[1]||"").length,Q=J>X?J:X,W=Number.parseInt($.toFixed(Q).replace(".","")),Y=Number.parseInt(q.toFixed(Q).replace(".",""));return W%Y/10**Q}class $$ extends j{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==M.number){let Q=this._getOrReturnCtx($);return z(Q,{code:G.invalid_type,expected:M.number,received:Q.parsedType}),S}let J=void 0,X=new f;for(let Q of this._def.checks)if(Q.kind==="int"){if(!L.isInteger($.data))J=this._getOrReturnCtx($,J),z(J,{code:G.invalid_type,expected:"integer",received:"float",message:Q.message}),X.dirty()}else if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)J=this._getOrReturnCtx($,J),z(J,{code:G.too_small,minimum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)J=this._getOrReturnCtx($,J),z(J,{code:G.too_big,maximum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="multipleOf"){if(Jq($.data,Q.value)!==0)J=this._getOrReturnCtx($,J),z(J,{code:G.not_multiple_of,multipleOf:Q.value,message:Q.message}),X.dirty()}else if(Q.kind==="finite"){if(!Number.isFinite($.data))J=this._getOrReturnCtx($,J),z(J,{code:G.not_finite,message:Q.message}),X.dirty()}else L.assertNever(Q);return{status:X.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,U.toString(q))}gt($,q){return this.setLimit("min",$,!1,U.toString(q))}lte($,q){return this.setLimit("max",$,!0,U.toString(q))}lt($,q){return this.setLimit("max",$,!1,U.toString(q))}setLimit($,q,J,X){return new $$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:J,message:U.toString(X)}]})}_addCheck($){return new $$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:U.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:U.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:U.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:U.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:U.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:U.toString(q)})}finite($){return this._addCheck({kind:"finite",message:U.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:U.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:U.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&L.isInteger($.value))}get isFinite(){let $=null,q=null;for(let J of this._def.checks)if(J.kind==="finite"||J.kind==="int"||J.kind==="multipleOf")return!0;else if(J.kind==="min"){if(q===null||J.value>q)q=J.value}else if(J.kind==="max"){if($===null||J.value<$)$=J.value}return Number.isFinite(q)&&Number.isFinite($)}}$$.create=($)=>{return new $$({checks:[],typeName:V.ZodNumber,coerce:$?.coerce||!1,...E($)})};class q$ extends j{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==M.bigint)return this._getInvalidInput($);let J=void 0,X=new f;for(let Q of this._def.checks)if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)J=this._getOrReturnCtx($,J),z(J,{code:G.too_small,type:"bigint",minimum:Q.value,inclusive:Q.inclusive,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)J=this._getOrReturnCtx($,J),z(J,{code:G.too_big,type:"bigint",maximum:Q.value,inclusive:Q.inclusive,message:Q.message}),X.dirty()}else if(Q.kind==="multipleOf"){if($.data%Q.value!==BigInt(0))J=this._getOrReturnCtx($,J),z(J,{code:G.not_multiple_of,multipleOf:Q.value,message:Q.message}),X.dirty()}else L.assertNever(Q);return{status:X.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return z(q,{code:G.invalid_type,expected:M.bigint,received:q.parsedType}),S}gte($,q){return this.setLimit("min",$,!0,U.toString(q))}gt($,q){return this.setLimit("min",$,!1,U.toString(q))}lte($,q){return this.setLimit("max",$,!0,U.toString(q))}lt($,q){return this.setLimit("max",$,!1,U.toString(q))}setLimit($,q,J,X){return new q$({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:J,message:U.toString(X)}]})}_addCheck($){return new q$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:U.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:U.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:U.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:U.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:U.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}q$.create=($)=>{return new q$({checks:[],typeName:V.ZodBigInt,coerce:$?.coerce??!1,...E($)})};class D$ extends j{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==M.boolean){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.boolean,received:J.parsedType}),S}return k($.data)}}D$.create=($)=>{return new D$({typeName:V.ZodBoolean,coerce:$?.coerce||!1,...E($)})};class H$ extends j{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==M.date){let Q=this._getOrReturnCtx($);return z(Q,{code:G.invalid_type,expected:M.date,received:Q.parsedType}),S}if(Number.isNaN($.data.getTime())){let Q=this._getOrReturnCtx($);return z(Q,{code:G.invalid_date}),S}let J=new f,X=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.getTime()<Q.value)X=this._getOrReturnCtx($,X),z(X,{code:G.too_small,message:Q.message,inclusive:!0,exact:!1,minimum:Q.value,type:"date"}),J.dirty()}else if(Q.kind==="max"){if($.data.getTime()>Q.value)X=this._getOrReturnCtx($,X),z(X,{code:G.too_big,message:Q.message,inclusive:!0,exact:!1,maximum:Q.value,type:"date"}),J.dirty()}else L.assertNever(Q);return{status:J.value,value:new Date($.data.getTime())}}_addCheck($){return new H$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:U.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:U.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}H$.create=($)=>{return new H$({checks:[],coerce:$?.coerce||!1,typeName:V.ZodDate,...E($)})};class h$ extends j{_parse($){if(this._getType($)!==M.symbol){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.symbol,received:J.parsedType}),S}return k($.data)}}h$.create=($)=>{return new h$({typeName:V.ZodSymbol,...E($)})};class A$ extends j{_parse($){if(this._getType($)!==M.undefined){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.undefined,received:J.parsedType}),S}return k($.data)}}A$.create=($)=>{return new A$({typeName:V.ZodUndefined,...E($)})};class F$ extends j{_parse($){if(this._getType($)!==M.null){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.null,received:J.parsedType}),S}return k($.data)}}F$.create=($)=>{return new F$({typeName:V.ZodNull,...E($)})};class _$ extends j{constructor(){super(...arguments);this._any=!0}_parse($){return k($.data)}}_$.create=($)=>{return new _$({typeName:V.ZodAny,...E($)})};class e extends j{constructor(){super(...arguments);this._unknown=!0}_parse($){return k($.data)}}e.create=($)=>{return new e({typeName:V.ZodUnknown,...E($)})};class d extends j{_parse($){let q=this._getOrReturnCtx($);return z(q,{code:G.invalid_type,expected:M.never,received:q.parsedType}),S}}d.create=($)=>{return new d({typeName:V.ZodNever,...E($)})};class Z$ extends j{_parse($){if(this._getType($)!==M.undefined){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.void,received:J.parsedType}),S}return k($.data)}}Z$.create=($)=>{return new Z$({typeName:V.ZodVoid,...E($)})};class x extends j{_parse($){let{ctx:q,status:J}=this._processInputParams($),X=this._def;if(q.parsedType!==M.array)return z(q,{code:G.invalid_type,expected:M.array,received:q.parsedType}),S;if(X.exactLength!==null){let W=q.data.length>X.exactLength.value,Y=q.data.length<X.exactLength.value;if(W||Y)z(q,{code:W?G.too_big:G.too_small,minimum:Y?X.exactLength.value:void 0,maximum:W?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),J.dirty()}if(X.minLength!==null){if(q.data.length<X.minLength.value)z(q,{code:G.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),J.dirty()}if(X.maxLength!==null){if(q.data.length>X.maxLength.value)z(q,{code:G.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),J.dirty()}if(q.common.async)return Promise.all([...q.data].map((W,Y)=>{return X.type._parseAsync(new l(q,W,q.path,Y))})).then((W)=>{return f.mergeArray(J,W)});let Q=[...q.data].map((W,Y)=>{return X.type._parseSync(new l(q,W,q.path,Y))});return f.mergeArray(J,Q)}get element(){return this._def.type}min($,q){return new x({...this._def,minLength:{value:$,message:U.toString(q)}})}max($,q){return new x({...this._def,maxLength:{value:$,message:U.toString(q)}})}length($,q){return new x({...this._def,exactLength:{value:$,message:U.toString(q)}})}nonempty($){return this.min(1,$)}}x.create=($,q)=>{return new x({type:$,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...E(q)})};function L$($){if($ instanceof N){let q={};for(let J in $.shape){let X=$.shape[J];q[J]=g.create(L$(X))}return new N({...$._def,shape:()=>q})}else if($ instanceof x)return new x({...$._def,type:L$($.element)});else if($ instanceof g)return g.create(L$($.unwrap()));else if($ instanceof a)return a.create(L$($.unwrap()));else if($ instanceof r)return r.create($.items.map((q)=>L$(q)));else return $}class N extends j{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=L.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==M.object){let _=this._getOrReturnCtx($);return z(_,{code:G.invalid_type,expected:M.object,received:_.parsedType}),S}let{status:J,ctx:X}=this._processInputParams($),{shape:Q,keys:W}=this._getCached(),Y=[];if(!(this._def.catchall instanceof d&&this._def.unknownKeys==="strip")){for(let _ in X.data)if(!W.includes(_))Y.push(_)}let H=[];for(let _ of W){let B=Q[_],R=X.data[_];H.push({key:{status:"valid",value:_},value:B._parse(new l(X,R,X.path,_)),alwaysSet:_ in X.data})}if(this._def.catchall instanceof d){let _=this._def.unknownKeys;if(_==="passthrough")for(let B of Y)H.push({key:{status:"valid",value:B},value:{status:"valid",value:X.data[B]}});else if(_==="strict"){if(Y.length>0)z(X,{code:G.unrecognized_keys,keys:Y}),J.dirty()}else if(_==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let _=this._def.catchall;for(let B of Y){let R=X.data[B];H.push({key:{status:"valid",value:B},value:_._parse(new l(X,R,X.path,B)),alwaysSet:B in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let _=[];for(let B of H){let R=await B.key,K=await B.value;_.push({key:R,value:K,alwaysSet:B.alwaysSet})}return _}).then((_)=>{return f.mergeObjectSync(J,_)});else return f.mergeObjectSync(J,H)}get shape(){return this._def.shape()}strict($){return U.errToObj,new N({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,J)=>{let X=this._def.errorMap?.(q,J).message??J.defaultError;if(q.code==="unrecognized_keys")return{message:U.errToObj($).message??X};return{message:X}}}:{}})}strip(){return new N({...this._def,unknownKeys:"strip"})}passthrough(){return new N({...this._def,unknownKeys:"passthrough"})}extend($){return new N({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new N({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:V.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new N({...this._def,catchall:$})}pick($){let q={};for(let J of L.objectKeys($))if($[J]&&this.shape[J])q[J]=this.shape[J];return new N({...this._def,shape:()=>q})}omit($){let q={};for(let J of L.objectKeys(this.shape))if(!$[J])q[J]=this.shape[J];return new N({...this._def,shape:()=>q})}deepPartial(){return L$(this)}partial($){let q={};for(let J of L.objectKeys(this.shape)){let X=this.shape[J];if($&&!$[J])q[J]=X;else q[J]=X.optional()}return new N({...this._def,shape:()=>q})}required($){let q={};for(let J of L.objectKeys(this.shape))if($&&!$[J])q[J]=this.shape[J];else{let Q=this.shape[J];while(Q instanceof g)Q=Q._def.innerType;q[J]=Q}return new N({...this._def,shape:()=>q})}keyof(){return A0(L.objectKeys(this.shape))}}N.create=($,q)=>{return new N({shape:()=>$,unknownKeys:"strip",catchall:d.create(),typeName:V.ZodObject,...E(q)})};N.strictCreate=($,q)=>{return new N({shape:()=>$,unknownKeys:"strict",catchall:d.create(),typeName:V.ZodObject,...E(q)})};N.lazycreate=($,q)=>{return new N({shape:$,unknownKeys:"strip",catchall:d.create(),typeName:V.ZodObject,...E(q)})};class w$ extends j{_parse($){let{ctx:q}=this._processInputParams($),J=this._def.options;function X(Q){for(let Y of Q)if(Y.result.status==="valid")return Y.result;for(let Y of Q)if(Y.result.status==="dirty")return q.common.issues.push(...Y.ctx.common.issues),Y.result;let W=Q.map((Y)=>new C(Y.ctx.common.issues));return z(q,{code:G.invalid_union,unionErrors:W}),S}if(q.common.async)return Promise.all(J.map(async(Q)=>{let W={...q,common:{...q.common,issues:[]},parent:null};return{result:await Q._parseAsync({data:q.data,path:q.path,parent:W}),ctx:W}})).then(X);else{let Q=void 0,W=[];for(let H of J){let _={...q,common:{...q.common,issues:[]},parent:null},B=H._parseSync({data:q.data,path:q.path,parent:_});if(B.status==="valid")return B;else if(B.status==="dirty"&&!Q)Q={result:B,ctx:_};if(_.common.issues.length)W.push(_.common.issues)}if(Q)return q.common.issues.push(...Q.ctx.common.issues),Q.result;let Y=W.map((H)=>new C(H));return z(q,{code:G.invalid_union,unionErrors:Y}),S}}get options(){return this._def.options}}w$.create=($,q)=>{return new w$({options:$,typeName:V.ZodUnion,...E(q)})};var s=($)=>{if($ instanceof N$)return s($.schema);else if($ instanceof u)return s($.innerType());else if($ instanceof b$)return[$.value];else if($ instanceof J$)return $.options;else if($ instanceof v$)return L.objectValues($.enum);else if($ instanceof f$)return s($._def.innerType);else if($ instanceof A$)return[void 0];else if($ instanceof F$)return[null];else if($ instanceof g)return[void 0,...s($.unwrap())];else if($ instanceof a)return[null,...s($.unwrap())];else if($ instanceof e$)return s($.unwrap());else if($ instanceof k$)return s($.unwrap());else if($ instanceof P$)return s($._def.innerType);else return[]};class t$ extends j{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==M.object)return z(q,{code:G.invalid_type,expected:M.object,received:q.parsedType}),S;let J=this.discriminator,X=q.data[J],Q=this.optionsMap.get(X);if(!Q)return z(q,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[J]}),S;if(q.common.async)return Q._parseAsync({data:q.data,path:q.path,parent:q});else return Q._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,J){let X=new Map;for(let Q of q){let W=s(Q.shape[$]);if(!W.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of W){if(X.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);X.set(Y,Q)}}return new t$({typeName:V.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:X,...E(J)})}}function F1($,q){let J=p($),X=p(q);if($===q)return{valid:!0,data:$};else if(J===M.object&&X===M.object){let Q=L.objectKeys(q),W=L.objectKeys($).filter((H)=>Q.indexOf(H)!==-1),Y={...$,...q};for(let H of W){let _=F1($[H],q[H]);if(!_.valid)return{valid:!1};Y[H]=_.data}return{valid:!0,data:Y}}else if(J===M.array&&X===M.array){if($.length!==q.length)return{valid:!1};let Q=[];for(let W=0;W<$.length;W++){let Y=$[W],H=q[W],_=F1(Y,H);if(!_.valid)return{valid:!1};Q.push(_.data)}return{valid:!0,data:Q}}else if(J===M.date&&X===M.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class O$ extends j{_parse($){let{status:q,ctx:J}=this._processInputParams($),X=(Q,W)=>{if(s$(Q)||s$(W))return S;let Y=F1(Q.value,W.value);if(!Y.valid)return z(J,{code:G.invalid_intersection_types}),S;if(a$(Q)||a$(W))q.dirty();return{status:q.value,value:Y.data}};if(J.common.async)return Promise.all([this._def.left._parseAsync({data:J.data,path:J.path,parent:J}),this._def.right._parseAsync({data:J.data,path:J.path,parent:J})]).then(([Q,W])=>X(Q,W));else return X(this._def.left._parseSync({data:J.data,path:J.path,parent:J}),this._def.right._parseSync({data:J.data,path:J.path,parent:J}))}}O$.create=($,q,J)=>{return new O$({left:$,right:q,typeName:V.ZodIntersection,...E(J)})};class r extends j{_parse($){let{status:q,ctx:J}=this._processInputParams($);if(J.parsedType!==M.array)return z(J,{code:G.invalid_type,expected:M.array,received:J.parsedType}),S;if(J.data.length<this._def.items.length)return z(J,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;if(!this._def.rest&&J.data.length>this._def.items.length)z(J,{code:G.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let Q=[...J.data].map((W,Y)=>{let H=this._def.items[Y]||this._def.rest;if(!H)return null;return H._parse(new l(J,W,J.path,Y))}).filter((W)=>!!W);if(J.common.async)return Promise.all(Q).then((W)=>{return f.mergeArray(q,W)});else return f.mergeArray(q,Q)}get items(){return this._def.items}rest($){return new r({...this._def,rest:$})}}r.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new r({items:$,typeName:V.ZodTuple,rest:null,...E(q)})};class x$ extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:J}=this._processInputParams($);if(J.parsedType!==M.object)return z(J,{code:G.invalid_type,expected:M.object,received:J.parsedType}),S;let X=[],Q=this._def.keyType,W=this._def.valueType;for(let Y in J.data)X.push({key:Q._parse(new l(J,Y,J.path,Y)),value:W._parse(new l(J,J.data[Y],J.path,Y)),alwaysSet:Y in J.data});if(J.common.async)return f.mergeObjectAsync(q,X);else return f.mergeObjectSync(q,X)}get element(){return this._def.valueType}static create($,q,J){if(q instanceof j)return new x$({keyType:$,valueType:q,typeName:V.ZodRecord,...E(J)});return new x$({keyType:Z.create(),valueType:$,typeName:V.ZodRecord,...E(q)})}}class g$ extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:J}=this._processInputParams($);if(J.parsedType!==M.map)return z(J,{code:G.invalid_type,expected:M.map,received:J.parsedType}),S;let X=this._def.keyType,Q=this._def.valueType,W=[...J.data.entries()].map(([Y,H],_)=>{return{key:X._parse(new l(J,Y,J.path,[_,"key"])),value:Q._parse(new l(J,H,J.path,[_,"value"]))}});if(J.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let H of W){let _=await H.key,B=await H.value;if(_.status==="aborted"||B.status==="aborted")return S;if(_.status==="dirty"||B.status==="dirty")q.dirty();Y.set(_.value,B.value)}return{status:q.value,value:Y}})}else{let Y=new Map;for(let H of W){let{key:_,value:B}=H;if(_.status==="aborted"||B.status==="aborted")return S;if(_.status==="dirty"||B.status==="dirty")q.dirty();Y.set(_.value,B.value)}return{status:q.value,value:Y}}}}g$.create=($,q,J)=>{return new g$({valueType:q,keyType:$,typeName:V.ZodMap,...E(J)})};class B$ extends j{_parse($){let{status:q,ctx:J}=this._processInputParams($);if(J.parsedType!==M.set)return z(J,{code:G.invalid_type,expected:M.set,received:J.parsedType}),S;let X=this._def;if(X.minSize!==null){if(J.data.size<X.minSize.value)z(J,{code:G.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),q.dirty()}if(X.maxSize!==null){if(J.data.size>X.maxSize.value)z(J,{code:G.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),q.dirty()}let Q=this._def.valueType;function W(H){let _=new Set;for(let B of H){if(B.status==="aborted")return S;if(B.status==="dirty")q.dirty();_.add(B.value)}return{status:q.value,value:_}}let Y=[...J.data.values()].map((H,_)=>Q._parse(new l(J,H,J.path,_)));if(J.common.async)return Promise.all(Y).then((H)=>W(H));else return W(Y)}min($,q){return new B$({...this._def,minSize:{value:$,message:U.toString(q)}})}max($,q){return new B$({...this._def,maxSize:{value:$,message:U.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}B$.create=($,q)=>{return new B$({valueType:$,minSize:null,maxSize:null,typeName:V.ZodSet,...E(q)})};class K$ extends j{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==M.function)return z(q,{code:G.invalid_type,expected:M.function,received:q.parsedType}),S;function J(Y,H){return y$({data:Y,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,E$(),o].filter((_)=>!!_),issueData:{code:G.invalid_arguments,argumentsError:H}})}function X(Y,H){return y$({data:Y,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,E$(),o].filter((_)=>!!_),issueData:{code:G.invalid_return_type,returnTypeError:H}})}let Q={errorMap:q.common.contextualErrorMap},W=q.data;if(this._def.returns instanceof G$){let Y=this;return k(async function(...H){let _=new C([]),B=await Y._def.args.parseAsync(H,Q).catch((A)=>{throw _.addIssue(J(H,A)),_}),R=await Reflect.apply(W,this,B);return await Y._def.returns._def.type.parseAsync(R,Q).catch((A)=>{throw _.addIssue(X(R,A)),_})})}else{let Y=this;return k(function(...H){let _=Y._def.args.safeParse(H,Q);if(!_.success)throw new C([J(H,_.error)]);let B=Reflect.apply(W,this,_.data),R=Y._def.returns.safeParse(B,Q);if(!R.success)throw new C([X(B,R.error)]);return R.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new K$({...this._def,args:r.create($).rest(e.create())})}returns($){return new K$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,J){return new K$({args:$?$:r.create([]).rest(e.create()),returns:q||e.create(),typeName:V.ZodFunction,...E(J)})}}class N$ extends j{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}N$.create=($,q)=>{return new N$({getter:$,typeName:V.ZodLazy,...E(q)})};class b$ extends j{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return z(q,{received:q.data,code:G.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:$.data}}get value(){return this._def.value}}b$.create=($,q)=>{return new b$({value:$,typeName:V.ZodLiteral,...E(q)})};function A0($,q){return new J$({values:$,typeName:V.ZodEnum,...E(q)})}class J$ extends j{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),J=this._def.values;return z(q,{expected:L.joinValues(J),received:q.parsedType,code:G.invalid_type}),S}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),J=this._def.values;return z(q,{received:q.data,code:G.invalid_enum_value,options:J}),S}return k($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return J$.create($,{...this._def,...q})}exclude($,q=this._def){return J$.create(this.options.filter((J)=>!$.includes(J)),{...this._def,...q})}}J$.create=A0;class v$ extends j{_parse($){let q=L.getValidEnumValues(this._def.values),J=this._getOrReturnCtx($);if(J.parsedType!==M.string&&J.parsedType!==M.number){let X=L.objectValues(q);return z(J,{expected:L.joinValues(X),received:J.parsedType,code:G.invalid_type}),S}if(!this._cache)this._cache=new Set(L.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let X=L.objectValues(q);return z(J,{received:J.data,code:G.invalid_enum_value,options:X}),S}return k($.data)}get enum(){return this._def.values}}v$.create=($,q)=>{return new v$({values:$,typeName:V.ZodNativeEnum,...E(q)})};class G$ extends j{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==M.promise&&q.common.async===!1)return z(q,{code:G.invalid_type,expected:M.promise,received:q.parsedType}),S;let J=q.parsedType===M.promise?q.data:Promise.resolve(q.data);return k(J.then((X)=>{return this._def.type.parseAsync(X,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}G$.create=($,q)=>{return new G$({type:$,typeName:V.ZodPromise,...E(q)})};class u extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:J}=this._processInputParams($),X=this._def.effect||null,Q={addIssue:(W)=>{if(z(J,W),W.fatal)q.abort();else q.dirty()},get path(){return J.path}};if(Q.addIssue=Q.addIssue.bind(Q),X.type==="preprocess"){let W=X.transform(J.data,Q);if(J.common.async)return Promise.resolve(W).then(async(Y)=>{if(q.value==="aborted")return S;let H=await this._def.schema._parseAsync({data:Y,path:J.path,parent:J});if(H.status==="aborted")return S;if(H.status==="dirty")return Y$(H.value);if(q.value==="dirty")return Y$(H.value);return H});else{if(q.value==="aborted")return S;let Y=this._def.schema._parseSync({data:W,path:J.path,parent:J});if(Y.status==="aborted")return S;if(Y.status==="dirty")return Y$(Y.value);if(q.value==="dirty")return Y$(Y.value);return Y}}if(X.type==="refinement"){let W=(Y)=>{let H=X.refinement(Y,Q);if(J.common.async)return Promise.resolve(H);if(H instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(J.common.async===!1){let Y=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(Y.status==="aborted")return S;if(Y.status==="dirty")q.dirty();return W(Y.value),{status:q.value,value:Y.value}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((Y)=>{if(Y.status==="aborted")return S;if(Y.status==="dirty")q.dirty();return W(Y.value).then(()=>{return{status:q.value,value:Y.value}})})}if(X.type==="transform")if(J.common.async===!1){let W=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(!t(W))return S;let Y=X.transform(W.value,Q);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:Y}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((W)=>{if(!t(W))return S;return Promise.resolve(X.transform(W.value,Q)).then((Y)=>({status:q.value,value:Y}))});L.assertNever(X)}}u.create=($,q,J)=>{return new u({schema:$,typeName:V.ZodEffects,effect:q,...E(J)})};u.createWithPreprocess=($,q,J)=>{return new u({schema:q,effect:{type:"preprocess",transform:$},typeName:V.ZodEffects,...E(J)})};class g extends j{_parse($){if(this._getType($)===M.undefined)return k(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}g.create=($,q)=>{return new g({innerType:$,typeName:V.ZodOptional,...E(q)})};class a extends j{_parse($){if(this._getType($)===M.null)return k(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}a.create=($,q)=>{return new a({innerType:$,typeName:V.ZodNullable,...E(q)})};class f$ extends j{_parse($){let{ctx:q}=this._processInputParams($),J=q.data;if(q.parsedType===M.undefined)J=this._def.defaultValue();return this._def.innerType._parse({data:J,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}f$.create=($,q)=>{return new f$({innerType:$,typeName:V.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...E(q)})};class P$ extends j{_parse($){let{ctx:q}=this._processInputParams($),J={...q,common:{...q.common,issues:[]}},X=this._def.innerType._parse({data:J.data,path:J.path,parent:{...J}});if(j$(X))return X.then((Q)=>{return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new C(J.common.issues)},input:J.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new C(J.common.issues)},input:J.data})}}removeCatch(){return this._def.innerType}}P$.create=($,q)=>{return new P$({innerType:$,typeName:V.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...E(q)})};class l$ extends j{_parse($){if(this._getType($)!==M.nan){let J=this._getOrReturnCtx($);return z(J,{code:G.invalid_type,expected:M.nan,received:J.parsedType}),S}return{status:"valid",value:$.data}}}l$.create=($)=>{return new l$({typeName:V.ZodNaN,...E($)})};var Xq=Symbol("zod_brand");class e$ extends j{_parse($){let{ctx:q}=this._processInputParams($),J=q.data;return this._def.type._parse({data:J,path:q.path,parent:q})}unwrap(){return this._def.type}}class u$ extends j{_parse($){let{status:q,ctx:J}=this._processInputParams($);if(J.common.async)return(async()=>{let Q=await this._def.in._parseAsync({data:J.data,path:J.path,parent:J});if(Q.status==="aborted")return S;if(Q.status==="dirty")return q.dirty(),Y$(Q.value);else return this._def.out._parseAsync({data:Q.value,path:J.path,parent:J})})();else{let X=this._def.in._parseSync({data:J.data,path:J.path,parent:J});if(X.status==="aborted")return S;if(X.status==="dirty")return q.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:J.path,parent:J})}}static create($,q){return new u$({in:$,out:q,typeName:V.ZodPipeline})}}class k$ extends j{_parse($){let q=this._def.innerType._parse($),J=(X)=>{if(t(X))X.value=Object.freeze(X.value);return X};return j$(q)?q.then((X)=>J(X)):J(q)}unwrap(){return this._def.innerType}}k$.create=($,q)=>{return new k$({innerType:$,typeName:V.ZodReadonly,...E(q)})};function j0($,q){let J=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof J==="string"?{message:J}:J}function F0($,q={},J){if($)return _$.create().superRefine((X,Q)=>{let W=$(X);if(W instanceof Promise)return W.then((Y)=>{if(!Y){let H=j0(q,X),_=H.fatal??J??!0;Q.addIssue({code:"custom",...H,fatal:_})}});if(!W){let Y=j0(q,X),H=Y.fatal??J??!0;Q.addIssue({code:"custom",...Y,fatal:H})}return});return _$.create()}var Qq={object:N.lazycreate},V;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(V||(V={}));var Wq=($,q={message:`Input not instance of ${$.name}`})=>F0((J)=>J instanceof $,q),w0=Z.create,O0=$$.create,Yq=l$.create,Hq=q$.create,N0=D$.create,_q=H$.create,Bq=h$.create,Gq=A$.create,Mq=F$.create,zq=_$.create,Uq=e.create,Rq=d.create,Sq=Z$.create,Vq=x.create,Eq=N.create,jq=N.strictCreate,Lq=w$.create,Kq=t$.create,Dq=O$.create,Aq=r.create,Fq=x$.create,wq=g$.create,Oq=B$.create,Nq=K$.create,bq=N$.create,vq=b$.create,fq=J$.create,Pq=v$.create,kq=G$.create,Iq=u.create,Tq=g.create,Cq=a.create,yq=u.createWithPreprocess,hq=u$.create,Zq=()=>w0().optional(),xq=()=>O0().optional(),gq=()=>N0().optional(),lq={string:($)=>Z.create({...$,coerce:!0}),number:($)=>$$.create({...$,coerce:!0}),boolean:($)=>D$.create({...$,coerce:!0}),bigint:($)=>q$.create({...$,coerce:!0}),date:($)=>H$.create({...$,coerce:!0})};var uq=S;var mq=D.object({name:D.string().default("genie"),defaultWindow:D.string().default("shell"),autoCreate:D.boolean().default(!0)}),cq=D.object({execTimeout:D.number().default(120000),readLines:D.number().default(100),worktreeBase:D.string().default(".worktrees")}),pq=D.object({tmuxDebug:D.boolean().default(!1),verbose:D.boolean().default(!1)}),dq=D.object({preference:D.enum(["auto","zsh","bash","fish"]).default("auto")}),rq=D.object({tmuxInstalled:D.boolean().default(!1),shellInstalled:D.boolean().default(!1)}),iq=D.object({enabled:D.boolean().default(!1)}),m=D.object({version:D.number().default(2),session:mq.default({}),terminal:cq.default({}),logging:pq.default({}),shell:dq.default({}),shortcuts:rq.default({}),claudio:iq.optional(),installMethod:D.enum(["source","npm","bun"]).optional(),setupComplete:D.boolean().default(!1),lastSetupAt:D.string().optional()}),b0=D.object({session:D.object({name:D.string().default("genie"),defaultWindow:D.string().default("shell")}).default({}),logging:D.object({tmuxDebug:D.boolean().default(!1)}).default({}),installMethod:D.enum(["source","npm","bun"]).optional()});var $1=P0(f0(),".genie"),M$=P0($1,"config.json"),w1=2;function JX(){return $1}function XX(){return M$}function sq(){return q1(M$)}function aq(){if(!q1($1))nq($1,{recursive:!0})}function k0($){let q=b0.safeParse($);if(q.success){let J=q.data;return m.parse({version:w1,session:{name:J.session.name,defaultWindow:J.session.defaultWindow,autoCreate:!0},terminal:{execTimeout:120000,readLines:100,worktreeBase:".worktrees"},logging:{tmuxDebug:J.logging.tmuxDebug,verbose:!1},shell:{preference:"auto"},shortcuts:{tmuxInstalled:!1,shellInstalled:!1},installMethod:J.installMethod,setupComplete:!1})}return m.parse({})}async function I0(){if(!q1(M$))return m.parse({});try{let $=v0(M$,"utf-8"),q=JSON.parse($);if(!q.version||q.version<w1){let J=k0(q);return await J1(J),J}return m.parse(q)}catch($){return console.warn(`Warning: Invalid genie config, using defaults: ${$.message}`),m.parse({})}}async function J1($){aq();try{let q=m.parse($),J=JSON.stringify(q,null,2);oq(M$,J,"utf-8")}catch(q){throw Error(`Failed to save genie config: ${q.message}`)}}function tq(){return m.parse({})}function T0(){if(!q1(M$))return m.parse({});try{let $=v0(M$,"utf-8"),q=JSON.parse($);if(!q.version||q.version<w1)return k0(q);return m.parse(q)}catch{return m.parse({})}}function QX($){let q=f0();if($.startsWith(q+"/"))return"~"+$.slice(q.length);if($===q)return"~";return $}function X1(){return T0().terminal}function WX(){if(!sq())return!1;return T0().setupComplete??!1}async function YX(){let $=await I0();$.setupComplete=!0,$.lastSetupAt=new Date().toISOString(),await J1($)}async function HX(){let $=tq();await J1($)}async function _X($){let q=await I0();q.shortcuts={...q.shortcuts,...$},await J1(q)}async function C0($,q){try{let X=X1().readLines,Q={lines:q.lines?parseInt(q.lines,10):X,from:q.from?parseInt(q.from,10):void 0,to:q.to?parseInt(q.to,10):void 0,range:q.range,search:q.search,grep:q.grep,follow:q.follow,all:q.all,reverse:q.reverse};if(q.follow){console.log(`Following session "${$}" (Ctrl+C to stop)...`),console.log("");let Y=await S0($,(H)=>{console.log(H)});process.on("SIGINT",()=>{Y(),console.log(`
|
|
45
|
-
Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let
|
|
46
|
-
`);console.log(JSON.stringify({session
|
|
48
|
+
`);return J}async function c8(D,F){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await k(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await l(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let X=$[0].id,Q="",J=!0,Y=setInterval(async()=>{if(!J){clearInterval(Y);return}try{let q=await p(X,100),H=p2(q);if(H!==Q){let _=H.split(`
|
|
49
|
+
`),G=Q.split(`
|
|
50
|
+
`),A=G.length>0?G.length-1:0;_.slice(A).forEach((K)=>{if(K&&K!==G[G.length-1])F(K)}),Q=H}}catch(q){clearInterval(Y),J=!1}},500);return()=>{J=!1,clearInterval(Y)}}import{existsSync as O0,mkdirSync as H9,readFileSync as B6,writeFileSync as _9}from"fs";import{homedir as $6}from"os";import{join as X6}from"path";var I={};Y8(I,{void:()=>w7,util:()=>w,unknown:()=>P7,union:()=>v7,undefined:()=>S7,tuple:()=>y7,transformer:()=>r7,symbol:()=>N7,string:()=>e8,strictObject:()=>Z7,setErrorMap:()=>o5,set:()=>l7,record:()=>h7,quotelessJson:()=>r5,promise:()=>n7,preprocess:()=>s7,pipeline:()=>t7,ostring:()=>e7,optional:()=>a7,onumber:()=>D9,oboolean:()=>F9,objectUtil:()=>Y3,object:()=>u7,number:()=>D6,nullable:()=>o7,null:()=>T7,never:()=>f7,nativeEnum:()=>i7,nan:()=>L7,map:()=>g7,makeIssue:()=>c2,literal:()=>c7,lazy:()=>p7,late:()=>K7,isValid:()=>uD,isDirty:()=>K0,isAsync:()=>A2,isAborted:()=>R0,intersection:()=>x7,instanceof:()=>j7,getParsedType:()=>GD,getErrorMap:()=>U2,function:()=>m7,enum:()=>d7,effect:()=>r7,discriminatedUnion:()=>k7,defaultErrorMap:()=>LD,datetimeRegex:()=>o8,date:()=>O7,custom:()=>t8,coerce:()=>E9,boolean:()=>F6,bigint:()=>M7,array:()=>I7,any:()=>b7,addIssueToContext:()=>C,ZodVoid:()=>i2,ZodUnknown:()=>ZD,ZodUnion:()=>j2,ZodUndefined:()=>R2,ZodType:()=>f,ZodTuple:()=>AD,ZodTransformer:()=>qD,ZodSymbol:()=>d2,ZodString:()=>XD,ZodSet:()=>nD,ZodSchema:()=>f,ZodRecord:()=>n2,ZodReadonly:()=>b2,ZodPromise:()=>rD,ZodPipeline:()=>o2,ZodParsedType:()=>U,ZodOptional:()=>JD,ZodObject:()=>y,ZodNumber:()=>vD,ZodNullable:()=>OD,ZodNull:()=>K2,ZodNever:()=>UD,ZodNativeEnum:()=>N2,ZodNaN:()=>a2,ZodMap:()=>r2,ZodLiteral:()=>O2,ZodLazy:()=>M2,ZodIssueCode:()=>W,ZodIntersection:()=>L2,ZodFunction:()=>z2,ZodFirstPartyTypeKind:()=>M,ZodError:()=>t,ZodEnum:()=>xD,ZodEffects:()=>qD,ZodDiscriminatedUnion:()=>j0,ZodDefault:()=>S2,ZodDate:()=>dD,ZodCatch:()=>T2,ZodBranded:()=>L0,ZodBoolean:()=>V2,ZodBigInt:()=>kD,ZodArray:()=>QD,ZodAny:()=>iD,Schema:()=>f,ParseStatus:()=>n,OK:()=>o,NEVER:()=>B9,INVALID:()=>j,EMPTY_PATH:()=>s5,DIRTY:()=>cD,BRAND:()=>R7});var w;(function(D){D.assertEqual=($)=>{};function F($){}D.assertIs=F;function E($){throw Error()}D.assertNever=E,D.arrayToEnum=($)=>{let X={};for(let Q of $)X[Q]=Q;return X},D.getValidEnumValues=($)=>{let X=D.objectKeys($).filter((J)=>typeof $[$[J]]!=="number"),Q={};for(let J of X)Q[J]=$[J];return D.objectValues(Q)},D.objectValues=($)=>{return D.objectKeys($).map(function(X){return $[X]})},D.objectKeys=typeof Object.keys==="function"?($)=>Object.keys($):($)=>{let X=[];for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))X.push(Q);return X},D.find=($,X)=>{for(let Q of $)if(X(Q))return Q;return},D.isInteger=typeof Number.isInteger==="function"?($)=>Number.isInteger($):($)=>typeof $==="number"&&Number.isFinite($)&&Math.floor($)===$;function B($,X=" | "){return $.map((Q)=>typeof Q==="string"?`'${Q}'`:Q).join(X)}D.joinValues=B,D.jsonStringifyReplacer=($,X)=>{if(typeof X==="bigint")return X.toString();return X}})(w||(w={}));var Y3;(function(D){D.mergeShapes=(F,E)=>{return{...F,...E}}})(Y3||(Y3={}));var U=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),GD=(D)=>{switch(typeof D){case"undefined":return U.undefined;case"string":return U.string;case"number":return Number.isNaN(D)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":if(Array.isArray(D))return U.array;if(D===null)return U.null;if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return U.promise;if(typeof Map<"u"&&D instanceof Map)return U.map;if(typeof Set<"u"&&D instanceof Set)return U.set;if(typeof Date<"u"&&D instanceof Date)return U.date;return U.object;default:return U.unknown}};var W=w.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"]),r5=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")};class t 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 X of $.issues)if(X.code==="invalid_union")X.unionErrors.map(B);else if(X.code==="invalid_return_type")B(X.returnTypeError);else if(X.code==="invalid_arguments")B(X.argumentsError);else if(X.path.length===0)E._errors.push(F(X));else{let Q=E,J=0;while(J<X.path.length){let Y=X.path[J];if(J!==X.path.length-1)Q[Y]=Q[Y]||{_errors:[]};else Q[Y]=Q[Y]||{_errors:[]},Q[Y]._errors.push(F(X));Q=Q[Y],J++}}};return B(this),E}static assert(D){if(!(D instanceof t))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.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()}}t.create=(D)=>{return new t(D)};var a5=(D,F)=>{let E;switch(D.code){case W.invalid_type:if(D.received===U.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,w.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:E=`Unrecognized key(s) in object: ${w.joinValues(D.keys,", ")}`;break;case W.invalid_union:E="Invalid input";break;case W.invalid_union_discriminator:E=`Invalid discriminator value. Expected ${w.joinValues(D.options)}`;break;case W.invalid_enum_value:E=`Invalid enum value. Expected ${w.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 w.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,w.assertNever(D)}return{message:E}},LD=a5;var d8=LD;function o5(D){d8=D}function U2(){return d8}var c2=(D)=>{let{data:F,path:E,errorMaps:B,issueData:$}=D,X=[...E,...$.path||[]],Q={...$,path:X};if($.message!==void 0)return{...$,path:X,message:$.message};let J="",Y=B.filter((q)=>!!q).slice().reverse();for(let q of Y)J=q(Q,{data:F,defaultError:J}).message;return{...$,path:X,message:J}},s5=[];function C(D,F){let E=U2(),B=c2({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,E,E===LD?void 0:LD].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,X=await B.value;E.push({key:$,value:X})}return n.mergeObjectSync(D,E)}static mergeObjectSync(D,F){let E={};for(let B of F){let{key:$,value:X}=B;if($.status==="aborted")return j;if(X.status==="aborted")return j;if($.status==="dirty")D.dirty();if(X.status==="dirty")D.dirty();if($.value!=="__proto__"&&(typeof X.value<"u"||B.alwaysSet))E[$.value]=X.value}return{status:D.value,value:E}}}var j=Object.freeze({status:"aborted"}),cD=(D)=>({status:"dirty",value:D}),o=(D)=>({status:"valid",value:D}),R0=(D)=>D.status==="aborted",K0=(D)=>D.status==="dirty",uD=(D)=>D.status==="valid",A2=(D)=>typeof Promise<"u"&&D instanceof Promise;var V;(function(D){D.errToObj=(F)=>typeof F==="string"?{message:F}:F||{},D.toString=(F)=>typeof F==="string"?F:F?.message})(V||(V={}));class YD{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 i8=(D,F)=>{if(uD(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 t(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:(Q,J)=>{let{message:Y}=D;if(Q.code==="invalid_enum_value")return{message:Y??J.defaultError};if(typeof J.data>"u")return{message:Y??B??J.defaultError};if(Q.code!=="invalid_type")return{message:J.defaultError};return{message:Y??E??J.defaultError}},description:$}}class f{get description(){return this._def.description}_getType(D){return GD(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:GD(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:GD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(A2(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:GD(D)},B=this._parseSync({data:D,path:E.path,parent:E});return i8(E,B)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:GD(D)};if(!this["~standard"].async)try{let E=this._parseSync({data:D,path:[],parent:F});return uD(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)=>uD(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:GD(D)},B=this._parse({data:D,path:E.path,parent:E}),$=await(A2(B)?B:Promise.resolve(B));return i8(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 X=D(B),Q=()=>$.addIssue({code:W.custom,...E(B)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((J)=>{if(!J)return Q(),!1;else return!0});if(!X)return Q(),!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 qD({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 JD.create(this,this._def)}nullable(){return OD.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return QD.create(this)}promise(){return rD.create(this,this._def)}or(D){return j2.create([this,D],this._def)}and(D){return L2.create(this,D,this._def)}transform(D){return new qD({...T(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new S2({...T(this._def),innerType:this,defaultValue:F,typeName:M.ZodDefault})}brand(){return new L0({typeName:M.ZodBranded,type:this,...T(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new T2({...T(this._def),innerType:this,catchValue:F,typeName:M.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return o2.create(this,D)}readonly(){return b2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var t5=/^c[^\s-]{8,}$/i,e5=/^[0-9a-z]+$/,D7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,F7=/^[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,E7=/^[a-z0-9_-]{21}$/i,B7=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$7=/^[-+]?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)?)??$/,X7=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q7="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",q3,J7=/^(?:(?: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])$/,Y7=/^(?:(?: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])$/,q7=/^(([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]))$/,H7=/^(([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])$/,_7=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,W7=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,r8="((\\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])))",G7=new RegExp(`^${r8}$`);function a8(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 U7(D){return new RegExp(`^${a8(D)}$`)}function o8(D){let F=`${r8}T${a8(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 A7(D,F){if((F==="v4"||!F)&&J7.test(D))return!0;if((F==="v6"||!F)&&q7.test(D))return!0;return!1}function C7(D,F){if(!B7.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 z7(D,F){if((F==="v4"||!F)&&Y7.test(D))return!0;if((F==="v6"||!F)&&H7.test(D))return!0;return!1}class XD extends f{_parse(D){if(this._def.coerce)D.data=String(D.data);if(this._getType(D)!==U.string){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:U.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 X=D.data.length>$.value,Q=D.data.length<$.value;if(X||Q){if(B=this._getOrReturnCtx(D,B),X)C(B,{code:W.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});else if(Q)C(B,{code:W.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});E.dirty()}}else if($.kind==="email"){if(!X7.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(!q3)q3=new RegExp(Q7,"u");if(!q3.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(!F7.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(!E7.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(!t5.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(!e5.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(!D7.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(!o8($).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(!G7.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(!U7($).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(!$7.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(!A7(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(!C7(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(!z7(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(!_7.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(!W7.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"base64url",code:W.invalid_string,message:$.message}),E.dirty()}else w.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,...V.errToObj(E)})}_addCheck(D){return new XD({...this._def,checks:[...this._def.checks,D]})}email(D){return this._addCheck({kind:"email",...V.errToObj(D)})}url(D){return this._addCheck({kind:"url",...V.errToObj(D)})}emoji(D){return this._addCheck({kind:"emoji",...V.errToObj(D)})}uuid(D){return this._addCheck({kind:"uuid",...V.errToObj(D)})}nanoid(D){return this._addCheck({kind:"nanoid",...V.errToObj(D)})}cuid(D){return this._addCheck({kind:"cuid",...V.errToObj(D)})}cuid2(D){return this._addCheck({kind:"cuid2",...V.errToObj(D)})}ulid(D){return this._addCheck({kind:"ulid",...V.errToObj(D)})}base64(D){return this._addCheck({kind:"base64",...V.errToObj(D)})}base64url(D){return this._addCheck({kind:"base64url",...V.errToObj(D)})}jwt(D){return this._addCheck({kind:"jwt",...V.errToObj(D)})}ip(D){return this._addCheck({kind:"ip",...V.errToObj(D)})}cidr(D){return this._addCheck({kind:"cidr",...V.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,...V.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,...V.errToObj(D?.message)})}duration(D){return this._addCheck({kind:"duration",...V.errToObj(D)})}regex(D,F){return this._addCheck({kind:"regex",regex:D,...V.errToObj(F)})}includes(D,F){return this._addCheck({kind:"includes",value:D,position:F?.position,...V.errToObj(F?.message)})}startsWith(D,F){return this._addCheck({kind:"startsWith",value:D,...V.errToObj(F)})}endsWith(D,F){return this._addCheck({kind:"endsWith",value:D,...V.errToObj(F)})}min(D,F){return this._addCheck({kind:"min",value:D,...V.errToObj(F)})}max(D,F){return this._addCheck({kind:"max",value:D,...V.errToObj(F)})}length(D,F){return this._addCheck({kind:"length",value:D,...V.errToObj(F)})}nonempty(D){return this.min(1,V.errToObj(D))}trim(){return new XD({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new XD({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new XD({...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}}XD.create=(D)=>{return new XD({checks:[],typeName:M.ZodString,coerce:D?.coerce??!1,...T(D)})};function V7(D,F){let E=(D.toString().split(".")[1]||"").length,B=(F.toString().split(".")[1]||"").length,$=E>B?E:B,X=Number.parseInt(D.toFixed($).replace(".","")),Q=Number.parseInt(F.toFixed($).replace(".",""));return X%Q/10**$}class vD extends f{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)!==U.number){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:U.number,received:$.parsedType}),j}let E=void 0,B=new n;for(let $ of this._def.checks)if($.kind==="int"){if(!w.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(V7(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 w.assertNever($);return{status:B.value,value:D.data}}gte(D,F){return this.setLimit("min",D,!0,V.toString(F))}gt(D,F){return this.setLimit("min",D,!1,V.toString(F))}lte(D,F){return this.setLimit("max",D,!0,V.toString(F))}lt(D,F){return this.setLimit("max",D,!1,V.toString(F))}setLimit(D,F,E,B){return new vD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:V.toString(B)}]})}_addCheck(D){return new vD({...this._def,checks:[...this._def.checks,D]})}int(D){return this._addCheck({kind:"int",message:V.toString(D)})}positive(D){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(D)})}negative(D){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:V.toString(F)})}finite(D){return this._addCheck({kind:"finite",message:V.toString(D)})}safe(D){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(D)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.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"&&w.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)}}vD.create=(D)=>{return new vD({checks:[],typeName:M.ZodNumber,coerce:D?.coerce||!1,...T(D)})};class kD extends f{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)!==U.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 w.assertNever($);return{status:B.value,value:D.data}}_getInvalidInput(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:U.bigint,received:F.parsedType}),j}gte(D,F){return this.setLimit("min",D,!0,V.toString(F))}gt(D,F){return this.setLimit("min",D,!1,V.toString(F))}lte(D,F){return this.setLimit("max",D,!0,V.toString(F))}lt(D,F){return this.setLimit("max",D,!1,V.toString(F))}setLimit(D,F,E,B){return new kD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:V.toString(B)}]})}_addCheck(D){return new kD({...this._def,checks:[...this._def.checks,D]})}positive(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(D)})}negative(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:V.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}}kD.create=(D)=>{return new kD({checks:[],typeName:M.ZodBigInt,coerce:D?.coerce??!1,...T(D)})};class V2 extends f{_parse(D){if(this._def.coerce)D.data=Boolean(D.data);if(this._getType(D)!==U.boolean){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.boolean,received:E.parsedType}),j}return o(D.data)}}V2.create=(D)=>{return new V2({typeName:M.ZodBoolean,coerce:D?.coerce||!1,...T(D)})};class dD extends f{_parse(D){if(this._def.coerce)D.data=new Date(D.data);if(this._getType(D)!==U.date){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:U.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 w.assertNever($);return{status:E.value,value:new Date(D.data.getTime())}}_addCheck(D){return new dD({...this._def,checks:[...this._def.checks,D]})}min(D,F){return this._addCheck({kind:"min",value:D.getTime(),message:V.toString(F)})}max(D,F){return this._addCheck({kind:"max",value:D.getTime(),message:V.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}}dD.create=(D)=>{return new dD({checks:[],coerce:D?.coerce||!1,typeName:M.ZodDate,...T(D)})};class d2 extends f{_parse(D){if(this._getType(D)!==U.symbol){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.symbol,received:E.parsedType}),j}return o(D.data)}}d2.create=(D)=>{return new d2({typeName:M.ZodSymbol,...T(D)})};class R2 extends f{_parse(D){if(this._getType(D)!==U.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.undefined,received:E.parsedType}),j}return o(D.data)}}R2.create=(D)=>{return new R2({typeName:M.ZodUndefined,...T(D)})};class K2 extends f{_parse(D){if(this._getType(D)!==U.null){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.null,received:E.parsedType}),j}return o(D.data)}}K2.create=(D)=>{return new K2({typeName:M.ZodNull,...T(D)})};class iD extends f{constructor(){super(...arguments);this._any=!0}_parse(D){return o(D.data)}}iD.create=(D)=>{return new iD({typeName:M.ZodAny,...T(D)})};class ZD extends f{constructor(){super(...arguments);this._unknown=!0}_parse(D){return o(D.data)}}ZD.create=(D)=>{return new ZD({typeName:M.ZodUnknown,...T(D)})};class UD extends f{_parse(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:U.never,received:F.parsedType}),j}}UD.create=(D)=>{return new UD({typeName:M.ZodNever,...T(D)})};class i2 extends f{_parse(D){if(this._getType(D)!==U.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.void,received:E.parsedType}),j}return o(D.data)}}i2.create=(D)=>{return new i2({typeName:M.ZodVoid,...T(D)})};class QD extends f{_parse(D){let{ctx:F,status:E}=this._processInputParams(D),B=this._def;if(F.parsedType!==U.array)return C(F,{code:W.invalid_type,expected:U.array,received:F.parsedType}),j;if(B.exactLength!==null){let X=F.data.length>B.exactLength.value,Q=F.data.length<B.exactLength.value;if(X||Q)C(F,{code:X?W.too_big:W.too_small,minimum:Q?B.exactLength.value:void 0,maximum:X?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((X,Q)=>{return B.type._parseAsync(new YD(F,X,F.path,Q))})).then((X)=>{return n.mergeArray(E,X)});let $=[...F.data].map((X,Q)=>{return B.type._parseSync(new YD(F,X,F.path,Q))});return n.mergeArray(E,$)}get element(){return this._def.type}min(D,F){return new QD({...this._def,minLength:{value:D,message:V.toString(F)}})}max(D,F){return new QD({...this._def,maxLength:{value:D,message:V.toString(F)}})}length(D,F){return new QD({...this._def,exactLength:{value:D,message:V.toString(F)}})}nonempty(D){return this.min(1,D)}}QD.create=(D,F)=>{return new QD({type:D,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...T(F)})};function C2(D){if(D instanceof y){let F={};for(let E in D.shape){let B=D.shape[E];F[E]=JD.create(C2(B))}return new y({...D._def,shape:()=>F})}else if(D instanceof QD)return new QD({...D._def,type:C2(D.element)});else if(D instanceof JD)return JD.create(C2(D.unwrap()));else if(D instanceof OD)return OD.create(C2(D.unwrap()));else if(D instanceof AD)return AD.create(D.items.map((F)=>C2(F)));else return D}class y extends f{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=w.objectKeys(D);return this._cached={shape:D,keys:F},this._cached}_parse(D){if(this._getType(D)!==U.object){let Y=this._getOrReturnCtx(D);return C(Y,{code:W.invalid_type,expected:U.object,received:Y.parsedType}),j}let{status:E,ctx:B}=this._processInputParams(D),{shape:$,keys:X}=this._getCached(),Q=[];if(!(this._def.catchall instanceof UD&&this._def.unknownKeys==="strip")){for(let Y in B.data)if(!X.includes(Y))Q.push(Y)}let J=[];for(let Y of X){let q=$[Y],H=B.data[Y];J.push({key:{status:"valid",value:Y},value:q._parse(new YD(B,H,B.path,Y)),alwaysSet:Y in B.data})}if(this._def.catchall instanceof UD){let Y=this._def.unknownKeys;if(Y==="passthrough")for(let q of Q)J.push({key:{status:"valid",value:q},value:{status:"valid",value:B.data[q]}});else if(Y==="strict"){if(Q.length>0)C(B,{code:W.unrecognized_keys,keys:Q}),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 Q){let H=B.data[q];J.push({key:{status:"valid",value:q},value:Y._parse(new YD(B,H,B.path,q)),alwaysSet:q in B.data})}}if(B.common.async)return Promise.resolve().then(async()=>{let Y=[];for(let q of J){let H=await q.key,_=await q.value;Y.push({key:H,value:_,alwaysSet:q.alwaysSet})}return Y}).then((Y)=>{return n.mergeObjectSync(E,Y)});else return n.mergeObjectSync(E,J)}get shape(){return this._def.shape()}strict(D){return V.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:V.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 w.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 w.objectKeys(this.shape))if(!D[E])F[E]=this.shape[E];return new y({...this._def,shape:()=>F})}deepPartial(){return C2(this)}partial(D){let F={};for(let E of w.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 w.objectKeys(this.shape))if(D&&!D[E])F[E]=this.shape[E];else{let $=this.shape[E];while($ instanceof JD)$=$._def.innerType;F[E]=$}return new y({...this._def,shape:()=>F})}keyof(){return s8(w.objectKeys(this.shape))}}y.create=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strip",catchall:UD.create(),typeName:M.ZodObject,...T(F)})};y.strictCreate=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strict",catchall:UD.create(),typeName:M.ZodObject,...T(F)})};y.lazycreate=(D,F)=>{return new y({shape:D,unknownKeys:"strip",catchall:UD.create(),typeName:M.ZodObject,...T(F)})};class j2 extends f{_parse(D){let{ctx:F}=this._processInputParams(D),E=this._def.options;function B($){for(let Q of $)if(Q.result.status==="valid")return Q.result;for(let Q of $)if(Q.result.status==="dirty")return F.common.issues.push(...Q.ctx.common.issues),Q.result;let X=$.map((Q)=>new t(Q.ctx.common.issues));return C(F,{code:W.invalid_union,unionErrors:X}),j}if(F.common.async)return Promise.all(E.map(async($)=>{let X={...F,common:{...F.common,issues:[]},parent:null};return{result:await $._parseAsync({data:F.data,path:F.path,parent:X}),ctx:X}})).then(B);else{let $=void 0,X=[];for(let J of E){let Y={...F,common:{...F.common,issues:[]},parent:null},q=J._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)X.push(Y.common.issues)}if($)return F.common.issues.push(...$.ctx.common.issues),$.result;let Q=X.map((J)=>new t(J));return C(F,{code:W.invalid_union,unionErrors:Q}),j}}get options(){return this._def.options}}j2.create=(D,F)=>{return new j2({options:D,typeName:M.ZodUnion,...T(F)})};var MD=(D)=>{if(D instanceof M2)return MD(D.schema);else if(D instanceof qD)return MD(D.innerType());else if(D instanceof O2)return[D.value];else if(D instanceof xD)return D.options;else if(D instanceof N2)return w.objectValues(D.enum);else if(D instanceof S2)return MD(D._def.innerType);else if(D instanceof R2)return[void 0];else if(D instanceof K2)return[null];else if(D instanceof JD)return[void 0,...MD(D.unwrap())];else if(D instanceof OD)return[null,...MD(D.unwrap())];else if(D instanceof L0)return MD(D.unwrap());else if(D instanceof b2)return MD(D.unwrap());else if(D instanceof T2)return MD(D._def.innerType);else return[]};class j0 extends f{_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==U.object)return C(F,{code:W.invalid_type,expected:U.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 X=MD($.shape[D]);if(!X.length)throw Error(`A discriminator value for key \`${D}\` could not be extracted from all schema options`);for(let Q of X){if(B.has(Q))throw Error(`Discriminator property ${String(D)} has duplicate value ${String(Q)}`);B.set(Q,$)}}return new j0({typeName:M.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:B,...T(E)})}}function H3(D,F){let E=GD(D),B=GD(F);if(D===F)return{valid:!0,data:D};else if(E===U.object&&B===U.object){let $=w.objectKeys(F),X=w.objectKeys(D).filter((J)=>$.indexOf(J)!==-1),Q={...D,...F};for(let J of X){let Y=H3(D[J],F[J]);if(!Y.valid)return{valid:!1};Q[J]=Y.data}return{valid:!0,data:Q}}else if(E===U.array&&B===U.array){if(D.length!==F.length)return{valid:!1};let $=[];for(let X=0;X<D.length;X++){let Q=D[X],J=F[X],Y=H3(Q,J);if(!Y.valid)return{valid:!1};$.push(Y.data)}return{valid:!0,data:$}}else if(E===U.date&&B===U.date&&+D===+F)return{valid:!0,data:D};else return{valid:!1}}class L2 extends f{_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=($,X)=>{if(R0($)||R0(X))return j;let Q=H3($.value,X.value);if(!Q.valid)return C(E,{code:W.invalid_intersection_types}),j;if(K0($)||K0(X))F.dirty();return{status:F.value,value:Q.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(([$,X])=>B($,X));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}))}}L2.create=(D,F,E)=>{return new L2({left:D,right:F,typeName:M.ZodIntersection,...T(E)})};class AD extends f{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==U.array)return C(E,{code:W.invalid_type,expected:U.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((X,Q)=>{let J=this._def.items[Q]||this._def.rest;if(!J)return null;return J._parse(new YD(E,X,E.path,Q))}).filter((X)=>!!X);if(E.common.async)return Promise.all($).then((X)=>{return n.mergeArray(F,X)});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 n2 extends f{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!==U.object)return C(E,{code:W.invalid_type,expected:U.object,received:E.parsedType}),j;let B=[],$=this._def.keyType,X=this._def.valueType;for(let Q in E.data)B.push({key:$._parse(new YD(E,Q,E.path,Q)),value:X._parse(new YD(E,E.data[Q],E.path,Q)),alwaysSet:Q 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 f)return new n2({keyType:D,valueType:F,typeName:M.ZodRecord,...T(E)});return new n2({keyType:XD.create(),valueType:D,typeName:M.ZodRecord,...T(F)})}}class r2 extends f{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!==U.map)return C(E,{code:W.invalid_type,expected:U.map,received:E.parsedType}),j;let B=this._def.keyType,$=this._def.valueType,X=[...E.data.entries()].map(([Q,J],Y)=>{return{key:B._parse(new YD(E,Q,E.path,[Y,"key"])),value:$._parse(new YD(E,J,E.path,[Y,"value"]))}});if(E.common.async){let Q=new Map;return Promise.resolve().then(async()=>{for(let J of X){let Y=await J.key,q=await J.value;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();Q.set(Y.value,q.value)}return{status:F.value,value:Q}})}else{let Q=new Map;for(let J of X){let{key:Y,value:q}=J;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();Q.set(Y.value,q.value)}return{status:F.value,value:Q}}}}r2.create=(D,F,E)=>{return new r2({valueType:F,keyType:D,typeName:M.ZodMap,...T(E)})};class nD extends f{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==U.set)return C(E,{code:W.invalid_type,expected:U.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 X(J){let Y=new Set;for(let q of J){if(q.status==="aborted")return j;if(q.status==="dirty")F.dirty();Y.add(q.value)}return{status:F.value,value:Y}}let Q=[...E.data.values()].map((J,Y)=>$._parse(new YD(E,J,E.path,Y)));if(E.common.async)return Promise.all(Q).then((J)=>X(J));else return X(Q)}min(D,F){return new nD({...this._def,minSize:{value:D,message:V.toString(F)}})}max(D,F){return new nD({...this._def,maxSize:{value:D,message:V.toString(F)}})}size(D,F){return this.min(D,F).max(D,F)}nonempty(D){return this.min(1,D)}}nD.create=(D,F)=>{return new nD({valueType:D,minSize:null,maxSize:null,typeName:M.ZodSet,...T(F)})};class z2 extends f{constructor(){super(...arguments);this.validate=this.implement}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==U.function)return C(F,{code:W.invalid_type,expected:U.function,received:F.parsedType}),j;function E(Q,J){return c2({data:Q,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,U2(),LD].filter((Y)=>!!Y),issueData:{code:W.invalid_arguments,argumentsError:J}})}function B(Q,J){return c2({data:Q,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,U2(),LD].filter((Y)=>!!Y),issueData:{code:W.invalid_return_type,returnTypeError:J}})}let $={errorMap:F.common.contextualErrorMap},X=F.data;if(this._def.returns instanceof rD){let Q=this;return o(async function(...J){let Y=new t([]),q=await Q._def.args.parseAsync(J,$).catch((G)=>{throw Y.addIssue(E(J,G)),Y}),H=await Reflect.apply(X,this,q);return await Q._def.returns._def.type.parseAsync(H,$).catch((G)=>{throw Y.addIssue(B(H,G)),Y})})}else{let Q=this;return o(function(...J){let Y=Q._def.args.safeParse(J,$);if(!Y.success)throw new t([E(J,Y.error)]);let q=Reflect.apply(X,this,Y.data),H=Q._def.returns.safeParse(q,$);if(!H.success)throw new t([B(q,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new z2({...this._def,args:AD.create(D).rest(ZD.create())})}returns(D){return new z2({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,E){return new z2({args:D?D:AD.create([]).rest(ZD.create()),returns:F||ZD.create(),typeName:M.ZodFunction,...T(E)})}}class M2 extends f{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})}}M2.create=(D,F)=>{return new M2({getter:D,typeName:M.ZodLazy,...T(F)})};class O2 extends f{_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}}O2.create=(D,F)=>{return new O2({value:D,typeName:M.ZodLiteral,...T(F)})};function s8(D,F){return new xD({values:D,typeName:M.ZodEnum,...T(F)})}class xD extends f{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{expected:w.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 o(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 xD.create(D,{...this._def,...F})}exclude(D,F=this._def){return xD.create(this.options.filter((E)=>!D.includes(E)),{...this._def,...F})}}xD.create=s8;class N2 extends f{_parse(D){let F=w.getValidEnumValues(this._def.values),E=this._getOrReturnCtx(D);if(E.parsedType!==U.string&&E.parsedType!==U.number){let B=w.objectValues(F);return C(E,{expected:w.joinValues(B),received:E.parsedType,code:W.invalid_type}),j}if(!this._cache)this._cache=new Set(w.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let B=w.objectValues(F);return C(E,{received:E.data,code:W.invalid_enum_value,options:B}),j}return o(D.data)}get enum(){return this._def.values}}N2.create=(D,F)=>{return new N2({values:D,typeName:M.ZodNativeEnum,...T(F)})};class rD extends f{unwrap(){return this._def.type}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==U.promise&&F.common.async===!1)return C(F,{code:W.invalid_type,expected:U.promise,received:F.parsedType}),j;let E=F.parsedType===U.promise?F.data:Promise.resolve(F.data);return o(E.then((B)=>{return this._def.type.parseAsync(B,{path:F.path,errorMap:F.common.contextualErrorMap})}))}}rD.create=(D,F)=>{return new rD({type:D,typeName:M.ZodPromise,...T(F)})};class qD extends f{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:(X)=>{if(C(E,X),X.fatal)F.abort();else F.dirty()},get path(){return E.path}};if($.addIssue=$.addIssue.bind($),B.type==="preprocess"){let X=B.transform(E.data,$);if(E.common.async)return Promise.resolve(X).then(async(Q)=>{if(F.value==="aborted")return j;let J=await this._def.schema._parseAsync({data:Q,path:E.path,parent:E});if(J.status==="aborted")return j;if(J.status==="dirty")return cD(J.value);if(F.value==="dirty")return cD(J.value);return J});else{if(F.value==="aborted")return j;let Q=this._def.schema._parseSync({data:X,path:E.path,parent:E});if(Q.status==="aborted")return j;if(Q.status==="dirty")return cD(Q.value);if(F.value==="dirty")return cD(Q.value);return Q}}if(B.type==="refinement"){let X=(Q)=>{let J=B.refinement(Q,$);if(E.common.async)return Promise.resolve(J);if(J instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Q};if(E.common.async===!1){let Q=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(Q.status==="aborted")return j;if(Q.status==="dirty")F.dirty();return X(Q.value),{status:F.value,value:Q.value}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((Q)=>{if(Q.status==="aborted")return j;if(Q.status==="dirty")F.dirty();return X(Q.value).then(()=>{return{status:F.value,value:Q.value}})})}if(B.type==="transform")if(E.common.async===!1){let X=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(!uD(X))return j;let Q=B.transform(X.value,$);if(Q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:F.value,value:Q}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((X)=>{if(!uD(X))return j;return Promise.resolve(B.transform(X.value,$)).then((Q)=>({status:F.value,value:Q}))});w.assertNever(B)}}qD.create=(D,F,E)=>{return new qD({schema:D,typeName:M.ZodEffects,effect:F,...T(E)})};qD.createWithPreprocess=(D,F,E)=>{return new qD({schema:F,effect:{type:"preprocess",transform:D},typeName:M.ZodEffects,...T(E)})};class JD extends f{_parse(D){if(this._getType(D)===U.undefined)return o(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}JD.create=(D,F)=>{return new JD({innerType:D,typeName:M.ZodOptional,...T(F)})};class OD extends f{_parse(D){if(this._getType(D)===U.null)return o(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}OD.create=(D,F)=>{return new OD({innerType:D,typeName:M.ZodNullable,...T(F)})};class S2 extends f{_parse(D){let{ctx:F}=this._processInputParams(D),E=F.data;if(F.parsedType===U.undefined)E=this._def.defaultValue();return this._def.innerType._parse({data:E,path:F.path,parent:F})}removeDefault(){return this._def.innerType}}S2.create=(D,F)=>{return new S2({innerType:D,typeName:M.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...T(F)})};class T2 extends f{_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(A2(B))return B.then(($)=>{return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new t(E.common.issues)},input:E.data})}});else return{status:"valid",value:B.status==="valid"?B.value:this._def.catchValue({get error(){return new t(E.common.issues)},input:E.data})}}removeCatch(){return this._def.innerType}}T2.create=(D,F)=>{return new T2({innerType:D,typeName:M.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...T(F)})};class a2 extends f{_parse(D){if(this._getType(D)!==U.nan){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:U.nan,received:E.parsedType}),j}return{status:"valid",value:D.data}}}a2.create=(D)=>{return new a2({typeName:M.ZodNaN,...T(D)})};var R7=Symbol("zod_brand");class L0 extends f{_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 o2 extends f{_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(),cD($.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 o2({in:D,out:F,typeName:M.ZodPipeline})}}class b2 extends f{_parse(D){let F=this._def.innerType._parse(D),E=(B)=>{if(uD(B))B.value=Object.freeze(B.value);return B};return A2(F)?F.then((B)=>E(B)):E(F)}unwrap(){return this._def.innerType}}b2.create=(D,F)=>{return new b2({innerType:D,typeName:M.ZodReadonly,...T(F)})};function n8(D,F){let E=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof E==="string"?{message:E}:E}function t8(D,F={},E){if(D)return iD.create().superRefine((B,$)=>{let X=D(B);if(X instanceof Promise)return X.then((Q)=>{if(!Q){let J=n8(F,B),Y=J.fatal??E??!0;$.addIssue({code:"custom",...J,fatal:Y})}});if(!X){let Q=n8(F,B),J=Q.fatal??E??!0;$.addIssue({code:"custom",...Q,fatal:J})}return});return iD.create()}var K7={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 j7=(D,F={message:`Input not instance of ${D.name}`})=>t8((E)=>E instanceof D,F),e8=XD.create,D6=vD.create,L7=a2.create,M7=kD.create,F6=V2.create,O7=dD.create,N7=d2.create,S7=R2.create,T7=K2.create,b7=iD.create,P7=ZD.create,f7=UD.create,w7=i2.create,I7=QD.create,u7=y.create,Z7=y.strictCreate,v7=j2.create,k7=j0.create,x7=L2.create,y7=AD.create,h7=n2.create,g7=r2.create,l7=nD.create,m7=z2.create,p7=M2.create,c7=O2.create,d7=xD.create,i7=N2.create,n7=rD.create,r7=qD.create,a7=JD.create,o7=OD.create,s7=qD.createWithPreprocess,t7=o2.create,e7=()=>e8().optional(),D9=()=>D6().optional(),F9=()=>F6().optional(),E9={string:(D)=>XD.create({...D,coerce:!0}),number:(D)=>vD.create({...D,coerce:!0}),boolean:(D)=>V2.create({...D,coerce:!0}),bigint:(D)=>kD.create({...D,coerce:!0}),date:(D)=>dD.create({...D,coerce:!0})};var B9=j;var $9=I.object({name:I.string().default("genie"),defaultWindow:I.string().default("shell"),autoCreate:I.boolean().default(!0)}),X9=I.object({execTimeout:I.number().default(120000),readLines:I.number().default(100),worktreeBase:I.string().default(".worktrees")}),Q9=I.object({tmuxDebug:I.boolean().default(!1),verbose:I.boolean().default(!1)}),J9=I.object({preference:I.enum(["auto","zsh","bash","fish"]).default("auto")}),Y9=I.object({tmuxInstalled:I.boolean().default(!1),shellInstalled:I.boolean().default(!1)}),q9=I.object({enabled:I.boolean().default(!1)}),HD=I.object({version:I.number().default(2),session:$9.default({}),terminal:X9.default({}),logging:Q9.default({}),shell:J9.default({}),shortcuts:Y9.default({}),claudio:q9.optional(),installMethod:I.enum(["source","npm","bun"]).optional(),setupComplete:I.boolean().default(!1),lastSetupAt:I.string().optional()}),E6=I.object({session:I.object({name:I.string().default("genie"),defaultWindow:I.string().default("shell")}).default({}),logging:I.object({tmuxDebug:I.boolean().default(!1)}).default({}),installMethod:I.enum(["source","npm","bun"]).optional()});var M0=X6($6(),".genie"),aD=X6(M0,"config.json"),_3=2;function W$(){return M0}function G$(){return aD}function W9(){return O0(aD)}function G9(){if(!O0(M0))H9(M0,{recursive:!0})}function Q6(D){let F=E6.safeParse(D);if(F.success){let E=F.data;return HD.parse({version:_3,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 HD.parse({})}async function J6(){if(!O0(aD))return HD.parse({});try{let D=B6(aD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<_3){let E=Q6(F);return await N0(E),E}return HD.parse(F)}catch(D){return console.warn(`Warning: Invalid genie config, using defaults: ${D.message}`),HD.parse({})}}async function N0(D){G9();try{let F=HD.parse(D),E=JSON.stringify(F,null,2);_9(aD,E,"utf-8")}catch(F){throw Error(`Failed to save genie config: ${F.message}`)}}function U9(){return HD.parse({})}function Y6(){if(!O0(aD))return HD.parse({});try{let D=B6(aD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<_3)return Q6(F);return HD.parse(F)}catch{return HD.parse({})}}function U$(D){let F=$6();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}function S0(){return Y6().terminal}function A$(){if(!W9())return!1;return Y6().setupComplete??!1}async function C$(){let D=await J6();D.setupComplete=!0,D.lastSetupAt=new Date().toISOString(),await N0(D)}async function z$(){let D=U9();await N0(D)}async function V$(D){let F=await J6();F.shortcuts={...F.shortcuts,...D},await N0(F)}async function q6(D,F){try{let B=S0().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 Q=await c8(D,(J)=>{console.log(J)});process.on("SIGINT",()=>{Q(),console.log(`
|
|
51
|
+
Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let X=await p8(D,$);if(F.json){let Q=X.split(`
|
|
52
|
+
`);console.log(JSON.stringify({session:D,lineCount:Q.length,content:Q},null,2));return}console.log(X)}catch(E){console.error(`Error reading session logs: ${E.message}`),process.exit(1)}}async function H6(D,F,E={}){let[B,$]=D.includes(":")?D.split(":"):[D,"shell"];try{let X=await Z(B);if(!X){if(!E.quiet)console.error(`Session "${B}" not found, creating...`);if(X=await pD(B),!X)console.error(`Failed to create session "${B}"`),process.exit(1)}let J=(await k(X.id)).find((A)=>A.name===$);if(!J){if(!E.quiet)console.error(`Window "${$}" not found, creating...`);if(J=await A0(X.id,$),!J)console.error(`Failed to create window "${$}"`),process.exit(1)}let Y=await l(J.id);if(!Y||Y.length===0)console.error(`No panes found in window "${$}"`),process.exit(1);let q=S0(),H=E.timeout??q.execTimeout,{output:_,exitCode:G}=await f8(Y[0].id,F,H);if(_&&!E.quiet)console.log(_);process.exit(G)}catch(X){console.error(`Error: ${X.message}`),process.exit(1)}}async function _6(D,F){try{let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await k(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await l(B[0].id);if(!$||$.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let X=$[0].id;await DD(X,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 V9}from"path";async function W6(D,F,E={}){try{let B=await Z(D);if(!B)console.error(`\u274C Session "${D}" not found`),process.exit(1);let $=await k(B.id);if(!$||$.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let X=await l($[0].id);if(!X||X.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let Q=X[0].id,J=F==="h"?"horizontal":"vertical",Y=await S(`display-message -p -t '${Q}' '#{pane_current_path}'`),q;if(E.worktree){if(!E.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let _=G2({baseDir:V9(E.workspace,".worktrees"),repoPath:E.workspace});if(!await _.worktreeExists(E.worktree)){let A=await _.createWorktree(E.worktree,!0);console.log(`\u2705 Worktree created at ${A.path}`)}q=_.getWorktreePath(E.worktree)}else if(E.workspace)q=E.workspace;else q=Y.trim()||void 0;if(!await z0(Q,J,void 0,q))console.error("\u274C Failed to split pane"),process.exit(1);if(console.log(`\u2705 Pane split ${J}ly in session "${D}"`),q)console.log(` Working directory: ${q}`)}catch(B){console.error(`\u274C Error splitting pane: ${B.message}`),process.exit(1)}}async function G6(D,F){await S(`set-hook -g ${D} '${F.replace(/'/g,"'\\''")}'`)}async function U6(D){await S(`set-hook -gu ${D}`)}async function A6(){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 C6(D,F){try{await G6(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 z6(){try{let D=await A6();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 V6(D){try{await U6(D),console.log(`\u2705 Hook removed: ${D}`)}catch(F){console.error(`\u274C Error removing hook: ${F.message}`),process.exit(1)}}async function R6(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await k(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 X=$.active?"yes":"no";console.log(`${$.id} ${$.name} ${X}`)}}catch(E){console.error(`Error listing windows: ${E.message}`),process.exit(1)}}async function K6(D,F){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await A0(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 j6(D){try{await b8(D),console.log(`Window removed: ${D}`)}catch(F){console.error(`Error removing window: ${F.message}`),process.exit(1)}}async function L6(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await k(E.id);if(B.length===0){if(F.json)console.log("[]");else console.log("No panes found");return}let $=[];for(let X of B){let Q=await l(X.id);for(let J of Q)$.push({id:J.id,windowId:X.id,windowName:X.name,title:J.title,active:J.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 X of $){let Q=X.active?"yes":"no",J=X.title||"-";console.log(`${X.id} ${X.windowName} ${J} ${Q}`)}}catch(E){console.error(`Error listing panes: ${E.message}`),process.exit(1)}}async function M6(D){try{await _2(D),console.log(`Pane removed: ${D}`)}catch(F){console.error(`Error removing pane: ${F.message}`),process.exit(1)}}async function O6(D,F={}){try{if(F.command){await O9(F.command,F.json);return}let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await k(E.id),$=0;for(let J of B){let Y=await l(J.id);$+=Y.length}let X="idle",Q={session:E.name,id:E.id,attached:E.attached,windows:B.length,panes:$,state:X};if(F.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(E){console.error(`Error getting status: ${E.message}`),process.exit(1)}}async function O9(D,F){try{let E=await P8(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
|
-
${
|
|
54
|
+
${B.result}`)}catch(E){console.error(`Error getting command status: ${E.message}`),process.exit(1)}}import{homedir as N6}from"os";import{join as _D}from"path";import{existsSync as oD,readFileSync as S6,writeFileSync as S9,mkdirSync as T9,appendFileSync as W3}from"fs";import*as T6 from"readline";function b6(){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
|
|
@@ -56,13 +62,13 @@ bind-key -n C-s split-window -v -c "#{pane_current_path}"
|
|
|
56
62
|
|
|
57
63
|
# Ctrl+Shift+S: Horizontal split
|
|
58
64
|
bind-key -n C-S split-window -h -c "#{pane_current_path}"
|
|
59
|
-
`}function
|
|
65
|
+
`}function P6(){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
|
|
71
|
+
`}function b9(){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)
|
|
@@ -99,7 +105,7 @@ 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
|
|
108
|
+
`}function P9(){console.log(`
|
|
103
109
|
Warp-like Terminal Shortcuts for tmux + Termux
|
|
104
110
|
|
|
105
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
|
|
@@ -118,19 +124,68 @@ 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
|
|
122
|
-
`);let
|
|
123
|
-
`+
|
|
124
|
-
`+
|
|
125
|
-
|
|
127
|
+
`)}async function P2(D){let F=T6.createInterface({input:process.stdin,output:process.stdout});return new Promise((E)=>{F.question(D,(B)=>{F.close(),E(B.trim().toLowerCase())})})}function sD(D,F){if(!oD(D))return!1;return S6(D,"utf-8").includes(F)}async function f9(){let D=N6(),F="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
|
|
128
|
+
`);let E=_D(D,".tmux.conf");if(sD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await P2(`Add shortcuts to ${E}? [Y/n] `)!=="n"){let Y=`
|
|
129
|
+
`+b6();W3(E,Y),console.log(`\u2705 Added to ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=oD(_D(D,".zshrc"))?_D(D,".zshrc"):_D(D,".bashrc");if(sD(B,"generated by genie-cli"))console.log(`\u2713 ${B} already has genie shortcuts`);else if(await P2(`Add shell functions to ${B}? [Y/n] `)!=="n"){let Y=`
|
|
130
|
+
`+b9();W3(B,Y),console.log(`\u2705 Added to ${B}`)}else console.log(`\u23ED\uFE0F Skipped ${B}`);let $=_D(D,".termux"),X=_D($,"termux.properties"),Q=oD($)||process.env.TERMUX_VERSION;if(Q)if(sD(X,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await P2(`Add extra keys to ${X}? [Y/n] `)!=="n"){if(!oD($))T9($,{recursive:!0});let Y=`
|
|
131
|
+
`+P6();W3(X,Y),console.log(`\u2705 Added to ${X}`),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"),
|
|
128
|
-
`)
|
|
133
|
+
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 b$(D){return sD(D,"generated by genie-cli")}function G3(D,F){if(!oD(D))return!1;let E=S6(D,"utf-8");if(!E.includes(F))return!1;let B=E.split(`
|
|
134
|
+
`),$=[],X=!1,Q=-1;for(let Y=0;Y<B.length;Y++){let q=B[Y];if(q.includes(F)&&!X){if(X=!0,Q===-1&&$.length>0&&$[$.length-1].trim()==="")$.pop();continue}if(X){if(q.trim()===""&&Y+1<B.length&&!B[Y+1].includes("genie")){X=!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()!=="")X=!1,$.push(q);continue}$.push(q)}while($.length>0&&$[$.length-1].trim()==="")$.pop();let J=$.length>0?$.join(`
|
|
129
135
|
`)+`
|
|
130
|
-
`:"";return
|
|
131
|
-
`);let
|
|
136
|
+
`:"";return S9(D,J),!0}async function P$(){let D=N6(),F="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
|
|
137
|
+
`);let E=_D(D,".tmux.conf");if(!sD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await P2(`Remove shortcuts from ${E}? [Y/n] `)!=="n"){if(G3(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(!oD(Y))continue;if(!sD(Y,"generated by genie-cli"))console.log(`\u2713 ${Y} has no genie shortcuts`);else if(await P2(`Remove shell functions from ${Y}? [Y/n] `)!=="n"){if(G3(Y,"generated by genie-cli"))console.log(`\u2705 Removed from ${Y}`)}else console.log(`\u23ED\uFE0F Skipped ${Y}`)}let X=_D(D,".termux"),Q=_D(X,"termux.properties"),J=oD(X)||process.env.TERMUX_VERSION;if(J)if(!sD(Q,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await P2(`Remove extra keys from ${Q}? [Y/n] `)!=="n"){if(G3(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(`
|
|
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"),
|
|
139
|
+
Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),J)console.log(" 3. Reload Termux: termux-reload-settings")}async function f6(D){if(D.tmux)console.log(b6());else if(D.termux)console.log(P6());else if(D.install)await f9();else P9()}var f2=[{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}],T0=[{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}],w6=[{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]})}],I6=[{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}],u6=[{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/}],Z6=[{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}],v6=[{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]})}],I9=[{type:"claude_plan_file",pattern:/(~\/\.claude\/plans\/[\w-]+\.md|\/[^\s]+\/\.claude\/plans\/[\w-]+\.md)/,extract:(D)=>({path:D[1]})}];function FD(D){return D.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function k6(D){let F=FD(D),E=w2(F,I9);if(E?.extracted?.path){let B=E.extracted.path;if(B.startsWith("~"))B=B.replace("~",process.env.HOME||"");return B}return null}function s2(D,F){let E=FD(D),B=[];for(let $ of F){let X=new RegExp($.pattern.source,$.pattern.flags||"g"),Q;while((Q=X.exec(E))!==null)if(B.push({type:$.type,match:Q,extracted:$.extract?$.extract(Q):void 0}),!$.pattern.flags?.includes("g"))break}return B}function t2(D,F){return s2(D,F).length>0}function w2(D,F){let E=s2(D,F);return E.length>0?E[0]:null}function ED(D,F={}){let{linesToAnalyze:E=50,minConfidence:B=0.3}=F,$=D.split(`
|
|
140
|
+
`),X=$.slice(-E).join(`
|
|
141
|
+
`),Q=FD(X),Y={timestamp:Date.now(),rawOutput:X},q=w2(Q,f2);if(q)return{...Y,type:"permission",detail:q.type.replace("_permission",""),confidence:0.9};let H=t2(Q,T0.filter((c)=>c.type==="claude_code_plan_approval")),_=$.slice(-15).join(`
|
|
142
|
+
`),G=FD(_),A=s2(G,T0);if(A.length>0||H){let c=A.filter((a)=>a.type==="claude_code_numbered_options"&&a.extracted?.option).map((a)=>a.extracted.option);if(c.length>=2||H)return{...Y,type:"question",options:c.length>0?c:void 0,detail:H?"plan_approval":void 0,confidence:0.85};let e=A.filter((a)=>a.extracted?.option&&a.type!=="claude_code_numbered_options").map((a)=>a.extracted.option);if(e.length>=2)return{...Y,type:"question",options:e,confidence:0.85}}let z=A.find((c)=>c.type==="yes_no_question");if(z)return{...Y,type:"question",options:["Yes","No"],detail:`default: ${z.extracted?.default||"y"}`,confidence:0.85};let K=w2(Q,w6);if(K)return{...Y,type:"error",detail:K.extracted?.message||K.match[0],confidence:0.8};let O=w2(Q,v6);if(O)return{...Y,type:"tool_use",detail:`${O.type}: ${O.extracted?.command||O.extracted?.file||O.extracted?.query||""}`,confidence:0.75};if(t2(Q,u6))return{...Y,type:"working",confidence:0.7};if(t2(Q,I6))return{...Y,type:"complete",confidence:0.6};let L=$.slice(-5).join(`
|
|
143
|
+
`),N=FD(L);if(t2(N,Z6))return{...Y,type:"idle",confidence:0.7};let u=N.trim();if(u.endsWith(">")||u.match(/>\s*$/))return{...Y,type:"idle",detail:"prompt detected",confidence:0.65};return{...Y,type:"unknown",confidence:B}}function x6(D,F){let E=ED(D),B=ED(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 y6(D){let F=FD(D),E=w2(F,f2);if(!E)return null;let B=F.split(`
|
|
144
|
+
`),$=B.findIndex((J)=>J.match(f2[0].pattern)||J.match(f2[1].pattern)||J.match(f2[2].pattern)),X,Q;if($>0){let J=B.slice(Math.max(0,$-5),$).join(`
|
|
145
|
+
`),Y=J.match(/(?:Command|command|Bash|bash):\s*(.+)/);if(Y)X=Y[1].trim();let q=J.match(/(?:File|file|Path|path):\s*(.+)/);if(q)Q=q[1].trim()}return{type:E.type.replace("_permission",""),command:X,file:Q}}function U3(D){let F=FD(D),E=s2(F,T0),B=[];for(let $ of E)if($.extracted?.option)B.push($.extracted.option);return B}import{EventEmitter as u9}from"events";class CD extends u9{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 k(D.id);if(!F||F.length===0)throw Error(`No windows found in session "${this.sessionName}"`);let E=await l(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=ED(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 $=x6(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],X=B.lastIndexOf($);if(X>=0&&X<B.length-1)return B.slice(X+1).join(`
|
|
148
|
+
`);let Q=new Set(E),J=B.filter((Y)=>!Q.has(Y));return J.length>0?J.join(`
|
|
149
|
+
`):null}emitEvent(D){this.emit(D.type,D),this.emit("event",D)}}async function h6(D,F,E=120000){return new Promise((B,$)=>{let Q=Date.now(),J=setTimeout(()=>{H(),$(Error("Timeout waiting for silence"))},E),Y=()=>{Q=Date.now()},q=setInterval(()=>{if(Date.now()-Q>=F)H(),B()},100),H=()=>{clearTimeout(J),clearInterval(q),D.off("activity",Y)};D.on("activity",Y)})}async function g6(D,F={}){let{silenceMs:E=3000,timeoutMs:B=120000,requireIdle:$=!0}=F;return new Promise((X,Q)=>{let J=setTimeout(()=>{A(),Q(Error("Timeout waiting for completion"))},B),Y=Date.now(),q=null,H=(z)=>{if(z.state)A(),X({state:z.state,reason:"complete event"})},_=()=>{Y=Date.now()},G=(z)=>{if(z.state?.type==="permission"||z.state?.type==="question")return;if($&&z.state?.type==="idle")A(),X({state:z.state,reason:"idle state"});if(z.state?.type==="error")A(),X({state:z.state,reason:"error"})},A=()=>{if(clearTimeout(J),q)clearInterval(q);D.off("complete",H),D.off("activity",_),D.off("state_change",G)};q=setInterval(()=>{let z=Date.now()-Y,K=D.getCurrentState();if(z>=E){if(K&&(K.type==="idle"||K.type==="complete"||K.type==="error"))A(),X({state:K,reason:`silence (${z}ms)`});else if(!$)A(),X({state:K||{type:"unknown",timestamp:Date.now(),rawOutput:"",confidence:0},reason:`silence (${z}ms) - non-idle`})}},500),D.on("complete",H),D.on("activity",_),D.on("state_change",G)})}function tD(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 h6(E,D,B);let X=Date.now()-$;return{complete:!0,state:E.getCurrentState()||void 0,reason:`silence for ${D}ms`,latencyMs:X,method:this.name}}catch(X){return{complete:!1,reason:X instanceof Error?X.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 b0(){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 g6(F,{timeoutMs:E,requireIdle:!0,silenceMs:2000}),X=Date.now()-B;return{complete:!0,state:$.state,reason:$.reason,latencyMs:X,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 A3(D,F,E={}){let{primaryTimeoutMs:B=30000,fallbackTimeoutMs:$=90000}=E,X={name:`hybrid(${D.name},${F.name})`,totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:X.name,description:`Try ${D.name} first, fall back to ${F.name}`,metrics:X,async detect(Q,J=120000){let Y=Date.now(),q=await D.detect(Q,Math.min(B,J));if(q.complete)return{...q,method:this.name,reason:`primary(${q.reason})`};let H=J-(Date.now()-Y);if(H<=0)return{complete:!1,reason:"timeout after primary method",latencyMs:Date.now()-Y,method:this.name};let _=await F.detect(Q,Math.min($,H));return{..._,method:this.name,reason:`fallback(${_.reason})`,latencyMs:Date.now()-Y}},recordResult(Q,J,Y){if(X.totalRuns++,X.avgLatencyMs=(X.avgLatencyMs*(X.totalRuns-1)+Q)/X.totalRuns,X.minLatencyMs=Math.min(X.minLatencyMs,Q),X.maxLatencyMs=Math.max(X.maxLatencyMs,Q),!J)if(Y)X.falsePositives++;else X.falseNegatives++;X.successRate=(X.totalRuns-X.falsePositives-X.falseNegatives)/X.totalRuns}}}function P0(){return A3(b0(),tD(5000),{primaryTimeoutMs:30000,fallbackTimeoutMs:90000})}var e2={"silence-3s":()=>tD(3000),"silence-5s":()=>tD(5000),"silence-10s":()=>tD(1e4),"state-detection":()=>b0(),hybrid:()=>P0(),"aggressive-hybrid":()=>A3(b0(),tD(2000),{primaryTimeoutMs:1e4,fallbackTimeoutMs:30000}),"conservative-hybrid":()=>A3(b0(),tD(1e4),{primaryTimeoutMs:60000,fallbackTimeoutMs:120000})};function C3(D){if(D in e2)return e2[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 tD($)}return P0()}async function I2(D,F){let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);if(F){let X=F.startsWith("%")?F:`%${F}`;return{session:E,paneId:X}}let B=await k(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await l(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 l6(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 m6(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 p6(D,F={}){try{let E=await Z(D);if(!E){if(E=await pD(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 X=await k(E.id);B=(await l(X[0].id))[0].id}let $=F.command||"claude";if(await DD(B,$,!1,!1),console.log(`\u2705 Started "${$}" in session "${D}"`),F.monitor){console.log("\u2139\uFE0F Starting event monitor...");let X=new CD(D,{pollIntervalMs:500,paneId:F.pane});X.on("event",(Q)=>{if(F.json)console.log(JSON.stringify(Q));else console.log(m6(Q))}),X.on("poll_error",(Q)=>{console.error(`\u26A0\uFE0F Poll error: ${Q.message}`)}),await X.start(),console.log("\u2705 Monitor active. Press Ctrl+C to stop."),process.on("SIGINT",()=>{X.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 c6(D,F,E={}){try{let{paneId:B}=await I2(D,E.pane);if(await DD(B,F,!1,!1),E.noWait){console.log(`\u2705 Message sent to session "${D}"`);return}let $=new CD(D,{pollIntervalMs:250,paneId:E.pane});await $.start();let X=E.method?C3(E.method):P0(),Q=E.timeout||120000;console.log(`\u2139\uFE0F Waiting for completion using "${X.name}"...`);try{let J=await X.detect($,Q);if($.stop(),E.json)console.log(JSON.stringify(J,null,2));else if(console.log(`\u2705 Completion detected: ${J.reason}`),console.log(` Latency: ${J.latencyMs}ms`),J.state)console.log(` State: ${l6(J.state)}`);let Y=await p(B,100);console.log(`
|
|
152
|
+
--- Response ---`),console.log(FD(Y).trim())}catch(J){$.stop(),console.error(`\u274C Completion detection failed: ${J.message}`),process.exit(1)}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}async function d6(D,F={}){try{let{paneId:E}=await I2(D,F.pane),B=await p(E,100),$=ED(B),X=null,Q=[],J=null;if($.type==="permission")X=y6(B);else if($.type==="question"){if(Q=U3(B),$.detail==="plan_approval")J=k6(B)}if(F.json)console.log(JSON.stringify({session:D,state:$.type,detail:$.detail,confidence:$.confidence,timestamp:$.timestamp,permissionDetails:X,questionOptions:Q,planFile:J},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)}%`),X){if(console.log(`
|
|
153
|
+
Permission Request:`),console.log(` Type: ${X.type}`),X.command)console.log(` Command: ${X.command}`);if(X.file)console.log(` File: ${X.file}`)}if(Q.length>0)console.log(`
|
|
154
|
+
Question Options:`),Q.forEach((H,_)=>{console.log(` [${_+1}] ${H}`)});if(J)console.log(`
|
|
155
|
+
Plan File: ${J}`);let q=FD(B).trim().split(`
|
|
156
|
+
`).slice(-5);console.log(`
|
|
157
|
+
Last output:`),q.forEach((H)=>console.log(` ${H}`))}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function i6(D,F={}){try{let E=new CD(D,{pollIntervalMs:F.poll||500,paneId:F.pane});E.on("event",($)=>{if(F.json)console.log(JSON.stringify($));else console.log(m6($))}),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: ${l6(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 z3(D,F={}){try{let{paneId:E}=await I2(D,F.pane),B=await p(E,50),$=ED(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 zD(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 X=new CD(D,{pollIntervalMs:250,paneId:F.pane});X.on("permission",async(Q)=>{try{let{paneId:J}=await I2(D,F.pane),Y=F.deny?"n":"y";await DD(J,Y,!1,!0),console.log(`\u2705 Auto-${F.deny?"denied":"approved"}: ${Q.state?.detail||"unknown"}`)}catch(J){console.error(`\u26A0\uFE0F Auto-approve failed: ${J.message}`)}}),await X.start(),process.on("SIGINT",()=>{X.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 V3(D,F,E={}){try{let{paneId:B}=await I2(D,E.pane),$=await p(B,50),X=ED($);if(X.type!=="question"){console.log(`\u2139\uFE0F No question pending (state: ${X.type})`);return}if(F.startsWith("text:")){let Q=F.slice(5);await S(`send-keys -t '${B}' End`),await zD(100),await S(`send-keys -t '${B}' Enter`),await zD(100),await S(`send-keys -t '${B}' ${Z9(Q)}`),await zD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Sent feedback: "${Q.substring(0,50)}${Q.length>50?"...":""}"`)}else if(/^\d+$/.test(F)){let Q=parseInt(F,10),Y=FD($).split(`
|
|
160
|
+
`),q=1;for(let _=0;_<Y.length;_++)if(Y[_].match(/^\s*\u276F\s*\d+\./)){let G=Y[_].match(/\u276F\s*(\d+)\./);if(G)q=parseInt(G[1],10);break}let H=Q-q;if(H>0)for(let _=0;_<H;_++)await S(`send-keys -t '${B}' Down`),await zD(50);else if(H<0)for(let _=0;_<Math.abs(H);_++)await S(`send-keys -t '${B}' Up`),await zD(50);await zD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Selected option ${Q} 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 Z9(D){return`"${D.replace(/"/g,"\\\"").replace(/\$/g,"\\$")}"`}function zD(D){return new Promise((F)=>setTimeout(F,D))}async function n6(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 $=C3(D),X=[],Q=`orc-experiment-${Date.now()}`,J=await pD(Q);if(!J)console.error("\u274C Failed to create test session"),process.exit(1);try{let Y=await k(J.id),H=(await l(Y[0].id))[0].id;for(let O=0;O<E;O++){console.log(`
|
|
161
|
+
Run ${O+1}/${E}...`),await DD(H,"clear",!1,!1),await new Promise((u)=>setTimeout(u,500));let L=new CD(Q,{pollIntervalMs:100});await L.start(),await DD(H,B,!1,!1);let N=await $.detect(L,30000);if(L.stop(),X.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((u)=>setTimeout(u,1000))}let _=X.filter((O)=>O.complete),G=_.reduce((O,L)=>O+L.latencyMs,0)/_.length||0,A=Math.min(..._.map((O)=>O.latencyMs))||0,z=Math.max(..._.map((O)=>O.latencyMs))||0,K={method:D,totalRuns:E,successfulRuns:_.length,successRate:_.length/E*100,avgLatencyMs:Math.round(G),minLatencyMs:A,maxLatencyMs:z,results:X};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 C0(J.id),console.log(`
|
|
163
|
+
\u2705 Cleaned up test session`)}}async function r6(){console.log("Available completion methods:"),console.log("");for(let D of Object.keys(e2)){let F=e2[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 a6(D,F,E={}){try{let{paneId:B}=await I2(D,E.pane),$=E.timeout||300000;await DD(B,F,!1,!1),console.log(`\u2705 Sent task: "${F.substring(0,50)}${F.length>50?"...":""}"`);let X=new CD(D,{pollIntervalMs:250,paneId:E.pane});await X.start();let Q=Date.now();console.log(`\u2139\uFE0F Monitoring for completion...${E.autoApprove?" (auto-approve enabled)":""}`);let J=null,Y=async()=>{let _=await p(B,30),G=ED(_);if(G.type!==J){let A=((Date.now()-Q)/1000).toFixed(1);console.log(`[${A}s] State: ${G.type}${G.detail?` (${G.detail})`:""}`),J=G.type}if(G.type==="permission"&&E.autoApprove)return console.log(" \u21B3 Auto-approving permission..."),await S(`send-keys -t '${B}' Enter`),await zD(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 zD(200),!1;console.log("\u26A0\uFE0F Question requires manual input");let A=U3(_);if(A.length>0)console.log(" Options:"),A.forEach((z,K)=>console.log(` [${K+1}] ${z}`));return!0}if(G.type==="idle"){let A=((Date.now()-Q)/1000).toFixed(1);return console.log(`\u2705 Task complete (${A}s)`),!0}if(G.type==="error")return console.log("\u274C Task encountered error"),!0;return!1},q=500,H=Math.ceil($/q);for(let _=0;_<H;_++){if(await Y())break;if(Date.now()-Q>$){console.log(`\u26A0\uFE0F Timeout after ${$/1000}s`);break}await zD(q)}if(X.stop(),E.json){let _=await p(B,30),G=ED(_);console.log(JSON.stringify({session:D,state:G.type,detail:G.detail,elapsedMs:Date.now()-Q},null,2))}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}var{$:e9}=globalThis.Bun;F2();var{$:r9}=globalThis.Bun;var O3="gt:agent";function hD(){return process.env.TERM_USE_BEADS_REGISTRY!=="false"}async function r(D){try{let F=await r9`bd ${D}`.quiet();return{stdout:F.stdout.toString().trim(),stderr:F.stderr.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",stderr:F.stderr?.toString().trim()||"",exitCode:F.exitCode||1}}}function E2(D){if(!D)return null;try{return JSON.parse(D)}catch{return null}}async function a9(D,F){let E=`Worker: ${D}`,{stdout:B,exitCode:$}=await r(["create",`--title=${E}`,"--type=agent",`--label=${O3}`,`--label=worker:${D}`,"--json"]);if($!==0)throw Error(`Failed to create agent bead: ${B}`);let X=E2(B);if(!X?.id)throw Error("Failed to parse created agent bead");let Q=JSON.stringify({paneId:F.paneId,session:F.session,worktree:F.worktree,repoPath:F.repoPath,taskId:F.taskId,taskTitle:F.taskTitle,startedAt:new Date().toISOString()});return await r(["update",X.id,`--metadata=${Q}`]),X.id}async function s6(D,F){let E=await B2(D);if(E)return E.id;return a9(D,F)}async function B2(D){let{stdout:F,exitCode:E}=await r(["list",`--label=${O3}`,`--label=worker:${D}`,"--json"]);if(E!==0||!F)return null;return E2(F)?.[0]||null}async function D0(D){let{exitCode:F}=await r(["delete",D]);if(F===0)return!0;let E=await B2(D);if(E)return{exitCode:F}=await r(["delete",E.id]),F===0;return!1}function o9(D){switch(D){case"spawning":return"spawning";case"working":return"working";case"idle":return"idle";case"permission":return"blocked";case"question":return"blocked";case"done":return"done";case"error":return"error";default:return"unknown"}}function s9(D){switch(D){case"spawning":return"spawning";case"working":return"working";case"idle":return"idle";case"blocked":return"permission";case"done":return"done";case"error":return"error";default:return"idle"}}async function gD(D,F){let E=await B2(D);if(!E)throw Error(`Agent not found for worker ${D}`);let B=o9(F),{exitCode:$,stderr:X}=await r(["agent","state",E.id,B]);if($!==0)throw Error(`Failed to set agent state: ${X}`)}async function N3(D){let F=await B2(D);if(!F)return;await r(["agent","heartbeat",F.id])}async function t6(D,F){let E=await B2(D);if(!E)throw Error(`Agent not found for worker ${D}`);let{exitCode:B,stderr:$}=await r(["slot","set",E.id,"hook",F]);if(B!==0)throw Error(`Failed to bind work: ${$}`)}async function F0(D){let F=await B2(D);if(!F)return;await r(["slot","clear",F.id,"hook"])}function e6(D,F){return{id:F.taskId,paneId:F.paneId,session:F.session,worktree:F.worktree,taskId:F.taskId,taskTitle:F.taskTitle,wishSlug:F.wishSlug,groupNumber:F.groupNumber,startedAt:F.startedAt,state:s9(D.state||"idle"),lastStateChange:new Date().toISOString(),repoPath:F.repoPath}}async function S3(D){let F=await B2(D);if(!F)return null;let{stdout:E,exitCode:B}=await r(["show",F.id,"--json"]);if(B!==0||!E)return null;let $=E2(E);if(!$?.metadata)return null;return e6($,$.metadata)}async function T3(){let{stdout:D,exitCode:F}=await r(["list",`--label=${O3}`,"--json"]);if(F!==0||!D)return[];let E=E2(D);if(!E)return[];let B=[];for(let $ of E)if($.metadata)B.push(e6($,$.metadata));return B}async function D1(D){let F=await T3(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function v2(D){return S3(D)}async function lD(){let{stdout:D,exitCode:F}=await r(["daemon","status","--json"]);if(F!==0)return{running:!1};return E2(D)||{running:!1}}async function E0(D){let F=["daemon","start"];if(D?.autoCommit)F.push("--auto-commit");if(D?.autoPush)F.push("--auto-push");let{exitCode:E}=await r(F);return E===0}async function b3(){let{exitCode:D}=await r(["daemon","stop"]);return D===0}async function F1(D){let{stdout:F,exitCode:E,stderr:B}=await r(["worktree","create",D,"--json"]);if(E!==0)return console.error(`bd worktree create failed: ${B}`),null;return E2(F)}async function w0(D){let{exitCode:F}=await r(["worktree","remove",D]);return F===0}async function t9(){let{stdout:D,exitCode:F}=await r(["worktree","list","--json"]);if(F!==0||!D)return[];return E2(D)||[]}async function E1(D){return(await t9()).find((E)=>E.name===D||E.branch===D)||null}async function B1(D){await F0(D),await D0(D)}async function I0(D,F){await gD(D,F),await N3(D)}import{join as D4}from"path";import{homedir as F4}from"os";var $2=hD(),E4=D4(F4(),".local","share","term","worktrees");async function P3(D){try{return{stdout:(await e9`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function $1(D){let{stdout:F,exitCode:E}=await P3(["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 B4(){let{stdout:D,exitCode:F}=await P3(["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 $1(B[1])}return null}}async function $4(D){let{exitCode:F}=await P3(["update",D,"--status","in_progress"]);return F===0}async function X4(){try{return(await S("display-message -p '#{session_name}'")).trim()||null}catch{return null}}async function Q4(D,F){if($2)try{let E=await E1(D);if(E)return console.log(`\u2139\uFE0F Worktree for ${D} already exists`),E.path;let B=await F1(D);if(B)return B.path;console.log("\u26A0\uFE0F bd worktree failed, falling back to git worktree")}catch(E){console.log(`\u26A0\uFE0F bd worktree error: ${E.message}, falling back`)}try{let E=new ID({baseDir:E4,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 J4(D,F){try{let E=await Z(D);if(!E)return console.error(`\u274C Session "${D}" not found`),null;let B=await k(E.id);if(!B||B.length===0)return console.error(`\u274C No windows in session "${D}"`),null;let $=await l(B[0].id);if(!$||$.length===0)return console.error(`\u274C No panes in session "${D}"`),null;let X=await z0($[0].id,"horizontal",50,F);if(!X)return console.error("\u274C Failed to create new pane"),null;return{paneId:X.id}}catch(E){return console.error(`\u274C Error spawning worker pane: ${E.message}`),null}}function Y4(D,F,E){let B=new CD(F,{pollIntervalMs:1000,paneId:E});B.on("state_change",async($)=>{if(!$.state)return;let X;switch($.state.type){case"working":case"tool_use":X="working";break;case"idle":X="idle";break;case"permission":X="permission";break;case"question":X="question";break;case"error":X="error";break;case"complete":X="done";break;default:return}try{if($2)await I0(D,X);await Z2(D,X)}catch{}}),B.on("poll_error",()=>{if($2)B1(D).catch(()=>{});eD(D).catch(()=>{}),B.stop()}),B.start().catch(()=>{})}async function X1(D,F={}){try{let E=process.cwd();if($2){if(!(await lD()).running)if(console.log("\uD83D\uDD04 Starting beads daemon for auto-sync..."),await E0({autoCommit:!0}))console.log(" \u2705 Daemon started");else console.log(" \u26A0\uFE0F Daemon failed to start (non-fatal)")}let B=null;if(D==="next"){if(console.log("\uD83D\uDD0D Finding next ready issue..."),B=await B4(),!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 $1(D),!B)console.error(`\u274C Issue "${D}" not found. Run \`bd list\` to see issues.`),process.exit(1);let $=B.id,X=$2?await v2($):null;if(!X)X=await yD($);if(X)console.error(`\u274C ${$} already has a worker (pane ${X.paneId})`),console.log(` Run \`term kill ${X.id}\` first, or work on a different issue.`),process.exit(1);let Q=F.session||await X4();if(!Q)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 $4($))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 Q4($,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 H=await J4(Q,Y);if(!H)process.exit(1);let{paneId:_}=H,G={id:$,paneId:_,session:Q,worktree:q,taskId:$,taskTitle:B.title,startedAt:new Date().toISOString(),state:"spawning",lastStateChange:new Date().toISOString(),repoPath:E};if($2)try{let z=await s6($,{paneId:_,session:Q,worktree:q,repoPath:E,taskId:$,taskTitle:B.title});await t6($,$),await gD($,"spawning")}catch(z){console.log(`\u26A0\uFE0F Beads registration failed: ${z.message} (non-fatal)`)}await j3(G),await DD(_,"claude",!1,!1),await new Promise((z)=>setTimeout(z,2000));let A=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 DD(_,A,!1,!1),$2)await gD($,"working").catch(()=>{});if(await Z2($,"working"),Y4($,Q,_),F.focus!==!1)await S(`select-pane -t '${_}'`);if(console.log(`
|
|
169
|
+
\u2705 Worker started for ${$}`),console.log(` Pane: ${_}`),console.log(` Session: ${Q}`),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{$:Q1}=globalThis.Bun;F2();var f3=hD();async function H4(D){try{return await p(D,1),!0}catch{return!1}}async function _4(D){try{let F=await p(D,30),E=ED(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 W4(){let D=[],F=[];try{let B=(await Q1`bd ready --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let X of $)D.push(`${X.id}`)}catch{let $=B.split(`
|
|
171
|
+
`).filter((X)=>X.trim());for(let X of $){let Q=X.match(/^(bd-\d+)/);if(Q)D.push(Q[1])}}}catch{}try{let B=(await Q1`bd list --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let X of $)if(X.blockedBy&&X.blockedBy.length>0)F.push(`${X.id} (blocked by ${X.blockedBy.join(", ")})`)}catch{}}catch{}return{ready:D,blocked:F}}function G4(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 J1(D={}){try{let F=[];if(f3)try{F=await T3()}catch{F=await ND()}else F=await ND();let E=await ND(),B=new Set(F.map((q)=>q.id));for(let q of E)if(!B.has(q.id))F.push(q);let $=[];for(let q of F){let H=await H4(q.paneId),_=q.state;if(H){_=await _4(q.paneId);let G=U4(_);if(G&&G!==q.state){if(f3)await I0(q.id,G).catch(()=>{});await Z2(q.id,G)}else if(f3)await N3(q.id).catch(()=>{})}else _="\uD83D\uDC80 dead";$.push({name:q.id,pane:q.paneId,task:q.taskTitle?`"${q.taskTitle.substring(0,25)}${q.taskTitle.length>25?"...":""}"`:q.taskId,state:_,time:G4(q.startedAt),alive:H})}let X=await W4(),Q=F.filter((q)=>$.find((H)=>H.name===q.id&&H.alive)).map((q)=>q.taskId),J=X.ready.filter((q)=>!Q.includes(q));if(D.json){console.log(JSON.stringify({workers:$,queue:{ready:J,blocked:X.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"),$.length===0)console.log("\u2502 (no workers) \u2502");else for(let q of $){let H=q.name.padEnd(8).substring(0,8),_=q.pane.padEnd(8).substring(0,8),G=q.task.padEnd(25).substring(0,25),A=q.state.padEnd(8).substring(0,8),z=q.time.padStart(4).substring(0,4);console.log(`\u2502 ${H} \u2502 ${_} \u2502 ${G} \u2502 ${A} \u2502${z}\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"),X.blocked.length>0)console.log(`
|
|
172
|
+
Blocked: ${X.blocked.slice(0,5).join(", ")}${X.blocked.length>5?"...":""}`);if(J.length>0)console.log(`Ready: ${J.slice(0,5).join(", ")}${J.length>5?"...":""}`);else if($.length>0)console.log(`
|
|
173
|
+
Ready: (none - all assigned or blocked)`);let Y=$.filter((q)=>!q.alive);if(Y.length>0)console.log(`
|
|
174
|
+
\u26A0\uFE0F ${Y.length} dead worker(s) detected. Run \`term kill <name>\` to clean up.`)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}function U4(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{$:m0}=globalThis.Bun;var $0=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",u0=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n";var w3=(D)=>D.name==="backspace",X2=(D)=>D.name==="tab";var SD=(D)=>D.name==="enter"||D.name==="return";class I3 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class u3 extends Error{name="CancelPromptError";message="Prompt was canceled"}class Z0 extends Error{name="ExitPromptError"}class Z3 extends Error{name="HookError"}class v3 extends Error{name="ValidationError"}import{AsyncResource as R4}from"async_hooks";import{AsyncLocalStorage as C4,AsyncResource as z4}from"async_hooks";var Y1=new C4;function V4(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function q1(D,F){let E=V4(D);return Y1.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function Q2(){let D=Y1.getStore();if(!D)throw new Z3("[Inquirer] Hook functions can only be called from within a prompt");return D}function k3(){return Q2().rl}function x3(D){let F=(...E)=>{let B=Q2(),$=!1,X=B.handleChange;B.handleChange=()=>{$=!0};let Q=D(...E);if($)X();return B.handleChange=X,Q};return z4.bind(F)}function k2(D){let F=Q2(),{index:E}=F,B={get(){return F.hooks[E]},set(X){F.hooks[E]=X},initialized:E in F.hooks},$=D(B);return F.index++,$}function H1(){Q2().handleChange()}var J2={queue(D){let F=Q2(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(k3());if(B!=null&&typeof B!=="function")throw new v3("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=Q2();x3(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=Q2();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function x(D){return k2((F)=>{let E=R4.bind(function(X){if(F.get()!==X)F.set(X),H1()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function TD(D,F){k2((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((X,Q)=>!Object.is(X,B[Q])))J2.queue(D);E.set(F)})}var BD=mD(v0(),1);import VD from"process";function L4(){if(VD.platform!=="win32")return VD.env.TERM!=="linux";return Boolean(VD.env.WT_SESSION)||Boolean(VD.env.TERMINUS_SUBLIME)||VD.env.ConEmuTask==="{cmd::Cmder}"||VD.env.TERM_PROGRAM==="Terminus-Sublime"||VD.env.TERM_PROGRAM==="vscode"||VD.env.TERM==="xterm-256color"||VD.env.TERM==="alacritty"||VD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var W1={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"},G1={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"},M4={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"},O4={...W1,...G1},N4={...W1,...M4},S4=L4(),T4=S4?O4:N4,x2=T4,LX=Object.entries(G1);var U1={prefix:{idle:BD.default.blue("?"),done:BD.default.green(x2.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>BD.default.yellow(D))},style:{answer:BD.default.cyan,message:BD.default.bold,error:(D)=>BD.default.red(`> ${D}`),defaultAnswer:(D)=>BD.default.dim(`(${D})`),help:BD.default.dim,highlight:BD.default.cyan,key:(D)=>BD.default.cyan(BD.default.bold(`<${D}>`))}};function A1(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 C1(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let X=F[B];F[B]=A1(X)&&A1($)?C1(X,$):$}return F}function WD(...D){let F=[U1,...D.filter((E)=>E!=null)];return C1(...F)}function bD({status:D="idle",theme:F}){let[E,B]=x(!1),[$,X]=x(0),{prefix:Q,spinner:J}=WD(F);if(TD(()=>{if(D==="loading"){let q,H=-1,_=setTimeout(()=>{B(!0),q=setInterval(()=>{H=H+1,X(H%J.frames.length)},J.interval)},300);return()=>{clearTimeout(_),clearInterval(q)}}else B(!1)},[D]),E)return J.frames[$];return typeof Q==="string"?Q:Q[D==="loading"?"idle":D]??Q.idle}function y3(D,F){return k2((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,X)=>$!==F[X])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function k0(D){return x({current:D})[0]}function PD(D){let F=k0(D);F.current=D,TD((E)=>{let B=!1,$=x3((X,Q)=>{if(B)return;F.current(Q,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var d1=mD(V1(),1),i1=mD(c1(),1);function J0(D,F){return D.split(`
|
|
175
|
+
`).flatMap((E)=>i1.default(E,F,{trim:!1,hard:!0}).split(`
|
|
176
|
+
`).map((B)=>B.trimEnd())).join(`
|
|
177
|
+
`)}function h0(){return d1.default({defaultWidth:80,output:k3().output})}function a4({active:D,renderedItems:F,pageSize:E,loop:B}){let $=k0({lastPointer:D,lastActive:void 0}),{lastPointer:X,lastActive:Q}=$.current,J=Math.floor(E/2),Y=F.reduce((_,G)=>_+G.length,0),q=F.slice(0,D).reduce((_,G)=>_+G.length,0),H=q;if(Y>E)if(B){if(H=X,Q!=null&&Q<D&&D-Q<E)H=Math.min(J,Math.abs(D-Q)===1?Math.min(X+(F[Q]?.length??0),Math.max(q,X)):X+D-Q)}else{let _=F.slice(D).reduce((G,A)=>G+A.length,0);H=_<E-J?E-_:Math.min(q,J)}return $.current.lastPointer=H,$.current.lastActive=D,H}function n3({items:D,active:F,renderItem:E,pageSize:B,loop:$=!0}){let X=h0(),Q=(L)=>(L%D.length+D.length)%D.length,J=D.map((L,N)=>{if(L==null)return[];return J0(E({item:L,index:N,isActive:N===F}),X).split(`
|
|
178
|
+
`)}),Y=J.reduce((L,N)=>L+N.length,0),q=(L)=>J[L]??[],H=a4({active:F,renderedItems:J,pageSize:B,loop:$}),_=q(F).slice(0,B),G=H+_.length<=B?H:B-_.length,A=Array.from({length:B});A.splice(G,_.length,..._);let z=new Set([F]),K=G+_.length,O=Q(F+1);while(K<B&&!z.has(O)&&($&&Y>B?O!==F:O>F)){let N=q(O).slice(0,B-K);A.splice(K,N.length,...N),z.add(O),K+=N.length,O=Q(O+1)}K=G-1,O=Q(F-1);while(K>=0&&!z.has(O)&&($&&Y>B?O!==F:O<F)){let L=q(O),N=L.slice(Math.max(0,L.length-K-1));A.splice(K-N.length+1,N.length,...N),z.add(O),K-=N.length,O=Q(O-1)}return A.filter((L)=>typeof L==="string").join(`
|
|
179
|
+
`)}var XF=mD(a1(),1);import*as $F from"readline";import{AsyncResource as EE}from"async_hooks";var Y2=[];Y2.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")Y2.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")Y2.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var g0=(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",r3=Symbol.for("signal-exit emitter"),a3=globalThis,s4=Object.defineProperty.bind(Object);class o1{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(a3[r3])return a3[r3];s4(a3,r3,{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 s3{}var t4=(D)=>{return{onExit(F,E){return D.onExit(F,E)},load(){return D.load()},unload(){return D.unload()}}};class s1 extends s3{onExit(){return()=>{}}load(){}unload(){}}class t1 extends s3{#E=o3.platform==="win32"?"SIGINT":"SIGHUP";#F=new o1;#D;#X;#Q;#$={};#B=!1;constructor(D){super();this.#D=D,this.#$={};for(let F of Y2)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 X=this.#F.emit("exit",null,F),Q=F==="SIGHUP"?this.#E:F;if(!X)D.kill(D.pid,Q)}};this.#Q=D.reallyExit,this.#X=D.emit}onExit(D,F){if(!g0(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 Y2)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.#J(D)}}unload(){if(!this.#B)return;this.#B=!1,Y2.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.#X,this.#D.reallyExit=this.#Q,this.#F.count-=1}#J(D){if(!g0(this.#D))return 0;return this.#D.exitCode=D||0,this.#F.emit("exit",this.#D.exitCode,null),this.#Q.call(this.#D,this.#D.exitCode)}#Y(D,...F){let E=this.#X;if(D==="exit"&&g0(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 o3=globalThis.process,{onExit:e1,load:QQ,unload:JQ}=t4(g0(o3)?new t1(o3):new s1);import{stripVTControlCharacters as DE}from"util";var e4="\x1B[G",FF="\x1B[?25l",EF="\x1B[?25h",t3=(D=1)=>D>0?`\x1B[${D}A`:"",e3=(D=1)=>D>0?`\x1B[${D}B`:"",D8=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},DF="\x1B[2K",F8=(D)=>D>0?(DF+t3(1)).repeat(D-1)+DF+e4:"";var BF=(D)=>D.split(`
|
|
180
|
+
`).length,FE=(D)=>D.split(`
|
|
181
|
+
`).pop()??"";class l0{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=FE(D),B=DE(E),$=B;if(this.rl.line.length>0)$=$.slice(0,-this.rl.line.length);this.rl.setPrompt($),this.cursorPos=this.rl.getCursorPos();let X=h0();if(D=J0(D,X),F=J0(F,X),B.length%X===0)D+=`
|
|
182
|
+
`;let Q=D+(F?`
|
|
183
|
+
`+F:""),Y=Math.floor(B.length/X)-this.cursorPos.rows+(F?BF(F):0);if(Y>0)Q+=t3(Y);Q+=D8(this.cursorPos.cols),this.write(e3(this.extraLinesUnderPrompt)+F8(this.height)+Q),this.extraLinesUnderPrompt=Y,this.height=BF(Q)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(D8(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=e3(this.extraLinesUnderPrompt);F+=D?F8(this.height):`
|
|
184
|
+
`,F+=EF,this.write(F),this.rl.close()}}class E8 extends Promise{static withResolver(){let D,F;return{promise:new Promise((B,$)=>{D=B,F=$}),resolve:D,reject:F}}}function BE(){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 fD(D){let F=BE();return(B,$={})=>{let{input:X=process.stdin,signal:Q}=$,J=new Set,Y=new XF.default;Y.pipe($.output??process.stdout);let q=$F.createInterface({terminal:!0,input:X,output:Y}),H=new l0(q),{promise:_,resolve:G,reject:A}=E8.withResolver(),z=()=>A(new u3);if(Q){let L=()=>A(new I3({cause:Q.reason}));if(Q.aborted)return L(),Object.assign(_,{cancel:z});Q.addEventListener("abort",L),J.add(()=>Q.removeEventListener("abort",L))}J.add(e1((L,N)=>{A(new Z0(`User force closed the prompt with ${L} ${N}`))}));let K=()=>A(new Z0("User force closed the prompt with SIGINT"));q.on("SIGINT",K),J.add(()=>q.removeListener("SIGINT",K));let O=()=>H.checkCursorPos();return q.input.on("keypress",O),J.add(()=>q.input.removeListener("keypress",O)),q1(q,(L)=>{let N=EE.bind(()=>J2.clearAll());return q.on("close",N),J.add(()=>q.removeListener("close",N)),L(()=>{try{let u=D(B,(a)=>{setImmediate(()=>G(a))});if(u===void 0){let a=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
|
|
185
|
+
at ${a}`)}let[c,e]=typeof u==="string"?[u]:u;H.render(c,e),J2.run()}catch(u){A(u)}}),Object.assign(_.then((u)=>{return J2.clearAll(),u},(u)=>{throw J2.clearAll(),u}).finally(()=>{J.forEach((u)=>u()),H.done({clearContent:Boolean($.clearPromptOnDone)}),Y.end()}).then(()=>_),{cancel:z})})}}var QF=mD(v0(),1);class l2{separator=QF.default.dim(Array.from({length:15}).join(x2.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 JF(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 YF(D){return D?"Yes":"No"}var Y0=fD((D,F)=>{let{transformer:E=YF}=D,[B,$]=x("idle"),[X,Q]=x(""),J=WD(D.theme),Y=bD({status:B,theme:J});PD((G,A)=>{if(B!=="idle")return;if(SD(G)){let z=JF(X,D.default);Q(E(z)),$("done"),F(z)}else if(X2(G)){let z=YF(!JF(X,D.default));A.clearLine(0),A.write(z),Q(z)}else Q(A.line)});let q=X,H="";if(B==="done")q=J.style.answer(X);else H=` ${J.style.defaultAnswer(D.default===!1?"y/N":"Y/n")}`;let _=J.style.message(D.message,B);return`${Y} ${_}${H} ${q}`});var $E={validationFailureMode:"keep"},XE=fD((D,F)=>{let{prefill:E="tab"}=D,B=WD($E,D.theme),[$,X]=x("idle"),[Q="",J]=x(D.default),[Y,q]=x(),[H,_]=x(""),G=bD({status:$,theme:B});async function A(N){let{required:u,pattern:c,patternError:e="Invalid input"}=D;if(u&&!N)return"You must provide a value";if(c&&!c.test(N))return e;if(typeof D.validate==="function")return await D.validate(N)||"You must provide a valid value";return!0}PD(async(N,u)=>{if($!=="idle")return;if(SD(N)){let c=H||Q;X("loading");let e=await A(c);if(e===!0)_(c),X("done"),F(c);else{if(B.validationFailureMode==="clear")_("");else u.write(H);q(e),X("idle")}}else if(w3(N)&&!H)J(void 0);else if(X2(N)&&!H)J(void 0),u.clearLine(0),u.write(Q),_(Q);else _(u.line),q(void 0)}),TD((N)=>{if(E==="editable"&&Q)N.write(Q),_(Q)},[]);let z=B.style.message(D.message,$),K=H;if(typeof D.transformer==="function")K=D.transformer(H,{isFinal:$==="done"});else if($==="done")K=B.style.answer(H);let O;if(Q&&$!=="done"&&!H)O=B.style.defaultAnswer(Q);let L="";if(Y)L=B.style.error(Y);return[[G,z,O,K].filter((N)=>N!==void 0).join(" "),L]});var QE=fD((D,F)=>{let{validate:E=()=>!0}=D,B=WD(D.theme),[$,X]=x("idle"),[Q,J]=x(),[Y,q]=x(""),H=bD({status:$,theme:B});PD(async(K,O)=>{if($!=="idle")return;if(SD(K)){let L=Y;X("loading");let N=await E(L);if(N===!0)q(L),X("done"),F(L);else O.write(Y),J(N||"You must provide a valid value"),X("idle")}else q(O.line),J(void 0)});let _=B.style.message(D.message,$),G="",A;if(D.mask)G=(typeof D.mask==="string"?D.mask:"*").repeat(Y.length);else if($!=="done")A=`${B.style.help("[input is masked]")}${FF}`;if($==="done")G=B.style.answer(G);let z="";if(Q)z=B.style.error(Q);return[[H,_,D.mask?G:A].join(" "),z]});var q2=mD(v0(),1);var JE={icon:{cursor:x2.pointer},style:{disabled:(D)=>q2.default.dim(`- ${D}`),searchTerm:(D)=>q2.default.cyan(D),description:(D)=>q2.default.cyan(D),keysHelpTip:(D)=>D.map(([F,E])=>`${q2.default.bold(F)} ${q2.default.dim(E)}`).join(q2.default.dim(" \u2022 "))},helpMode:"always"};function B8(D){return!l2.isSeparator(D)&&!D.disabled}function YE(D){return D.map((F)=>{if(l2.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 qE=fD((D,F)=>{let{pageSize:E=7,validate:B=()=>!0}=D,$=WD(JE,D.theme),[X,Q]=x("loading"),[J,Y]=x(""),[q,H]=x([]),[_,G]=x(),A=bD({status:X,theme:$}),z=y3(()=>{let v=q.findIndex(B8),s=q.findLastIndex(B8);return{first:v,last:s}},[q]),[K=z.first,O]=x();TD(()=>{let v=new AbortController;return Q("loading"),G(void 0),(async()=>{try{let $D=await D.source(J||void 0,{signal:v.signal});if(!v.signal.aborted)O(void 0),G(void 0),H(YE($D)),Q("idle")}catch($D){if(!v.signal.aborted&&$D instanceof Error)G($D.message)}})(),()=>{v.abort()}},[J]);let L=q[K];PD(async(v,s)=>{if(SD(v))if(L){Q("loading");let $D=await B(L.value);if(Q("idle"),$D===!0)Q("done"),F(L.value);else if(L.name===J)G($D||"You must provide a valid value");else s.write(L.name),Y(L.name)}else s.write(J);else if(X2(v)&&L)s.clearLine(0),s.write(L.name),Y(L.name);else if(X!=="loading"&&($0(v)||u0(v))){if(s.clearLine(0),$0(v)&&K!==z.first||u0(v)&&K!==z.last){let $D=$0(v)?-1:1,H2=K;do H2=(H2+$D+q.length)%q.length;while(!B8(q[H2]));O(H2)}}else Y(s.line)});let N=$.style.message(D.message,X),u;if($.helpMode!=="never")if(D.instructions){let{pager:v,navigation:s}=D.instructions;u=$.style.help(q.length>E?v:s)}else u=$.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]);let c=n3({items:q,active:K,renderItem({item:v,isActive:s}){if(l2.isSeparator(v))return` ${v.separator}`;if(v.disabled){let c0=typeof v.disabled==="string"?v.disabled:"(disabled)";return $.style.disabled(`${v.name} ${c0}`)}let $D=s?$.style.highlight:(c0)=>c0,H2=s?$.icon.cursor:" ";return $D(`${H2} ${v.name}`)},pageSize:E,loop:!1}),e;if(_)e=$.style.error(_);else if(q.length===0&&J!==""&&X==="idle")e=$.style.error("No results found");let a;if(X==="done"&&L)return[A,N,$.style.answer(L.short)].filter(Boolean).join(" ").trimEnd();else a=$.style.searchTerm(J);let J8=L?.description,zF=[A,N,a].filter(Boolean).join(" ").trimEnd(),VF=[e??c," ",J8?$.style.description(J8):"",u].filter(Boolean).join(`
|
|
186
|
+
`).trimEnd();return[zF,VF]});F2();import{join as HE}from"path";import{homedir as _E}from"os";var $8=hD(),WE=HE(_E(),".local","share","term","worktrees");async function qF(D){try{return{stdout:(await m0`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function GE(D){let{exitCode:F}=await qF(["close",D]);return F===0}async function UE(){let{exitCode:D}=await qF(["sync"]);return D===0}async function AE(D,F){try{let B=(await m0`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 m0`git -C ${D} checkout ${B}`.quiet(),console.log(` Merging ${F}...`),await m0`git -C ${D} merge ${F} --no-edit`.quiet(),!0}catch(E){return console.error(`\u26A0\uFE0F Merge failed: ${E.message}`),!1}}async function CE(D,F){if($8)try{if(await w0(D))return!0}catch{}try{let E=new ID({baseDir:WE,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 zE(D){try{return await _2(D),!0}catch{return!1}}async function HF(D,F={}){try{let E=$8?await v2(D):null;if(!E)E=await yD(D);if(!E)console.log(`\u2139\uFE0F No active worker for ${D}. Closing issue only.`);if(!F.yes){if(!await Y0({message:`Close ${D}${E?` and kill worker (pane ${E.paneId})`:""}?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDCDD Closing ${D}...`),!await GE(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 UE())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 AE(E.repoPath,D))console.log(" \u2705 Merged to main")}if(console.log("\uD83C\uDF33 Removing worktree..."),await CE(D,E.repoPath))console.log(" \u2705 Worktree removed")}if(E){if(console.log("\uD83D\uDC80 Killing worker pane..."),await zE(E.paneId),console.log(" \u2705 Pane killed"),$8)try{await F0(E.id),await gD(E.id,"done"),await D0(E.id)}catch{}await eD(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)}}F2();import{join as RE}from"path";import{homedir as KE}from"os";var q0=hD(),jE=RE(KE(),".local","share","term","worktrees");async function LE(D){try{return await _2(D),!0}catch{return!1}}async function ME(D,F){if(q0)try{if(await w0(D))return!0}catch{}try{let E=new ID({baseDir:jE,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 _F(D,F={}){try{let E=await L3(D);if(!E&&q0)E=await S3(D);if(!E)E=await M3(D);if(!E&&q0)E=await D1(D);if(!E)E=await yD(D);if(!E&&q0)E=await v2(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 Y0({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 LE(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 ME(E.taskId,E.repoPath))console.log(" \u2705 Worktree removed")}if(q0)try{await F0(E.id),await gD(E.id,"error"),await D0(E.id)}catch{}await eD(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)}}async function WF(D={}){try{let F=await lD();if(F.running){if(console.log("\u2139\uFE0F Daemon is already running"),F.pid)console.log(` PID: ${F.pid}`);return}if(console.log("\uD83D\uDE80 Starting beads daemon..."),await E0({autoCommit:D.autoCommit!==!1,autoPush:D.autoPush})){console.log(" \u2705 Daemon started");let B=await lD();if(B.pid)console.log(` PID: ${B.pid}`);if(B.autoCommit)console.log(" Auto-commit: enabled");if(B.autoPush)console.log(" Auto-push: enabled")}else console.error("\u274C Failed to start daemon"),console.log(" Check `bd daemon status` for details"),process.exit(1)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}async function GF(){try{if(!(await lD()).running){console.log("\u2139\uFE0F Daemon is not running");return}if(console.log("\uD83D\uDED1 Stopping beads daemon..."),await b3())console.log(" \u2705 Daemon stopped");else console.error("\u274C Failed to stop daemon"),process.exit(1)}catch(D){console.error(`\u274C Error: ${D.message}`),process.exit(1)}}async function UF(D={}){try{let F=await lD();if(D.json){console.log(JSON.stringify(F,null,2));return}if(console.log("Beads Daemon Status"),console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(`Running: ${F.running?"\u2705 yes":"\u274C no"}`),F.running){if(F.pid)console.log(`PID: ${F.pid}`);if(F.lastSync)console.log(`Last sync: ${F.lastSync}`);if(F.autoCommit!==void 0)console.log(`Auto-commit: ${F.autoCommit?"enabled":"disabled"}`);if(F.autoPush!==void 0)console.log(`Auto-push: ${F.autoPush?"enabled":"disabled"}`)}else console.log("\nRun `term daemon start` to start the daemon")}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}async function AF(D={}){try{if((await lD()).running)console.log("\uD83D\uDED1 Stopping beads daemon..."),await b3(),console.log(" \u2705 Stopped");if(console.log("\uD83D\uDE80 Starting beads daemon..."),await E0({autoCommit:D.autoCommit!==!1,autoPush:D.autoPush}))console.log(" \u2705 Daemon restarted");else console.error("\u274C Failed to restart daemon"),process.exit(1)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}var h=new O8;h.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
|
|
134
189
|
|
|
135
190
|
Collaborative Usage:
|
|
136
191
|
AI runs: term exec genie:shell '<command>'
|
|
@@ -138,4 +193,12 @@ Collaborative Usage:
|
|
|
138
193
|
AI reads: term read genie
|
|
139
194
|
|
|
140
195
|
Workflow: new \u2192 exec \u2192 read \u2192 rm
|
|
141
|
-
Full control: window new/ls/rm, pane ls/rm, split, status
|
|
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
|
|
204
|
+
term daemon start - Start beads daemon for auto-sync`).version(N8);h.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 h8(D,F)});h.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async(D)=>{await g8(D)});h.command("attach <name>").description("Attach to a tmux session").action(async(D)=>{await l8(D)});h.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async(D,F)=>{await m8(D,F)});h.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 q6(D,F)});h.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 H6(D,F.join(" "),{quiet:E.quiet,timeout:E.timeout?parseInt(E.timeout,10):void 0})});h.command("send <session> <keys>").description("Send raw keys to a tmux session").action(async(D,F)=>{await _6(D,F)});h.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 W6(D,F,E)});h.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 O6(D,F)});var X8=h.command("window").description("Manage tmux windows");X8.command("new <session> <name>").description("Create a new window in session").action(async(D,F)=>{await K6(D,F)});X8.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async(D,F)=>{await R6(D,F)});X8.command("rm <window-id>").description("Remove window by ID").action(async(D)=>{await j6(D)});var CF=h.command("pane").description("Manage tmux panes");CF.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async(D,F)=>{await L6(D,F)});CF.command("rm <pane-id>").description("Remove pane by ID").action(async(D)=>{await M6(D)});var Q8=h.command("hook").description("Manage tmux hooks");Q8.command("set <event> <command>").description("Set a tmux hook").action(async(D,F)=>{await C6(D,F)});Q8.command("list").description("List all tmux hooks").action(async()=>{await z6()});Q8.command("rm <event>").description("Remove a tmux hook").action(async(D)=>{await V6(D)});h.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 f6(D)});h.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 X1(D,F)});h.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 J1(D)});h.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 HF(D,F)});h.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 _F(D,F)});h.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(() => (F2(),D2)),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 z3(B.session,{pane:B.paneId,deny:F.deny})});h.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(() => (F2(),D2)),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 V3(B.session,F,{pane:B.paneId})});var p0=h.command("daemon").description("Manage beads daemon for auto-sync");p0.command("start").description("Start beads daemon (auto-commit, auto-sync)").option("--no-auto-commit","Disable auto-commit").option("--auto-push","Enable auto-push to remote").action(async(D)=>{await WF(D)});p0.command("stop").description("Stop beads daemon").action(async()=>{await GF()});p0.command("status").description("Show daemon status").option("--json","Output as JSON").action(async(D)=>{await UF(D)});p0.command("restart").description("Restart beads daemon").option("--no-auto-commit","Disable auto-commit").option("--auto-push","Enable auto-push to remote").action(async(D)=>{await AF(D)});var wD=h.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 p6(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 c6(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 d6(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 i6(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 z3(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 V3(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 n6(D,F)});wD.command("methods").description("List available completion detection methods").action(async()=>{await r6()});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 a6(D,F,E)});h.parse();
|