@automagik/genie 0.260202.1833 → 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/dist/term.js CHANGED
@@ -1,57 +1,57 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var h1=Object.create;var{getPrototypeOf:g1,defineProperty:w0,getOwnPropertyNames:l1}=Object;var m1=Object.prototype.hasOwnProperty;var xD=(D,F,E)=>{E=D!=null?h1(g1(D)):{};let B=F||!D||!D.__esModule?w0(E,"default",{value:D,enumerable:!0}):E;for(let $ of l1(D))if(!m1.call(B,$))w0(B,$,{get:()=>D[$],enumerable:!0});return B};var m=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var h3=(D,F)=>{for(var E in F)w0(D,E,{get:F[E],enumerable:!0,configurable:!0,set:(B)=>F[E]=()=>B})};var p1=(D,F)=>()=>(D&&(F=D(D=0)),F);var VD=import.meta.require;var Z2=m((c1)=>{class P0 extends Error{constructor(D,F,E){super(E);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=D,this.nestedError=void 0}}class g3 extends P0{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}c1.CommanderError=P0;c1.InvalidArgumentError=g3});var s2=m((a1)=>{var{InvalidArgumentError:n1}=Z2();class l3{constructor(D,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.concat(D)}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,E)=>{if(!this.argChoices.includes(F))throw new n1(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(F,E);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function r1(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}a1.Argument=l3;a1.humanReadableArgName=r1});var I0=m((e1)=>{var{humanReadableArgName:t1}=s2();class m3{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(D){let F=D.commands.filter((B)=>!B._hidden),E=D._getHelpCommand();if(E&&!E._hidden)F.push(E);if(this.sortSubcommands)F.sort((B,$)=>{return B.name().localeCompare($.name())});return F}compareOptions(D,F){let E=(B)=>{return B.short?B.short.replace(/^-/,""):B.long.replace(/^--/,"")};return E(D).localeCompare(E(F))}visibleOptions(D){let F=D.options.filter((B)=>!B.hidden),E=D._getHelpOption();if(E&&!E.hidden){let B=E.short&&D._findOption(E.short),$=E.long&&D._findOption(E.long);if(!B&&!$)F.push(E);else if(E.long&&!$)F.push(D.createOption(E.long,E.description));else if(E.short&&!B)F.push(D.createOption(E.short,E.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let F=[];for(let E=D.parent;E;E=E.parent){let B=E.options.filter(($)=>!$.hidden);F.push(...B)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((F)=>{F.description=F.description||D._argsDescription[F.name()]||""});if(D.registeredArguments.find((F)=>F.description))return D.registeredArguments;return[]}subcommandTerm(D){let F=D.registeredArguments.map((E)=>t1(E)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,F){return F.visibleCommands(D).reduce((E,B)=>{return Math.max(E,F.subcommandTerm(B).length)},0)}longestOptionTermLength(D,F){return F.visibleOptions(D).reduce((E,B)=>{return Math.max(E,F.optionTerm(B).length)},0)}longestGlobalOptionTermLength(D,F){return F.visibleGlobalOptions(D).reduce((E,B)=>{return Math.max(E,F.optionTerm(B).length)},0)}longestArgumentTermLength(D,F){return F.visibleArguments(D).reduce((E,B)=>{return Math.max(E,F.argumentTerm(B).length)},0)}commandUsage(D){let F=D._name;if(D._aliases[0])F=F+"|"+D._aliases[0];let E="";for(let B=D.parent;B;B=B.parent)E=B.name()+" "+E;return E+F+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((E)=>JSON.stringify(E)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)F.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)F.push(`env: ${D.envVar}`);if(F.length>0)return`${D.description} (${F.join(", ")})`;return D.description}argumentDescription(D){let F=[];if(D.argChoices)F.push(`choices: ${D.argChoices.map((E)=>JSON.stringify(E)).join(", ")}`);if(D.defaultValue!==void 0)F.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(F.length>0){let E=`(${F.join(", ")})`;if(D.description)return`${D.description} ${E}`;return E}return D.description}formatHelp(D,F){let E=F.padWidth(D,F),B=F.helpWidth||80,$=2,J=2;function X(U,R){if(R){let K=`${U.padEnd(E+2)}${R}`;return F.wrap(K,B-2,E+2)}return U}function Q(U){return U.join(`
4
- `).replace(/^/gm," ".repeat(2))}let Y=[`Usage: ${F.commandUsage(D)}`,""],q=F.commandDescription(D);if(q.length>0)Y=Y.concat([F.wrap(q,B,0),""]);let _=F.visibleArguments(D).map((U)=>{return X(F.argumentTerm(U),F.argumentDescription(U))});if(_.length>0)Y=Y.concat(["Arguments:",Q(_),""]);let H=F.visibleOptions(D).map((U)=>{return X(F.optionTerm(U),F.optionDescription(U))});if(H.length>0)Y=Y.concat(["Options:",Q(H),""]);if(this.showGlobalOptions){let U=F.visibleGlobalOptions(D).map((R)=>{return X(F.optionTerm(R),F.optionDescription(R))});if(U.length>0)Y=Y.concat(["Global Options:",Q(U),""])}let G=F.visibleCommands(D).map((U)=>{return X(F.subcommandTerm(U),F.subcommandDescription(U))});if(G.length>0)Y=Y.concat(["Commands:",Q(G),""]);return Y.join(`
5
- `)}padWidth(D,F){return Math.max(F.longestOptionTermLength(D,F),F.longestGlobalOptionTermLength(D,F),F.longestSubcommandTermLength(D,F),F.longestArgumentTermLength(D,F))}wrap(D,F,E,B=40){let J=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if(D.match(J))return D;let X=F-E;if(X<B)return D;let Q=D.slice(0,E),Y=D.slice(E).replace(`\r
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
- `),q=" ".repeat(E),H=`\\s${"\u200B"}`,G=new RegExp(`
8
- |.{1,${X-1}}([${H}]|$)|[^${H}]+?([${H}]|$)`,"g"),U=Y.match(G)||[];return Q+U.map((R,K)=>{if(R===`
9
- `)return"";return(K>0?q:"")+R.trimEnd()}).join(`
10
- `)}}e1.Help=m3});var u0=m(($F)=>{var{InvalidArgumentError:FF}=Z2();class p3{constructor(D,F){this.flags=D,this.description=F||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let E=BF(D);if(this.short=E.shortFlag,this.long=E.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(D,F){return this.defaultValue=D,this.defaultValueDescription=F,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let F=D;if(typeof D==="string")F={[D]:!0};return this.implied=Object.assign(this.implied||{},F),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_concatValue(D,F){if(F===this.defaultValue||!Array.isArray(F))return[D];return F.concat(D)}choices(D){return this.argChoices=D.slice(),this.parseArg=(F,E)=>{if(!this.argChoices.includes(F))throw new FF(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(F,E);return F},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return EF(this.name().replace(/^no-/,""))}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class c3{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((F)=>{if(F.negate)this.negativeOptions.set(F.attributeName(),F);else this.positiveOptions.set(F.attributeName(),F)}),this.negativeOptions.forEach((F,E)=>{if(this.positiveOptions.has(E))this.dualOptions.add(E)})}valueFromOption(D,F){let E=F.attributeName();if(!this.dualOptions.has(E))return!0;let B=this.negativeOptions.get(E).presetArg,$=B!==void 0?B:!1;return F.negate===($===D)}}function EF(D){return D.split("-").reduce((F,E)=>{return F+E[0].toUpperCase()+E.slice(1)})}function BF(D){let F,E,B=D.split(/[ |,]+/);if(B.length>1&&!/^[[<]/.test(B[1]))F=B.shift();if(E=B.shift(),!F&&/^-[^-]$/.test(E))F=E,E=void 0;return{shortFlag:F,longFlag:E}}$F.Option=p3;$F.DualOptions=c3});var d3=m((qF)=>{function QF(D,F){if(Math.abs(D.length-F.length)>3)return Math.max(D.length,F.length);let E=[];for(let B=0;B<=D.length;B++)E[B]=[B];for(let B=0;B<=F.length;B++)E[0][B]=B;for(let B=1;B<=F.length;B++)for(let $=1;$<=D.length;$++){let J=1;if(D[$-1]===F[B-1])J=0;else J=1;if(E[$][B]=Math.min(E[$-1][B]+1,E[$][B-1]+1,E[$-1][B-1]+J),$>1&&B>1&&D[$-1]===F[B-2]&&D[$-2]===F[B-1])E[$][B]=Math.min(E[$][B],E[$-2][B-2]+1)}return E[D.length][F.length]}function YF(D,F){if(!F||F.length===0)return"";F=Array.from(new Set(F));let E=D.startsWith("--");if(E)D=D.slice(2),F=F.map((X)=>X.slice(2));let B=[],$=3,J=0.4;if(F.forEach((X)=>{if(X.length<=1)return;let Q=QF(D,X),Y=Math.max(D.length,X.length);if((Y-Q)/Y>J){if(Q<$)$=Q,B=[X];else if(Q===$)B.push(X)}}),B.sort((X,Q)=>X.localeCompare(Q)),E)B=B.map((X)=>`--${X}`);if(B.length>1)return`
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
11
  (Did you mean one of ${B.join(", ")}?)`;if(B.length===1)return`
12
- (Did you mean ${B[0]}?)`;return""}qF.suggestSimilar=YF});var a3=m((CF)=>{var HF=VD("events").EventEmitter,f0=VD("child_process"),RD=VD("path"),Z0=VD("fs"),h=VD("process"),{Argument:WF,humanReadableArgName:GF}=s2(),{CommanderError:k0}=Z2(),{Help:AF}=I0(),{Option:i3,DualOptions:UF}=u0(),{suggestSimilar:n3}=d3();class v0 extends HF{constructor(D){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=D||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(F)=>h.stdout.write(F),writeErr:(F)=>h.stderr.write(F),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,outputError:(F,E)=>E(F)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let F=this;F;F=F.parent)D.push(F);return D}command(D,F,E){let B=F,$=E;if(typeof B==="object"&&B!==null)$=B,B=null;$=$||{};let[,J,X]=D.match(/([^ ]+) *(.*)/),Q=this.createCommand(J);if(B)Q.description(B),Q._executableHandler=!0;if($.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!($.noHelp||$.hidden),Q._executableFile=$.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),B)return this;return Q}createCommand(D){return new v0(D)}createHelp(){return Object.assign(new AF,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,D),this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,F){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
13
- - specify the name in Command constructor or using .name()`);if(F=F||{},F.isDefault)this._defaultCommandName=D._name;if(F.noHelp||F.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,F){return new WF(D,F)}argument(D,F,E,B){let $=this.createArgument(D,F);if(typeof E==="function")$.default(B).argParser(E);else $.default(E);return this.addArgument($),this}arguments(D){return D.trim().split(/ +/).forEach((F)=>{this.argument(F)}),this}addArgument(D){let F=this.registeredArguments.slice(-1)[0];if(F&&F.variadic)throw Error(`only the last argument can be variadic '${F.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,F){if(typeof D==="boolean")return this._addImplicitHelpCommand=D,this;D=D??"help [command]";let[,E,B]=D.match(/([^ ]+) *(.*)/),$=F??"display help for command",J=this.createCommand(E);if(J.helpOption(!1),B)J.arguments(B);if($)J.description($);return this._addImplicitHelpCommand=!0,this._helpCommand=J,this}addHelpCommand(D,F){if(typeof D!=="object")return this.helpCommand(D,F),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,F){let E=["preSubcommand","preAction","postAction"];if(!E.includes(D))throw Error(`Unexpected value for event passed to hook : '${D}'.
14
- Expecting one of '${E.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(F);else this._lifeCycleHooks[D]=[F];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(F)=>{if(F.code!=="commander.executeSubCommandAsync")throw F};return this}_exit(D,F,E){if(this._exitCallback)this._exitCallback(new k0(D,F,E));h.exit(D)}action(D){let F=(E)=>{let B=this.registeredArguments.length,$=E.slice(0,B);if(this._storeOptionsAsProperties)$[B]=this;else $[B]=this.opts();return $.push(this),D.apply(this,$)};return this._actionHandler=F,this}createOption(D,F){return new i3(D,F)}_callParseArg(D,F,E,B){try{return D.parseArg(F,E)}catch($){if($.code==="commander.invalidArgument"){let J=`${B} ${$.message}`;this.error(J,{exitCode:$.exitCode,code:$.code})}throw $}}_registerOption(D){let F=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(F){let E=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${E}'
15
- - already used by option '${F.flags}'`)}this.options.push(D)}_registerCommand(D){let F=(B)=>{return[B.name()].concat(B.aliases())},E=F(D).find((B)=>this._findCommand(B));if(E){let B=F(this._findCommand(E)).join("|"),$=F(D).join("|");throw Error(`cannot add command '${$}' as already have command '${B}'`)}this.commands.push(D)}addOption(D){this._registerOption(D);let F=D.name(),E=D.attributeName();if(D.negate){let $=D.long.replace(/^--no-/,"--");if(!this._findOption($))this.setOptionValueWithSource(E,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(E,D.defaultValue,"default");let B=($,J,X)=>{if($==null&&D.presetArg!==void 0)$=D.presetArg;let Q=this.getOptionValue(E);if($!==null&&D.parseArg)$=this._callParseArg(D,$,Q,J);else if($!==null&&D.variadic)$=D._concatValue($,Q);if($==null)if(D.negate)$=!1;else if(D.isBoolean()||D.optional)$=!0;else $="";this.setOptionValueWithSource(E,$,X)};if(this.on("option:"+F,($)=>{let J=`error: option '${D.flags}' argument '${$}' is invalid.`;B($,J,"cli")}),D.envVar)this.on("optionEnv:"+F,($)=>{let J=`error: option '${D.flags}' value '${$}' from env '${D.envVar}' is invalid.`;B($,J,"env")});return this}_optionEx(D,F,E,B,$){if(typeof F==="object"&&F instanceof i3)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let J=this.createOption(F,E);if(J.makeOptionMandatory(!!D.mandatory),typeof B==="function")J.default($).argParser(B);else if(B instanceof RegExp){let X=B;B=(Q,Y)=>{let q=X.exec(Q);return q?q[0]:Y},J.default($).argParser(B)}else J.default(B);return this.addOption(J)}option(D,F,E,B){return this._optionEx({},D,F,E,B)}requiredOption(D,F,E,B){return this._optionEx({mandatory:!0},D,F,E,B)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(D=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,F){return this.setOptionValueWithSource(D,F,void 0)}setOptionValueWithSource(D,F,E){if(this._storeOptionsAsProperties)this[D]=F;else this._optionValues[D]=F;return this._optionValueSources[D]=E,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let F;return this._getCommandAndAncestors().forEach((E)=>{if(E.getOptionValueSource(D)!==void 0)F=E.getOptionValueSource(D)}),F}_prepareUserArgs(D,F){if(D!==void 0&&!Array.isArray(D))throw Error("first parameter to parse must be array or undefined");if(F=F||{},D===void 0&&F.from===void 0){if(h.versions?.electron)F.from="electron";let B=h.execArgv??[];if(B.includes("-e")||B.includes("--eval")||B.includes("-p")||B.includes("--print"))F.from="eval"}if(D===void 0)D=h.argv;this.rawArgs=D.slice();let E;switch(F.from){case void 0:case"node":this._scriptPath=D[1],E=D.slice(2);break;case"electron":if(h.defaultApp)this._scriptPath=D[1],E=D.slice(2);else E=D.slice(1);break;case"user":E=D.slice(0);break;case"eval":E=D.slice(1);break;default:throw Error(`unexpected parse option { from: '${F.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",E}parse(D,F){let E=this._prepareUserArgs(D,F);return this._parseCommand([],E),this}async parseAsync(D,F){let E=this._prepareUserArgs(D,F);return await this._parseCommand([],E),this}_executeSubCommand(D,F){F=F.slice();let E=!1,B=[".js",".ts",".tsx",".mjs",".cjs"];function $(q,_){let H=RD.resolve(q,_);if(Z0.existsSync(H))return H;if(B.includes(RD.extname(_)))return;let G=B.find((U)=>Z0.existsSync(`${H}${U}`));if(G)return`${H}${G}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let J=D._executableFile||`${this._name}-${D._name}`,X=this._executableDir||"";if(this._scriptPath){let q;try{q=Z0.realpathSync(this._scriptPath)}catch(_){q=this._scriptPath}X=RD.resolve(RD.dirname(q),X)}if(X){let q=$(X,J);if(!q&&!D._executableFile&&this._scriptPath){let _=RD.basename(this._scriptPath,RD.extname(this._scriptPath));if(_!==this._name)q=$(X,`${_}-${D._name}`)}J=q||J}E=B.includes(RD.extname(J));let Q;if(h.platform!=="win32")if(E)F.unshift(J),F=r3(h.execArgv).concat(F),Q=f0.spawn(h.argv[0],F,{stdio:"inherit"});else Q=f0.spawn(J,F,{stdio:"inherit"});else F.unshift(J),F=r3(h.execArgv).concat(F),Q=f0.spawn(h.execPath,F,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((_)=>{h.on(_,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(_)})});let Y=this._exitCallback;Q.on("close",(q)=>{if(q=q??1,!Y)h.exit(q);else Y(new k0(q,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(q)=>{if(q.code==="ENOENT"){let _=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",H=`'${J}' does not exist
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
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
- - ${_}`;throw Error(H)}else if(q.code==="EACCES")throw Error(`'${J}' not executable`);if(!Y)h.exit(1);else{let _=new k0(1,"commander.executeSubCommandAsync","(error)");_.nestedError=q,Y(_)}}),this.runningCommand=Q}_dispatchSubcommand(D,F,E){let B=this._findCommand(D);if(!B)this.help({error:!0});let $;return $=this._chainOrCallSubCommandHook($,B,"preSubcommand"),$=this._chainOrCall($,()=>{if(B._executableHandler)this._executeSubCommand(B,F.concat(E));else return B._parseCommand(F,E)}),$}_dispatchHelpCommand(D){if(!D)this.help();let F=this._findCommand(D);if(F&&!F._executableHandler)F.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,F)=>{if(D.required&&this.args[F]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(E,B,$)=>{let J=B;if(B!==null&&E.parseArg){let X=`error: command-argument value '${B}' is invalid for argument '${E.name()}'.`;J=this._callParseArg(E,B,$,X)}return J};this._checkNumberOfArguments();let F=[];this.registeredArguments.forEach((E,B)=>{let $=E.defaultValue;if(E.variadic){if(B<this.args.length){if($=this.args.slice(B),E.parseArg)$=$.reduce((J,X)=>{return D(E,X,J)},E.defaultValue)}else if($===void 0)$=[]}else if(B<this.args.length){if($=this.args[B],E.parseArg)$=D(E,$,E.defaultValue)}F[B]=$}),this.processedArgs=F}_chainOrCall(D,F){if(D&&D.then&&typeof D.then==="function")return D.then(()=>F());return F()}_chainOrCallHooks(D,F){let E=D,B=[];if(this._getCommandAndAncestors().reverse().filter(($)=>$._lifeCycleHooks[F]!==void 0).forEach(($)=>{$._lifeCycleHooks[F].forEach((J)=>{B.push({hookedCommand:$,callback:J})})}),F==="postAction")B.reverse();return B.forEach(($)=>{E=this._chainOrCall(E,()=>{return $.callback($.hookedCommand,this)})}),E}_chainOrCallSubCommandHook(D,F,E){let B=D;if(this._lifeCycleHooks[E]!==void 0)this._lifeCycleHooks[E].forEach(($)=>{B=this._chainOrCall(B,()=>{return $(this,F)})});return B}_parseCommand(D,F){let E=this.parseOptions(F);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(E.operands),F=E.unknown,this.args=D.concat(F),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),F);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(F),this._dispatchSubcommand(this._defaultCommandName,D,F);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(E.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let B=()=>{if(E.unknown.length>0)this.unknownOption(E.unknown[0])},$=`command:${this.name()}`;if(this._actionHandler){B(),this._processArguments();let J;if(J=this._chainOrCallHooks(J,"preAction"),J=this._chainOrCall(J,()=>this._actionHandler(this.processedArgs)),this.parent)J=this._chainOrCall(J,()=>{this.parent.emit($,D,F)});return J=this._chainOrCallHooks(J,"postAction"),J}if(this.parent&&this.parent.listenerCount($))B(),this._processArguments(),this.parent.emit($,D,F);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,F);if(this.listenerCount("command:*"))this.emit("command:*",D,F);else if(this.commands.length)this.unknownCommand();else B(),this._processArguments()}else if(this.commands.length)B(),this.help({error:!0});else B(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((F)=>F._name===D||F._aliases.includes(D))}_findOption(D){return this.options.find((F)=>F.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((F)=>{if(F.mandatory&&D.getOptionValue(F.attributeName())===void 0)D.missingMandatoryOptionValue(F)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((E)=>{let B=E.attributeName();if(this.getOptionValue(B)===void 0)return!1;return this.getOptionValueSource(B)!=="default"});D.filter((E)=>E.conflictsWith.length>0).forEach((E)=>{let B=D.find(($)=>E.conflictsWith.includes($.attributeName()));if(B)this._conflictingOption(E,B)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let F=[],E=[],B=F,$=D.slice();function J(Q){return Q.length>1&&Q[0]==="-"}let X=null;while($.length){let Q=$.shift();if(Q==="--"){if(B===E)B.push(Q);B.push(...$);break}if(X&&!J(Q)){this.emit(`option:${X.name()}`,Q);continue}if(X=null,J(Q)){let Y=this._findOption(Q);if(Y){if(Y.required){let q=$.shift();if(q===void 0)this.optionMissingArgument(Y);this.emit(`option:${Y.name()}`,q)}else if(Y.optional){let q=null;if($.length>0&&!J($[0]))q=$.shift();this.emit(`option:${Y.name()}`,q)}else this.emit(`option:${Y.name()}`);X=Y.variadic?Y:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let Y=this._findOption(`-${Q[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Q.slice(2));else this.emit(`option:${Y.name()}`),$.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let Y=Q.indexOf("="),q=this._findOption(Q.slice(0,Y));if(q&&(q.required||q.optional)){this.emit(`option:${q.name()}`,Q.slice(Y+1));continue}}if(J(Q))B=E;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&E.length===0){if(this._findCommand(Q)){if(F.push(Q),$.length>0)E.push(...$);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(F.push(Q),$.length>0)F.push(...$);break}else if(this._defaultCommandName){if(E.push(Q),$.length>0)E.push(...$);break}}if(this._passThroughOptions){if(B.push(Q),$.length>0)B.push(...$);break}B.push(Q)}return{operands:F,unknown:E}}opts(){if(this._storeOptionsAsProperties){let D={},F=this.options.length;for(let E=0;E<F;E++){let B=this.options[E].attributeName();D[B]=B===this._versionOptionName?this._version:this[B]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,F)=>Object.assign(D,F.opts()),{})}error(D,F){if(this._outputConfiguration.outputError(`${D}
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 E=F||{},B=E.exitCode||1,$=E.code||"commander.error";this._exit(B,$,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in h.env){let F=D.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,h.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new UF(this.options),F=(E)=>{return this.getOptionValue(E)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(E))};this.options.filter((E)=>E.implied!==void 0&&F(E.attributeName())&&D.valueFromOption(this.getOptionValue(E.attributeName()),E)).forEach((E)=>{Object.keys(E.implied).filter((B)=>!F(B)).forEach((B)=>{this.setOptionValueWithSource(B,E.implied[B],"implied")})})}missingArgument(D){let F=`error: missing required argument '${D}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(D){let F=`error: option '${D.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let F=`error: required option '${D.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,F){let E=(J)=>{let X=J.attributeName(),Q=this.getOptionValue(X),Y=this.options.find((_)=>_.negate&&X===_.attributeName()),q=this.options.find((_)=>!_.negate&&X===_.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return q||J},B=(J)=>{let X=E(J),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},$=`error: ${B(D)} cannot be used with ${B(F)}`;this.error($,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let F="";if(D.startsWith("--")&&this._showSuggestionAfterError){let B=[],$=this;do{let J=$.createHelp().visibleOptions($).filter((X)=>X.long).map((X)=>X.long);B=B.concat(J),$=$.parent}while($&&!$._enablePositionalOptions);F=n3(D,B)}let E=`error: unknown option '${D}'${F}`;this.error(E,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,E=F===1?"":"s",$=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${E} but got ${D.length}.`;this.error($,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],F="";if(this._showSuggestionAfterError){let B=[];this.createHelp().visibleCommands(this).forEach(($)=>{if(B.push($.name()),$.alias())B.push($.alias())}),F=n3(D,B)}let E=`error: unknown command '${D}'${F}`;this.error(E,{code:"commander.unknownCommand"})}version(D,F,E){if(D===void 0)return this._version;this._version=D,F=F||"-V, --version",E=E||"output the version number";let B=this.createOption(F,E);return this._versionOptionName=B.attributeName(),this._registerOption(B),this.on("option:"+B.name(),()=>{this._outputConfiguration.writeOut(`${D}
22
- `),this._exit(0,"commander.version",D)}),this}description(D,F){if(D===void 0&&F===void 0)return this._description;if(this._description=D,F)this._argsDescription=F;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(D===F._name)throw Error("Command alias can't be the same as its name");let E=this.parent?._findCommand(D);if(E){let B=[E.name()].concat(E.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${B}'`)}return F._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((F)=>this.alias(F)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((E)=>{return GF(E)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}nameFromFilename(D){return this._name=RD.basename(D,RD.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let F=this.createHelp();if(F.helpWidth===void 0)F.helpWidth=D&&D.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return F.formatHelp(this,F)}_getHelpContext(D){D=D||{};let F={error:!!D.error},E;if(F.error)E=(B)=>this._outputConfiguration.writeErr(B);else E=(B)=>this._outputConfiguration.writeOut(B);return F.write=D.write||E,F.command=this,F}outputHelp(D){let F;if(typeof D==="function")F=D,D=void 0;let E=this._getHelpContext(D);this._getCommandAndAncestors().reverse().forEach(($)=>$.emit("beforeAllHelp",E)),this.emit("beforeHelp",E);let B=this.helpInformation(E);if(F){if(B=F(B),typeof B!=="string"&&!Buffer.isBuffer(B))throw Error("outputHelp callback must return a string or a Buffer")}if(E.write(B),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",E),this._getCommandAndAncestors().forEach(($)=>$.emit("afterAllHelp",E))}helpOption(D,F){if(typeof D==="boolean"){if(D)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return D=D??"-h, --help",F=F??"display help for command",this._helpOption=this.createOption(D,F),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this}help(D){this.outputHelp(D);let F=h.exitCode||0;if(F===0&&D&&typeof D!=="function"&&D.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(D,F){let E=["beforeAll","before","after","afterAll"];if(!E.includes(D))throw Error(`Unexpected value for position to addHelpText.
23
- Expecting one of '${E.join("', '")}'`);let B=`${D}Help`;return this.on(B,($)=>{let J;if(typeof F==="function")J=F({error:$.error,command:$.command});else J=F;if(J)$.write(`${J}
24
- `)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find((B)=>F.is(B)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function r3(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let E,B="127.0.0.1",$="9229",J;if((J=F.match(/^(--inspect(-brk)?)$/))!==null)E=J[1];else if((J=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(E=J[1],/^\d+$/.test(J[3]))$=J[3];else B=J[3];else if((J=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)E=J[1],B=J[3],$=J[4];if(E&&$!=="0")return`${E}=${B}:${parseInt($)+1}`;return F})}CF.Command=v0});var e3=m((KF)=>{var{Argument:o3}=s2(),{Command:x0}=a3(),{CommanderError:VF,InvalidArgumentError:s3}=Z2(),{Help:RF}=I0(),{Option:t3}=u0();KF.program=new x0;KF.createCommand=(D)=>new x0(D);KF.createOption=(D,F)=>new t3(D,F);KF.createArgument=(D,F)=>new o3(D,F);KF.Command=x0;KF.Option=t3;KF.Argument=o3;KF.Help=RF;KF.CommanderError=VF;KF.InvalidArgumentError=s3;KF.InvalidOptionArgumentError=s3});var oD={};h3(oD,{updateState:()=>T2,update:()=>X9,unregister:()=>rD,register:()=>J3,list:()=>aD,hasWorkerForTask:()=>Y9,getRegistryPath:()=>W9,getElapsedTime:()=>_9,getConfigDir:()=>H9,getByState:()=>q9,get:()=>X3,findByWish:()=>Q9,findByTask:()=>vD,findByPane:()=>Q3});import{mkdir as F9,readFile as E9,writeFile as B9}from"fs/promises";import{join as T6}from"path";import{homedir as $9}from"os";async function J9(){await F9(B3,{recursive:!0})}async function S2(){try{let D=await E9($3,"utf-8");return JSON.parse(D)}catch{return{workers:{},lastUpdated:new Date().toISOString()}}}async function z0(D){await J9(),D.lastUpdated=new Date().toISOString(),await B9($3,JSON.stringify(D,null,2))}async function J3(D){let F=await S2();F.workers[D.id]=D,await z0(F)}async function rD(D){let F=await S2();delete F.workers[D],await z0(F)}async function X3(D){return(await S2()).workers[D]||null}async function aD(){let D=await S2();return Object.values(D.workers)}async function T2(D,F){let E=await S2(),B=E.workers[D];if(B)B.state=F,B.lastStateChange=new Date().toISOString(),await z0(E)}async function X9(D,F){let E=await S2(),B=E.workers[D];if(B){if(Object.assign(B,F),F.state)B.lastStateChange=new Date().toISOString();await z0(E)}}async function Q3(D){let F=await aD(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function vD(D){return(await aD()).find((E)=>E.taskId===D)||null}async function Q9(D){return(await aD()).filter((E)=>E.wishSlug===D)}async function Y9(D){return await vD(D)!==null}async function q9(D){return(await aD()).filter((E)=>E.state===D)}function _9(D){let F=new Date(D.startedAt).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60),J;if($>0)J=`${$}h ${B%60}m`;else if(B>0)J=`${B}m`;else J="<1m";return{ms:E,formatted:J}}function H9(){return B3}function W9(){return $3}var B3,$3;var sD=p1(()=>{B3=T6($9(),".config","term"),$3=T6(B3,"workers.json")});var K0=m((u$,k6)=>{var Z9=VD("tty"),k9=Z9?.WriteStream?.prototype?.hasColors?.()??!1,w=(D,F)=>{if(!k9)return($)=>$;let E=`\x1B[${D}m`,B=`\x1B[${F}m`;return($)=>{let J=$+"",X=J.indexOf(B);if(X===-1)return E+J+B;let Q=E,Y=0,_=(F===22?B:"")+E;while(X!==-1)Q+=J.slice(Y,X)+_,Y=X+B.length,X=J.indexOf(B,Y);return Q+=J.slice(Y)+B,Q}},b={};b.reset=w(0,0);b.bold=w(1,22);b.dim=w(2,22);b.italic=w(3,23);b.underline=w(4,24);b.overline=w(53,55);b.inverse=w(7,27);b.hidden=w(8,28);b.strikethrough=w(9,29);b.black=w(30,39);b.red=w(31,39);b.green=w(32,39);b.yellow=w(33,39);b.blue=w(34,39);b.magenta=w(35,39);b.cyan=w(36,39);b.white=w(37,39);b.gray=w(90,39);b.bgBlack=w(40,49);b.bgRed=w(41,49);b.bgGreen=w(42,49);b.bgYellow=w(43,49);b.bgBlue=w(44,49);b.bgMagenta=w(45,49);b.bgCyan=w(46,49);b.bgWhite=w(47,49);b.bgGray=w(100,49);b.redBright=w(91,39);b.greenBright=w(92,39);b.yellowBright=w(93,39);b.blueBright=w(94,39);b.magentaBright=w(95,39);b.cyanBright=w(96,39);b.whiteBright=w(97,39);b.bgRedBright=w(101,49);b.bgGreenBright=w(102,49);b.bgYellowBright=w(103,49);b.bgBlueBright=w(104,49);b.bgMagentaBright=w(105,49);b.bgCyanBright=w(106,49);b.bgWhiteBright=w(107,49);k6.exports=b});var m6=m((t$,l6)=>{l6.exports=p9;function m9(D){let F={defaultWidth:0,output:process.stdout,tty:VD("tty")};if(!D)return F;return Object.keys(F).forEach(function(E){if(!D[E])D[E]=F[E]}),D}function p9(D){let F=m9(D);if(F.output.getWindowSize)return F.output.getWindowSize()[0]||F.defaultWidth;if(F.tty.getWindowSize)return F.tty.getWindowSize()[1]||F.defaultWidth;if(F.output.columns)return F.output.columns;if(process.env.CLI_WIDTH){let E=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(E)&&E!==0)return E}return F.defaultWidth}});var c6=m((e$,p6)=>{p6.exports=({onlyFirst:D=!1}={})=>{let F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(F,D?void 0:"g")}});var z3=m((DJ,d6)=>{var c9=c6();d6.exports=(D)=>typeof D==="string"?D.replace(c9(),""):D});var n6=m((FJ,V3)=>{var i6=(D)=>{if(Number.isNaN(D))return!1;if(D>=4352&&(D<=4447||D===9001||D===9002||11904<=D&&D<=12871&&D!==12351||12880<=D&&D<=19903||19968<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65131||65281<=D&&D<=65376||65504<=D&&D<=65510||110592<=D&&D<=110593||127488<=D&&D<=127569||131072<=D&&D<=262141))return!0;return!1};V3.exports=i6;V3.exports.default=i6});var a6=m((EJ,r6)=>{r6.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var s6=m((BJ,R3)=>{var d9=z3(),i9=n6(),n9=a6(),o6=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=d9(D),D.length===0)return 0;D=D.replace(n9()," ");let F=0;for(let E=0;E<D.length;E++){let B=D.codePointAt(E);if(B<=31||B>=127&&B<=159)continue;if(B>=768&&B<=879)continue;if(B>65535)E++;F+=i9(B)?2:1}return F};R3.exports=o6;R3.exports.default=o6});var e6=m(($J,t6)=>{t6.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var K3=m((JJ,F1)=>{var n2=e6(),D1={};for(let D of Object.keys(n2))D1[n2[D]]=D;var V={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};F1.exports=V;for(let D of Object.keys(V)){if(!("channels"in V[D]))throw Error("missing channels property: "+D);if(!("labels"in V[D]))throw Error("missing channel labels property: "+D);if(V[D].labels.length!==V[D].channels)throw Error("channel and label counts mismatch: "+D);let{channels:F,labels:E}=V[D];delete V[D].channels,delete V[D].labels,Object.defineProperty(V[D],"channels",{value:F}),Object.defineProperty(V[D],"labels",{value:E})}V.rgb.hsl=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.min(F,E,B),J=Math.max(F,E,B),X=J-$,Q,Y;if(J===$)Q=0;else if(F===J)Q=(E-B)/X;else if(E===J)Q=2+(B-F)/X;else if(B===J)Q=4+(F-E)/X;if(Q=Math.min(Q*60,360),Q<0)Q+=360;let q=($+J)/2;if(J===$)Y=0;else if(q<=0.5)Y=X/(J+$);else Y=X/(2-J-$);return[Q,Y*100,q*100]};V.rgb.hsv=function(D){let F,E,B,$,J,X=D[0]/255,Q=D[1]/255,Y=D[2]/255,q=Math.max(X,Q,Y),_=q-Math.min(X,Q,Y),H=function(G){return(q-G)/6/_+0.5};if(_===0)$=0,J=0;else{if(J=_/q,F=H(X),E=H(Q),B=H(Y),X===q)$=B-E;else if(Q===q)$=0.3333333333333333+F-B;else if(Y===q)$=0.6666666666666666+E-F;if($<0)$+=1;else if($>1)$-=1}return[$*360,J*100,q*100]};V.rgb.hwb=function(D){let F=D[0],E=D[1],B=D[2],$=V.rgb.hsl(D)[0],J=0.00392156862745098*Math.min(F,Math.min(E,B));return B=1-0.00392156862745098*Math.max(F,Math.max(E,B)),[$,J*100,B*100]};V.rgb.cmyk=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.min(1-F,1-E,1-B),J=(1-F-$)/(1-$)||0,X=(1-E-$)/(1-$)||0,Q=(1-B-$)/(1-$)||0;return[J*100,X*100,Q*100,$*100]};function r9(D,F){return(D[0]-F[0])**2+(D[1]-F[1])**2+(D[2]-F[2])**2}V.rgb.keyword=function(D){let F=D1[D];if(F)return F;let E=1/0,B;for(let $ of Object.keys(n2)){let J=n2[$],X=r9(D,J);if(X<E)E=X,B=$}return B};V.keyword.rgb=function(D){return n2[D]};V.rgb.xyz=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255;F=F>0.04045?((F+0.055)/1.055)**2.4:F/12.92,E=E>0.04045?((E+0.055)/1.055)**2.4:E/12.92,B=B>0.04045?((B+0.055)/1.055)**2.4:B/12.92;let $=F*0.4124+E*0.3576+B*0.1805,J=F*0.2126+E*0.7152+B*0.0722,X=F*0.0193+E*0.1192+B*0.9505;return[$*100,J*100,X*100]};V.rgb.lab=function(D){let F=V.rgb.xyz(D),E=F[0],B=F[1],$=F[2];E/=95.047,B/=100,$/=108.883,E=E>0.008856?E**0.3333333333333333:7.787*E+0.13793103448275862,B=B>0.008856?B**0.3333333333333333:7.787*B+0.13793103448275862,$=$>0.008856?$**0.3333333333333333:7.787*$+0.13793103448275862;let J=116*B-16,X=500*(E-B),Q=200*(B-$);return[J,X,Q]};V.hsl.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$,J,X;if(E===0)return X=B*255,[X,X,X];if(B<0.5)$=B*(1+E);else $=B+E-B*E;let Q=2*B-$,Y=[0,0,0];for(let q=0;q<3;q++){if(J=F+0.3333333333333333*-(q-1),J<0)J++;if(J>1)J--;if(6*J<1)X=Q+($-Q)*6*J;else if(2*J<1)X=$;else if(3*J<2)X=Q+($-Q)*(0.6666666666666666-J)*6;else X=Q;Y[q]=X*255}return Y};V.hsl.hsv=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=E,J=Math.max(B,0.01);B*=2,E*=B<=1?B:2-B,$*=J<=1?J:2-J;let X=(B+E)/2,Q=B===0?2*$/(J+$):2*E/(B+E);return[F,Q*100,X*100]};V.hsv.rgb=function(D){let F=D[0]/60,E=D[1]/100,B=D[2]/100,$=Math.floor(F)%6,J=F-Math.floor(F),X=255*B*(1-E),Q=255*B*(1-E*J),Y=255*B*(1-E*(1-J));switch(B*=255,$){case 0:return[B,Y,X];case 1:return[Q,B,X];case 2:return[X,B,Y];case 3:return[X,Q,B];case 4:return[Y,X,B];case 5:return[B,X,Q]}};V.hsv.hsl=function(D){let F=D[0],E=D[1]/100,B=D[2]/100,$=Math.max(B,0.01),J,X;X=(2-E)*B;let Q=(2-E)*$;return J=E*$,J/=Q<=1?Q:2-Q,J=J||0,X/=2,[F,J*100,X*100]};V.hwb.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100,$=E+B,J;if($>1)E/=$,B/=$;let X=Math.floor(6*F),Q=1-B;if(J=6*F-X,(X&1)!==0)J=1-J;let Y=E+J*(Q-E),q,_,H;switch(X){default:case 6:case 0:q=Q,_=Y,H=E;break;case 1:q=Y,_=Q,H=E;break;case 2:q=E,_=Q,H=Y;break;case 3:q=E,_=Y,H=Q;break;case 4:q=Y,_=E,H=Q;break;case 5:q=Q,_=E,H=Y;break}return[q*255,_*255,H*255]};V.cmyk.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$=D[3]/100,J=1-Math.min(1,F*(1-$)+$),X=1-Math.min(1,E*(1-$)+$),Q=1-Math.min(1,B*(1-$)+$);return[J*255,X*255,Q*255]};V.xyz.rgb=function(D){let F=D[0]/100,E=D[1]/100,B=D[2]/100,$,J,X;return $=F*3.2406+E*-1.5372+B*-0.4986,J=F*-0.9689+E*1.8758+B*0.0415,X=F*0.0557+E*-0.204+B*1.057,$=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92,J=J>0.0031308?1.055*J**0.4166666666666667-0.055:J*12.92,X=X>0.0031308?1.055*X**0.4166666666666667-0.055:X*12.92,$=Math.min(Math.max(0,$),1),J=Math.min(Math.max(0,J),1),X=Math.min(Math.max(0,X),1),[$*255,J*255,X*255]};V.xyz.lab=function(D){let F=D[0],E=D[1],B=D[2];F/=95.047,E/=100,B/=108.883,F=F>0.008856?F**0.3333333333333333:7.787*F+0.13793103448275862,E=E>0.008856?E**0.3333333333333333:7.787*E+0.13793103448275862,B=B>0.008856?B**0.3333333333333333:7.787*B+0.13793103448275862;let $=116*E-16,J=500*(F-E),X=200*(E-B);return[$,J,X]};V.lab.xyz=function(D){let F=D[0],E=D[1],B=D[2],$,J,X;J=(F+16)/116,$=E/500+J,X=J-B/200;let Q=J**3,Y=$**3,q=X**3;return J=Q>0.008856?Q:(J-0.13793103448275862)/7.787,$=Y>0.008856?Y:($-0.13793103448275862)/7.787,X=q>0.008856?q:(X-0.13793103448275862)/7.787,$*=95.047,J*=100,X*=108.883,[$,J,X]};V.lab.lch=function(D){let F=D[0],E=D[1],B=D[2],$;if($=Math.atan2(B,E)*360/2/Math.PI,$<0)$+=360;let X=Math.sqrt(E*E+B*B);return[F,X,$]};V.lch.lab=function(D){let F=D[0],E=D[1],$=D[2]/360*2*Math.PI,J=E*Math.cos($),X=E*Math.sin($);return[F,J,X]};V.rgb.ansi16=function(D,F=null){let[E,B,$]=D,J=F===null?V.rgb.hsv(D)[2]:F;if(J=Math.round(J/50),J===0)return 30;let X=30+(Math.round($/255)<<2|Math.round(B/255)<<1|Math.round(E/255));if(J===2)X+=60;return X};V.hsv.ansi16=function(D){return V.rgb.ansi16(V.hsv.rgb(D),D[2])};V.rgb.ansi256=function(D){let F=D[0],E=D[1],B=D[2];if(F===E&&E===B){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(E/255*5)+Math.round(B/255*5)};V.ansi16.rgb=function(D){let F=D%10;if(F===0||F===7){if(D>50)F+=3.5;return F=F/10.5*255,[F,F,F]}let E=(~~(D>50)+1)*0.5,B=(F&1)*E*255,$=(F>>1&1)*E*255,J=(F>>2&1)*E*255;return[B,$,J]};V.ansi256.rgb=function(D){if(D>=232){let J=(D-232)*10+8;return[J,J,J]}D-=16;let F,E=Math.floor(D/36)/5*255,B=Math.floor((F=D%36)/6)/5*255,$=F%6/5*255;return[E,B,$]};V.rgb.hex=function(D){let E=(((Math.round(D[0])&255)<<16)+((Math.round(D[1])&255)<<8)+(Math.round(D[2])&255)).toString(16).toUpperCase();return"000000".substring(E.length)+E};V.hex.rgb=function(D){let F=D.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!F)return[0,0,0];let E=F[0];if(F[0].length===3)E=E.split("").map((Q)=>{return Q+Q}).join("");let B=parseInt(E,16),$=B>>16&255,J=B>>8&255,X=B&255;return[$,J,X]};V.rgb.hcg=function(D){let F=D[0]/255,E=D[1]/255,B=D[2]/255,$=Math.max(Math.max(F,E),B),J=Math.min(Math.min(F,E),B),X=$-J,Q,Y;if(X<1)Q=J/(1-X);else Q=0;if(X<=0)Y=0;else if($===F)Y=(E-B)/X%6;else if($===E)Y=2+(B-F)/X;else Y=4+(F-E)/X;return Y/=6,Y%=1,[Y*360,X*100,Q*100]};V.hsl.hcg=function(D){let F=D[1]/100,E=D[2]/100,B=E<0.5?2*F*E:2*F*(1-E),$=0;if(B<1)$=(E-0.5*B)/(1-B);return[D[0],B*100,$*100]};V.hsv.hcg=function(D){let F=D[1]/100,E=D[2]/100,B=F*E,$=0;if(B<1)$=(E-B)/(1-B);return[D[0],B*100,$*100]};V.hcg.rgb=function(D){let F=D[0]/360,E=D[1]/100,B=D[2]/100;if(E===0)return[B*255,B*255,B*255];let $=[0,0,0],J=F%1*6,X=J%1,Q=1-X,Y=0;switch(Math.floor(J)){case 0:$[0]=1,$[1]=X,$[2]=0;break;case 1:$[0]=Q,$[1]=1,$[2]=0;break;case 2:$[0]=0,$[1]=1,$[2]=X;break;case 3:$[0]=0,$[1]=Q,$[2]=1;break;case 4:$[0]=X,$[1]=0,$[2]=1;break;default:$[0]=1,$[1]=0,$[2]=Q}return Y=(1-E)*B,[(E*$[0]+Y)*255,(E*$[1]+Y)*255,(E*$[2]+Y)*255]};V.hcg.hsv=function(D){let F=D[1]/100,E=D[2]/100,B=F+E*(1-F),$=0;if(B>0)$=F/B;return[D[0],$*100,B*100]};V.hcg.hsl=function(D){let F=D[1]/100,B=D[2]/100*(1-F)+0.5*F,$=0;if(B>0&&B<0.5)$=F/(2*B);else if(B>=0.5&&B<1)$=F/(2*(1-B));return[D[0],$*100,B*100]};V.hcg.hwb=function(D){let F=D[1]/100,E=D[2]/100,B=F+E*(1-F);return[D[0],(B-F)*100,(1-B)*100]};V.hwb.hcg=function(D){let F=D[1]/100,B=1-D[2]/100,$=B-F,J=0;if($<1)J=(B-$)/(1-$);return[D[0],$*100,J*100]};V.apple.rgb=function(D){return[D[0]/65535*255,D[1]/65535*255,D[2]/65535*255]};V.rgb.apple=function(D){return[D[0]/255*65535,D[1]/255*65535,D[2]/255*65535]};V.gray.rgb=function(D){return[D[0]/100*255,D[0]/100*255,D[0]/100*255]};V.gray.hsl=function(D){return[0,0,D[0]]};V.gray.hsv=V.gray.hsl;V.gray.hwb=function(D){return[0,100,D[0]]};V.gray.cmyk=function(D){return[0,0,0,D[0]]};V.gray.lab=function(D){return[D[0],0,0]};V.gray.hex=function(D){let F=Math.round(D[0]/100*255)&255,B=((F<<16)+(F<<8)+F).toString(16).toUpperCase();return"000000".substring(B.length)+B};V.rgb.gray=function(D){return[(D[0]+D[1]+D[2])/3/255*100]}});var B1=m((XJ,E1)=>{var L0=K3();function a9(){let D={},F=Object.keys(L0);for(let E=F.length,B=0;B<E;B++)D[F[B]]={distance:-1,parent:null};return D}function o9(D){let F=a9(),E=[D];F[D].distance=0;while(E.length){let B=E.pop(),$=Object.keys(L0[B]);for(let J=$.length,X=0;X<J;X++){let Q=$[X],Y=F[Q];if(Y.distance===-1)Y.distance=F[B].distance+1,Y.parent=B,E.unshift(Q)}}return F}function s9(D,F){return function(E){return F(D(E))}}function t9(D,F){let E=[F[D].parent,D],B=L0[F[D].parent][D],$=F[D].parent;while(F[$].parent)E.unshift(F[$].parent),B=s9(L0[F[$].parent][$],B),$=F[$].parent;return B.conversion=E,B}E1.exports=function(D){let F=o9(D),E={},B=Object.keys(F);for(let $=B.length,J=0;J<$;J++){let X=B[J];if(F[X].parent===null)continue;E[X]=t9(X,F)}return E}});var J1=m((QJ,$1)=>{var j3=K3(),e9=B1(),P2={},D4=Object.keys(j3);function F4(D){let F=function(...E){let B=E[0];if(B===void 0||B===null)return B;if(B.length>1)E=B;return D(E)};if("conversion"in D)F.conversion=D.conversion;return F}function E4(D){let F=function(...E){let B=E[0];if(B===void 0||B===null)return B;if(B.length>1)E=B;let $=D(E);if(typeof $==="object")for(let J=$.length,X=0;X<J;X++)$[X]=Math.round($[X]);return $};if("conversion"in D)F.conversion=D.conversion;return F}D4.forEach((D)=>{P2[D]={},Object.defineProperty(P2[D],"channels",{value:j3[D].channels}),Object.defineProperty(P2[D],"labels",{value:j3[D].labels});let F=e9(D);Object.keys(F).forEach((B)=>{let $=F[B];P2[D][B]=E4($),P2[D][B].raw=F4($)})});$1.exports=P2});var H1=m((YJ,_1)=>{var X1=(D,F)=>(...E)=>{return`\x1B[${D(...E)+F}m`},Q1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};5;${B}m`},Y1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};2;${B[0]};${B[1]};${B[2]}m`},M0=(D)=>D,q1=(D,F,E)=>[D,F,E],I2=(D,F,E)=>{Object.defineProperty(D,F,{get:()=>{let B=E();return Object.defineProperty(D,F,{value:B,enumerable:!0,configurable:!0}),B},enumerable:!0,configurable:!0})},L3,u2=(D,F,E,B)=>{if(L3===void 0)L3=J1();let $=B?10:0,J={};for(let[X,Q]of Object.entries(L3)){let Y=X==="ansi16"?"ansi":X;if(X===F)J[Y]=D(E,$);else if(typeof Q==="object")J[Y]=D(Q[F],$)}return J};function B4(){let D=new Map,F={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};F.color.gray=F.color.blackBright,F.bgColor.bgGray=F.bgColor.bgBlackBright,F.color.grey=F.color.blackBright,F.bgColor.bgGrey=F.bgColor.bgBlackBright;for(let[E,B]of Object.entries(F)){for(let[$,J]of Object.entries(B))F[$]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},B[$]=F[$],D.set(J[0],J[1]);Object.defineProperty(F,E,{value:B,enumerable:!1})}return Object.defineProperty(F,"codes",{value:D,enumerable:!1}),F.color.close="\x1B[39m",F.bgColor.close="\x1B[49m",I2(F.color,"ansi",()=>u2(X1,"ansi16",M0,!1)),I2(F.color,"ansi256",()=>u2(Q1,"ansi256",M0,!1)),I2(F.color,"ansi16m",()=>u2(Y1,"rgb",q1,!1)),I2(F.bgColor,"ansi",()=>u2(X1,"ansi16",M0,!0)),I2(F.bgColor,"ansi256",()=>u2(Q1,"ansi256",M0,!0)),I2(F.bgColor,"ansi16m",()=>u2(Y1,"rgb",q1,!0)),F}Object.defineProperty(_1,"exports",{enumerable:!0,get:B4})});var A1=m((qJ,G1)=>{var r2=s6(),$4=z3(),J4=H1(),O3=new Set(["\x1B","\x9B"]),W1=(D)=>`${O3.values().next().value}[${D}m`,X4=(D)=>D.split(" ").map((F)=>r2(F)),M3=(D,F,E)=>{let B=[...F],$=!1,J=r2($4(D[D.length-1]));for(let[X,Q]of B.entries()){let Y=r2(Q);if(J+Y<=E)D[D.length-1]+=Q;else D.push(Q),J=0;if(O3.has(Q))$=!0;else if($&&Q==="m"){$=!1;continue}if($)continue;if(J+=Y,J===E&&X<B.length-1)D.push(""),J=0}if(!J&&D[D.length-1].length>0&&D.length>1)D[D.length-2]+=D.pop()},Q4=(D)=>{let F=D.split(" "),E=F.length;while(E>0){if(r2(F[E-1])>0)break;E--}if(E===F.length)return D;return F.slice(0,E).join(" ")+F.slice(E).join("")},Y4=(D,F,E={})=>{if(E.trim!==!1&&D.trim()==="")return"";let B="",$="",J,X=X4(D),Q=[""];for(let[Y,q]of D.split(" ").entries()){if(E.trim!==!1)Q[Q.length-1]=Q[Q.length-1].trimLeft();let _=r2(Q[Q.length-1]);if(Y!==0){if(_>=F&&(E.wordWrap===!1||E.trim===!1))Q.push(""),_=0;if(_>0||E.trim===!1)Q[Q.length-1]+=" ",_++}if(E.hard&&X[Y]>F){let H=F-_,G=1+Math.floor((X[Y]-H-1)/F);if(Math.floor((X[Y]-1)/F)<G)Q.push("");M3(Q,q,F);continue}if(_+X[Y]>F&&_>0&&X[Y]>0){if(E.wordWrap===!1&&_<F){M3(Q,q,F);continue}Q.push("")}if(_+X[Y]>F&&E.wordWrap===!1){M3(Q,q,F);continue}Q[Q.length-1]+=q}if(E.trim!==!1)Q=Q.map(Q4);B=Q.join(`
25
- `);for(let[Y,q]of[...B].entries()){if($+=q,O3.has(q)){let H=parseFloat(/\d[^m]*/.exec(B.slice(Y,Y+4)));J=H===39?null:H}let _=J4.codes.get(Number(J));if(J&&_){if(B[Y+1]===`
26
- `)$+=W1(_);else if(q===`
27
- `)$+=W1(J)}}return $};G1.exports=(D,F,E)=>{return String(D).normalize().replace(/\r\n/g,`
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
28
  `).split(`
29
- `).map((B)=>Y4(B,F,E)).join(`
30
- `)}});var R1=m((UJ,V1)=>{var _4=VD("stream");class z1 extends _4{#E=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#F(D,F){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return F}#D(D,...F){if(typeof this._dest?.[D]==="function")this._dest[D](...F);if(typeof this._src?.[D]==="function")this._src[D](...F)}get isTTY(){if(this.#E!==null)return this.#E;return this.#F("isTTY",!1)}set isTTY(D){this.#E=D}get rows(){return this.#F("rows")}get columns(){return this.#F("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,F){return this._dest=D,super.pipe(D,F)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#D("destroy",...D)}destroySoon(...D){return this.#D("destroySoon",...D)}close(...D){return this.#D("close",...D)}}V1.exports=z1});var D8=xD(e3(),1),{program:n4,createCommand:r4,createArgument:a4,createOption:o4,CommanderError:s4,InvalidArgumentError:t4,InvalidOptionArgumentError:e4,Command:F8,Argument:DE,Option:FE,Help:EE}=D8.default;var E8="0.260202.1833";import{join as B5}from"path";var i=[];for(let D=0;D<256;++D)i.push((D+256).toString(16).slice(1));function B8(D,F=0){return(i[D[F+0]]+i[D[F+1]]+i[D[F+2]]+i[D[F+3]]+"-"+i[D[F+4]]+i[D[F+5]]+"-"+i[D[F+6]]+i[D[F+7]]+"-"+i[D[F+8]]+i[D[F+9]]+"-"+i[D[F+10]]+i[D[F+11]]+i[D[F+12]]+i[D[F+13]]+i[D[F+14]]+i[D[F+15]]).toLowerCase()}import{randomFillSync as uF}from"crypto";var e2=new Uint8Array(256),t2=e2.length;function y0(){if(t2>e2.length-16)uF(e2),t2=0;return e2.slice(t2,t2+=16)}import{randomUUID as fF}from"crypto";var h0={randomUUID:fF};function ZF(D,F,E){if(h0.randomUUID&&!F&&!D)return h0.randomUUID();D=D||{};let B=D.random??D.rng?.()??y0();if(B.length<16)throw Error("Random bytes length must be >= 16");if(B[6]=B[6]&15|64,B[8]=B[8]&63|128,F){if(E=E||0,E<0||E+16>F.length)throw RangeError(`UUID byte range ${E}:${E+15} is out of buffer bounds`);for(let $=0;$<16;++$)F[E+$]=B[$];return F}return B8(B)}var D0=ZF;import{exec as kF}from"child_process";import{promisify as vF}from"util";import{join as xF}from"path";import{mkdirSync as yF,existsSync as hF}from"fs";import{homedir as gF}from"os";var lF=vF(kF);function mF(){let D=xF(gF(),".genie","logs","tmux");if(!hF(D))yF(D,{recursive:!0});return D}function pF(D){return D.filter((F)=>!/^-v+$/.test(F))}function cF(){return process.env.GENIE_TMUX_DEBUG==="1"}async function $8(D){let F=typeof D==="string"?D.split(/\s+/).filter(Boolean):D,E=pF(F),B=cF(),$={};if(B)E=["-v",...E],$.cwd=mF();let J=`tmux ${E.join(" ")}`,{stdout:X}=await lF(J,$);return X.trim()}var dF={type:"bash"};async function S(D){try{return await $8(D)}catch(F){throw Error(`Failed to execute tmux command: ${F.message}`)}}async function m0(){try{let F=await S("list-sessions -F '#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}'");if(!F)return[];return F.split(`
31
- `).map((E)=>{let[B,$,J,X]=E.split(":");return{id:B,name:$,attached:J==="1",windows:parseInt(X,10)}})}catch(D){if(D.message.includes("no server running"))return[];throw D}}async function Z(D){try{return(await m0()).find((E)=>E.name===D)||null}catch(F){return null}}async function v(D){try{let E=await S(`list-windows -t '${D}' -F '#{window_id}:#{window_name}:#{?window_active,1,0}'`);if(!E)return[];return E.split(`
32
- `).map((B)=>{let[$,J,X]=B.split(":");return{id:$,name:J,active:X==="1",sessionId:D}})}catch(F){if(F.message.includes("no server running")||F.message.includes("session not found"))return[];throw F}}async function g(D){try{let E=await S(`list-panes -t '${D}' -F '#{pane_id}:#{pane_title}:#{?pane_active,1,0}'`);if(!E)return[];return E.split(`
33
- `).map((B)=>{let[$,J,X]=B.split(":");return{id:$,windowId:D,title:J,active:X==="1"}})}catch(F){if(F.message.includes("no server running")||F.message.includes("window not found"))return[];throw F}}async function p(D,F=200,E=!1){try{return await S(`capture-pane -p ${E?"-e":""} -t '${D}' -S -${F} -E -`)}catch(B){if(B.message.includes("no server running")||B.message.includes("pane not found"))return"";throw B}}async function yD(D){return await S(`new-session -d -s "${D}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),Z(D)}async function E0(D,F){let E=await S(`new-window -t '${D}' -n '${F}'`);return(await v(D)).find(($)=>$.name===F)||null}async function B0(D){await S(`kill-session -t '${D}'`)}async function J8(D){await S(`kill-window -t '${D}'`)}async function $2(D){await S(`kill-pane -t '${D}'`)}async function $0(D,F="vertical",E){let B="split-window";if(F==="horizontal")B+=" -h";else B+=" -v";if(B+=` -t '${D}'`,E!==void 0&&E>0&&E<100)B+=` -p ${E}`;await S(B);let $=await S(`display-message -p -t '${D}' '#{window_id}'`),J=await g($);return J.length>0?J[J.length-1]:null}var g0=new Map,l0="TMUX_MCP_START",F0="TMUX_MCP_DONE_";async function e(D,F,E,B){let $=D0(),J;if(E||B)J=F;else{let X=iF();J=`echo "${l0}"; ${F}; echo "${X}"`}if(g0.set($,{id:$,paneId:D,command:F,status:"pending",startTime:new Date,rawMode:E||B}),B)if(["Up","Down","Left","Right","Escape","Tab","Enter","Space","BSpace","Delete","Home","End","PageUp","PageDown","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(J))await S(`send-keys -t '${D}' ${J}`);else for(let Q of J)await S(`send-keys -t '${D}' '${Q.replace(/'/g,"'\\''")}'`);else await S(`send-keys -t '${D}' '${J.replace(/'/g,"'\\''")}' Enter`);return $}async function X8(D){let F=g0.get(D);if(!F)return null;if(F.status!=="pending")return F;let E=await p(F.paneId,1000);if(F.rawMode)return F.result="Status tracking unavailable for rawMode commands. Use capture-pane to monitor interactive apps instead.",F;let B=E.lastIndexOf(l0),$=E.lastIndexOf(F0);if(B===-1||$===-1||$<=B)return F.result="Command output could not be captured properly",F;let J=E.substring($).split(`
34
- `)[0],X=new RegExp(`${F0}(\\d+)`),Q=J.match(X);if(Q){let Y=parseInt(Q[1],10);F.status=Y===0?"completed":"error",F.exitCode=Y;let q=B+l0.length,_=E.substring(q,$).trim();F.result=_.substring(_.indexOf(`
35
- `)+1).trim(),g0.set(D,F)}return F}function iF(){return dF.type==="fish"?`${F0}$status`:`${F0}$?`}async function Q8(D,F,E=120000){let B=D0().substring(0,8),$=`/tmp/genie-${B}.out`,J=`/tmp/genie-${B}.exit`,X=`genie-${B}`,Y=`{ ${F.replace(/'/g,"'\\''")}; } 2>&1 | tee ${$}; echo \${PIPESTATUS[0]} > ${J}; tmux wait-for -S ${X}`;await S(`send-keys -t '${D}' '${Y.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([S(`wait-for ${X}`),new Promise((H,G)=>setTimeout(()=>G(Error("Command timed out")),E))])}catch(H){if(H.message==="Command timed out"){try{await S(`wait-for -S ${X}`)}catch{}return{output:"",exitCode:124}}throw H}let q="",_=0;try{let{readFile:H,unlink:G}=await import("fs/promises");q=await H($,"utf-8"),q=q.trim();let U=await H(J,"utf-8");_=parseInt(U.trim(),10)||0,await G($).catch(()=>{}),await G(J).catch(()=>{})}catch(H){console.error("Failed to read command output:",H)}return{output:q,exitCode:_}}var{$:KD}=globalThis.Bun;import{mkdir as Y8,rm as q8,access as p0,readFile as nF,writeFile as rF}from"fs/promises";import{join as J2,basename as aF}from"path";function J0(D){return D.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function oF(D){let F=D.match(/^(\d+)([hdwm])$/i);if(!F)throw Error(`Invalid timeframe format: ${D}. Use format like 7d, 2w, 1m, 24h`);let E=parseInt(F[1],10),B=F[2].toLowerCase();return E*{h:3600000,d:86400000,w:604800000,m:2592000000}[B]}class PD{baseDir;repoPath;metadataPath;constructor(D){this.baseDir=D.baseDir,this.repoPath=D.repoPath,this.metadataPath=J2(this.baseDir,".metadata.json")}async loadMetadata(){try{let D=await nF(this.metadataPath,"utf-8");return JSON.parse(D)}catch{return{worktrees:{}}}}async saveMetadata(D){await Y8(this.baseDir,{recursive:!0}),await rF(this.metadataPath,JSON.stringify(D,null,2))}async createWorktree(D,F=!1,E){let B=J0(D),$=J2(this.baseDir,B);await Y8(this.baseDir,{recursive:!0});try{throw await p0($),Error(`Worktree already exists at ${$}`)}catch(Q){if(Q.code!=="ENOENT")throw Q}if(F)if(E)await KD`git -C ${this.repoPath} worktree add -b ${D} ${$} ${E}`.quiet();else await KD`git -C ${this.repoPath} worktree add -b ${D} ${$}`.quiet();else{if(!await this.branchExists(D))throw Error(`Branch '${D}' does not exist. Use -b to create a new branch.`);await KD`git -C ${this.repoPath} worktree add ${$} ${D}`.quiet()}let J=await this.loadMetadata();J.worktrees[B]={branch:D,createdAt:new Date().toISOString()},await this.saveMetadata(J);let X=await this.getCommitHash($);return{path:$,branch:D,commitHash:X,createdAt:new Date}}async removeWorktree(D){let F=J0(D),E=J2(this.baseDir,F);try{await KD`git -C ${this.repoPath} worktree remove ${E} --force`.quiet()}catch{try{await q8(E,{recursive:!0,force:!0})}catch{}}try{await p0(E),await q8(E,{recursive:!0,force:!0})}catch{}let B=await this.loadMetadata();delete B.worktrees[F],await this.saveMetadata(B)}async listWorktrees(){let F=(await KD`git -C ${this.repoPath} worktree list --porcelain`.quiet()).stdout.toString(),E=[],B={};for(let X of F.split(`
36
- `))if(X.startsWith("worktree ")){if(B.path)E.push(B);B={path:X.slice(9)}}else if(X.startsWith("HEAD "))B.commitHash=X.slice(5);else if(X.startsWith("branch "))B.branch=X.slice(7).replace("refs/heads/","");if(B.path)E.push(B);let $=E.filter((X)=>X.path.startsWith(this.baseDir)),J=await this.loadMetadata();for(let X of $){let Q=aF(X.path),Y=J.worktrees[Q];if(Y)X.createdAt=new Date(Y.createdAt);X.size=await this.getDiskUsage(X.path)}return $}async cleanup(D,F=!1){let E=oF(D),B=Date.now(),$=await this.listWorktrees(),J=[];for(let X of $)if(X.createdAt){if(B-X.createdAt.getTime()>E)J.push(X)}if(!F)for(let X of J)await this.removeWorktree(X.branch);return J}async prune(){await KD`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage(D){try{let E=(await KD`du -sb ${D}`.quiet()).stdout.toString().trim(),B=parseInt(E.split("\t")[0],10);return isNaN(B)?0:B}catch{return 0}}getWorktreePath(D){let F=J0(D);return J2(this.baseDir,F)}async worktreeExists(D){let F=J0(D),E=J2(this.baseDir,F);try{return await p0(E),!0}catch{return!1}}async branchExists(D){try{return await KD`git -C ${this.repoPath} rev-parse --verify ${D}`.quiet(),!0}catch{return!1}}async getCommitHash(D){return(await KD`git -C ${D} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function X2(D){let F=D?.baseDir||J2(process.cwd(),".worktrees"),E=D?.repoPath||process.cwd();return new PD({baseDir:F,repoPath:E})}import{mkdir as sF,readFile as tF,writeFile as eF,access as D5}from"fs/promises";import{join as _8}from"path";import{homedir as F5}from"os";var H8=_8(F5(),".config","term"),c0=_8(H8,"sessions.json");async function E5(){await sF(H8,{recursive:!0})}async function d0(){try{await D5(c0);let D=await tF(c0,"utf-8");return JSON.parse(D)}catch{return{sessions:{}}}}async function W8(D){await E5(),await eF(c0,JSON.stringify(D,null,2))}async function G8(D,F){let E=await d0();E.sessions[D]={...F,createdAt:new Date().toISOString()},await W8(E)}async function A8(D){return(await d0()).sessions[D]||null}async function U8(D){let F=await d0();delete F.sessions[D],await W8(F)}async function C8(D,F={}){try{if(await Z(D))console.error(`\u274C Session "${D}" already exists`),process.exit(1);let B=F.workspace||process.cwd(),$;if(F.worktree){if(!F.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let X=X2({baseDir:B5(F.workspace,".worktrees"),repoPath:F.workspace});if(await X.worktreeExists(D))console.error(`\u274C Worktree for "${D}" already exists`),process.exit(1);let Y=await X.createWorktree(D,!0);$=Y.path,B=Y.path,console.log(`\u2705 Worktree created at ${$}`)}if(!await yD(D))console.error(`\u274C Failed to create session "${D}"`),process.exit(1);if(await S(`send-keys -t '${D}' 'cd ${B}' Enter`),$)await G8(D,{worktreePath:$,workspace:F.workspace});if(console.log(`\u2705 Session "${D}" created`),B!==process.cwd())console.log(` Working directory: ${B}`);console.log(`
37
- To attach: term attach ${D}`)}catch(E){console.error(`\u274C Error creating session: ${E.message}`),process.exit(1)}}async function z8(D={}){try{let F=await m0();if(D.json){console.log(JSON.stringify(F,null,2));return}if(F.length===0){console.log("No tmux sessions found");return}console.log("SESSION ID\t\tNAME\t\t\tWINDOWS\t\tATTACHED"),console.log("\u2500".repeat(80));for(let E of F){let B=E.attached?"yes":"no";console.log(`${E.id} ${E.name} ${E.windows} ${B}`)}}catch(F){console.error(`Error listing sessions: ${F.message}`),process.exit(1)}}import{exec as X5}from"child_process";import{promisify as Q5}from"util";var Y5=Q5(X5);async function V8(D){try{if(!await Z(D))console.error(`\u274C Session "${D}" not found`),process.exit(1);console.log(`\uD83D\uDCCE Attaching to session "${D}"...`),await Y5(`tmux attach -t "${D}"`)}catch(F){console.error(`\u274C Error attaching to session: ${F.message}`),process.exit(1)}}import{join as _5}from"path";async function R8(D,F={}){try{let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await A8(D);if(await B0(E.id),B?.worktreePath&&B?.workspace&&!F.keepWorktree)await X2({baseDir:_5(B.workspace,".worktrees"),repoPath:B.workspace}).removeWorktree(D),console.log(`\u2705 Session "${D}" and worktree removed`);else if(B?.worktreePath&&F.keepWorktree)console.log(`\u2705 Session "${D}" removed (worktree kept at ${B.worktreePath})`);else console.log(`\u2705 Session "${D}" removed`);if(B)await U8(D)}catch(E){console.error(`\u274C Error removing session: ${E.message}`),process.exit(1)}}function k2(D){let E=D.split(`
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
38
  `).filter((B)=>{let $=B.trim();if($.match(/^TMUX_MCP_START$/))return!1;if($.match(/^TMUX_MCP_DONE_\d+$/))return!1;if($.includes("TMUX_MCP_START"))return!1;if($.includes("TMUX_MCP_DONE_"))return!1;if(B.includes('echo "TMUX_MCP_START"'))return!1;if(B.includes('echo "TMUX_MCP_DONE_'))return!1;if(B.includes("-bash:"))return!1;if(B.includes("warning: setlocale:"))return!1;if(B.includes("cannot change locale"))return!1;if($==="or directory")return!1;return!0});while(E.length>0&&E[0].trim()==="")E.shift();while(E.length>0&&E[E.length-1].trim()==="")E.pop();return E.join(`
39
- `)}async function K8(D,F={}){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await v(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await g(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let J=$[0].id;if(F.range){let Y=F.range.split(":");if(Y.length===2)F.from=parseInt(Y[0],10),F.to=parseInt(Y[1],10)}if(F.all){let Y=await p(J,1e4);return k2(Y)}if(F.from!==void 0&&F.to!==void 0){let Y=await p(J,1e4),H=k2(Y).split(`
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
40
  `).slice(F.from,F.to+1).join(`
41
- `);if(F.reverse)return H.split(`
41
+ `);if(F.reverse)return _.split(`
42
42
  `).reverse().join(`
43
- `);return H}if(F.search||F.grep){let Y=F.search||F.grep,q=await p(J,1e4),H=k2(q).split(`
44
- `);try{let G=new RegExp(Y,"i"),U=H.filter((R)=>G.test(R));if(F.reverse)return U.reverse().join(`
45
- `);return U.join(`
46
- `)}catch(G){throw Error(`Invalid regex pattern: ${G.message}`)}}let X=F.lines||100,Q=await p(J,X);if(Q=k2(Q),F.reverse)Q=Q.split(`
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(`
47
47
  `).reverse().join(`
48
- `);return Q}async function j8(D,F){let E=await Z(D);if(!E)throw Error(`Session "${D}" not found`);let B=await v(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await g(B[0].id);if(!$||$.length===0)throw Error(`No panes found in session "${D}"`);let J=$[0].id,X="",Q=!0,Y=setInterval(async()=>{if(!Q){clearInterval(Y);return}try{let q=await p(J,100),_=k2(q);if(_!==X){let H=_.split(`
49
- `),G=X.split(`
50
- `),U=G.length>0?G.length-1:0;H.slice(U).forEach((K)=>{if(K&&K!==G[G.length-1])F(K)}),X=_}}catch(q){clearInterval(Y),Q=!1}},500);return()=>{Q=!1,clearInterval(Y)}}import{existsSync as H0,mkdirSync as w7,readFileSync as Z8,writeFileSync as P7}from"fs";import{homedir as k8}from"os";import{join as v8}from"path";var u={};h3(u,{void:()=>o5,util:()=>I,unknown:()=>r5,union:()=>D7,undefined:()=>d5,tuple:()=>B7,transformer:()=>G7,symbol:()=>c5,string:()=>P8,strictObject:()=>e5,setErrorMap:()=>U5,set:()=>X7,record:()=>$7,quotelessJson:()=>G5,promise:()=>W7,preprocess:()=>C7,pipeline:()=>z7,ostring:()=>V7,optional:()=>A7,onumber:()=>R7,oboolean:()=>K7,objectUtil:()=>i0,object:()=>t5,number:()=>I8,nullable:()=>U7,null:()=>i5,never:()=>a5,nativeEnum:()=>H7,nan:()=>l5,map:()=>J7,makeIssue:()=>v2,literal:()=>q7,lazy:()=>Y7,late:()=>h5,isValid:()=>ID,isDirty:()=>Q0,isAsync:()=>Y2,isAborted:()=>X0,intersection:()=>E7,instanceof:()=>g5,getParsedType:()=>WD,getErrorMap:()=>Q2,function:()=>Q7,enum:()=>_7,effect:()=>G7,discriminatedUnion:()=>F7,defaultErrorMap:()=>jD,datetimeRegex:()=>T8,date:()=>p5,custom:()=>w8,coerce:()=>j7,boolean:()=>u8,bigint:()=>m5,array:()=>s5,any:()=>n5,addIssueToContext:()=>C,ZodVoid:()=>y2,ZodUnknown:()=>uD,ZodUnion:()=>A2,ZodUndefined:()=>W2,ZodType:()=>P,ZodTuple:()=>AD,ZodTransformer:()=>YD,ZodSymbol:()=>x2,ZodString:()=>$D,ZodSet:()=>mD,ZodSchema:()=>P,ZodRecord:()=>h2,ZodReadonly:()=>j2,ZodPromise:()=>pD,ZodPipeline:()=>m2,ZodParsedType:()=>A,ZodOptional:()=>XD,ZodObject:()=>y,ZodNumber:()=>fD,ZodNullable:()=>MD,ZodNull:()=>G2,ZodNever:()=>GD,ZodNativeEnum:()=>V2,ZodNaN:()=>l2,ZodMap:()=>g2,ZodLiteral:()=>z2,ZodLazy:()=>C2,ZodIssueCode:()=>W,ZodIntersection:()=>U2,ZodFunction:()=>_2,ZodFirstPartyTypeKind:()=>M,ZodError:()=>s,ZodEnum:()=>kD,ZodEffects:()=>YD,ZodDiscriminatedUnion:()=>Y0,ZodDefault:()=>R2,ZodDate:()=>gD,ZodCatch:()=>K2,ZodBranded:()=>q0,ZodBoolean:()=>H2,ZodBigInt:()=>ZD,ZodArray:()=>JD,ZodAny:()=>lD,Schema:()=>P,ParseStatus:()=>n,OK:()=>a,NEVER:()=>L7,INVALID:()=>j,EMPTY_PATH:()=>C5,DIRTY:()=>hD,BRAND:()=>y5});var I;(function(D){D.assertEqual=($)=>{};function F($){}D.assertIs=F;function E($){throw Error()}D.assertNever=E,D.arrayToEnum=($)=>{let J={};for(let X of $)J[X]=X;return J},D.getValidEnumValues=($)=>{let J=D.objectKeys($).filter((Q)=>typeof $[$[Q]]!=="number"),X={};for(let Q of J)X[Q]=$[Q];return D.objectValues(X)},D.objectValues=($)=>{return D.objectKeys($).map(function(J){return $[J]})},D.objectKeys=typeof Object.keys==="function"?($)=>Object.keys($):($)=>{let J=[];for(let X in $)if(Object.prototype.hasOwnProperty.call($,X))J.push(X);return J},D.find=($,J)=>{for(let X of $)if(J(X))return X;return},D.isInteger=typeof Number.isInteger==="function"?($)=>Number.isInteger($):($)=>typeof $==="number"&&Number.isFinite($)&&Math.floor($)===$;function B($,J=" | "){return $.map((X)=>typeof X==="string"?`'${X}'`:X).join(J)}D.joinValues=B,D.jsonStringifyReplacer=($,J)=>{if(typeof J==="bigint")return J.toString();return J}})(I||(I={}));var i0;(function(D){D.mergeShapes=(F,E)=>{return{...F,...E}}})(i0||(i0={}));var A=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),WD=(D)=>{switch(typeof D){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(D)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":if(Array.isArray(D))return A.array;if(D===null)return A.null;if(D.then&&typeof D.then==="function"&&D.catch&&typeof D.catch==="function")return A.promise;if(typeof Map<"u"&&D instanceof Map)return A.map;if(typeof Set<"u"&&D instanceof Set)return A.set;if(typeof Date<"u"&&D instanceof Date)return A.date;return A.object;default:return A.unknown}};var W=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),G5=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")};class s extends Error{get errors(){return this.issues}constructor(D){super();this.issues=[],this.addIssue=(E)=>{this.issues=[...this.issues,E]},this.addIssues=(E=[])=>{this.issues=[...this.issues,...E]};let F=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,F);else this.__proto__=F;this.name="ZodError",this.issues=D}format(D){let F=D||function($){return $.message},E={_errors:[]},B=($)=>{for(let J of $.issues)if(J.code==="invalid_union")J.unionErrors.map(B);else if(J.code==="invalid_return_type")B(J.returnTypeError);else if(J.code==="invalid_arguments")B(J.argumentsError);else if(J.path.length===0)E._errors.push(F(J));else{let X=E,Q=0;while(Q<J.path.length){let Y=J.path[Q];if(Q!==J.path.length-1)X[Y]=X[Y]||{_errors:[]};else X[Y]=X[Y]||{_errors:[]},X[Y]._errors.push(F(J));X=X[Y],Q++}}};return B(this),E}static assert(D){if(!(D instanceof s))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(D=(F)=>F.message){let F={},E=[];for(let B of this.issues)if(B.path.length>0){let $=B.path[0];F[$]=F[$]||[],F[$].push(D(B))}else E.push(D(B));return{formErrors:E,fieldErrors:F}}get formErrors(){return this.flatten()}}s.create=(D)=>{return new s(D)};var A5=(D,F)=>{let E;switch(D.code){case W.invalid_type:if(D.received===A.undefined)E="Required";else E=`Expected ${D.expected}, received ${D.received}`;break;case W.invalid_literal:E=`Invalid literal value, expected ${JSON.stringify(D.expected,I.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:E=`Unrecognized key(s) in object: ${I.joinValues(D.keys,", ")}`;break;case W.invalid_union:E="Invalid input";break;case W.invalid_union_discriminator:E=`Invalid discriminator value. Expected ${I.joinValues(D.options)}`;break;case W.invalid_enum_value:E=`Invalid enum value. Expected ${I.joinValues(D.options)}, received '${D.received}'`;break;case W.invalid_arguments:E="Invalid function arguments";break;case W.invalid_return_type:E="Invalid function return type";break;case W.invalid_date:E="Invalid date";break;case W.invalid_string:if(typeof D.validation==="object")if("includes"in D.validation){if(E=`Invalid input: must include "${D.validation.includes}"`,typeof D.validation.position==="number")E=`${E} at one or more positions greater than or equal to ${D.validation.position}`}else if("startsWith"in D.validation)E=`Invalid input: must start with "${D.validation.startsWith}"`;else if("endsWith"in D.validation)E=`Invalid input: must end with "${D.validation.endsWith}"`;else I.assertNever(D.validation);else if(D.validation!=="regex")E=`Invalid ${D.validation}`;else E="Invalid";break;case W.too_small:if(D.type==="array")E=`Array must contain ${D.exact?"exactly":D.inclusive?"at least":"more than"} ${D.minimum} element(s)`;else if(D.type==="string")E=`String must contain ${D.exact?"exactly":D.inclusive?"at least":"over"} ${D.minimum} character(s)`;else if(D.type==="number")E=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="bigint")E=`Number must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${D.minimum}`;else if(D.type==="date")E=`Date must be ${D.exact?"exactly equal to ":D.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(D.minimum))}`;else E="Invalid input";break;case W.too_big:if(D.type==="array")E=`Array must contain ${D.exact?"exactly":D.inclusive?"at most":"less than"} ${D.maximum} element(s)`;else if(D.type==="string")E=`String must contain ${D.exact?"exactly":D.inclusive?"at most":"under"} ${D.maximum} character(s)`;else if(D.type==="number")E=`Number must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="bigint")E=`BigInt must be ${D.exact?"exactly":D.inclusive?"less than or equal to":"less than"} ${D.maximum}`;else if(D.type==="date")E=`Date must be ${D.exact?"exactly":D.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(D.maximum))}`;else E="Invalid input";break;case W.custom:E="Invalid input";break;case W.invalid_intersection_types:E="Intersection results could not be merged";break;case W.not_multiple_of:E=`Number must be a multiple of ${D.multipleOf}`;break;case W.not_finite:E="Number must be finite";break;default:E=F.defaultError,I.assertNever(D)}return{message:E}},jD=A5;var L8=jD;function U5(D){L8=D}function Q2(){return L8}var v2=(D)=>{let{data:F,path:E,errorMaps:B,issueData:$}=D,J=[...E,...$.path||[]],X={...$,path:J};if($.message!==void 0)return{...$,path:J,message:$.message};let Q="",Y=B.filter((q)=>!!q).slice().reverse();for(let q of Y)Q=q(X,{data:F,defaultError:Q}).message;return{...$,path:J,message:Q}},C5=[];function C(D,F){let E=Q2(),B=v2({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,E,E===jD?void 0:jD].filter(($)=>!!$)});D.common.issues.push(B)}class n{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(D,F){let E=[];for(let B of F){if(B.status==="aborted")return j;if(B.status==="dirty")D.dirty();E.push(B.value)}return{status:D.value,value:E}}static async mergeObjectAsync(D,F){let E=[];for(let B of F){let $=await B.key,J=await B.value;E.push({key:$,value:J})}return n.mergeObjectSync(D,E)}static mergeObjectSync(D,F){let E={};for(let B of F){let{key:$,value:J}=B;if($.status==="aborted")return j;if(J.status==="aborted")return j;if($.status==="dirty")D.dirty();if(J.status==="dirty")D.dirty();if($.value!=="__proto__"&&(typeof J.value<"u"||B.alwaysSet))E[$.value]=J.value}return{status:D.value,value:E}}}var j=Object.freeze({status:"aborted"}),hD=(D)=>({status:"dirty",value:D}),a=(D)=>({status:"valid",value:D}),X0=(D)=>D.status==="aborted",Q0=(D)=>D.status==="dirty",ID=(D)=>D.status==="valid",Y2=(D)=>typeof Promise<"u"&&D instanceof Promise;var z;(function(D){D.errToObj=(F)=>typeof F==="string"?{message:F}:F||{},D.toString=(F)=>typeof F==="string"?F:F?.message})(z||(z={}));class QD{constructor(D,F,E,B){this._cachedPath=[],this.parent=D,this.data=F,this._path=E,this._key=B}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var M8=(D,F)=>{if(ID(F))return{success:!0,data:F.value};else{if(!D.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let E=new s(D.common.issues);return this._error=E,this._error}}}};function T(D){if(!D)return{};let{errorMap:F,invalid_type_error:E,required_error:B,description:$}=D;if(F&&(E||B))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(F)return{errorMap:F,description:$};return{errorMap:(X,Q)=>{let{message:Y}=D;if(X.code==="invalid_enum_value")return{message:Y??Q.defaultError};if(typeof Q.data>"u")return{message:Y??B??Q.defaultError};if(X.code!=="invalid_type")return{message:Q.defaultError};return{message:Y??E??Q.defaultError}},description:$}}class P{get description(){return this._def.description}_getType(D){return WD(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:WD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}_processInputParams(D){return{status:new n,ctx:{common:D.parent.common,data:D.data,parsedType:WD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(Y2(F))throw Error("Synchronous parse encountered promise.");return F}_parseAsync(D){let F=this._parse(D);return Promise.resolve(F)}parse(D,F){let E=this.safeParse(D,F);if(E.success)return E.data;throw E.error}safeParse(D,F){let E={common:{issues:[],async:F?.async??!1,contextualErrorMap:F?.errorMap},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)},B=this._parseSync({data:D,path:E.path,parent:E});return M8(E,B)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)};if(!this["~standard"].async)try{let E=this._parseSync({data:D,path:[],parent:F});return ID(E)?{value:E.value}:{issues:F.common.issues}}catch(E){if(E?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;F.common={issues:[],async:!0}}return this._parseAsync({data:D,path:[],parent:F}).then((E)=>ID(E)?{value:E.value}:{issues:F.common.issues})}async parseAsync(D,F){let E=await this.safeParseAsync(D,F);if(E.success)return E.data;throw E.error}async safeParseAsync(D,F){let E={common:{issues:[],contextualErrorMap:F?.errorMap,async:!0},path:F?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:WD(D)},B=this._parse({data:D,path:E.path,parent:E}),$=await(Y2(B)?B:Promise.resolve(B));return M8(E,$)}refine(D,F){let E=(B)=>{if(typeof F==="string"||typeof F>"u")return{message:F};else if(typeof F==="function")return F(B);else return F};return this._refinement((B,$)=>{let J=D(B),X=()=>$.addIssue({code:W.custom,...E(B)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Q)=>{if(!Q)return X(),!1;else return!0});if(!J)return X(),!1;else return!0})}refinement(D,F){return this._refinement((E,B)=>{if(!D(E))return B.addIssue(typeof F==="function"?F(E,B):F),!1;else return!0})}_refinement(D){return new YD({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:D}})}superRefine(D){return this._refinement(D)}constructor(D){this.spa=this.safeParseAsync,this._def=D,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(F)=>this["~validate"](F)}}optional(){return XD.create(this,this._def)}nullable(){return MD.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return JD.create(this)}promise(){return pD.create(this,this._def)}or(D){return A2.create([this,D],this._def)}and(D){return U2.create(this,D,this._def)}transform(D){return new YD({...T(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new R2({...T(this._def),innerType:this,defaultValue:F,typeName:M.ZodDefault})}brand(){return new q0({typeName:M.ZodBranded,type:this,...T(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new K2({...T(this._def),innerType:this,catchValue:F,typeName:M.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return m2.create(this,D)}readonly(){return j2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var z5=/^c[^\s-]{8,}$/i,V5=/^[0-9a-z]+$/,R5=/^[0-9A-HJKMNP-TV-Z]{26}$/i,K5=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,j5=/^[a-z0-9_-]{21}$/i,L5=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,M5=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,O5=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",n0,S5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,T5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,b5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,w5=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,P5=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I5=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,N8="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",u5=new RegExp(`^${N8}$`);function S8(D){let F="[0-5]\\d";if(D.precision)F=`${F}\\.\\d{${D.precision}}`;else if(D.precision==null)F=`${F}(\\.\\d+)?`;let E=D.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${F})${E}`}function f5(D){return new RegExp(`^${S8(D)}$`)}function T8(D){let F=`${N8}T${S8(D)}`,E=[];if(E.push(D.local?"Z?":"Z"),D.offset)E.push("([+-]\\d{2}:?\\d{2})");return F=`${F}(${E.join("|")})`,new RegExp(`^${F}$`)}function Z5(D,F){if((F==="v4"||!F)&&S5.test(D))return!0;if((F==="v6"||!F)&&b5.test(D))return!0;return!1}function k5(D,F){if(!L5.test(D))return!1;try{let[E]=D.split(".");if(!E)return!1;let B=E.replace(/-/g,"+").replace(/_/g,"/").padEnd(E.length+(4-E.length%4)%4,"="),$=JSON.parse(atob(B));if(typeof $!=="object"||$===null)return!1;if("typ"in $&&$?.typ!=="JWT")return!1;if(!$.alg)return!1;if(F&&$.alg!==F)return!1;return!0}catch{return!1}}function v5(D,F){if((F==="v4"||!F)&&T5.test(D))return!0;if((F==="v6"||!F)&&w5.test(D))return!0;return!1}class $D extends P{_parse(D){if(this._def.coerce)D.data=String(D.data);if(this._getType(D)!==A.string){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.string,received:$.parsedType}),j}let E=new n,B=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(D.data.length<$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),E.dirty()}else if($.kind==="max"){if(D.data.length>$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),E.dirty()}else if($.kind==="length"){let J=D.data.length>$.value,X=D.data.length<$.value;if(J||X){if(B=this._getOrReturnCtx(D,B),J)C(B,{code:W.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});else if(X)C(B,{code:W.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});E.dirty()}}else if($.kind==="email"){if(!O5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"email",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="emoji"){if(!n0)n0=new RegExp(N5,"u");if(!n0.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"emoji",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="uuid"){if(!K5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"uuid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="nanoid"){if(!j5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"nanoid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cuid"){if(!z5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"cuid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cuid2"){if(!V5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"cuid2",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="ulid"){if(!R5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"ulid",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="url")try{new URL(D.data)}catch{B=this._getOrReturnCtx(D,B),C(B,{validation:"url",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="regex"){if($.regex.lastIndex=0,!$.regex.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"regex",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="trim")D.data=D.data.trim();else if($.kind==="includes"){if(!D.data.includes($.value,$.position))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{includes:$.value,position:$.position},message:$.message}),E.dirty()}else if($.kind==="toLowerCase")D.data=D.data.toLowerCase();else if($.kind==="toUpperCase")D.data=D.data.toUpperCase();else if($.kind==="startsWith"){if(!D.data.startsWith($.value))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{startsWith:$.value},message:$.message}),E.dirty()}else if($.kind==="endsWith"){if(!D.data.endsWith($.value))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:{endsWith:$.value},message:$.message}),E.dirty()}else if($.kind==="datetime"){if(!T8($).test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"datetime",message:$.message}),E.dirty()}else if($.kind==="date"){if(!u5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"date",message:$.message}),E.dirty()}else if($.kind==="time"){if(!f5($).test(D.data))B=this._getOrReturnCtx(D,B),C(B,{code:W.invalid_string,validation:"time",message:$.message}),E.dirty()}else if($.kind==="duration"){if(!M5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"duration",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="ip"){if(!Z5(D.data,$.version))B=this._getOrReturnCtx(D,B),C(B,{validation:"ip",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="jwt"){if(!k5(D.data,$.alg))B=this._getOrReturnCtx(D,B),C(B,{validation:"jwt",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="cidr"){if(!v5(D.data,$.version))B=this._getOrReturnCtx(D,B),C(B,{validation:"cidr",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="base64"){if(!P5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"base64",code:W.invalid_string,message:$.message}),E.dirty()}else if($.kind==="base64url"){if(!I5.test(D.data))B=this._getOrReturnCtx(D,B),C(B,{validation:"base64url",code:W.invalid_string,message:$.message}),E.dirty()}else I.assertNever($);return{status:E.value,value:D.data}}_regex(D,F,E){return this.refinement((B)=>D.test(B),{validation:F,code:W.invalid_string,...z.errToObj(E)})}_addCheck(D){return new $D({...this._def,checks:[...this._def.checks,D]})}email(D){return this._addCheck({kind:"email",...z.errToObj(D)})}url(D){return this._addCheck({kind:"url",...z.errToObj(D)})}emoji(D){return this._addCheck({kind:"emoji",...z.errToObj(D)})}uuid(D){return this._addCheck({kind:"uuid",...z.errToObj(D)})}nanoid(D){return this._addCheck({kind:"nanoid",...z.errToObj(D)})}cuid(D){return this._addCheck({kind:"cuid",...z.errToObj(D)})}cuid2(D){return this._addCheck({kind:"cuid2",...z.errToObj(D)})}ulid(D){return this._addCheck({kind:"ulid",...z.errToObj(D)})}base64(D){return this._addCheck({kind:"base64",...z.errToObj(D)})}base64url(D){return this._addCheck({kind:"base64url",...z.errToObj(D)})}jwt(D){return this._addCheck({kind:"jwt",...z.errToObj(D)})}ip(D){return this._addCheck({kind:"ip",...z.errToObj(D)})}cidr(D){return this._addCheck({kind:"cidr",...z.errToObj(D)})}datetime(D){if(typeof D==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:D});return this._addCheck({kind:"datetime",precision:typeof D?.precision>"u"?null:D?.precision,offset:D?.offset??!1,local:D?.local??!1,...z.errToObj(D?.message)})}date(D){return this._addCheck({kind:"date",message:D})}time(D){if(typeof D==="string")return this._addCheck({kind:"time",precision:null,message:D});return this._addCheck({kind:"time",precision:typeof D?.precision>"u"?null:D?.precision,...z.errToObj(D?.message)})}duration(D){return this._addCheck({kind:"duration",...z.errToObj(D)})}regex(D,F){return this._addCheck({kind:"regex",regex:D,...z.errToObj(F)})}includes(D,F){return this._addCheck({kind:"includes",value:D,position:F?.position,...z.errToObj(F?.message)})}startsWith(D,F){return this._addCheck({kind:"startsWith",value:D,...z.errToObj(F)})}endsWith(D,F){return this._addCheck({kind:"endsWith",value:D,...z.errToObj(F)})}min(D,F){return this._addCheck({kind:"min",value:D,...z.errToObj(F)})}max(D,F){return this._addCheck({kind:"max",value:D,...z.errToObj(F)})}length(D,F){return this._addCheck({kind:"length",value:D,...z.errToObj(F)})}nonempty(D){return this.min(1,z.errToObj(D))}trim(){return new $D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((D)=>D.kind==="datetime")}get isDate(){return!!this._def.checks.find((D)=>D.kind==="date")}get isTime(){return!!this._def.checks.find((D)=>D.kind==="time")}get isDuration(){return!!this._def.checks.find((D)=>D.kind==="duration")}get isEmail(){return!!this._def.checks.find((D)=>D.kind==="email")}get isURL(){return!!this._def.checks.find((D)=>D.kind==="url")}get isEmoji(){return!!this._def.checks.find((D)=>D.kind==="emoji")}get isUUID(){return!!this._def.checks.find((D)=>D.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((D)=>D.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((D)=>D.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((D)=>D.kind==="cuid2")}get isULID(){return!!this._def.checks.find((D)=>D.kind==="ulid")}get isIP(){return!!this._def.checks.find((D)=>D.kind==="ip")}get isCIDR(){return!!this._def.checks.find((D)=>D.kind==="cidr")}get isBase64(){return!!this._def.checks.find((D)=>D.kind==="base64")}get isBase64url(){return!!this._def.checks.find((D)=>D.kind==="base64url")}get minLength(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxLength(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}}$D.create=(D)=>{return new $D({checks:[],typeName:M.ZodString,coerce:D?.coerce??!1,...T(D)})};function x5(D,F){let E=(D.toString().split(".")[1]||"").length,B=(F.toString().split(".")[1]||"").length,$=E>B?E:B,J=Number.parseInt(D.toFixed($).replace(".","")),X=Number.parseInt(F.toFixed($).replace(".",""));return J%X/10**$}class fD extends P{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(D){if(this._def.coerce)D.data=Number(D.data);if(this._getType(D)!==A.number){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.number,received:$.parsedType}),j}let E=void 0,B=new n;for(let $ of this._def.checks)if($.kind==="int"){if(!I.isInteger(D.data))E=this._getOrReturnCtx(D,E),C(E,{code:W.invalid_type,expected:"integer",received:"float",message:$.message}),B.dirty()}else if($.kind==="min"){if($.inclusive?D.data<$.value:D.data<=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_small,minimum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),B.dirty()}else if($.kind==="max"){if($.inclusive?D.data>$.value:D.data>=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_big,maximum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),B.dirty()}else if($.kind==="multipleOf"){if(x5(D.data,$.value)!==0)E=this._getOrReturnCtx(D,E),C(E,{code:W.not_multiple_of,multipleOf:$.value,message:$.message}),B.dirty()}else if($.kind==="finite"){if(!Number.isFinite(D.data))E=this._getOrReturnCtx(D,E),C(E,{code:W.not_finite,message:$.message}),B.dirty()}else I.assertNever($);return{status:B.value,value:D.data}}gte(D,F){return this.setLimit("min",D,!0,z.toString(F))}gt(D,F){return this.setLimit("min",D,!1,z.toString(F))}lte(D,F){return this.setLimit("max",D,!0,z.toString(F))}lt(D,F){return this.setLimit("max",D,!1,z.toString(F))}setLimit(D,F,E,B){return new fD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:z.toString(B)}]})}_addCheck(D){return new fD({...this._def,checks:[...this._def.checks,D]})}int(D){return this._addCheck({kind:"int",message:z.toString(D)})}positive(D){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(D)})}negative(D){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:z.toString(F)})}finite(D){return this._addCheck({kind:"finite",message:z.toString(D)})}safe(D){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(D)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(D)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}get isInt(){return!!this._def.checks.find((D)=>D.kind==="int"||D.kind==="multipleOf"&&I.isInteger(D.value))}get isFinite(){let D=null,F=null;for(let E of this._def.checks)if(E.kind==="finite"||E.kind==="int"||E.kind==="multipleOf")return!0;else if(E.kind==="min"){if(F===null||E.value>F)F=E.value}else if(E.kind==="max"){if(D===null||E.value<D)D=E.value}return Number.isFinite(F)&&Number.isFinite(D)}}fD.create=(D)=>{return new fD({checks:[],typeName:M.ZodNumber,coerce:D?.coerce||!1,...T(D)})};class ZD extends P{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(D){if(this._def.coerce)try{D.data=BigInt(D.data)}catch{return this._getInvalidInput(D)}if(this._getType(D)!==A.bigint)return this._getInvalidInput(D);let E=void 0,B=new n;for(let $ of this._def.checks)if($.kind==="min"){if($.inclusive?D.data<$.value:D.data<=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_small,type:"bigint",minimum:$.value,inclusive:$.inclusive,message:$.message}),B.dirty()}else if($.kind==="max"){if($.inclusive?D.data>$.value:D.data>=$.value)E=this._getOrReturnCtx(D,E),C(E,{code:W.too_big,type:"bigint",maximum:$.value,inclusive:$.inclusive,message:$.message}),B.dirty()}else if($.kind==="multipleOf"){if(D.data%$.value!==BigInt(0))E=this._getOrReturnCtx(D,E),C(E,{code:W.not_multiple_of,multipleOf:$.value,message:$.message}),B.dirty()}else I.assertNever($);return{status:B.value,value:D.data}}_getInvalidInput(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:A.bigint,received:F.parsedType}),j}gte(D,F){return this.setLimit("min",D,!0,z.toString(F))}gt(D,F){return this.setLimit("min",D,!1,z.toString(F))}lte(D,F){return this.setLimit("max",D,!0,z.toString(F))}lt(D,F){return this.setLimit("max",D,!1,z.toString(F))}setLimit(D,F,E,B){return new ZD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:z.toString(B)}]})}_addCheck(D){return new ZD({...this._def,checks:[...this._def.checks,D]})}positive(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(D)})}negative(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(D)})}nonpositive(D){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(D)})}nonnegative(D){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(D)})}multipleOf(D,F){return this._addCheck({kind:"multipleOf",value:D,message:z.toString(F)})}get minValue(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D}get maxValue(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D}}ZD.create=(D)=>{return new ZD({checks:[],typeName:M.ZodBigInt,coerce:D?.coerce??!1,...T(D)})};class H2 extends P{_parse(D){if(this._def.coerce)D.data=Boolean(D.data);if(this._getType(D)!==A.boolean){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.boolean,received:E.parsedType}),j}return a(D.data)}}H2.create=(D)=>{return new H2({typeName:M.ZodBoolean,coerce:D?.coerce||!1,...T(D)})};class gD extends P{_parse(D){if(this._def.coerce)D.data=new Date(D.data);if(this._getType(D)!==A.date){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.date,received:$.parsedType}),j}if(Number.isNaN(D.data.getTime())){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_date}),j}let E=new n,B=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(D.data.getTime()<$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_small,message:$.message,inclusive:!0,exact:!1,minimum:$.value,type:"date"}),E.dirty()}else if($.kind==="max"){if(D.data.getTime()>$.value)B=this._getOrReturnCtx(D,B),C(B,{code:W.too_big,message:$.message,inclusive:!0,exact:!1,maximum:$.value,type:"date"}),E.dirty()}else I.assertNever($);return{status:E.value,value:new Date(D.data.getTime())}}_addCheck(D){return new gD({...this._def,checks:[...this._def.checks,D]})}min(D,F){return this._addCheck({kind:"min",value:D.getTime(),message:z.toString(F)})}max(D,F){return this._addCheck({kind:"max",value:D.getTime(),message:z.toString(F)})}get minDate(){let D=null;for(let F of this._def.checks)if(F.kind==="min"){if(D===null||F.value>D)D=F.value}return D!=null?new Date(D):null}get maxDate(){let D=null;for(let F of this._def.checks)if(F.kind==="max"){if(D===null||F.value<D)D=F.value}return D!=null?new Date(D):null}}gD.create=(D)=>{return new gD({checks:[],coerce:D?.coerce||!1,typeName:M.ZodDate,...T(D)})};class x2 extends P{_parse(D){if(this._getType(D)!==A.symbol){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.symbol,received:E.parsedType}),j}return a(D.data)}}x2.create=(D)=>{return new x2({typeName:M.ZodSymbol,...T(D)})};class W2 extends P{_parse(D){if(this._getType(D)!==A.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.undefined,received:E.parsedType}),j}return a(D.data)}}W2.create=(D)=>{return new W2({typeName:M.ZodUndefined,...T(D)})};class G2 extends P{_parse(D){if(this._getType(D)!==A.null){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.null,received:E.parsedType}),j}return a(D.data)}}G2.create=(D)=>{return new G2({typeName:M.ZodNull,...T(D)})};class lD extends P{constructor(){super(...arguments);this._any=!0}_parse(D){return a(D.data)}}lD.create=(D)=>{return new lD({typeName:M.ZodAny,...T(D)})};class uD extends P{constructor(){super(...arguments);this._unknown=!0}_parse(D){return a(D.data)}}uD.create=(D)=>{return new uD({typeName:M.ZodUnknown,...T(D)})};class GD extends P{_parse(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:A.never,received:F.parsedType}),j}}GD.create=(D)=>{return new GD({typeName:M.ZodNever,...T(D)})};class y2 extends P{_parse(D){if(this._getType(D)!==A.undefined){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.void,received:E.parsedType}),j}return a(D.data)}}y2.create=(D)=>{return new y2({typeName:M.ZodVoid,...T(D)})};class JD extends P{_parse(D){let{ctx:F,status:E}=this._processInputParams(D),B=this._def;if(F.parsedType!==A.array)return C(F,{code:W.invalid_type,expected:A.array,received:F.parsedType}),j;if(B.exactLength!==null){let J=F.data.length>B.exactLength.value,X=F.data.length<B.exactLength.value;if(J||X)C(F,{code:J?W.too_big:W.too_small,minimum:X?B.exactLength.value:void 0,maximum:J?B.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:B.exactLength.message}),E.dirty()}if(B.minLength!==null){if(F.data.length<B.minLength.value)C(F,{code:W.too_small,minimum:B.minLength.value,type:"array",inclusive:!0,exact:!1,message:B.minLength.message}),E.dirty()}if(B.maxLength!==null){if(F.data.length>B.maxLength.value)C(F,{code:W.too_big,maximum:B.maxLength.value,type:"array",inclusive:!0,exact:!1,message:B.maxLength.message}),E.dirty()}if(F.common.async)return Promise.all([...F.data].map((J,X)=>{return B.type._parseAsync(new QD(F,J,F.path,X))})).then((J)=>{return n.mergeArray(E,J)});let $=[...F.data].map((J,X)=>{return B.type._parseSync(new QD(F,J,F.path,X))});return n.mergeArray(E,$)}get element(){return this._def.type}min(D,F){return new JD({...this._def,minLength:{value:D,message:z.toString(F)}})}max(D,F){return new JD({...this._def,maxLength:{value:D,message:z.toString(F)}})}length(D,F){return new JD({...this._def,exactLength:{value:D,message:z.toString(F)}})}nonempty(D){return this.min(1,D)}}JD.create=(D,F)=>{return new JD({type:D,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...T(F)})};function q2(D){if(D instanceof y){let F={};for(let E in D.shape){let B=D.shape[E];F[E]=XD.create(q2(B))}return new y({...D._def,shape:()=>F})}else if(D instanceof JD)return new JD({...D._def,type:q2(D.element)});else if(D instanceof XD)return XD.create(q2(D.unwrap()));else if(D instanceof MD)return MD.create(q2(D.unwrap()));else if(D instanceof AD)return AD.create(D.items.map((F)=>q2(F)));else return D}class y extends P{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let D=this._def.shape(),F=I.objectKeys(D);return this._cached={shape:D,keys:F},this._cached}_parse(D){if(this._getType(D)!==A.object){let Y=this._getOrReturnCtx(D);return C(Y,{code:W.invalid_type,expected:A.object,received:Y.parsedType}),j}let{status:E,ctx:B}=this._processInputParams(D),{shape:$,keys:J}=this._getCached(),X=[];if(!(this._def.catchall instanceof GD&&this._def.unknownKeys==="strip")){for(let Y in B.data)if(!J.includes(Y))X.push(Y)}let Q=[];for(let Y of J){let q=$[Y],_=B.data[Y];Q.push({key:{status:"valid",value:Y},value:q._parse(new QD(B,_,B.path,Y)),alwaysSet:Y in B.data})}if(this._def.catchall instanceof GD){let Y=this._def.unknownKeys;if(Y==="passthrough")for(let q of X)Q.push({key:{status:"valid",value:q},value:{status:"valid",value:B.data[q]}});else if(Y==="strict"){if(X.length>0)C(B,{code:W.unrecognized_keys,keys:X}),E.dirty()}else if(Y==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let Y=this._def.catchall;for(let q of X){let _=B.data[q];Q.push({key:{status:"valid",value:q},value:Y._parse(new QD(B,_,B.path,q)),alwaysSet:q in B.data})}}if(B.common.async)return Promise.resolve().then(async()=>{let Y=[];for(let q of Q){let _=await q.key,H=await q.value;Y.push({key:_,value:H,alwaysSet:q.alwaysSet})}return Y}).then((Y)=>{return n.mergeObjectSync(E,Y)});else return n.mergeObjectSync(E,Q)}get shape(){return this._def.shape()}strict(D){return z.errToObj,new y({...this._def,unknownKeys:"strict",...D!==void 0?{errorMap:(F,E)=>{let B=this._def.errorMap?.(F,E).message??E.defaultError;if(F.code==="unrecognized_keys")return{message:z.errToObj(D).message??B};return{message:B}}}:{}})}strip(){return new y({...this._def,unknownKeys:"strip"})}passthrough(){return new y({...this._def,unknownKeys:"passthrough"})}extend(D){return new y({...this._def,shape:()=>({...this._def.shape(),...D})})}merge(D){return new y({unknownKeys:D._def.unknownKeys,catchall:D._def.catchall,shape:()=>({...this._def.shape(),...D._def.shape()}),typeName:M.ZodObject})}setKey(D,F){return this.augment({[D]:F})}catchall(D){return new y({...this._def,catchall:D})}pick(D){let F={};for(let E of I.objectKeys(D))if(D[E]&&this.shape[E])F[E]=this.shape[E];return new y({...this._def,shape:()=>F})}omit(D){let F={};for(let E of I.objectKeys(this.shape))if(!D[E])F[E]=this.shape[E];return new y({...this._def,shape:()=>F})}deepPartial(){return q2(this)}partial(D){let F={};for(let E of I.objectKeys(this.shape)){let B=this.shape[E];if(D&&!D[E])F[E]=B;else F[E]=B.optional()}return new y({...this._def,shape:()=>F})}required(D){let F={};for(let E of I.objectKeys(this.shape))if(D&&!D[E])F[E]=this.shape[E];else{let $=this.shape[E];while($ instanceof XD)$=$._def.innerType;F[E]=$}return new y({...this._def,shape:()=>F})}keyof(){return b8(I.objectKeys(this.shape))}}y.create=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strip",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};y.strictCreate=(D,F)=>{return new y({shape:()=>D,unknownKeys:"strict",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};y.lazycreate=(D,F)=>{return new y({shape:D,unknownKeys:"strip",catchall:GD.create(),typeName:M.ZodObject,...T(F)})};class A2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=this._def.options;function B($){for(let X of $)if(X.result.status==="valid")return X.result;for(let X of $)if(X.result.status==="dirty")return F.common.issues.push(...X.ctx.common.issues),X.result;let J=$.map((X)=>new s(X.ctx.common.issues));return C(F,{code:W.invalid_union,unionErrors:J}),j}if(F.common.async)return Promise.all(E.map(async($)=>{let J={...F,common:{...F.common,issues:[]},parent:null};return{result:await $._parseAsync({data:F.data,path:F.path,parent:J}),ctx:J}})).then(B);else{let $=void 0,J=[];for(let Q of E){let Y={...F,common:{...F.common,issues:[]},parent:null},q=Q._parseSync({data:F.data,path:F.path,parent:Y});if(q.status==="valid")return q;else if(q.status==="dirty"&&!$)$={result:q,ctx:Y};if(Y.common.issues.length)J.push(Y.common.issues)}if($)return F.common.issues.push(...$.ctx.common.issues),$.result;let X=J.map((Q)=>new s(Q));return C(F,{code:W.invalid_union,unionErrors:X}),j}}get options(){return this._def.options}}A2.create=(D,F)=>{return new A2({options:D,typeName:M.ZodUnion,...T(F)})};var LD=(D)=>{if(D instanceof C2)return LD(D.schema);else if(D instanceof YD)return LD(D.innerType());else if(D instanceof z2)return[D.value];else if(D instanceof kD)return D.options;else if(D instanceof V2)return I.objectValues(D.enum);else if(D instanceof R2)return LD(D._def.innerType);else if(D instanceof W2)return[void 0];else if(D instanceof G2)return[null];else if(D instanceof XD)return[void 0,...LD(D.unwrap())];else if(D instanceof MD)return[null,...LD(D.unwrap())];else if(D instanceof q0)return LD(D.unwrap());else if(D instanceof j2)return LD(D.unwrap());else if(D instanceof K2)return LD(D._def.innerType);else return[]};class Y0 extends P{_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.object)return C(F,{code:W.invalid_type,expected:A.object,received:F.parsedType}),j;let E=this.discriminator,B=F.data[E],$=this.optionsMap.get(B);if(!$)return C(F,{code:W.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[E]}),j;if(F.common.async)return $._parseAsync({data:F.data,path:F.path,parent:F});else return $._parseSync({data:F.data,path:F.path,parent:F})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(D,F,E){let B=new Map;for(let $ of F){let J=LD($.shape[D]);if(!J.length)throw Error(`A discriminator value for key \`${D}\` could not be extracted from all schema options`);for(let X of J){if(B.has(X))throw Error(`Discriminator property ${String(D)} has duplicate value ${String(X)}`);B.set(X,$)}}return new Y0({typeName:M.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:B,...T(E)})}}function r0(D,F){let E=WD(D),B=WD(F);if(D===F)return{valid:!0,data:D};else if(E===A.object&&B===A.object){let $=I.objectKeys(F),J=I.objectKeys(D).filter((Q)=>$.indexOf(Q)!==-1),X={...D,...F};for(let Q of J){let Y=r0(D[Q],F[Q]);if(!Y.valid)return{valid:!1};X[Q]=Y.data}return{valid:!0,data:X}}else if(E===A.array&&B===A.array){if(D.length!==F.length)return{valid:!1};let $=[];for(let J=0;J<D.length;J++){let X=D[J],Q=F[J],Y=r0(X,Q);if(!Y.valid)return{valid:!1};$.push(Y.data)}return{valid:!0,data:$}}else if(E===A.date&&B===A.date&&+D===+F)return{valid:!0,data:D};else return{valid:!1}}class U2 extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=($,J)=>{if(X0($)||X0(J))return j;let X=r0($.value,J.value);if(!X.valid)return C(E,{code:W.invalid_intersection_types}),j;if(Q0($)||Q0(J))F.dirty();return{status:F.value,value:X.data}};if(E.common.async)return Promise.all([this._def.left._parseAsync({data:E.data,path:E.path,parent:E}),this._def.right._parseAsync({data:E.data,path:E.path,parent:E})]).then(([$,J])=>B($,J));else return B(this._def.left._parseSync({data:E.data,path:E.path,parent:E}),this._def.right._parseSync({data:E.data,path:E.path,parent:E}))}}U2.create=(D,F,E)=>{return new U2({left:D,right:F,typeName:M.ZodIntersection,...T(E)})};class AD extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.array)return C(E,{code:W.invalid_type,expected:A.array,received:E.parsedType}),j;if(E.data.length<this._def.items.length)return C(E,{code:W.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;if(!this._def.rest&&E.data.length>this._def.items.length)C(E,{code:W.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F.dirty();let $=[...E.data].map((J,X)=>{let Q=this._def.items[X]||this._def.rest;if(!Q)return null;return Q._parse(new QD(E,J,E.path,X))}).filter((J)=>!!J);if(E.common.async)return Promise.all($).then((J)=>{return n.mergeArray(F,J)});else return n.mergeArray(F,$)}get items(){return this._def.items}rest(D){return new AD({...this._def,rest:D})}}AD.create=(D,F)=>{if(!Array.isArray(D))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new AD({items:D,typeName:M.ZodTuple,rest:null,...T(F)})};class h2 extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.object)return C(E,{code:W.invalid_type,expected:A.object,received:E.parsedType}),j;let B=[],$=this._def.keyType,J=this._def.valueType;for(let X in E.data)B.push({key:$._parse(new QD(E,X,E.path,X)),value:J._parse(new QD(E,E.data[X],E.path,X)),alwaysSet:X in E.data});if(E.common.async)return n.mergeObjectAsync(F,B);else return n.mergeObjectSync(F,B)}get element(){return this._def.valueType}static create(D,F,E){if(F instanceof P)return new h2({keyType:D,valueType:F,typeName:M.ZodRecord,...T(E)});return new h2({keyType:$D.create(),valueType:D,typeName:M.ZodRecord,...T(F)})}}class g2 extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.map)return C(E,{code:W.invalid_type,expected:A.map,received:E.parsedType}),j;let B=this._def.keyType,$=this._def.valueType,J=[...E.data.entries()].map(([X,Q],Y)=>{return{key:B._parse(new QD(E,X,E.path,[Y,"key"])),value:$._parse(new QD(E,Q,E.path,[Y,"value"]))}});if(E.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let Q of J){let Y=await Q.key,q=await Q.value;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();X.set(Y.value,q.value)}return{status:F.value,value:X}})}else{let X=new Map;for(let Q of J){let{key:Y,value:q}=Q;if(Y.status==="aborted"||q.status==="aborted")return j;if(Y.status==="dirty"||q.status==="dirty")F.dirty();X.set(Y.value,q.value)}return{status:F.value,value:X}}}}g2.create=(D,F,E)=>{return new g2({valueType:F,keyType:D,typeName:M.ZodMap,...T(E)})};class mD extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.parsedType!==A.set)return C(E,{code:W.invalid_type,expected:A.set,received:E.parsedType}),j;let B=this._def;if(B.minSize!==null){if(E.data.size<B.minSize.value)C(E,{code:W.too_small,minimum:B.minSize.value,type:"set",inclusive:!0,exact:!1,message:B.minSize.message}),F.dirty()}if(B.maxSize!==null){if(E.data.size>B.maxSize.value)C(E,{code:W.too_big,maximum:B.maxSize.value,type:"set",inclusive:!0,exact:!1,message:B.maxSize.message}),F.dirty()}let $=this._def.valueType;function J(Q){let Y=new Set;for(let q of Q){if(q.status==="aborted")return j;if(q.status==="dirty")F.dirty();Y.add(q.value)}return{status:F.value,value:Y}}let X=[...E.data.values()].map((Q,Y)=>$._parse(new QD(E,Q,E.path,Y)));if(E.common.async)return Promise.all(X).then((Q)=>J(Q));else return J(X)}min(D,F){return new mD({...this._def,minSize:{value:D,message:z.toString(F)}})}max(D,F){return new mD({...this._def,maxSize:{value:D,message:z.toString(F)}})}size(D,F){return this.min(D,F).max(D,F)}nonempty(D){return this.min(1,D)}}mD.create=(D,F)=>{return new mD({valueType:D,minSize:null,maxSize:null,typeName:M.ZodSet,...T(F)})};class _2 extends P{constructor(){super(...arguments);this.validate=this.implement}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.function)return C(F,{code:W.invalid_type,expected:A.function,received:F.parsedType}),j;function E(X,Q){return v2({data:X,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,Q2(),jD].filter((Y)=>!!Y),issueData:{code:W.invalid_arguments,argumentsError:Q}})}function B(X,Q){return v2({data:X,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,Q2(),jD].filter((Y)=>!!Y),issueData:{code:W.invalid_return_type,returnTypeError:Q}})}let $={errorMap:F.common.contextualErrorMap},J=F.data;if(this._def.returns instanceof pD){let X=this;return a(async function(...Q){let Y=new s([]),q=await X._def.args.parseAsync(Q,$).catch((G)=>{throw Y.addIssue(E(Q,G)),Y}),_=await Reflect.apply(J,this,q);return await X._def.returns._def.type.parseAsync(_,$).catch((G)=>{throw Y.addIssue(B(_,G)),Y})})}else{let X=this;return a(function(...Q){let Y=X._def.args.safeParse(Q,$);if(!Y.success)throw new s([E(Q,Y.error)]);let q=Reflect.apply(J,this,Y.data),_=X._def.returns.safeParse(q,$);if(!_.success)throw new s([B(q,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new _2({...this._def,args:AD.create(D).rest(uD.create())})}returns(D){return new _2({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,E){return new _2({args:D?D:AD.create([]).rest(uD.create()),returns:F||uD.create(),typeName:M.ZodFunction,...T(E)})}}class C2 extends P{get schema(){return this._def.getter()}_parse(D){let{ctx:F}=this._processInputParams(D);return this._def.getter()._parse({data:F.data,path:F.path,parent:F})}}C2.create=(D,F)=>{return new C2({getter:D,typeName:M.ZodLazy,...T(F)})};class z2 extends P{_parse(D){if(D.data!==this._def.value){let F=this._getOrReturnCtx(D);return C(F,{received:F.data,code:W.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:D.data}}get value(){return this._def.value}}z2.create=(D,F)=>{return new z2({value:D,typeName:M.ZodLiteral,...T(F)})};function b8(D,F){return new kD({values:D,typeName:M.ZodEnum,...T(F)})}class kD extends P{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{expected:I.joinValues(E),received:F.parsedType,code:W.invalid_type}),j}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(D.data)){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{received:F.data,code:W.invalid_enum_value,options:E}),j}return a(D.data)}get options(){return this._def.values}get enum(){let D={};for(let F of this._def.values)D[F]=F;return D}get Values(){let D={};for(let F of this._def.values)D[F]=F;return D}get Enum(){let D={};for(let F of this._def.values)D[F]=F;return D}extract(D,F=this._def){return kD.create(D,{...this._def,...F})}exclude(D,F=this._def){return kD.create(this.options.filter((E)=>!D.includes(E)),{...this._def,...F})}}kD.create=b8;class V2 extends P{_parse(D){let F=I.getValidEnumValues(this._def.values),E=this._getOrReturnCtx(D);if(E.parsedType!==A.string&&E.parsedType!==A.number){let B=I.objectValues(F);return C(E,{expected:I.joinValues(B),received:E.parsedType,code:W.invalid_type}),j}if(!this._cache)this._cache=new Set(I.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let B=I.objectValues(F);return C(E,{received:E.data,code:W.invalid_enum_value,options:B}),j}return a(D.data)}get enum(){return this._def.values}}V2.create=(D,F)=>{return new V2({values:D,typeName:M.ZodNativeEnum,...T(F)})};class pD extends P{unwrap(){return this._def.type}_parse(D){let{ctx:F}=this._processInputParams(D);if(F.parsedType!==A.promise&&F.common.async===!1)return C(F,{code:W.invalid_type,expected:A.promise,received:F.parsedType}),j;let E=F.parsedType===A.promise?F.data:Promise.resolve(F.data);return a(E.then((B)=>{return this._def.type.parseAsync(B,{path:F.path,errorMap:F.common.contextualErrorMap})}))}}pD.create=(D,F)=>{return new pD({type:D,typeName:M.ZodPromise,...T(F)})};class YD extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=this._def.effect||null,$={addIssue:(J)=>{if(C(E,J),J.fatal)F.abort();else F.dirty()},get path(){return E.path}};if($.addIssue=$.addIssue.bind($),B.type==="preprocess"){let J=B.transform(E.data,$);if(E.common.async)return Promise.resolve(J).then(async(X)=>{if(F.value==="aborted")return j;let Q=await this._def.schema._parseAsync({data:X,path:E.path,parent:E});if(Q.status==="aborted")return j;if(Q.status==="dirty")return hD(Q.value);if(F.value==="dirty")return hD(Q.value);return Q});else{if(F.value==="aborted")return j;let X=this._def.schema._parseSync({data:J,path:E.path,parent:E});if(X.status==="aborted")return j;if(X.status==="dirty")return hD(X.value);if(F.value==="dirty")return hD(X.value);return X}}if(B.type==="refinement"){let J=(X)=>{let Q=B.refinement(X,$);if(E.common.async)return Promise.resolve(Q);if(Q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(E.common.async===!1){let X=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(X.status==="aborted")return j;if(X.status==="dirty")F.dirty();return J(X.value),{status:F.value,value:X.value}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((X)=>{if(X.status==="aborted")return j;if(X.status==="dirty")F.dirty();return J(X.value).then(()=>{return{status:F.value,value:X.value}})})}if(B.type==="transform")if(E.common.async===!1){let J=this._def.schema._parseSync({data:E.data,path:E.path,parent:E});if(!ID(J))return j;let X=B.transform(J.value,$);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:F.value,value:X}}else return this._def.schema._parseAsync({data:E.data,path:E.path,parent:E}).then((J)=>{if(!ID(J))return j;return Promise.resolve(B.transform(J.value,$)).then((X)=>({status:F.value,value:X}))});I.assertNever(B)}}YD.create=(D,F,E)=>{return new YD({schema:D,typeName:M.ZodEffects,effect:F,...T(E)})};YD.createWithPreprocess=(D,F,E)=>{return new YD({schema:F,effect:{type:"preprocess",transform:D},typeName:M.ZodEffects,...T(E)})};class XD extends P{_parse(D){if(this._getType(D)===A.undefined)return a(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}XD.create=(D,F)=>{return new XD({innerType:D,typeName:M.ZodOptional,...T(F)})};class MD extends P{_parse(D){if(this._getType(D)===A.null)return a(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}MD.create=(D,F)=>{return new MD({innerType:D,typeName:M.ZodNullable,...T(F)})};class R2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=F.data;if(F.parsedType===A.undefined)E=this._def.defaultValue();return this._def.innerType._parse({data:E,path:F.path,parent:F})}removeDefault(){return this._def.innerType}}R2.create=(D,F)=>{return new R2({innerType:D,typeName:M.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...T(F)})};class K2 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E={...F,common:{...F.common,issues:[]}},B=this._def.innerType._parse({data:E.data,path:E.path,parent:{...E}});if(Y2(B))return B.then(($)=>{return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new s(E.common.issues)},input:E.data})}});else return{status:"valid",value:B.status==="valid"?B.value:this._def.catchValue({get error(){return new s(E.common.issues)},input:E.data})}}removeCatch(){return this._def.innerType}}K2.create=(D,F)=>{return new K2({innerType:D,typeName:M.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...T(F)})};class l2 extends P{_parse(D){if(this._getType(D)!==A.nan){let E=this._getOrReturnCtx(D);return C(E,{code:W.invalid_type,expected:A.nan,received:E.parsedType}),j}return{status:"valid",value:D.data}}}l2.create=(D)=>{return new l2({typeName:M.ZodNaN,...T(D)})};var y5=Symbol("zod_brand");class q0 extends P{_parse(D){let{ctx:F}=this._processInputParams(D),E=F.data;return this._def.type._parse({data:E,path:F.path,parent:F})}unwrap(){return this._def.type}}class m2 extends P{_parse(D){let{status:F,ctx:E}=this._processInputParams(D);if(E.common.async)return(async()=>{let $=await this._def.in._parseAsync({data:E.data,path:E.path,parent:E});if($.status==="aborted")return j;if($.status==="dirty")return F.dirty(),hD($.value);else return this._def.out._parseAsync({data:$.value,path:E.path,parent:E})})();else{let B=this._def.in._parseSync({data:E.data,path:E.path,parent:E});if(B.status==="aborted")return j;if(B.status==="dirty")return F.dirty(),{status:"dirty",value:B.value};else return this._def.out._parseSync({data:B.value,path:E.path,parent:E})}}static create(D,F){return new m2({in:D,out:F,typeName:M.ZodPipeline})}}class j2 extends P{_parse(D){let F=this._def.innerType._parse(D),E=(B)=>{if(ID(B))B.value=Object.freeze(B.value);return B};return Y2(F)?F.then((B)=>E(B)):E(F)}unwrap(){return this._def.innerType}}j2.create=(D,F)=>{return new j2({innerType:D,typeName:M.ZodReadonly,...T(F)})};function O8(D,F){let E=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof E==="string"?{message:E}:E}function w8(D,F={},E){if(D)return lD.create().superRefine((B,$)=>{let J=D(B);if(J instanceof Promise)return J.then((X)=>{if(!X){let Q=O8(F,B),Y=Q.fatal??E??!0;$.addIssue({code:"custom",...Q,fatal:Y})}});if(!J){let X=O8(F,B),Q=X.fatal??E??!0;$.addIssue({code:"custom",...X,fatal:Q})}return});return lD.create()}var h5={object:y.lazycreate},M;(function(D){D.ZodString="ZodString",D.ZodNumber="ZodNumber",D.ZodNaN="ZodNaN",D.ZodBigInt="ZodBigInt",D.ZodBoolean="ZodBoolean",D.ZodDate="ZodDate",D.ZodSymbol="ZodSymbol",D.ZodUndefined="ZodUndefined",D.ZodNull="ZodNull",D.ZodAny="ZodAny",D.ZodUnknown="ZodUnknown",D.ZodNever="ZodNever",D.ZodVoid="ZodVoid",D.ZodArray="ZodArray",D.ZodObject="ZodObject",D.ZodUnion="ZodUnion",D.ZodDiscriminatedUnion="ZodDiscriminatedUnion",D.ZodIntersection="ZodIntersection",D.ZodTuple="ZodTuple",D.ZodRecord="ZodRecord",D.ZodMap="ZodMap",D.ZodSet="ZodSet",D.ZodFunction="ZodFunction",D.ZodLazy="ZodLazy",D.ZodLiteral="ZodLiteral",D.ZodEnum="ZodEnum",D.ZodEffects="ZodEffects",D.ZodNativeEnum="ZodNativeEnum",D.ZodOptional="ZodOptional",D.ZodNullable="ZodNullable",D.ZodDefault="ZodDefault",D.ZodCatch="ZodCatch",D.ZodPromise="ZodPromise",D.ZodBranded="ZodBranded",D.ZodPipeline="ZodPipeline",D.ZodReadonly="ZodReadonly"})(M||(M={}));var g5=(D,F={message:`Input not instance of ${D.name}`})=>w8((E)=>E instanceof D,F),P8=$D.create,I8=fD.create,l5=l2.create,m5=ZD.create,u8=H2.create,p5=gD.create,c5=x2.create,d5=W2.create,i5=G2.create,n5=lD.create,r5=uD.create,a5=GD.create,o5=y2.create,s5=JD.create,t5=y.create,e5=y.strictCreate,D7=A2.create,F7=Y0.create,E7=U2.create,B7=AD.create,$7=h2.create,J7=g2.create,X7=mD.create,Q7=_2.create,Y7=C2.create,q7=z2.create,_7=kD.create,H7=V2.create,W7=pD.create,G7=YD.create,A7=XD.create,U7=MD.create,C7=YD.createWithPreprocess,z7=m2.create,V7=()=>P8().optional(),R7=()=>I8().optional(),K7=()=>u8().optional(),j7={string:(D)=>$D.create({...D,coerce:!0}),number:(D)=>fD.create({...D,coerce:!0}),boolean:(D)=>H2.create({...D,coerce:!0}),bigint:(D)=>ZD.create({...D,coerce:!0}),date:(D)=>gD.create({...D,coerce:!0})};var L7=j;var M7=u.object({name:u.string().default("genie"),defaultWindow:u.string().default("shell"),autoCreate:u.boolean().default(!0)}),O7=u.object({execTimeout:u.number().default(120000),readLines:u.number().default(100),worktreeBase:u.string().default(".worktrees")}),N7=u.object({tmuxDebug:u.boolean().default(!1),verbose:u.boolean().default(!1)}),S7=u.object({preference:u.enum(["auto","zsh","bash","fish"]).default("auto")}),T7=u.object({tmuxInstalled:u.boolean().default(!1),shellInstalled:u.boolean().default(!1)}),b7=u.object({enabled:u.boolean().default(!1)}),qD=u.object({version:u.number().default(2),session:M7.default({}),terminal:O7.default({}),logging:N7.default({}),shell:S7.default({}),shortcuts:T7.default({}),claudio:b7.optional(),installMethod:u.enum(["source","npm","bun"]).optional(),setupComplete:u.boolean().default(!1),lastSetupAt:u.string().optional()}),f8=u.object({session:u.object({name:u.string().default("genie"),defaultWindow:u.string().default("shell")}).default({}),logging:u.object({tmuxDebug:u.boolean().default(!1)}).default({}),installMethod:u.enum(["source","npm","bun"]).optional()});var _0=v8(k8(),".genie"),cD=v8(_0,"config.json"),a0=2;function NB(){return _0}function SB(){return cD}function I7(){return H0(cD)}function u7(){if(!H0(_0))w7(_0,{recursive:!0})}function x8(D){let F=f8.safeParse(D);if(F.success){let E=F.data;return qD.parse({version:a0,session:{name:E.session.name,defaultWindow:E.session.defaultWindow,autoCreate:!0},terminal:{execTimeout:120000,readLines:100,worktreeBase:".worktrees"},logging:{tmuxDebug:E.logging.tmuxDebug,verbose:!1},shell:{preference:"auto"},shortcuts:{tmuxInstalled:!1,shellInstalled:!1},installMethod:E.installMethod,setupComplete:!1})}return qD.parse({})}async function y8(){if(!H0(cD))return qD.parse({});try{let D=Z8(cD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<a0){let E=x8(F);return await W0(E),E}return qD.parse(F)}catch(D){return console.warn(`Warning: Invalid genie config, using defaults: ${D.message}`),qD.parse({})}}async function W0(D){u7();try{let F=qD.parse(D),E=JSON.stringify(F,null,2);P7(cD,E,"utf-8")}catch(F){throw Error(`Failed to save genie config: ${F.message}`)}}function f7(){return qD.parse({})}function h8(){if(!H0(cD))return qD.parse({});try{let D=Z8(cD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<a0)return x8(F);return qD.parse(F)}catch{return qD.parse({})}}function TB(D){let F=k8();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}function G0(){return h8().terminal}function bB(){if(!I7())return!1;return h8().setupComplete??!1}async function wB(){let D=await y8();D.setupComplete=!0,D.lastSetupAt=new Date().toISOString(),await W0(D)}async function PB(){let D=f7();await W0(D)}async function IB(D){let F=await y8();F.shortcuts={...F.shortcuts,...D},await W0(F)}async function g8(D,F){try{let B=G0().readLines,$={lines:F.lines?parseInt(F.lines,10):B,from:F.from?parseInt(F.from,10):void 0,to:F.to?parseInt(F.to,10):void 0,range:F.range,search:F.search,grep:F.grep,follow:F.follow,all:F.all,reverse:F.reverse};if(F.follow){console.log(`Following session "${D}" (Ctrl+C to stop)...`),console.log("");let X=await j8(D,(Q)=>{console.log(Q)});process.on("SIGINT",()=>{X(),console.log(`
51
- Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let J=await K8(D,$);if(F.json){let X=J.split(`
52
- `);console.log(JSON.stringify({session:D,lineCount:X.length,content:X},null,2));return}console.log(J)}catch(E){console.error(`Error reading session logs: ${E.message}`),process.exit(1)}}async function l8(D,F,E={}){let[B,$]=D.includes(":")?D.split(":"):[D,"shell"];try{let J=await Z(B);if(!J){if(!E.quiet)console.error(`Session "${B}" not found, creating...`);if(J=await yD(B),!J)console.error(`Failed to create session "${B}"`),process.exit(1)}let Q=(await v(J.id)).find((U)=>U.name===$);if(!Q){if(!E.quiet)console.error(`Window "${$}" not found, creating...`);if(Q=await E0(J.id,$),!Q)console.error(`Failed to create window "${$}"`),process.exit(1)}let Y=await g(Q.id);if(!Y||Y.length===0)console.error(`No panes found in window "${$}"`),process.exit(1);let q=G0(),_=E.timeout??q.execTimeout,{output:H,exitCode:G}=await Q8(Y[0].id,F,_);if(H&&!E.quiet)console.log(H);process.exit(G)}catch(J){console.error(`Error: ${J.message}`),process.exit(1)}}async function m8(D,F){try{let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await g(B[0].id);if(!$||$.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let J=$[0].id;await e(J,F,!1,!0),console.log(`\u2705 Keys sent to session "${D}"`)}catch(E){console.error(`\u274C Error sending keys: ${E.message}`),process.exit(1)}}import{join as x7}from"path";async function p8(D,F,E={}){try{let B=await Z(D);if(!B)console.error(`\u274C Session "${D}" not found`),process.exit(1);let $=await v(B.id);if(!$||$.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let J=await g($[0].id);if(!J||J.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let X=J[0].id,Q=F==="h"?"horizontal":"vertical",Y;if(E.worktree){if(!E.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let _=X2({baseDir:x7(E.workspace,".worktrees"),repoPath:E.workspace});if(!await _.worktreeExists(E.worktree)){let G=await _.createWorktree(E.worktree,!0);console.log(`\u2705 Worktree created at ${G.path}`)}Y=_.getWorktreePath(E.worktree)}else if(E.workspace)Y=E.workspace;let q=await $0(X,Q);if(!q)console.error("\u274C Failed to split pane"),process.exit(1);if(Y&&q)await S(`send-keys -t '${q.id}' 'cd ${Y}' Enter`);if(console.log(`\u2705 Pane split ${Q}ly in session "${D}"`),Y)console.log(` Working directory: ${Y}`)}catch(B){console.error(`\u274C Error splitting pane: ${B.message}`),process.exit(1)}}async function c8(D,F){await S(`set-hook -g ${D} '${F.replace(/'/g,"'\\''")}'`)}async function d8(D){await S(`set-hook -gu ${D}`)}async function i8(){let D=["after-bind-key","after-capture-pane","after-copy-mode","after-display-message","after-display-panes","after-kill-pane","after-list-buffers","after-list-clients","after-list-keys","after-list-panes","after-list-sessions","after-list-windows","after-load-buffer","after-lock-server","after-new-session","after-new-window","after-paste-buffer","after-pipe-pane","after-queue","after-refresh-client","after-rename-session","after-rename-window","after-resize-pane","after-resize-window","after-save-buffer","after-select-layout","after-select-pane","after-select-window","after-send-keys","after-set-buffer","after-set-environment","after-set-option","after-show-environment","after-show-messages","after-show-options","after-split-window","after-unbind-key","alert-activity","alert-bell","alert-silence","client-attached","client-detached","client-resized","client-session-changed","pane-died","pane-exited","pane-focus-in","pane-focus-out","pane-mode-changed","pane-set-clipboard","session-closed","session-created","session-renamed","session-window-changed","window-linked","window-pane-changed","window-renamed","window-unlinked"],F=[];for(let E of D)try{let B=await S(`show-hooks -g ${E}`);if(B.trim()){let $=B.trim().split(" ");if($.length>=2)F.push({event:$[0],command:$.slice(1).join(" ")})}}catch(B){continue}return F}async function n8(D,F){try{await c8(D,F),console.log(`\u2705 Hook set: ${D} \u2192 ${F}`)}catch(E){console.error(`\u274C Error setting hook: ${E.message}`),process.exit(1)}}async function r8(){try{let D=await i8();if(D.length===0){console.log("No hooks configured");return}console.log("EVENT\t\t\t\tCOMMAND"),console.log("\u2500".repeat(80));for(let F of D)console.log(`${F.event} ${F.command}`)}catch(D){console.error(`\u274C Error listing hooks: ${D.message}`),process.exit(1)}}async function a8(D){try{await d8(D),console.log(`\u2705 Hook removed: ${D}`)}catch(F){console.error(`\u274C Error removing hook: ${F.message}`),process.exit(1)}}async function o8(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(F.json){console.log(JSON.stringify(B,null,2));return}if(B.length===0){console.log("No windows found");return}console.log("WINDOW ID\t\tNAME\t\t\tACTIVE"),console.log("\u2500".repeat(60));for(let $ of B){let J=$.active?"yes":"no";console.log(`${$.id} ${$.name} ${J}`)}}catch(E){console.error(`Error listing windows: ${E.message}`),process.exit(1)}}async function s8(D,F){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await E0(E.id,F);if(B)console.log(`Window created: ${B.id}`);else console.error("Failed to create window"),process.exit(1)}catch(E){console.error(`Error creating window: ${E.message}`),process.exit(1)}}async function t8(D){try{await J8(D),console.log(`Window removed: ${D}`)}catch(F){console.error(`Error removing window: ${F.message}`),process.exit(1)}}async function e8(D,F={}){try{let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id);if(B.length===0){if(F.json)console.log("[]");else console.log("No panes found");return}let $=[];for(let J of B){let X=await g(J.id);for(let Q of X)$.push({id:Q.id,windowId:J.id,windowName:J.name,title:Q.title,active:Q.active})}if(F.json){console.log(JSON.stringify($,null,2));return}if($.length===0){console.log("No panes found");return}console.log("PANE ID\t\tWINDOW\t\t\tTITLE\t\t\tACTIVE"),console.log("\u2500".repeat(80));for(let J of $){let X=J.active?"yes":"no",Q=J.title||"-";console.log(`${J.id} ${J.windowName} ${Q} ${X}`)}}catch(E){console.error(`Error listing panes: ${E.message}`),process.exit(1)}}async function D6(D){try{await $2(D),console.log(`Pane removed: ${D}`)}catch(F){console.error(`Error removing pane: ${F.message}`),process.exit(1)}}async function F6(D,F={}){try{if(F.command){await p7(F.command,F.json);return}let E=await Z(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await v(E.id),$=0;for(let Q of B){let Y=await g(Q.id);$+=Y.length}let J="idle",X={session:E.name,id:E.id,attached:E.attached,windows:B.length,panes:$,state:J};if(F.json){console.log(JSON.stringify(X,null,2));return}console.log(`Session: ${X.session}`),console.log(`ID: ${X.id}`),console.log(`Attached: ${X.attached?"yes":"no"}`),console.log(`Windows: ${X.windows}`),console.log(`Panes: ${X.panes}`),console.log(`State: ${X.state}`)}catch(E){console.error(`Error getting status: ${E.message}`),process.exit(1)}}async function p7(D,F){try{let E=await X8(D);if(!E)console.error(`Command "${D}" not found`),process.exit(1);let B={id:E.id,paneId:E.paneId,command:E.command,status:E.status,exitCode:E.exitCode,startTime:E.startTime.toISOString(),result:E.result};if(F){console.log(JSON.stringify(B,null,2));return}if(console.log(`Command: ${B.id}`),console.log(`Status: ${B.status}`),console.log(`Exit Code: ${B.exitCode??"N/A"}`),console.log(`Start Time: ${B.startTime}`),B.result)console.log(`
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(`
53
53
  Output:
54
- ${B.result}`)}catch(E){console.error(`Error getting command status: ${E.message}`),process.exit(1)}}import{homedir as E6}from"os";import{join as _D}from"path";import{existsSync as dD,readFileSync as B6,writeFileSync as d7,mkdirSync as i7,appendFileSync as o0}from"fs";import*as $6 from"readline";function J6(){return`# Warp-like keyboard shortcuts (generated by genie-cli)
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)
55
55
  # To use: add to ~/.tmux.conf or source this file
56
56
 
57
57
  # Ctrl+T: New window (tab) in current session
@@ -62,13 +62,13 @@ bind-key -n C-s split-window -v -c "#{pane_current_path}"
62
62
 
63
63
  # Ctrl+Shift+S: Horizontal split
64
64
  bind-key -n C-S split-window -h -c "#{pane_current_path}"
65
- `}function X6(){return`# Warp-like extra keys (generated by genie-cli)
65
+ `}function P6(){return`# Warp-like extra keys (generated by genie-cli)
66
66
  # To use: add to ~/.termux/termux.properties
67
67
 
68
68
  # Extra keys row with F-keys for shortcuts
69
69
  # F1=New Tab, F2=VSplit, F3=HSplit
70
70
  extra-keys = [['ESC','TAB','CTRL','ALT','F1','F2','F3']]
71
- `}function n7(){return`# Warp-like shortcuts (generated by genie-cli)
71
+ `}function b9(){return`# Warp-like shortcuts (generated by genie-cli)
72
72
  # To use: add to ~/.bashrc or ~/.zshrc
73
73
 
74
74
  # Disable Ctrl+S flow control (required for Ctrl+S to work in tmux)
@@ -105,7 +105,7 @@ genie-hsplit() {
105
105
  bind -x '"eOP":"genie-new-tab"' 2>/dev/null # F1
106
106
  bind -x '"eOQ":"genie-vsplit"' 2>/dev/null # F2
107
107
  bind -x '"eOR":"genie-hsplit"' 2>/dev/null # F3
108
- `}function r7(){console.log(`
108
+ `}function P9(){console.log(`
109
109
  Warp-like Terminal Shortcuts for tmux + Termux
110
110
 
111
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
@@ -124,68 +124,68 @@ Commands:
124
124
  term shortcuts --tmux Output tmux.conf snippet
125
125
  term shortcuts --termux Output termux.properties snippet
126
126
  term shortcuts --install Install to config files
127
- `)}async function L2(D){let F=$6.createInterface({input:process.stdin,output:process.stdout});return new Promise((E)=>{F.question(D,(B)=>{F.close(),E(B.trim().toLowerCase())})})}function iD(D,F){if(!dD(D))return!1;return B6(D,"utf-8").includes(F)}async function a7(){let D=E6(),F="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
128
- `);let E=_D(D,".tmux.conf");if(iD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await L2(`Add shortcuts to ${E}? [Y/n] `)!=="n"){let Y=`
129
- `+J6();o0(E,Y),console.log(`\u2705 Added to ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=dD(_D(D,".zshrc"))?_D(D,".zshrc"):_D(D,".bashrc");if(iD(B,"generated by genie-cli"))console.log(`\u2713 ${B} already has genie shortcuts`);else if(await L2(`Add shell functions to ${B}? [Y/n] `)!=="n"){let Y=`
130
- `+n7();o0(B,Y),console.log(`\u2705 Added to ${B}`)}else console.log(`\u23ED\uFE0F Skipped ${B}`);let $=_D(D,".termux"),J=_D($,"termux.properties"),X=dD($)||process.env.TERMUX_VERSION;if(X)if(iD(J,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await L2(`Add extra keys to ${J}? [Y/n] `)!=="n"){if(!dD($))i7($,{recursive:!0});let Y=`
131
- `+X6();o0(J,Y),console.log(`\u2705 Added to ${J}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
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(`
132
132
  \u2705 Installation 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"),X)console.log(" 3. Reload Termux: termux-reload-settings")}function lB(D){return iD(D,"generated by genie-cli")}function s0(D,F){if(!dD(D))return!1;let E=B6(D,"utf-8");if(!E.includes(F))return!1;let B=E.split(`
134
- `),$=[],J=!1,X=-1;for(let Y=0;Y<B.length;Y++){let q=B[Y];if(q.includes(F)&&!J){if(J=!0,X===-1&&$.length>0&&$[$.length-1].trim()==="")$.pop();continue}if(J){if(q.trim()===""&&Y+1<B.length&&!B[Y+1].includes("genie")){J=!1;continue}if(!(q.includes("genie")||q.includes("Ctrl+")||q.includes("split-window")||q.includes("new-window")||q.includes("stty -ixon")||q.includes("Warp-like")||q.includes("bind-key -n")||q.includes("extra-keys")||q.includes("F1=")||q.includes("bind -x")||q.startsWith("#")&&B[Y-1]?.includes("genie"))&&q.trim()!=="")J=!1,$.push(q);continue}$.push(q)}while($.length>0&&$[$.length-1].trim()==="")$.pop();let Q=$.length>0?$.join(`
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(`
135
135
  `)+`
136
- `:"";return d7(D,Q),!0}async function mB(){let D=E6(),F="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
137
- `);let E=_D(D,".tmux.conf");if(!iD(E,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await L2(`Remove shortcuts from ${E}? [Y/n] `)!=="n"){if(s0(E,"generated by genie-cli"))console.log(`\u2705 Removed from ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=_D(D,".zshrc"),$=_D(D,".bashrc");for(let Y of[B,$]){if(!dD(Y))continue;if(!iD(Y,"generated by genie-cli"))console.log(`\u2713 ${Y} has no genie shortcuts`);else if(await L2(`Remove shell functions from ${Y}? [Y/n] `)!=="n"){if(s0(Y,"generated by genie-cli"))console.log(`\u2705 Removed from ${Y}`)}else console.log(`\u23ED\uFE0F Skipped ${Y}`)}let J=_D(D,".termux"),X=_D(J,"termux.properties"),Q=dD(J)||process.env.TERMUX_VERSION;if(Q)if(!iD(X,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await L2(`Remove extra keys from ${X}? [Y/n] `)!=="n"){if(s0(X,"generated by genie-cli"))console.log(`\u2705 Removed from ${X}`),console.log(" Run: termux-reload-settings")}else console.log("\u23ED\uFE0F Skipped termux.properties");if(console.log(`
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(`
138
138
  \u2705 Uninstallation complete!`),console.log(`
139
- Next steps:`),console.log(" 1. Reload tmux: tmux source ~/.tmux.conf"),console.log(" 2. Restart your shell or run: source ~/.bashrc"),Q)console.log(" 3. Reload Termux: termux-reload-settings")}async function Q6(D){if(D.tmux)console.log(J6());else if(D.termux)console.log(X6());else if(D.install)await a7();else r7()}var M2=[{type:"bash_permission",pattern:/Allow (?:Bash|bash|command|shell).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"file_permission",pattern:/Allow (?:Edit|Write|Read|file|reading|writing|editing).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"mcp_permission",pattern:/Allow (?:MCP|mcp|tool).*\?\s*(?:\[([YyNn])\/([YyNn])\])?/i,extract:(D)=>({default:D[1]||"y"})},{type:"generic_permission",pattern:/^(?:Allow|Confirm|Approve)\s+(?:this|the|once|always)?\s*(?:\w+)?\s*\?\s*(?:\[([YyNn])\/([YyNn])\])?/im,extract:(D)=>({default:D[1]||"y"})},{type:"claude_code_yes_no",pattern:/(?:Yes|No)\s*$/m},{type:"claude_code_permission_block",pattern:/(?:Allow|Run|Execute)\s+(?:once|always)/i}],A0=[{type:"numbered_options",pattern:/\[(\d+)\]\s+(.+?)(?=\[(\d+)\]|$)/g,extract:(D)=>({number:D[1],option:D[2].trim()})},{type:"lettered_options",pattern:/\(([a-z])\)\s+(.+?)(?=\([a-z]\)|$)/gi,extract:(D)=>({letter:D[1],option:D[2].trim()})},{type:"yes_no_question",pattern:/\?\s*\[([YyNn])\/([YyNn])\]\s*$/,extract:(D)=>({default:D[1]})},{type:"claude_code_numbered_options",pattern:/(?:\u276F|>)?\s*(\d+)\.\s+(.+?)(?:\n|$)/g,extract:(D)=>({number:D[1],option:D[2].trim()})},{type:"claude_code_plan_approval",pattern:/Would you like to proceed\?/i}],Y6=[{type:"error",pattern:/(?:^|\n)\s*(?:Error|ERROR|error):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"failed",pattern:/(?:^|\n)\s*(?:Failed|FAILED|failed):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"exception",pattern:/(?:^|\n)\s*(?:Exception|EXCEPTION|Uncaught|Unhandled):\s*(.+)/,extract:(D)=>({message:D[1]})},{type:"api_error",pattern:/(?:API|api)\s+(?:error|Error|ERROR):\s*(.+)/,extract:(D)=>({message:D[1]})}],q6=[{type:"checkmark",pattern:/[\u2713\u2714\u2611\uFE0E]/},{type:"success_message",pattern:/(?:Successfully|Completed|Done|Finished|Created|Updated|Saved)/i},{type:"task_complete",pattern:/(?:task|operation|process)\s+(?:complete|completed|finished|done)/i}],_6=[{type:"thinking",pattern:/(?:Thinking|thinking|Processing|processing)\.\.\./},{type:"spinner",pattern:/[\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F\u28FE\u28FD\u28FB\u28BF\u287F\u28DF\u28EF\u28F7]/},{type:"loading",pattern:/(?:Loading|loading|Working|working)\.\.\./},{type:"claude_code_working",pattern:/[\uD83D\uDEE0\uFE0F\uD83D\uDD27\u2699\uFE0F]\s*(?:Read|Edit|Write|Bash|Glob|Grep|Task)/},{type:"claude_code_streaming",pattern:/\u258C$/},{type:"claude_code_propagating",pattern:/Propagating\u2026/}],H6=[{type:"claude_prompt",pattern:/(?:^|\n)\s*>\s*$/},{type:"claude_code_prompt",pattern:/\u276F\s*(?!\d\.)/},{type:"claude_code_input_line",pattern:/\u276F\s*.+\n\u2500+\n/},{type:"idle_indicator",pattern:/\|\s*idle\s*$/i},{type:"input_prompt",pattern:/(?:^|\n)(?:Enter|Input|Type|Provide).*:\s*$/i}],W6=[{type:"run_command",pattern:/(?:Run|Running|Executing)\s+(?:command|bash):\s*(.+)/i,extract:(D)=>({command:D[1]})},{type:"read_file",pattern:/(?:Read|Reading)\s+(?:file):\s*(.+)/i,extract:(D)=>({file:D[1]})},{type:"write_file",pattern:/(?:Write|Writing|Edit|Editing)\s+(?:file|to):\s*(.+)/i,extract:(D)=>({file:D[1]})},{type:"search",pattern:/(?:Search|Searching|Grep|Glob)(?:ing)?:\s*(.+)/i,extract:(D)=>({query:D[1]})}],s7=[{type:"claude_plan_file",pattern:/(~\/\.claude\/plans\/[\w-]+\.md|\/[^\s]+\/\.claude\/plans\/[\w-]+\.md)/,extract:(D)=>({path:D[1]})}];function DD(D){return D.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function G6(D){let F=DD(D),E=O2(F,s7);if(E?.extracted?.path){let B=E.extracted.path;if(B.startsWith("~"))B=B.replace("~",process.env.HOME||"");return B}return null}function p2(D,F){let E=DD(D),B=[];for(let $ of F){let J=new RegExp($.pattern.source,$.pattern.flags||"g"),X;while((X=J.exec(E))!==null)if(B.push({type:$.type,match:X,extracted:$.extract?$.extract(X):void 0}),!$.pattern.flags?.includes("g"))break}return B}function c2(D,F){return p2(D,F).length>0}function O2(D,F){let E=p2(D,F);return E.length>0?E[0]:null}function FD(D,F={}){let{linesToAnalyze:E=50,minConfidence:B=0.3}=F,$=D.split(`
140
- `),J=$.slice(-E).join(`
141
- `),X=DD(J),Y={timestamp:Date.now(),rawOutput:J},q=O2(X,M2);if(q)return{...Y,type:"permission",detail:q.type.replace("_permission",""),confidence:0.9};let _=c2(X,A0.filter((c)=>c.type==="claude_code_plan_approval")),H=$.slice(-15).join(`
142
- `),G=DD(H),U=p2(G,A0);if(U.length>0||_){let c=U.filter((r)=>r.type==="claude_code_numbered_options"&&r.extracted?.option).map((r)=>r.extracted.option);if(c.length>=2||_)return{...Y,type:"question",options:c.length>0?c:void 0,detail:_?"plan_approval":void 0,confidence:0.85};let t=U.filter((r)=>r.extracted?.option&&r.type!=="claude_code_numbered_options").map((r)=>r.extracted.option);if(t.length>=2)return{...Y,type:"question",options:t,confidence:0.85}}let R=U.find((c)=>c.type==="yes_no_question");if(R)return{...Y,type:"question",options:["Yes","No"],detail:`default: ${R.extracted?.default||"y"}`,confidence:0.85};let K=O2(X,Y6);if(K)return{...Y,type:"error",detail:K.extracted?.message||K.match[0],confidence:0.8};let O=O2(X,W6);if(O)return{...Y,type:"tool_use",detail:`${O.type}: ${O.extracted?.command||O.extracted?.file||O.extracted?.query||""}`,confidence:0.75};if(c2(X,_6))return{...Y,type:"working",confidence:0.7};if(c2(X,q6))return{...Y,type:"complete",confidence:0.6};let L=$.slice(-5).join(`
143
- `),N=DD(L);if(c2(N,H6))return{...Y,type:"idle",confidence:0.7};let f=N.trim();if(f.endsWith(">")||f.match(/>\s*$/))return{...Y,type:"idle",detail:"prompt detected",confidence:0.65};return{...Y,type:"unknown",confidence:B}}function A6(D,F){let E=FD(D),B=FD(F);if(E.type==="permission"||E.type==="question")return{complete:!1,reason:`awaiting ${E.type}`,confidence:0.95};if(E.type==="error")return{complete:!0,reason:"error detected",confidence:0.8};if(E.type==="idle")return{complete:!0,reason:"idle prompt detected",confidence:E.confidence};if(E.type==="complete")return{complete:!0,reason:"completion marker detected",confidence:E.confidence};if(B.type==="working"&&E.type!=="working")return{complete:!0,reason:"work finished",confidence:0.6};if(E.type==="working"||E.type==="tool_use")return{complete:!1,reason:"still working",confidence:0.7};return{complete:!1,reason:"unknown state",confidence:0.3}}function U6(D){let F=DD(D),E=O2(F,M2);if(!E)return null;let B=F.split(`
144
- `),$=B.findIndex((Q)=>Q.match(M2[0].pattern)||Q.match(M2[1].pattern)||Q.match(M2[2].pattern)),J,X;if($>0){let Q=B.slice(Math.max(0,$-5),$).join(`
145
- `),Y=Q.match(/(?:Command|command|Bash|bash):\s*(.+)/);if(Y)J=Y[1].trim();let q=Q.match(/(?:File|file|Path|path):\s*(.+)/);if(q)X=q[1].trim()}return{type:E.type.replace("_permission",""),command:J,file:X}}function t0(D){let F=DD(D),E=p2(F,A0),B=[];for(let $ of E)if($.extracted?.option)B.push($.extracted.option);return B}import{EventEmitter as t7}from"events";class UD extends t7{sessionName;paneId=null;explicitPaneId=null;options;pollTimer=null;lastOutput="";lastOutputTime=Date.now();lastState=null;running=!1;constructor(D,F={}){super();this.sessionName=D,this.explicitPaneId=F.paneId||null,this.options={pollIntervalMs:F.pollIntervalMs??500,captureLines:F.captureLines??30,silenceThresholdMs:F.silenceThresholdMs??3000}}async start(){if(this.running)return;if(this.explicitPaneId)this.paneId=this.explicitPaneId.startsWith("%")?this.explicitPaneId:`%${this.explicitPaneId}`;else{let D=await Z(this.sessionName);if(!D)throw Error(`Session "${this.sessionName}" not found`);let F=await v(D.id);if(!F||F.length===0)throw Error(`No windows found in session "${this.sessionName}"`);let E=await g(F[0].id);if(!E||E.length===0)throw Error(`No panes found in session "${this.sessionName}"`);this.paneId=E[0].id}this.running=!0,this.lastOutputTime=Date.now(),await this.poll(),this.pollTimer=setInterval(()=>this.poll(),this.options.pollIntervalMs),this.emit("started",{sessionName:this.sessionName,paneId:this.paneId})}stop(){if(this.pollTimer)clearInterval(this.pollTimer),this.pollTimer=null;this.running=!1,this.emit("stopped")}isRunning(){return this.running}getCurrentState(){return this.lastState}getSilenceMs(){return Date.now()-this.lastOutputTime}async poll(){if(!this.paneId||!this.running)return;try{let D=await p(this.paneId,this.options.captureLines),F=Date.now();if(D!==this.lastOutput){let E=this.getNewContent(this.lastOutput,D);if(E)this.lastOutputTime=F,this.emitEvent({type:"output",output:E,timestamp:F}),this.emitEvent({type:"activity",timestamp:F});let B=FD(D);if(this.lastState&&B.type!==this.lastState.type){if(this.emitEvent({type:"state_change",state:B,timestamp:F}),B.type==="permission")this.emitEvent({type:"permission",state:B,timestamp:F});else if(B.type==="question")this.emitEvent({type:"question",state:B,timestamp:F});else if(B.type==="error")this.emitEvent({type:"error",state:B,timestamp:F});let $=A6(D,this.lastOutput);if($.complete&&$.confidence>0.6)this.emitEvent({type:"complete",state:B,timestamp:F})}this.lastState=B,this.lastOutput=D}else{let E=F-this.lastOutputTime;if(E>=this.options.silenceThresholdMs&&E%this.options.silenceThresholdMs<this.options.pollIntervalMs)this.emitEvent({type:"silence",silenceMs:E,timestamp:F})}}catch(D){this.emit("poll_error",D)}}getNewContent(D,F){if(D===F)return null;if(!D)return F;let E=D.split(`
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
146
  `),B=F.split(`
147
- `),$=E[E.length-1],J=B.lastIndexOf($);if(J>=0&&J<B.length-1)return B.slice(J+1).join(`
148
- `);let X=new Set(E),Q=B.filter((Y)=>!X.has(Y));return Q.length>0?Q.join(`
149
- `):null}emitEvent(D){this.emit(D.type,D),this.emit("event",D)}}async function C6(D,F,E=120000){return new Promise((B,$)=>{let X=Date.now(),Q=setTimeout(()=>{_(),$(Error("Timeout waiting for silence"))},E),Y=()=>{X=Date.now()},q=setInterval(()=>{if(Date.now()-X>=F)_(),B()},100),_=()=>{clearTimeout(Q),clearInterval(q),D.off("activity",Y)};D.on("activity",Y)})}async function z6(D,F={}){let{silenceMs:E=3000,timeoutMs:B=120000,requireIdle:$=!0}=F;return new Promise((J,X)=>{let Q=setTimeout(()=>{U(),X(Error("Timeout waiting for completion"))},B),Y=Date.now(),q=null,_=(R)=>{if(R.state)U(),J({state:R.state,reason:"complete event"})},H=()=>{Y=Date.now()},G=(R)=>{if(R.state?.type==="permission"||R.state?.type==="question")return;if($&&R.state?.type==="idle")U(),J({state:R.state,reason:"idle state"});if(R.state?.type==="error")U(),J({state:R.state,reason:"error"})},U=()=>{if(clearTimeout(Q),q)clearInterval(q);D.off("complete",_),D.off("activity",H),D.off("state_change",G)};q=setInterval(()=>{let R=Date.now()-Y,K=D.getCurrentState();if(R>=E){if(K&&(K.type==="idle"||K.type==="complete"||K.type==="error"))U(),J({state:K,reason:`silence (${R}ms)`});else if(!$)U(),J({state:K||{type:"unknown",timestamp:Date.now(),rawOutput:"",confidence:0},reason:`silence (${R}ms) - non-idle`})}},500),D.on("complete",_),D.on("activity",H),D.on("state_change",G)})}function nD(D){let F={name:`silence-${D}ms`,totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:`silence-${D}ms`,description:`Detect completion when no output for ${D}ms`,metrics:F,async detect(E,B=120000){let $=Date.now();try{await C6(E,D,B);let J=Date.now()-$;return{complete:!0,state:E.getCurrentState()||void 0,reason:`silence for ${D}ms`,latencyMs:J,method:this.name}}catch(J){return{complete:!1,reason:J instanceof Error?J.message:"unknown error",latencyMs:Date.now()-$,method:this.name}}},recordResult(E,B,$){if(F.totalRuns++,F.avgLatencyMs=(F.avgLatencyMs*(F.totalRuns-1)+E)/F.totalRuns,F.minLatencyMs=Math.min(F.minLatencyMs,E),F.maxLatencyMs=Math.max(F.maxLatencyMs,E),!B)if($)F.falsePositives++;else F.falseNegatives++;F.successRate=(F.totalRuns-F.falsePositives-F.falseNegatives)/F.totalRuns}}}function U0(){let D={name:"state-detection",totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:"state-detection",description:"Detect completion when idle state is detected",metrics:D,async detect(F,E=120000){let B=Date.now();try{let $=await z6(F,{timeoutMs:E,requireIdle:!0,silenceMs:2000}),J=Date.now()-B;return{complete:!0,state:$.state,reason:$.reason,latencyMs:J,method:this.name}}catch($){return{complete:!1,reason:$ instanceof Error?$.message:"unknown error",latencyMs:Date.now()-B,method:this.name}}},recordResult(F,E,B){if(D.totalRuns++,D.avgLatencyMs=(D.avgLatencyMs*(D.totalRuns-1)+F)/D.totalRuns,D.minLatencyMs=Math.min(D.minLatencyMs,F),D.maxLatencyMs=Math.max(D.maxLatencyMs,F),!E)if(B)D.falsePositives++;else D.falseNegatives++;D.successRate=(D.totalRuns-D.falsePositives-D.falseNegatives)/D.totalRuns}}}function e0(D,F,E={}){let{primaryTimeoutMs:B=30000,fallbackTimeoutMs:$=90000}=E,J={name:`hybrid(${D.name},${F.name})`,totalRuns:0,avgLatencyMs:0,minLatencyMs:1/0,maxLatencyMs:0,falsePositives:0,falseNegatives:0,successRate:1};return{name:J.name,description:`Try ${D.name} first, fall back to ${F.name}`,metrics:J,async detect(X,Q=120000){let Y=Date.now(),q=await D.detect(X,Math.min(B,Q));if(q.complete)return{...q,method:this.name,reason:`primary(${q.reason})`};let _=Q-(Date.now()-Y);if(_<=0)return{complete:!1,reason:"timeout after primary method",latencyMs:Date.now()-Y,method:this.name};let H=await F.detect(X,Math.min($,_));return{...H,method:this.name,reason:`fallback(${H.reason})`,latencyMs:Date.now()-Y}},recordResult(X,Q,Y){if(J.totalRuns++,J.avgLatencyMs=(J.avgLatencyMs*(J.totalRuns-1)+X)/J.totalRuns,J.minLatencyMs=Math.min(J.minLatencyMs,X),J.maxLatencyMs=Math.max(J.maxLatencyMs,X),!Q)if(Y)J.falsePositives++;else J.falseNegatives++;J.successRate=(J.totalRuns-J.falsePositives-J.falseNegatives)/J.totalRuns}}}function C0(){return e0(U0(),nD(5000),{primaryTimeoutMs:30000,fallbackTimeoutMs:90000})}var d2={"silence-3s":()=>nD(3000),"silence-5s":()=>nD(5000),"silence-10s":()=>nD(1e4),"state-detection":()=>U0(),hybrid:()=>C0(),"aggressive-hybrid":()=>e0(U0(),nD(2000),{primaryTimeoutMs:1e4,fallbackTimeoutMs:30000}),"conservative-hybrid":()=>e0(U0(),nD(1e4),{primaryTimeoutMs:60000,fallbackTimeoutMs:120000})};function D3(D){if(D in d2)return d2[D]();let F=D.match(/^silence-(\d+)(ms|s)?$/);if(F){let E=parseInt(F[1],10),$=(F[2]||"ms")==="s"?E*1000:E;return nD($)}return C0()}async function N2(D,F){let E=await Z(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);if(F){let J=F.startsWith("%")?F:`%${F}`;return{session:E,paneId:J}}let B=await v(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await g(B[0].id);if(!$||$.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);return{session:E,paneId:$[0].id}}function V6(D){let F=`${D.type}`;if(D.detail)F+=` (${D.detail})`;if(D.options&&D.options.length>0)F+=`
150
- Options: ${D.options.join(", ")}`;return F+=` [confidence: ${(D.confidence*100).toFixed(0)}%]`,F}function R6(D){let F=new Date(D.timestamp).toISOString().split("T")[1].split(".")[0];switch(D.type){case"output":return`[${F}] OUTPUT: ${(D.output||"").substring(0,100).replace(/\n/g,"\\n")}`;case"state_change":return`[${F}] STATE: ${D.state?.type||"unknown"}${D.state?.detail?` (${D.state.detail})`:""}`;case"silence":return`[${F}] SILENCE: ${D.silenceMs}ms`;case"activity":return`[${F}] ACTIVITY`;case"permission":return`[${F}] PERMISSION: ${D.state?.detail||"unknown"}`;case"question":return`[${F}] QUESTION: ${D.state?.options?.join(", ")||"unknown"}`;case"error":return`[${F}] ERROR: ${D.state?.detail||"unknown"}`;case"complete":return`[${F}] COMPLETE`;default:return`[${F}] ${D.type}`}}async function K6(D,F={}){try{let E=await Z(D);if(!E){if(E=await yD(D),!E)console.error(`\u274C Failed to create session "${D}"`),process.exit(1);console.log(`\u2705 Created session "${D}"`)}else console.log(`\u2139\uFE0F Session "${D}" already exists`);let B;if(F.pane)B=F.pane.startsWith("%")?F.pane:`%${F.pane}`;else{let J=await v(E.id);B=(await g(J[0].id))[0].id}let $=F.command||"claude";if(await e(B,$,!1,!1),console.log(`\u2705 Started "${$}" in session "${D}"`),F.monitor){console.log("\u2139\uFE0F Starting event monitor...");let J=new UD(D,{pollIntervalMs:500,paneId:F.pane});J.on("event",(X)=>{if(F.json)console.log(JSON.stringify(X));else console.log(R6(X))}),J.on("poll_error",(X)=>{console.error(`\u26A0\uFE0F Poll error: ${X.message}`)}),await J.start(),console.log("\u2705 Monitor active. Press Ctrl+C to stop."),process.on("SIGINT",()=>{J.stop(),console.log(`
151
- \u2705 Monitor stopped.`),process.exit(0)}),await new Promise(()=>{})}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function j6(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane);if(await e(B,F,!1,!1),E.noWait){console.log(`\u2705 Message sent to session "${D}"`);return}let $=new UD(D,{pollIntervalMs:250,paneId:E.pane});await $.start();let J=E.method?D3(E.method):C0(),X=E.timeout||120000;console.log(`\u2139\uFE0F Waiting for completion using "${J.name}"...`);try{let Q=await J.detect($,X);if($.stop(),E.json)console.log(JSON.stringify(Q,null,2));else if(console.log(`\u2705 Completion detected: ${Q.reason}`),console.log(` Latency: ${Q.latencyMs}ms`),Q.state)console.log(` State: ${V6(Q.state)}`);let Y=await p(B,100);console.log(`
152
- --- Response ---`),console.log(DD(Y).trim())}catch(Q){$.stop(),console.error(`\u274C Completion detection failed: ${Q.message}`),process.exit(1)}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}async function L6(D,F={}){try{let{paneId:E}=await N2(D,F.pane),B=await p(E,100),$=FD(B),J=null,X=[],Q=null;if($.type==="permission")J=U6(B);else if($.type==="question"){if(X=t0(B),$.detail==="plan_approval")Q=G6(B)}if(F.json)console.log(JSON.stringify({session:D,state:$.type,detail:$.detail,confidence:$.confidence,timestamp:$.timestamp,permissionDetails:J,questionOptions:X,planFile:Q},null,2));else{if(console.log(`Session: ${D}`),console.log(`State: ${$.type}`),$.detail)console.log(`Detail: ${$.detail}`);if(console.log(`Confidence: ${($.confidence*100).toFixed(0)}%`),J){if(console.log(`
153
- Permission Request:`),console.log(` Type: ${J.type}`),J.command)console.log(` Command: ${J.command}`);if(J.file)console.log(` File: ${J.file}`)}if(X.length>0)console.log(`
154
- Question Options:`),X.forEach((_,H)=>{console.log(` [${H+1}] ${_}`)});if(Q)console.log(`
155
- Plan File: ${Q}`);let q=DD(B).trim().split(`
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
156
  `).slice(-5);console.log(`
157
- Last output:`),q.forEach((_)=>console.log(` ${_}`))}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function M6(D,F={}){try{let E=new UD(D,{pollIntervalMs:F.poll||500,paneId:F.pane});E.on("event",($)=>{if(F.json)console.log(JSON.stringify($));else console.log(R6($))}),E.on("poll_error",($)=>{console.error(`\u26A0\uFE0F Poll error: ${$.message}`)}),await E.start(),console.log(`\u2705 Watching session "${D}". Press Ctrl+C to stop.`);let B=E.getCurrentState();if(B)console.log(`Initial state: ${V6(B)}`);process.on("SIGINT",()=>{E.stop(),console.log(`
158
- \u2705 Watch stopped.`),process.exit(0)}),await new Promise(()=>{})}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function F3(D,F={}){try{let{paneId:E}=await N2(D,F.pane),B=await p(E,50),$=FD(B);if($.type!=="permission"&&!F.auto){console.log(`\u2139\uFE0F No permission request pending (state: ${$.type})`);return}if(F.deny)await S(`send-keys -t '${E}' Down`),await CD(100);if(await S(`send-keys -t '${E}' Enter`),console.log(`\u2705 ${F.deny?"Denied":"Approved"} permission in session "${D}"`),F.auto){console.log("\u2139\uFE0F Auto-approve mode enabled. Press Ctrl+C to stop.");let J=new UD(D,{pollIntervalMs:250,paneId:F.pane});J.on("permission",async(X)=>{try{let{paneId:Q}=await N2(D,F.pane),Y=F.deny?"n":"y";await e(Q,Y,!1,!0),console.log(`\u2705 Auto-${F.deny?"denied":"approved"}: ${X.state?.detail||"unknown"}`)}catch(Q){console.error(`\u26A0\uFE0F Auto-approve failed: ${Q.message}`)}}),await J.start(),process.on("SIGINT",()=>{J.stop(),console.log(`
159
- \u2705 Auto-approve stopped.`),process.exit(0)}),await new Promise(()=>{})}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function E3(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane),$=await p(B,50),J=FD($);if(J.type!=="question"){console.log(`\u2139\uFE0F No question pending (state: ${J.type})`);return}if(F.startsWith("text:")){let X=F.slice(5);await S(`send-keys -t '${B}' End`),await CD(100),await S(`send-keys -t '${B}' Enter`),await CD(100),await S(`send-keys -t '${B}' ${e7(X)}`),await CD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Sent feedback: "${X.substring(0,50)}${X.length>50?"...":""}"`)}else if(/^\d+$/.test(F)){let X=parseInt(F,10),Y=DD($).split(`
160
- `),q=1;for(let H=0;H<Y.length;H++)if(Y[H].match(/^\s*\u276F\s*\d+\./)){let G=Y[H].match(/\u276F\s*(\d+)\./);if(G)q=parseInt(G[1],10);break}let _=X-q;if(_>0)for(let H=0;H<_;H++)await S(`send-keys -t '${B}' Down`),await CD(50);else if(_<0)for(let H=0;H<Math.abs(_);H++)await S(`send-keys -t '${B}' Up`),await CD(50);await CD(100),await S(`send-keys -t '${B}' Enter`),console.log(`\u2705 Selected option ${X} in session "${D}"`)}else await S(`send-keys -t '${B}' '${F}'`),console.log(`\u2705 Sent '${F}' to session "${D}"`)}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}function e7(D){return`"${D.replace(/"/g,"\\\"").replace(/\$/g,"\\$")}"`}function CD(D){return new Promise((F)=>setTimeout(F,D))}async function O6(D,F={}){let E=F.runs||1,B=F.task||'echo "Hello, World!"';console.log(`\uD83E\uDDEA Experiment: Testing "${D}" method`),console.log(` Runs: ${E}`),console.log(` Task: ${B}`),console.log("");let $=D3(D),J=[],X=`orc-experiment-${Date.now()}`,Q=await yD(X);if(!Q)console.error("\u274C Failed to create test session"),process.exit(1);try{let Y=await v(Q.id),_=(await g(Y[0].id))[0].id;for(let O=0;O<E;O++){console.log(`
161
- Run ${O+1}/${E}...`),await e(_,"clear",!1,!1),await new Promise((f)=>setTimeout(f,500));let L=new UD(X,{pollIntervalMs:100});await L.start(),await e(_,B,!1,!1);let N=await $.detect(L,30000);if(L.stop(),J.push({run:O+1,latencyMs:N.latencyMs,complete:N.complete,reason:N.reason}),console.log(` Complete: ${N.complete}`),console.log(` Latency: ${N.latencyMs}ms`),console.log(` Reason: ${N.reason}`),O<E-1)await new Promise((f)=>setTimeout(f,1000))}let H=J.filter((O)=>O.complete),G=H.reduce((O,L)=>O+L.latencyMs,0)/H.length||0,U=Math.min(...H.map((O)=>O.latencyMs))||0,R=Math.max(...H.map((O)=>O.latencyMs))||0,K={method:D,totalRuns:E,successfulRuns:H.length,successRate:H.length/E*100,avgLatencyMs:Math.round(G),minLatencyMs:U,maxLatencyMs:R,results:J};if(console.log(`
162
- --- Summary ---`),F.json)console.log(JSON.stringify(K,null,2));else console.log(`Method: ${K.method}`),console.log(`Success Rate: ${K.successRate.toFixed(1)}%`),console.log(`Avg Latency: ${K.avgLatencyMs}ms`),console.log(`Min Latency: ${K.minLatencyMs}ms`),console.log(`Max Latency: ${K.maxLatencyMs}ms`)}finally{await B0(Q.id),console.log(`
163
- \u2705 Cleaned up test session`)}}async function N6(){console.log("Available completion methods:"),console.log("");for(let D of Object.keys(d2)){let F=d2[D]();console.log(` ${D}`),console.log(` ${F.description}`),console.log("")}console.log("Custom methods:"),console.log(" silence-Xms - Silence timeout (e.g., silence-2000ms)"),console.log(" silence-Xs - Silence timeout (e.g., silence-5s)")}async function S6(D,F,E={}){try{let{paneId:B}=await N2(D,E.pane),$=E.timeout||300000;await e(B,F,!1,!1),console.log(`\u2705 Sent task: "${F.substring(0,50)}${F.length>50?"...":""}"`);let J=new UD(D,{pollIntervalMs:250,paneId:E.pane});await J.start();let X=Date.now();console.log(`\u2139\uFE0F Monitoring for completion...${E.autoApprove?" (auto-approve enabled)":""}`);let Q=null,Y=async()=>{let H=await p(B,30),G=FD(H);if(G.type!==Q){let U=((Date.now()-X)/1000).toFixed(1);console.log(`[${U}s] State: ${G.type}${G.detail?` (${G.detail})`:""}`),Q=G.type}if(G.type==="permission"&&E.autoApprove)return console.log(" \u21B3 Auto-approving permission..."),await S(`send-keys -t '${B}' Enter`),await CD(200),!1;if(G.type==="question"){if(G.detail==="plan_approval"&&E.autoApprove)return console.log(" \u21B3 Auto-approving plan..."),await S(`send-keys -t '${B}' Enter`),await CD(200),!1;console.log("\u26A0\uFE0F Question requires manual input");let U=t0(H);if(U.length>0)console.log(" Options:"),U.forEach((R,K)=>console.log(` [${K+1}] ${R}`));return!0}if(G.type==="idle"){let U=((Date.now()-X)/1000).toFixed(1);return console.log(`\u2705 Task complete (${U}s)`),!0}if(G.type==="error")return console.log("\u274C Task encountered error"),!0;return!1},q=500,_=Math.ceil($/q);for(let H=0;H<_;H++){if(await Y())break;if(Date.now()-X>$){console.log(`\u26A0\uFE0F Timeout after ${$/1000}s`);break}await CD(q)}if(J.stop(),E.json){let H=await p(B,30),G=FD(H);console.log(JSON.stringify({session:D,state:G.type,detail:G.detail,elapsedMs:Date.now()-X},null,2))}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}var{$:G9}=globalThis.Bun;sD();import{join as A9}from"path";import{homedir as U9}from"os";var C9=A9(U9(),".local","share","term","worktrees");async function Y3(D){try{return{stdout:(await G9`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function b6(D){let{stdout:F,exitCode:E}=await Y3(["show",D,"--json"]);if(E!==0||!F)return null;try{let B=JSON.parse(F);return{id:B.id,title:B.title||B.description?.substring(0,50)||"Untitled",status:B.status,blockedBy:B.blockedBy||[]}}catch{return null}}async function z9(){let{stdout:D,exitCode:F}=await Y3(["ready","--json"]);if(F!==0||!D)return null;try{let E=JSON.parse(D);if(Array.isArray(E)&&E.length>0){let B=E[0];return{id:B.id,title:B.title||B.description?.substring(0,50)||"Untitled",status:B.status,blockedBy:B.blockedBy||[]}}return null}catch{let E=D.split(`
164
- `).filter((B)=>B.trim());if(E.length>0){let B=E[0].match(/^(bd-\d+)/);if(B)return b6(B[1])}return null}}async function V9(D){let{exitCode:F}=await Y3(["update",D,"--status","in_progress"]);return F===0}async function R9(){try{return(await S("display-message -p '#{session_name}'")).trim()||null}catch{return null}}async function K9(D,F){try{let E=new PD({baseDir:C9,repoPath:F});if(await E.worktreeExists(D))return console.log(`\u2139\uFE0F Worktree for ${D} already exists`),E.getWorktreePath(D);return(await E.createWorktree(D,!0)).path}catch(E){return console.error(`\u26A0\uFE0F Failed to create worktree: ${E.message}`),null}}async function j9(D,F){try{let E=await Z(D);if(!E)return console.error(`\u274C Session "${D}" not found`),null;let B=await v(E.id);if(!B||B.length===0)return console.error(`\u274C No windows in session "${D}"`),null;let $=await g(B[0].id);if(!$||$.length===0)return console.error(`\u274C No panes in session "${D}"`),null;let J=await $0($[0].id,"horizontal",50,F);if(!J)return console.error("\u274C Failed to create new pane"),null;return{paneId:J.id}}catch(E){return console.error(`\u274C Error spawning worker pane: ${E.message}`),null}}function L9(D,F,E){let B=new UD(F,{pollIntervalMs:1000,paneId:E});B.on("state_change",async($)=>{if(!$.state)return;let J;switch($.state.type){case"working":case"tool_use":J="working";break;case"idle":J="idle";break;case"permission":J="permission";break;case"question":J="question";break;case"error":J="error";break;case"complete":J="done";break;default:return}try{await T2(D,J)}catch{}}),B.on("poll_error",()=>{rD(D).catch(()=>{}),B.stop()}),B.start().catch(()=>{})}async function w6(D,F={}){try{let E=process.cwd(),B=null;if(D==="next"){if(console.log("\uD83D\uDD0D Finding next ready issue..."),B=await z9(),!B){console.log("\u2139\uFE0F No ready issues. Run `bd ready` to see the queue.");return}console.log(`\uD83D\uDCCB Found: ${B.id} - "${B.title}"`)}else if(D==="wish")console.error("\u274C `term work wish` is not yet implemented. Coming in Phase 1.5."),process.exit(1);else if(B=await b6(D),!B)console.error(`\u274C Issue "${D}" not found. Run \`bd list\` to see issues.`),process.exit(1);let $=B.id,J=await vD($);if(J)console.error(`\u274C ${$} already has a worker (pane ${J.paneId})`),console.log(` Run \`term kill ${J.id}\` first, or work on a different issue.`),process.exit(1);let X=F.session||await R9();if(!X)console.error("\u274C Not in a tmux session. Attach to a session first or use --session."),process.exit(1);if(console.log(`\uD83D\uDCDD Claiming ${$}...`),!await V9($))console.error(`\u274C Failed to claim ${$}. Check \`bd show ${$}\`.`),process.exit(1);let Y=E,q=null;if(!F.noWorktree)if(console.log(`\uD83C\uDF33 Creating worktree for ${$}...`),q=await K9($,E),q)Y=q,console.log(` Created: ${q}`);else console.log("\u26A0\uFE0F Worktree creation failed. Using shared repo.");console.log("\uD83D\uDE80 Spawning worker pane...");let _=await j9(X,Y);if(!_)process.exit(1);let{paneId:H}=_,G={id:$,paneId:H,session:X,worktree:q,taskId:$,taskTitle:B.title,startedAt:new Date().toISOString(),state:"spawning",lastStateChange:new Date().toISOString(),repoPath:E};await J3(G),await e(H,"claude",!1,!1),await new Promise((R)=>setTimeout(R,2000));let U=F.prompt||`Work on beads issue ${$}: "${B.title}"
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
165
 
166
166
  Read the issue details with: bd show ${$}
167
167
 
168
- When you're done, commit your changes and let me know.`;if(await e(H,U,!1,!1),await T2($,"working"),L9($,X,H),F.focus!==!1)await S(`select-pane -t '${H}'`);if(console.log(`
169
- \u2705 Worker started for ${$}`),console.log(` Pane: ${H}`),console.log(` Session: ${X}`),q)console.log(` Worktree: ${q}`);console.log(`
170
- Commands:`),console.log(" term workers - Check worker status"),console.log(` term approve ${$} - Approve permissions`),console.log(` term close ${$} - Close issue when done`),console.log(` term kill ${$} - Force kill worker`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var{$:P6}=globalThis.Bun;sD();async function O9(D){try{return await p(D,1),!0}catch{return!1}}async function N9(D){try{let F=await p(D,30),E=FD(F);switch(E.type){case"working":case"tool_use":return"working";case"idle":return"idle";case"permission":return"\u26A0\uFE0F perm";case"question":return"\u26A0\uFE0F question";case"error":return"\u274C error";case"complete":return"\u2705 done";default:return E.type}}catch{return"unknown"}}async function S9(){let D=[],F=[];try{let B=(await P6`bd ready --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)D.push(`${J.id}`)}catch{let $=B.split(`
171
- `).filter((J)=>J.trim());for(let J of $){let X=J.match(/^(bd-\d+)/);if(X)D.push(X[1])}}}catch{}try{let B=(await P6`bd list --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)if(J.blockedBy&&J.blockedBy.length>0)F.push(`${J.id} (blocked by ${J.blockedBy.join(", ")})`)}catch{}}catch{}return{ready:D,blocked:F}}function T9(D){let F=new Date(D).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60);if($>0)return`${$}h ${B%60}m`;else if(B>0)return`${B}m`;return"<1m"}async function I6(D={}){try{let F=await aD(),E=[];for(let Q of F){let Y=await O9(Q.paneId),q=Q.state;if(Y){q=await N9(Q.paneId);let _=b9(q);if(_&&_!==Q.state)await T2(Q.id,_)}else q="\uD83D\uDC80 dead";E.push({name:Q.id,pane:Q.paneId,task:Q.taskTitle?`"${Q.taskTitle.substring(0,25)}${Q.taskTitle.length>25?"...":""}"`:Q.taskId,state:q,time:T9(Q.startedAt),alive:Y})}let B=await S9(),$=F.filter((Q)=>E.find((Y)=>Y.name===Q.id&&Y.alive)).map((Q)=>Q.taskId),J=B.ready.filter((Q)=>!$.includes(Q));if(D.json){console.log(JSON.stringify({workers:E,queue:{ready:J,blocked:B.blocked}},null,2));return}if(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 WORKERS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2524"),console.log("\u2502 Name \u2502 Pane \u2502 Task \u2502 State \u2502Time\u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2524"),E.length===0)console.log("\u2502 (no workers) \u2502");else for(let Q of E){let Y=Q.name.padEnd(8).substring(0,8),q=Q.pane.padEnd(8).substring(0,8),_=Q.task.padEnd(25).substring(0,25),H=Q.state.padEnd(8).substring(0,8),G=Q.time.padStart(4).substring(0,4);console.log(`\u2502 ${Y} \u2502 ${q} \u2502 ${_} \u2502 ${H} \u2502${G}\u2502`)}if(console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"),B.blocked.length>0)console.log(`
172
- Blocked: ${B.blocked.slice(0,5).join(", ")}${B.blocked.length>5?"...":""}`);if(J.length>0)console.log(`Ready: ${J.slice(0,5).join(", ")}${J.length>5?"...":""}`);else if(E.length>0)console.log(`
173
- Ready: (none - all assigned or blocked)`);let X=E.filter((Q)=>!Q.alive);if(X.length>0)console.log(`
174
- \u26A0\uFE0F ${X.length} dead worker(s) detected. Run \`term kill <name>\` to clean up.`)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}function b9(D){if(D==="working")return"working";if(D==="idle")return"idle";if(D==="\u26A0\uFE0F perm")return"permission";if(D==="\u26A0\uFE0F question")return"question";if(D==="\u274C error")return"error";if(D==="\u2705 done")return"done";return null}var{$:T0}=globalThis.Bun;var i2=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",V0=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n";var q3=(D)=>D.name==="backspace",tD=(D)=>D.name==="tab";var OD=(D)=>D.name==="enter"||D.name==="return";class _3 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class H3 extends Error{name="CancelPromptError";message="Prompt was canceled"}class R0 extends Error{name="ExitPromptError"}class W3 extends Error{name="HookError"}class G3 extends Error{name="ValidationError"}import{AsyncResource as f9}from"async_hooks";import{AsyncLocalStorage as P9,AsyncResource as I9}from"async_hooks";var u6=new P9;function u9(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function f6(D,F){let E=u9(D);return u6.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function eD(){let D=u6.getStore();if(!D)throw new W3("[Inquirer] Hook functions can only be called from within a prompt");return D}function A3(){return eD().rl}function U3(D){let F=(...E)=>{let B=eD(),$=!1,J=B.handleChange;B.handleChange=()=>{$=!0};let X=D(...E);if($)J();return B.handleChange=J,X};return I9.bind(F)}function b2(D){let F=eD(),{index:E}=F,B={get(){return F.hooks[E]},set(J){F.hooks[E]=J},initialized:E in F.hooks},$=D(B);return F.index++,$}function Z6(){eD().handleChange()}var D2={queue(D){let F=eD(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(A3());if(B!=null&&typeof B!=="function")throw new G3("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=eD();U3(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=eD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function x(D){return b2((F)=>{let E=f9.bind(function(J){if(F.get()!==J)F.set(J),Z6()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function ND(D,F){b2((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((J,X)=>!Object.is(J,B[X])))D2.queue(D);E.set(F)})}var ED=xD(K0(),1);import zD from"process";function v9(){if(zD.platform!=="win32")return zD.env.TERM!=="linux";return Boolean(zD.env.WT_SESSION)||Boolean(zD.env.TERMINUS_SUBLIME)||zD.env.ConEmuTask==="{cmd::Cmder}"||zD.env.TERM_PROGRAM==="Terminus-Sublime"||zD.env.TERM_PROGRAM==="vscode"||zD.env.TERM==="xterm-256color"||zD.env.TERM==="alacritty"||zD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var v6={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},x6={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},x9={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},y9={...v6,...x6},h9={...v6,...x9},g9=v9(),l9=g9?y9:h9,w2=l9,Z$=Object.entries(x6);var y6={prefix:{idle:ED.default.blue("?"),done:ED.default.green(w2.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>ED.default.yellow(D))},style:{answer:ED.default.cyan,message:ED.default.bold,error:(D)=>ED.default.red(`> ${D}`),defaultAnswer:(D)=>ED.default.dim(`(${D})`),help:ED.default.dim,highlight:ED.default.cyan,key:(D)=>ED.default.cyan(ED.default.bold(`<${D}>`))}};function h6(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function g6(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let J=F[B];F[B]=h6(J)&&h6($)?g6(J,$):$}return F}function HD(...D){let F=[y6,...D.filter((E)=>E!=null)];return g6(...F)}function SD({status:D="idle",theme:F}){let[E,B]=x(!1),[$,J]=x(0),{prefix:X,spinner:Q}=HD(F);if(ND(()=>{if(D==="loading"){let q,_=-1,H=setTimeout(()=>{B(!0),q=setInterval(()=>{_=_+1,J(_%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(H),clearInterval(q)}}else B(!1)},[D]),E)return Q.frames[$];return typeof X==="string"?X:X[D==="loading"?"idle":D]??X.idle}function C3(D,F){return b2((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,J)=>$!==F[J])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function j0(D){return x({current:D})[0]}function TD(D){let F=j0(D);F.current=D,ND((E)=>{let B=!1,$=U3((J,X)=>{if(B)return;F.current(X,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var U1=xD(m6(),1),C1=xD(A1(),1);function a2(D,F){return D.split(`
175
- `).flatMap((E)=>C1.default(E,F,{trim:!1,hard:!0}).split(`
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
176
  `).map((B)=>B.trimEnd())).join(`
177
- `)}function O0(){return U1.default({defaultWidth:80,output:A3().output})}function q4({active:D,renderedItems:F,pageSize:E,loop:B}){let $=j0({lastPointer:D,lastActive:void 0}),{lastPointer:J,lastActive:X}=$.current,Q=Math.floor(E/2),Y=F.reduce((H,G)=>H+G.length,0),q=F.slice(0,D).reduce((H,G)=>H+G.length,0),_=q;if(Y>E)if(B){if(_=J,X!=null&&X<D&&D-X<E)_=Math.min(Q,Math.abs(D-X)===1?Math.min(J+(F[X]?.length??0),Math.max(q,J)):J+D-X)}else{let H=F.slice(D).reduce((G,U)=>G+U.length,0);_=H<E-Q?E-H:Math.min(q,Q)}return $.current.lastPointer=_,$.current.lastActive=D,_}function N3({items:D,active:F,renderItem:E,pageSize:B,loop:$=!0}){let J=O0(),X=(L)=>(L%D.length+D.length)%D.length,Q=D.map((L,N)=>{if(L==null)return[];return a2(E({item:L,index:N,isActive:N===F}),J).split(`
178
- `)}),Y=Q.reduce((L,N)=>L+N.length,0),q=(L)=>Q[L]??[],_=q4({active:F,renderedItems:Q,pageSize:B,loop:$}),H=q(F).slice(0,B),G=_+H.length<=B?_:B-H.length,U=Array.from({length:B});U.splice(G,H.length,...H);let R=new Set([F]),K=G+H.length,O=X(F+1);while(K<B&&!R.has(O)&&($&&Y>B?O!==F:O>F)){let N=q(O).slice(0,B-K);U.splice(K,N.length,...N),R.add(O),K+=N.length,O=X(O+1)}K=G-1,O=X(F-1);while(K>=0&&!R.has(O)&&($&&Y>B?O!==F:O<F)){let L=q(O),N=L.slice(Math.max(0,L.length-K-1));U.splice(K-N.length+1,N.length,...N),R.add(O),K-=N.length,O=X(O-1)}return U.filter((L)=>typeof L==="string").join(`
179
- `)}var w1=xD(R1(),1);import*as b1 from"readline";import{AsyncResource as C4}from"async_hooks";var F2=[];F2.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")F2.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")F2.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var N0=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",S3=Symbol.for("signal-exit emitter"),T3=globalThis,H4=Object.defineProperty.bind(Object);class K1{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(T3[S3])return T3[S3];H4(T3,S3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,F){this.listeners[D].push(F)}removeListener(D,F){let E=this.listeners[D],B=E.indexOf(F);if(B===-1)return;if(B===0&&E.length===1)E.length=0;else E.splice(B,1)}emit(D,F,E){if(this.emitted[D])return!1;this.emitted[D]=!0;let B=!1;for(let $ of this.listeners[D])B=$(F,E)===!0||B;if(D==="exit")B=this.emit("afterExit",F,E)||B;return B}}class w3{}var W4=(D)=>{return{onExit(F,E){return D.onExit(F,E)},load(){return D.load()},unload(){return D.unload()}}};class j1 extends w3{onExit(){return()=>{}}load(){}unload(){}}class L1 extends w3{#E=b3.platform==="win32"?"SIGINT":"SIGHUP";#F=new K1;#D;#J;#X;#$={};#B=!1;constructor(D){super();this.#D=D,this.#$={};for(let F of F2)this.#$[F]=()=>{let E=this.#D.listeners(F),{count:B}=this.#F,$=D;if(typeof $.__signal_exit_emitter__==="object"&&typeof $.__signal_exit_emitter__.count==="number")B+=$.__signal_exit_emitter__.count;if(E.length===B){this.unload();let J=this.#F.emit("exit",null,F),X=F==="SIGHUP"?this.#E:F;if(!J)D.kill(D.pid,X)}};this.#X=D.reallyExit,this.#J=D.emit}onExit(D,F){if(!N0(this.#D))return()=>{};if(this.#B===!1)this.load();let E=F?.alwaysLast?"afterExit":"exit";return this.#F.on(E,D),()=>{if(this.#F.removeListener(E,D),this.#F.listeners.exit.length===0&&this.#F.listeners.afterExit.length===0)this.unload()}}load(){if(this.#B)return;this.#B=!0,this.#F.count+=1;for(let D of F2)try{let F=this.#$[D];if(F)this.#D.on(D,F)}catch(F){}this.#D.emit=(D,...F)=>{return this.#Y(D,...F)},this.#D.reallyExit=(D)=>{return this.#Q(D)}}unload(){if(!this.#B)return;this.#B=!1,F2.forEach((D)=>{let F=this.#$[D];if(!F)throw Error("Listener not defined for signal: "+D);try{this.#D.removeListener(D,F)}catch(E){}}),this.#D.emit=this.#J,this.#D.reallyExit=this.#X,this.#F.count-=1}#Q(D){if(!N0(this.#D))return 0;return this.#D.exitCode=D||0,this.#F.emit("exit",this.#D.exitCode,null),this.#X.call(this.#D,this.#D.exitCode)}#Y(D,...F){let E=this.#J;if(D==="exit"&&N0(this.#D)){if(typeof F[0]==="number")this.#D.exitCode=F[0];let B=E.call(this.#D,D,...F);return this.#F.emit("exit",this.#D.exitCode,null),B}else return E.call(this.#D,D,...F)}}var b3=globalThis.process,{onExit:M1,load:VJ,unload:RJ}=W4(N0(b3)?new L1(b3):new j1);import{stripVTControlCharacters as A4}from"util";var G4="\x1B[G",N1="\x1B[?25l",S1="\x1B[?25h",P3=(D=1)=>D>0?`\x1B[${D}A`:"",I3=(D=1)=>D>0?`\x1B[${D}B`:"",u3=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},O1="\x1B[2K",f3=(D)=>D>0?(O1+P3(1)).repeat(D-1)+O1+G4:"";var T1=(D)=>D.split(`
180
- `).length,U4=(D)=>D.split(`
181
- `).pop()??"";class S0{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(D){this.rl=D,this.cursorPos=D.getCursorPos()}write(D){this.rl.output.unmute(),this.rl.output.write(D),this.rl.output.mute()}render(D,F=""){let E=U4(D),B=A4(E),$=B;if(this.rl.line.length>0)$=$.slice(0,-this.rl.line.length);this.rl.setPrompt($),this.cursorPos=this.rl.getCursorPos();let J=O0();if(D=a2(D,J),F=a2(F,J),B.length%J===0)D+=`
182
- `;let X=D+(F?`
183
- `+F:""),Y=Math.floor(B.length/J)-this.cursorPos.rows+(F?T1(F):0);if(Y>0)X+=P3(Y);X+=u3(this.cursorPos.cols),this.write(I3(this.extraLinesUnderPrompt)+f3(this.height)+X),this.extraLinesUnderPrompt=Y,this.height=T1(X)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(u3(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=I3(this.extraLinesUnderPrompt);F+=D?f3(this.height):`
184
- `,F+=S1,this.write(F),this.rl.close()}}class Z3 extends Promise{static withResolver(){let D,F;return{promise:new Promise((B,$)=>{D=B,F=$}),resolve:D,reject:F}}}function z4(){let D=Error.prepareStackTrace,F=[];try{Error.prepareStackTrace=(E,B)=>{let $=B.slice(1);return F=$,$},Error().stack}catch{return F}return Error.prepareStackTrace=D,F}function bD(D){let F=z4();return(B,$={})=>{let{input:J=process.stdin,signal:X}=$,Q=new Set,Y=new w1.default;Y.pipe($.output??process.stdout);let q=b1.createInterface({terminal:!0,input:J,output:Y}),_=new S0(q),{promise:H,resolve:G,reject:U}=Z3.withResolver(),R=()=>U(new H3);if(X){let L=()=>U(new _3({cause:X.reason}));if(X.aborted)return L(),Object.assign(H,{cancel:R});X.addEventListener("abort",L),Q.add(()=>X.removeEventListener("abort",L))}Q.add(M1((L,N)=>{U(new R0(`User force closed the prompt with ${L} ${N}`))}));let K=()=>U(new R0("User force closed the prompt with SIGINT"));q.on("SIGINT",K),Q.add(()=>q.removeListener("SIGINT",K));let O=()=>_.checkCursorPos();return q.input.on("keypress",O),Q.add(()=>q.input.removeListener("keypress",O)),f6(q,(L)=>{let N=C4.bind(()=>D2.clearAll());return q.on("close",N),Q.add(()=>q.removeListener("close",N)),L(()=>{try{let f=D(B,(r)=>{setImmediate(()=>G(r))});if(f===void 0){let r=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
185
- at ${r}`)}let[c,t]=typeof f==="string"?[f]:f;_.render(c,t),D2.run()}catch(f){U(f)}}),Object.assign(H.then((f)=>{return D2.clearAll(),f},(f)=>{throw D2.clearAll(),f}).finally(()=>{Q.forEach((f)=>f()),_.done({clearContent:Boolean($.clearPromptOnDone)}),Y.end()}).then(()=>H),{cancel:R})})}}var P1=xD(K0(),1);class f2{separator=P1.default.dim(Array.from({length:15}).join(w2.line));type="separator";constructor(D){if(D)this.separator=D}static isSeparator(D){return Boolean(D&&typeof D==="object"&&"type"in D&&D.type==="separator")}}function I1(D,F){let E=F!==!1;if(/^(y|yes)/i.test(D))E=!0;else if(/^(n|no)/i.test(D))E=!1;return E}function u1(D){return D?"Yes":"No"}var o2=bD((D,F)=>{let{transformer:E=u1}=D,[B,$]=x("idle"),[J,X]=x(""),Q=HD(D.theme),Y=SD({status:B,theme:Q});TD((G,U)=>{if(B!=="idle")return;if(OD(G)){let R=I1(J,D.default);X(E(R)),$("done"),F(R)}else if(tD(G)){let R=u1(!I1(J,D.default));U.clearLine(0),U.write(R),X(R)}else X(U.line)});let q=J,_="";if(B==="done")q=Q.style.answer(J);else _=` ${Q.style.defaultAnswer(D.default===!1?"y/N":"Y/n")}`;let H=Q.style.message(D.message,B);return`${Y} ${H}${_} ${q}`});var V4={validationFailureMode:"keep"},R4=bD((D,F)=>{let{prefill:E="tab"}=D,B=HD(V4,D.theme),[$,J]=x("idle"),[X="",Q]=x(D.default),[Y,q]=x(),[_,H]=x(""),G=SD({status:$,theme:B});async function U(N){let{required:f,pattern:c,patternError:t="Invalid input"}=D;if(f&&!N)return"You must provide a value";if(c&&!c.test(N))return t;if(typeof D.validate==="function")return await D.validate(N)||"You must provide a valid value";return!0}TD(async(N,f)=>{if($!=="idle")return;if(OD(N)){let c=_||X;J("loading");let t=await U(c);if(t===!0)H(c),J("done"),F(c);else{if(B.validationFailureMode==="clear")H("");else f.write(_);q(t),J("idle")}}else if(q3(N)&&!_)Q(void 0);else if(tD(N)&&!_)Q(void 0),f.clearLine(0),f.write(X),H(X);else H(f.line),q(void 0)}),ND((N)=>{if(E==="editable"&&X)N.write(X),H(X)},[]);let R=B.style.message(D.message,$),K=_;if(typeof D.transformer==="function")K=D.transformer(_,{isFinal:$==="done"});else if($==="done")K=B.style.answer(_);let O;if(X&&$!=="done"&&!_)O=B.style.defaultAnswer(X);let L="";if(Y)L=B.style.error(Y);return[[G,R,O,K].filter((N)=>N!==void 0).join(" "),L]});var K4=bD((D,F)=>{let{validate:E=()=>!0}=D,B=HD(D.theme),[$,J]=x("idle"),[X,Q]=x(),[Y,q]=x(""),_=SD({status:$,theme:B});TD(async(K,O)=>{if($!=="idle")return;if(OD(K)){let L=Y;J("loading");let N=await E(L);if(N===!0)q(L),J("done"),F(L);else O.write(Y),Q(N||"You must provide a valid value"),J("idle")}else q(O.line),Q(void 0)});let H=B.style.message(D.message,$),G="",U;if(D.mask)G=(typeof D.mask==="string"?D.mask:"*").repeat(Y.length);else if($!=="done")U=`${B.style.help("[input is masked]")}${N1}`;if($==="done")G=B.style.answer(G);let R="";if(X)R=B.style.error(X);return[[_,H,D.mask?G:U].join(" "),R]});var E2=xD(K0(),1);var j4={icon:{cursor:w2.pointer},style:{disabled:(D)=>E2.default.dim(`- ${D}`),searchTerm:(D)=>E2.default.cyan(D),description:(D)=>E2.default.cyan(D),keysHelpTip:(D)=>D.map(([F,E])=>`${E2.default.bold(F)} ${E2.default.dim(E)}`).join(E2.default.dim(" \u2022 "))},helpMode:"always"};function k3(D){return!f2.isSeparator(D)&&!D.disabled}function L4(D){return D.map((F)=>{if(f2.isSeparator(F))return F;if(typeof F==="string")return{value:F,name:F,short:F,disabled:!1};let E=F.name??String(F.value),B={value:F.value,name:E,short:F.short??E,disabled:F.disabled??!1};if(F.description)B.description=F.description;return B})}var M4=bD((D,F)=>{let{pageSize:E=7,validate:B=()=>!0}=D,$=HD(j4,D.theme),[J,X]=x("loading"),[Q,Y]=x(""),[q,_]=x([]),[H,G]=x(),U=SD({status:J,theme:$}),R=C3(()=>{let k=q.findIndex(k3),o=q.findLastIndex(k3);return{first:k,last:o}},[q]),[K=R.first,O]=x();ND(()=>{let k=new AbortController;return X("loading"),G(void 0),(async()=>{try{let BD=await D.source(Q||void 0,{signal:k.signal});if(!k.signal.aborted)O(void 0),G(void 0),_(L4(BD)),X("idle")}catch(BD){if(!k.signal.aborted&&BD instanceof Error)G(BD.message)}})(),()=>{k.abort()}},[Q]);let L=q[K];TD(async(k,o)=>{if(OD(k))if(L){X("loading");let BD=await B(L.value);if(X("idle"),BD===!0)X("done"),F(L.value);else if(L.name===Q)G(BD||"You must provide a valid value");else o.write(L.name),Y(L.name)}else o.write(Q);else if(tD(k)&&L)o.clearLine(0),o.write(L.name),Y(L.name);else if(J!=="loading"&&(i2(k)||V0(k))){if(o.clearLine(0),i2(k)&&K!==R.first||V0(k)&&K!==R.last){let BD=i2(k)?-1:1,B2=K;do B2=(B2+BD+q.length)%q.length;while(!k3(q[B2]));O(B2)}}else Y(o.line)});let N=$.style.message(D.message,J),f;if($.helpMode!=="never")if(D.instructions){let{pager:k,navigation:o}=D.instructions;f=$.style.help(q.length>E?k:o)}else f=$.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]);let c=N3({items:q,active:K,renderItem({item:k,isActive:o}){if(f2.isSeparator(k))return` ${k.separator}`;if(k.disabled){let b0=typeof k.disabled==="string"?k.disabled:"(disabled)";return $.style.disabled(`${k.name} ${b0}`)}let BD=o?$.style.highlight:(b0)=>b0,B2=o?$.icon.cursor:" ";return BD(`${B2} ${k.name}`)},pageSize:E,loop:!1}),t;if(H)t=$.style.error(H);else if(q.length===0&&Q!==""&&J==="idle")t=$.style.error("No results found");let r;if(J==="done"&&L)return[U,N,$.style.answer(L.short)].filter(Boolean).join(" ").trimEnd();else r=$.style.searchTerm(Q);let y3=L?.description,x1=[U,N,r].filter(Boolean).join(" ").trimEnd(),y1=[t??c," ",y3?$.style.description(y3):"",f].filter(Boolean).join(`
186
- `).trimEnd();return[x1,y1]});sD();import{join as O4}from"path";import{homedir as N4}from"os";var S4=O4(N4(),".local","share","term","worktrees");async function f1(D){try{return{stdout:(await T0`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function T4(D){let{exitCode:F}=await f1(["close",D]);return F===0}async function b4(){let{exitCode:D}=await f1(["sync"]);return D===0}async function w4(D,F){try{let B=(await T0`git -C ${D} branch --show-current`.quiet()).stdout.toString().trim();if(B===F)return console.log(`\u26A0\uFE0F Already on branch ${F}. Skipping merge.`),!0;return console.log(` Switching to ${B}...`),await T0`git -C ${D} checkout ${B}`.quiet(),console.log(` Merging ${F}...`),await T0`git -C ${D} merge ${F} --no-edit`.quiet(),!0}catch(E){return console.error(`\u26A0\uFE0F Merge failed: ${E.message}`),!1}}async function P4(D,F){try{let E=new PD({baseDir:S4,repoPath:F});if(await E.worktreeExists(D))return await E.removeWorktree(D),!0;return!0}catch(E){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${E.message}`),!1}}async function I4(D){try{return await $2(D),!0}catch{return!1}}async function Z1(D,F={}){try{let E=await vD(D);if(!E)console.log(`\u2139\uFE0F No active worker for ${D}. Closing issue only.`);if(!F.yes){if(!await o2({message:`Close ${D}${E?` and kill worker (pane ${E.paneId})`:""}?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDCDD Closing ${D}...`),!await T4(D))console.error(`\u274C Failed to close ${D}. Check \`bd show ${D}\`.`);else console.log(" \u2705 Issue closed");if(!F.noSync)if(console.log("\uD83D\uDD04 Syncing beads..."),await b4())console.log(" \u2705 Synced to git");else console.log(" \u26A0\uFE0F Sync failed (non-fatal)");if(E?.worktree&&!F.keepWorktree){if(F.merge){if(console.log("\uD83D\uDD00 Merging changes..."),await w4(E.repoPath,D))console.log(" \u2705 Merged to main")}if(console.log("\uD83C\uDF33 Removing worktree..."),await P4(D,E.repoPath))console.log(" \u2705 Worktree removed")}if(E)console.log("\uD83D\uDC80 Killing worker pane..."),await I4(E.paneId),console.log(" \u2705 Pane killed"),await rD(E.id),console.log(" \u2705 Worker unregistered");console.log(`
187
- \u2705 ${D} closed successfully`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}sD();import{join as f4}from"path";import{homedir as Z4}from"os";var k4=f4(Z4(),".local","share","term","worktrees");async function v4(D){try{return await $2(D),!0}catch{return!1}}async function x4(D,F){try{let E=new PD({baseDir:k4,repoPath:F});if(await E.worktreeExists(D))return await E.removeWorktree(D),!0;return!0}catch(E){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${E.message}`),!1}}async function k1(D,F={}){try{let E=await X3(D);if(!E)E=await Q3(D);if(!E)E=await vD(D);if(!E)console.error(`\u274C Worker "${D}" not found.`),console.log(" Run `term workers` to see active workers."),process.exit(1);if(!F.yes){if(!await o2({message:`Kill worker ${E.id} (pane ${E.paneId})?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDC80 Killing worker pane ${E.paneId}...`),await v4(E.paneId))console.log(" \u2705 Pane killed");else console.log(" \u2139\uFE0F Pane already gone");if(E.worktree&&!F.keepWorktree){if(console.log("\uD83C\uDF33 Removing worktree..."),await x4(E.taskId,E.repoPath))console.log(" \u2705 Worktree removed")}await rD(E.id),console.log(" \u2705 Worker unregistered"),console.log(`
188
- \u26A0\uFE0F Task ${E.taskId} is still in_progress in beads.`),console.log(` Run \`bd update ${E.taskId} --status open\` to reopen,`),console.log(` or \`term work ${E.taskId}\` to start a new worker.`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var l=new F8;l.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
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)
189
189
 
190
190
  Collaborative Usage:
191
191
  AI runs: term exec genie:shell '<command>'
@@ -200,4 +200,5 @@ Worker Orchestration:
200
200
  term work next - Work on next ready issue
201
201
  term workers - List all workers and states
202
202
  term close <bd-id> - Close issue, cleanup worker
203
- term kill <worker> - Force kill a stuck worker`).version(E8);l.command("new <name>").description("Create a new tmux session").option("-d, --workspace <path>","Working directory for the session").option("-w, --worktree","Create git worktree in .worktrees/<name>/").action(async(D,F)=>{await C8(D,F)});l.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async(D)=>{await z8(D)});l.command("attach <name>").description("Attach to a tmux session").action(async(D)=>{await V8(D)});l.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async(D,F)=>{await R8(D,F)});l.command("read <session>").description("Read logs from a tmux session").option("-n, --lines <number>","Number of lines to read (default: 100)","100").option("--from <line>","Start line number").option("--to <line>","End line number").option("--range <range>","Line range (e.g., 100:200)").option("--search <pattern>","Search for pattern").option("--grep <pattern>","Regex search pattern").option("-f, --follow","Follow mode (live tail)").option("--all","Export entire scrollback buffer").option("--reverse","Reverse chronological (newest first)").option("--json","Output as JSON").action(async(D,F)=>{await g8(D,F)});l.command("exec <session> <command...>").description("Execute command in a tmux session").option("-q, --quiet","Suppress stdout output").option("-t, --timeout <ms>","Timeout in milliseconds (default: 120000)").action(async(D,F,E)=>{await l8(D,F.join(" "),{quiet:E.quiet,timeout:E.timeout?parseInt(E.timeout,10):void 0})});l.command("send <session> <keys>").description("Send raw keys to a tmux session").action(async(D,F)=>{await m8(D,F)});l.command("split <session> [direction]").description("Split pane in a tmux session (h=horizontal, v=vertical)").option("-d, --workspace <path>","Working directory for the new pane").option("-w, --worktree <branch>","Create git worktree in .worktrees/<branch>/").action(async(D,F,E)=>{await p8(D,F,E)});l.command("status <session>").description("Check session state (idle/busy, pane count)").option("--command <id>","Check specific command status").option("--json","Output as JSON").action(async(D,F)=>{await F6(D,F)});var v3=l.command("window").description("Manage tmux windows");v3.command("new <session> <name>").description("Create a new window in session").action(async(D,F)=>{await s8(D,F)});v3.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async(D,F)=>{await o8(D,F)});v3.command("rm <window-id>").description("Remove window by ID").action(async(D)=>{await t8(D)});var v1=l.command("pane").description("Manage tmux panes");v1.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async(D,F)=>{await e8(D,F)});v1.command("rm <pane-id>").description("Remove pane by ID").action(async(D)=>{await D6(D)});var x3=l.command("hook").description("Manage tmux hooks");x3.command("set <event> <command>").description("Set a tmux hook").action(async(D,F)=>{await n8(D,F)});x3.command("list").description("List all tmux hooks").action(async()=>{await r8()});x3.command("rm <event>").description("Remove a tmux hook").action(async(D)=>{await a8(D)});l.command("shortcuts").description("Warp-like keyboard shortcuts for tmux/Termux").option("--tmux","Output tmux.conf snippet").option("--termux","Output termux.properties snippet").option("--install","Install to config files (interactive)").action(async(D)=>{await Q6(D)});l.command("work <target>").description('Spawn worker bound to beads issue (target: bd-id, "next", or "wish")').option("--no-worktree","Use shared repo instead of worktree").option("-s, --session <name>","Target tmux session").option("--no-focus","Don't focus the worker pane").option("-p, --prompt <message>","Custom initial prompt").action(async(D,F)=>{await w6(D,F)});l.command("workers").description("List all workers and their states").option("--json","Output as JSON").option("-w, --watch","Live updates (coming soon)").action(async(D)=>{if(D.watch)console.log("\u2139\uFE0F --watch mode coming in Phase 1.5");await I6(D)});l.command("close <task-id>").description("Close beads issue and cleanup worker").option("--no-sync","Skip bd sync").option("--keep-worktree","Don't remove the worktree").option("--merge","Merge worktree changes to main branch").option("-y, --yes","Skip confirmation").action(async(D,F)=>{await Z1(D,F)});l.command("kill <worker>").description("Force kill a worker").option("-y, --yes","Skip confirmation").option("--keep-worktree","Don't remove the worktree").action(async(D,F)=>{await k1(D,F)});l.command("approve <worker>").description("Approve pending permission request for a worker").option("--deny","Deny instead of approve").action(async(D,F)=>{let E=await Promise.resolve().then(() => (sD(),oD)),B=await E.get(D);if(!B)B=await E.findByTask(D);if(!B)console.error(`\u274C Worker "${D}" not found. Run \`term workers\` to see workers.`),process.exit(1);await F3(B.session,{pane:B.paneId,deny:F.deny})});l.command("answer <worker> <choice>").description('Answer a question for a worker (use "text:..." for text input)').action(async(D,F)=>{let E=await Promise.resolve().then(() => (sD(),oD)),B=await E.get(D);if(!B)B=await E.findByTask(D);if(!B)console.error(`\u274C Worker "${D}" not found. Run \`term workers\` to see workers.`),process.exit(1);await E3(B.session,F,{pane:B.paneId})});var wD=l.command("orc").description("Orchestrate Claude Code sessions");wD.command("start <session>").description("Start Claude Code in a session with optional monitoring").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").option("-m, --monitor","Enable real-time event monitoring").option("-c, --command <cmd>","Command to run instead of claude").option("--json","Output events as JSON").action(async(D,F)=>{await K6(D,F)});wD.command("send <session> <message>").description("Send message to Claude and track completion").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--method <name>","Completion detection method").option("-t, --timeout <ms>","Timeout in milliseconds").option("--no-wait","Send without waiting for completion").option("--json","Output as JSON").action(async(D,F,E)=>{await j6(D,F,E)});wD.command("status <session>").description("Show current Claude state and details").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--json","Output as JSON").action(async(D,F)=>{await L6(D,F)});wD.command("watch <session>").description("Watch session events in real-time").option("--pane <id>","Target specific pane ID (e.g., %16)").option("--json","Output events as JSON").option("-p, --poll <ms>","Poll interval in milliseconds").action(async(D,F)=>{await M6(D,F)});wD.command("approve <session>").description("Approve pending permission request").option("-p, --pane <id>","Specific pane ID to target").option("--auto","Auto-approve all future permissions (dangerous!)").option("--deny","Deny instead of approve").action(async(D,F)=>{await F3(D,F)});wD.command("answer <session> <choice>").description('Answer a question with the given choice (use "text:..." to send feedback)').option("-p, --pane <id>","Specific pane ID to target").action(async(D,F,E)=>{await E3(D,F,E)});wD.command("experiment <method>").description("Test a completion detection method").option("-n, --runs <number>","Number of test runs").option("--task <command>","Test command to run").option("--json","Output as JSON").action(async(D,F)=>{await O6(D,F)});wD.command("methods").description("List available completion detection methods").action(async()=>{await N6()});wD.command("run <session> <message>").description("Send task and auto-approve until idle (fire-and-forget)").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").option("-a, --auto-approve","Auto-approve permissions and plans").option("-t, --timeout <ms>","Timeout in milliseconds (default: 300000)").option("--json","Output final state as JSON").action(async(D,F,E)=>{await S6(D,F,E)});l.parse();
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();