@automagik/genie 0.260202.1833 → 0.260203.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +67 -0
  3. package/.beads/interactions.jsonl +0 -0
  4. package/.beads/issues.jsonl +9 -0
  5. package/.beads/metadata.json +4 -0
  6. package/.claude/skills/brainstorm/SKILL.md +53 -0
  7. package/.claude/skills/genie-base/SKILL.md +66 -0
  8. package/.claude/skills/genie-base/assets/workspace/AGENTS.md +191 -0
  9. package/.claude/skills/genie-base/assets/workspace/ENVIRONMENT.md +18 -0
  10. package/.claude/skills/genie-base/assets/workspace/HEARTBEAT.md +4 -0
  11. package/.claude/skills/genie-base/assets/workspace/IDENTITY.md +17 -0
  12. package/.claude/skills/genie-base/assets/workspace/MEMORY.md +16 -0
  13. package/.claude/skills/genie-base/assets/workspace/ROLE.md +14 -0
  14. package/.claude/skills/genie-base/assets/workspace/SOUL.md +36 -0
  15. package/.claude/skills/genie-base/assets/workspace/TOOLS.md +25 -0
  16. package/.claude/skills/genie-base/assets/workspace/USER.md +13 -0
  17. package/.claude/skills/genie-base/assets/workspace/memory/2026-01-30.md +6 -0
  18. package/.claude/skills/genie-base/assets/workspace/memory/2026-01-31.md +16 -0
  19. package/.claude/skills/genie-base/assets/workspace/memory/882c22be-9710-41c1-91f8-ed82947ef6ce.txt +1 -0
  20. package/.claude/skills/genie-base/scripts/install-workspace.sh +107 -0
  21. package/.claude/skills/genie-base/scripts/sanity-sweep.sh +60 -0
  22. package/.claude/skills/genie-blank-init/SKILL.md +37 -0
  23. package/.claude/skills/genie-blank-init/assets/BOOTSTRAP.md +44 -0
  24. package/.claude/skills/genie-blank-init/assets/IDENTITY.md +9 -0
  25. package/.claude/skills/genie-blank-init/assets/SOUL.md +10 -0
  26. package/.claude/skills/genie-blank-init/assets/USER.md +9 -0
  27. package/.claude/skills/genie-blank-init/scripts/apply-blank-init.sh +117 -0
  28. package/.claude/skills/genie-forge/SKILL.md +171 -0
  29. package/.claude/skills/genie-plan-review/CLAUDE.md +11 -0
  30. package/.claude/skills/genie-plan-review/SKILL.md +53 -0
  31. package/.claude/skills/genie-review/SKILL.md +171 -0
  32. package/.claude/skills/genie-wish/SKILL.md +141 -0
  33. package/.claude-plugin/marketplace.json +18 -0
  34. package/.genie/.gitkeep +3 -0
  35. package/.genie/backlog/hooks-v2.md +82 -0
  36. package/.genie/wishes/upgrade-brainstorm-handoff/wish.md +124 -0
  37. package/.gitattributes +3 -0
  38. package/AGENTS.md +75 -0
  39. package/bun.lock +55 -0
  40. package/dist/claudio.js +1 -1
  41. package/dist/genie.js +1 -1
  42. package/dist/term.js +123 -99
  43. package/docs/CO-ORCHESTRATION-GUIDE.md +368 -0
  44. package/package.json +5 -1
  45. package/plugin/.claude-plugin/plugin.json +18 -0
  46. package/plugin/README.md +120 -0
  47. package/plugin/agents/implementor.md +92 -0
  48. package/plugin/agents/quality-reviewer.md +113 -0
  49. package/plugin/agents/spec-reviewer.md +90 -0
  50. package/plugin/hooks/hooks.json +3 -0
  51. package/plugin/references/review-criteria.md +72 -0
  52. package/plugin/references/wish-template.md +92 -0
  53. package/plugin/scripts/genie.cjs +141 -0
  54. package/plugin/scripts/smart-install.js +308 -0
  55. package/plugin/scripts/src/install-genie-cli.sh +120 -0
  56. package/plugin/scripts/src/validate-completion.ts +142 -0
  57. package/plugin/scripts/src/validate-wish.ts +137 -0
  58. package/plugin/scripts/term.cjs +229 -0
  59. package/plugin/scripts/validate-completion.cjs +16 -0
  60. package/plugin/scripts/validate-wish.cjs +17 -0
  61. package/plugin/scripts/worker-service.cjs +28 -0
  62. package/plugin/skills/brainstorm/SKILL.md +106 -0
  63. package/plugin/skills/forge/SKILL.md +171 -0
  64. package/plugin/skills/genie-base/SKILL.md +99 -0
  65. package/plugin/skills/genie-base/assets/workspace/AGENTS.md +191 -0
  66. package/plugin/skills/genie-base/assets/workspace/ENVIRONMENT.md +18 -0
  67. package/plugin/skills/genie-base/assets/workspace/HEARTBEAT.md +4 -0
  68. package/plugin/skills/genie-base/assets/workspace/IDENTITY.md +17 -0
  69. package/plugin/skills/genie-base/assets/workspace/MEMORY.md +16 -0
  70. package/plugin/skills/genie-base/assets/workspace/ROLE.md +14 -0
  71. package/plugin/skills/genie-base/assets/workspace/SOUL.md +36 -0
  72. package/plugin/skills/genie-base/assets/workspace/TOOLS.md +25 -0
  73. package/plugin/skills/genie-base/assets/workspace/USER.md +13 -0
  74. package/plugin/skills/genie-base/scripts/install-workspace.sh +107 -0
  75. package/plugin/skills/genie-base/scripts/sanity-sweep.sh +60 -0
  76. package/plugin/skills/genie-blank-init/SKILL.md +73 -0
  77. package/plugin/skills/genie-blank-init/assets/BOOTSTRAP.md +44 -0
  78. package/plugin/skills/genie-blank-init/assets/IDENTITY.md +9 -0
  79. package/plugin/skills/genie-blank-init/assets/SOUL.md +10 -0
  80. package/plugin/skills/genie-blank-init/assets/USER.md +9 -0
  81. package/plugin/skills/genie-blank-init/scripts/apply-blank-init.sh +117 -0
  82. package/plugin/skills/genie-cli-dev/CLAUDE.md +19 -0
  83. package/plugin/skills/genie-cli-dev/SKILL.md +292 -0
  84. package/plugin/skills/plan-review/SKILL.md +101 -0
  85. package/plugin/skills/review/SKILL.md +221 -0
  86. package/plugin/skills/wish/SKILL.md +110 -0
  87. package/plugin/skills/work-orchestration/SKILL.md +110 -0
  88. package/scripts/build.js +132 -0
  89. package/scripts/smart-install.js +308 -0
  90. package/scripts/sync.js +134 -0
  91. package/src/lib/beads-registry.ts +595 -0
  92. package/src/lib/orchestrator/event-monitor.ts +2 -0
  93. package/src/lib/skill-loader.ts +215 -0
  94. package/src/lib/tmux.ts +30 -11
  95. package/src/lib/version.ts +1 -1
  96. package/src/lib/worker-registry.ts +10 -0
  97. package/src/services/worker-service.ts +351 -0
  98. package/src/term-commands/close.ts +48 -3
  99. package/src/term-commands/create.ts +95 -0
  100. package/src/term-commands/daemon.ts +176 -0
  101. package/src/term-commands/kill.ts +56 -2
  102. package/src/term-commands/orchestrate.ts +3 -2
  103. package/src/term-commands/send.ts +43 -15
  104. package/src/term-commands/spawn.ts +446 -0
  105. package/src/term-commands/split.ts +20 -8
  106. package/src/term-commands/work.ts +279 -37
  107. package/src/term-commands/workers.ts +36 -2
  108. package/src/term.ts +120 -7
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 gF=Object.create;var{getPrototypeOf:lF,defineProperty:D3,getOwnPropertyNames:mF}=Object;var cF=Object.prototype.hasOwnProperty;var iD=(D,F,E)=>{E=D!=null?gF(lF(D)):{};let B=F||!D||!D.__esModule?D3(E,"default",{value:D,enumerable:!0}):E;for(let $ of mF(D))if(!cF.call(B,$))D3(B,$,{get:()=>D[$],enumerable:!0});return B};var c=(D,F)=>()=>(F||D((F={exports:{}}).exports,F),F.exports);var N8=(D,F)=>{for(var E in F)D3(D,E,{get:F[E],enumerable:!0,configurable:!0,set:(B)=>F[E]=()=>B})};var pF=(D,F)=>()=>(D&&(F=D(D=0)),F);var FD=import.meta.require;var i2=c((dF)=>{class F3 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 S8 extends F3{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}dF.CommanderError=F3;dF.InvalidArgumentError=S8});var z0=c((oF)=>{var{InvalidArgumentError:rF}=i2();class T8{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 rF(`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 aF(D){let F=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+F+">":"["+F+"]"}oF.Argument=T8;oF.humanReadableArgName=aF});var E3=c((D5)=>{var{humanReadableArgName:eF}=z0();class b8{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)=>eF(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(U,z){if(z){let R=`${U.padEnd(E+2)}${z}`;return F.wrap(R,B-2,E+2)}return U}function J(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 H=F.visibleArguments(D).map((U)=>{return Q(F.argumentTerm(U),F.argumentDescription(U))});if(H.length>0)Y=Y.concat(["Arguments:",J(H),""]);let _=F.visibleOptions(D).map((U)=>{return Q(F.optionTerm(U),F.optionDescription(U))});if(_.length>0)Y=Y.concat(["Options:",J(_),""]);if(this.showGlobalOptions){let U=F.visibleGlobalOptions(D).map((z)=>{return Q(F.optionTerm(z),F.optionDescription(z))});if(U.length>0)Y=Y.concat(["Global Options:",J(U),""])}let G=F.visibleCommands(D).map((U)=>{return Q(F.subcommandTerm(U),F.subcommandDescription(U))});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"),U=Y.match(G)||[];return J+U.map((z,R)=>{if(z===`
9
+ `)return"";return(R>0?q:"")+z.trimEnd()}).join(`
10
+ `)}}D5.Help=b8});var B3=c((X5)=>{var{InvalidArgumentError:E5}=i2();class P8{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=$5(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 E5(`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 B5(this.name().replace(/^no-/,""))}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class f8{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 B5(D){return D.split("-").reduce((F,E)=>{return F+E[0].toUpperCase()+E.slice(1)})}function $5(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}}X5.Option=P8;X5.DualOptions=f8});var Z8=c((H5)=>{function Y5(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 q5(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=Y5(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""}H5.suggestSimilar=q5});var u8=c((z5)=>{var G5=FD("events").EventEmitter,$3=FD("child_process"),OD=FD("path"),X3=FD("fs"),l=FD("process"),{Argument:W5,humanReadableArgName:U5}=z0(),{CommanderError:Q3}=i2(),{Help:A5}=E3(),{Option:I8,DualOptions:C5}=B3(),{suggestSimilar:w8}=Z8();class J3 extends G5{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)=>l.stdout.write(F),writeErr:(F)=>l.stderr.write(F),getOutHelpWidth:()=>l.stdout.isTTY?l.stdout.columns:void 0,getErrHelpWidth:()=>l.stderr.isTTY?l.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 J3(D)}createHelp(){return Object.assign(new A5,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 W5(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 Q3(D,F,E));l.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 I8(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 I8)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(l.versions?.electron)F.from="electron";let B=l.execArgv??[];if(B.includes("-e")||B.includes("--eval")||B.includes("-p")||B.includes("--print"))F.from="eval"}if(D===void 0)D=l.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(l.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 _=OD.resolve(q,H);if(X3.existsSync(_))return _;if(B.includes(OD.extname(H)))return;let G=B.find((U)=>X3.existsSync(`${_}${U}`));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=X3.realpathSync(this._scriptPath)}catch(H){q=this._scriptPath}Q=OD.resolve(OD.dirname(q),Q)}if(Q){let q=$(Q,X);if(!q&&!D._executableFile&&this._scriptPath){let H=OD.basename(this._scriptPath,OD.extname(this._scriptPath));if(H!==this._name)q=$(Q,`${H}-${D._name}`)}X=q||X}E=B.includes(OD.extname(X));let J;if(l.platform!=="win32")if(E)F.unshift(X),F=v8(l.execArgv).concat(F),J=$3.spawn(l.argv[0],F,{stdio:"inherit"});else J=$3.spawn(X,F,{stdio:"inherit"});else F.unshift(X),F=v8(l.execArgv).concat(F),J=$3.spawn(l.execPath,F,{stdio:"inherit"});if(!J.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((H)=>{l.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)l.exit(q);else Y(new Q3(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)l.exit(1);else{let H=new Q3(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 l.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()}`,l.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new C5(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=w8(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=w8(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 U5(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=OD.basename(D,OD.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=l.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 v8(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})}z5.Command=J3});var h8=c((L5)=>{var{Argument:x8}=z0(),{Command:Y3}=u8(),{CommanderError:K5,InvalidArgumentError:k8}=i2(),{Help:R5}=E3(),{Option:y8}=B3();L5.program=new Y3;L5.createCommand=(D)=>new Y3(D);L5.createOption=(D,F)=>new y8(D,F);L5.createArgument=(D,F)=>new x8(D,F);L5.Command=Y3;L5.Option=y8;L5.Argument=x8;L5.Help=R5;L5.CommanderError=K5;L5.InvalidArgumentError=k8;L5.InvalidOptionArgumentError=k8});var lD={};N8(lD,{updateState:()=>PD,update:()=>w3,unregister:()=>B2,register:()=>$0,list:()=>RD,hasWorkerForTask:()=>H4,getRegistryPath:()=>U4,getElapsedTime:()=>G4,getConfigDir:()=>W4,getByState:()=>_4,get:()=>I3,findByWish:()=>Y4,findByTask:()=>LD,findBySessionId:()=>q4,findByPane:()=>v3});import{mkdir as B4,readFile as $4,writeFile as X4}from"fs/promises";import{join as _1}from"path";import{homedir as Q4}from"os";async function J4(){await B4(f3,{recursive:!0})}async function k2(){try{let D=await $4(Z3,"utf-8");return JSON.parse(D)}catch{return{workers:{},lastUpdated:new Date().toISOString()}}}async function x0(D){await J4(),D.lastUpdated=new Date().toISOString(),await X4(Z3,JSON.stringify(D,null,2))}async function $0(D){let F=await k2();F.workers[D.id]=D,await x0(F)}async function B2(D){let F=await k2();delete F.workers[D],await x0(F)}async function I3(D){return(await k2()).workers[D]||null}async function RD(){let D=await k2();return Object.values(D.workers)}async function PD(D,F){let E=await k2(),B=E.workers[D];if(B)B.state=F,B.lastStateChange=new Date().toISOString(),await x0(E)}async function w3(D,F){let E=await k2(),B=E.workers[D];if(B){if(Object.assign(B,F),F.state)B.lastStateChange=new Date().toISOString();await x0(E)}}async function v3(D){let F=await RD(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function LD(D){return(await RD()).find((E)=>E.taskId===D)||null}async function Y4(D){return(await RD()).filter((E)=>E.wishSlug===D)}async function q4(D){return(await RD()).find((E)=>E.claudeSessionId===D)||null}async function H4(D){return await LD(D)!==null}async function _4(D){return(await RD()).filter((E)=>E.state===D)}function G4(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 W4(){return f3}function U4(){return Z3}var f3,Z3;var mD=pF(()=>{f3=_1(Q4(),".config","term"),Z3=_1(f3,"workers.json")});var c0=c((rX,N1)=>{var u4=FD("tty"),x4=u4?.WriteStream?.prototype?.hasColors?.()??!1,P=(D,F)=>{if(!x4)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);N1.exports=b});var I1=c((UQ,Z1)=>{Z1.exports=p4;function c4(D){let F={defaultWidth:0,output:process.stdout,tty:FD("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=c4(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 v1=c((AQ,w1)=>{w1.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 s3=c((CQ,u1)=>{var d4=v1();u1.exports=(D)=>typeof D==="string"?D.replace(d4(),""):D});var k1=c((zQ,t3)=>{var x1=(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};t3.exports=x1;t3.exports.default=x1});var h1=c((VQ,y1)=>{y1.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 l1=c((KQ,e3)=>{var i4=s3(),n4=k1(),r4=h1(),g1=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=i4(D),D.length===0)return 0;D=D.replace(r4()," ");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+=n4(B)?2:1}return F};e3.exports=g1;e3.exports.default=g1});var c1=c((RQ,m1)=>{m1.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 D8=c((LQ,d1)=>{var H0=c1(),p1={};for(let D of Object.keys(H0))p1[H0[D]]=D;var K={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"]}};d1.exports=K;for(let D of Object.keys(K)){if(!("channels"in K[D]))throw Error("missing channels property: "+D);if(!("labels"in K[D]))throw Error("missing channel labels property: "+D);if(K[D].labels.length!==K[D].channels)throw Error("channel and label counts mismatch: "+D);let{channels:F,labels:E}=K[D];delete K[D].channels,delete K[D].labels,Object.defineProperty(K[D],"channels",{value:F}),Object.defineProperty(K[D],"labels",{value:E})}K.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]};K.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]};K.rgb.hwb=function(D){let F=D[0],E=D[1],B=D[2],$=K.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]};K.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 a4(D,F){return(D[0]-F[0])**2+(D[1]-F[1])**2+(D[2]-F[2])**2}K.rgb.keyword=function(D){let F=p1[D];if(F)return F;let E=1/0,B;for(let $ of Object.keys(H0)){let X=H0[$],Q=a4(D,X);if(Q<E)E=Q,B=$}return B};K.keyword.rgb=function(D){return H0[D]};K.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]};K.rgb.lab=function(D){let F=K.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]};K.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};K.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]};K.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]}};K.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]};K.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]};K.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]};K.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]};K.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]};K.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]};K.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,$]};K.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]};K.rgb.ansi16=function(D,F=null){let[E,B,$]=D,X=F===null?K.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};K.hsv.ansi16=function(D){return K.rgb.ansi16(K.hsv.rgb(D),D[2])};K.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)};K.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]};K.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,$]};K.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};K.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]};K.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]};K.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]};K.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]};K.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]};K.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]};K.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]};K.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]};K.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]};K.apple.rgb=function(D){return[D[0]/65535*255,D[1]/65535*255,D[2]/65535*255]};K.rgb.apple=function(D){return[D[0]/255*65535,D[1]/255*65535,D[2]/255*65535]};K.gray.rgb=function(D){return[D[0]/100*255,D[0]/100*255,D[0]/100*255]};K.gray.hsl=function(D){return[0,0,D[0]]};K.gray.hsv=K.gray.hsl;K.gray.hwb=function(D){return[0,100,D[0]]};K.gray.cmyk=function(D){return[0,0,0,D[0]]};K.gray.lab=function(D){return[D[0],0,0]};K.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};K.rgb.gray=function(D){return[(D[0]+D[1]+D[2])/3/255*100]}});var n1=c((jQ,i1)=>{var d0=D8();function o4(){let D={},F=Object.keys(d0);for(let E=F.length,B=0;B<E;B++)D[F[B]]={distance:-1,parent:null};return D}function s4(D){let F=o4(),E=[D];F[D].distance=0;while(E.length){let B=E.pop(),$=Object.keys(d0[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 t4(D,F){return function(E){return F(D(E))}}function e4(D,F){let E=[F[D].parent,D],B=d0[F[D].parent][D],$=F[D].parent;while(F[$].parent)E.unshift(F[$].parent),B=t4(d0[F[$].parent][$],B),$=F[$].parent;return B.conversion=E,B}i1.exports=function(D){let F=s4(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]=e4(Q,F)}return E}});var a1=c((MQ,r1)=>{var F8=D8(),DE=n1(),l2={},FE=Object.keys(F8);function EE(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 BE(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}FE.forEach((D)=>{l2[D]={},Object.defineProperty(l2[D],"channels",{value:F8[D].channels}),Object.defineProperty(l2[D],"labels",{value:F8[D].labels});let F=DE(D);Object.keys(F).forEach((B)=>{let $=F[B];l2[D][B]=BE($),l2[D][B].raw=EE($)})});r1.exports=l2});var FF=c((OQ,DF)=>{var o1=(D,F)=>(...E)=>{return`\x1B[${D(...E)+F}m`},s1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};5;${B}m`},t1=(D,F)=>(...E)=>{let B=D(...E);return`\x1B[${38+F};2;${B[0]};${B[1]};${B[2]}m`},i0=(D)=>D,e1=(D,F,E)=>[D,F,E],m2=(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})},E8,c2=(D,F,E,B)=>{if(E8===void 0)E8=a1();let $=B?10:0,X={};for(let[Q,J]of Object.entries(E8)){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 $E(){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",m2(F.color,"ansi",()=>c2(o1,"ansi16",i0,!1)),m2(F.color,"ansi256",()=>c2(s1,"ansi256",i0,!1)),m2(F.color,"ansi16m",()=>c2(t1,"rgb",e1,!1)),m2(F.bgColor,"ansi",()=>c2(o1,"ansi16",i0,!0)),m2(F.bgColor,"ansi256",()=>c2(s1,"ansi256",i0,!0)),m2(F.bgColor,"ansi16m",()=>c2(t1,"rgb",e1,!0)),F}Object.defineProperty(DF,"exports",{enumerable:!0,get:$E})});var $F=c((NQ,BF)=>{var _0=l1(),XE=s3(),QE=FF(),$8=new Set(["\x1B","\x9B"]),EF=(D)=>`${$8.values().next().value}[${D}m`,JE=(D)=>D.split(" ").map((F)=>_0(F)),B8=(D,F,E)=>{let B=[...F],$=!1,X=_0(XE(D[D.length-1]));for(let[Q,J]of B.entries()){let Y=_0(J);if(X+Y<=E)D[D.length-1]+=J;else D.push(J),X=0;if($8.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()},YE=(D)=>{let F=D.split(" "),E=F.length;while(E>0){if(_0(F[E-1])>0)break;E--}if(E===F.length)return D;return F.slice(0,E).join(" ")+F.slice(E).join("")},qE=(D,F,E={})=>{if(E.trim!==!1&&D.trim()==="")return"";let B="",$="",X,Q=JE(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=_0(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("");B8(J,q,F);continue}if(H+Q[Y]>F&&H>0&&Q[Y]>0){if(E.wordWrap===!1&&H<F){B8(J,q,F);continue}J.push("")}if(H+Q[Y]>F&&E.wordWrap===!1){B8(J,q,F);continue}J[J.length-1]+=q}if(E.trim!==!1)J=J.map(YE);B=J.join(`
25
+ `);for(let[Y,q]of[...B].entries()){if($+=q,$8.has(q)){let _=parseFloat(/\d[^m]*/.exec(B.slice(Y,Y+4)));X=_===39?null:_}let H=QE.codes.get(Number(X));if(X&&H){if(B[Y+1]===`
26
+ `)$+=EF(H);else if(q===`
27
+ `)$+=EF(X)}}return $};BF.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)=>qE(B,F,E)).join(`
30
+ `)}});var qF=c((ZQ,YF)=>{var _E=FD("stream");class JF extends _E{#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)}}YF.exports=JF});var g8=iD(h8(),1),{program:HB,createCommand:_B,createArgument:GB,createOption:WB,CommanderError:UB,InvalidArgumentError:AB,InvalidOptionArgumentError:CB,Command:l8,Argument:zB,Option:VB,Help:KB}=g8.default;var m8="0.260203.0043";import{join as X7}from"path";var r=[];for(let D=0;D<256;++D)r.push((D+256).toString(16).slice(1));function c8(D,F=0){return(r[D[F+0]]+r[D[F+1]]+r[D[F+2]]+r[D[F+3]]+"-"+r[D[F+4]]+r[D[F+5]]+"-"+r[D[F+6]]+r[D[F+7]]+"-"+r[D[F+8]]+r[D[F+9]]+"-"+r[D[F+10]]+r[D[F+11]]+r[D[F+12]]+r[D[F+13]]+r[D[F+14]]+r[D[F+15]]).toLowerCase()}import{randomFillSync as w5}from"crypto";var K0=new Uint8Array(256),V0=K0.length;function q3(){if(V0>K0.length-16)w5(K0),V0=0;return K0.slice(V0,V0+=16)}import{randomUUID as v5}from"crypto";var H3={randomUUID:v5};function u5(D,F,E){if(H3.randomUUID&&!F&&!D)return H3.randomUUID();D=D||{};let B=D.random??D.rng?.()??q3();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 c8(B)}var R0=u5;import{exec as x5}from"child_process";import{promisify as k5}from"util";import{join as y5}from"path";import{mkdirSync as h5,existsSync as g5}from"fs";import{homedir as l5}from"os";var m5=k5(x5);function c5(){let D=y5(l5(),".genie","logs","tmux");if(!g5(D))h5(D,{recursive:!0});return D}function p5(D){return D.filter((F)=>!/^-v+$/.test(F))}function d5(){return process.env.GENIE_TMUX_DEBUG==="1"}async function p8(D){let F=typeof D==="string"?D.split(/\s+/).filter(Boolean):D,E=p5(F),B=d5(),$={};if(B)E=["-v",...E],$.cwd=c5();let X=`tmux ${E.join(" ")}`,{stdout:Q}=await m5(X,$);return Q.trim()}var i5={type:"bash"};async function O(D){try{return await p8(D)}catch(F){throw Error(`Failed to execute tmux command: ${F.message}`)}}async function W3(){try{let F=await O("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 v(D){try{return(await W3()).find((E)=>E.name===D)||null}catch(F){return null}}async function x(D){try{let E=await O(`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 h(D){try{let E=await O(`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 O(`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 nD(D){return await O(`new-session -d -s "${D}" -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8`),v(D)}async function j0(D,F){let E=await O(`new-window -t '${D}' -n '${F}'`);return(await x(D)).find(($)=>$.name===F)||null}async function M0(D){await O(`kill-session -t '${D}'`)}async function d8(D){await O(`kill-window -t '${D}'`)}async function W2(D){await O(`kill-pane -t '${D}'`)}function n5(D){return D.replace(/'/g,"'\\''")}async function U2(D,F="vertical",E,B){let $="split-window";if(F==="horizontal")$+=" -h";else $+=" -v";if(B)$+=` -c '${n5(B)}'`;if(E!==void 0&&E>0&&E<100)$+=` -p ${E}`;$+=` -t '${D}'`,$+=" -P -F '#{pane_id}'";let X=(await O($)).trim(),Q=await O(`display-message -p -t '${X}' '#{window_id}'`);return{id:X,windowId:Q.trim(),active:!1,title:""}}var _3=new Map,G3="TMUX_MCP_START",L0="TMUX_MCP_DONE_";async function QD(D,F,E,B){let $=R0(),X;if(E||B)X=F;else{let Q=r5();X=`echo "${G3}"; ${F}; echo "${Q}"`}if(_3.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 O(`send-keys -t '${D}' ${X}`);else for(let J of X)await O(`send-keys -t '${D}' '${J.replace(/'/g,"'\\''")}'`);else await O(`send-keys -t '${D}' '${X.replace(/'/g,"'\\''")}' Enter`);return $}async function i8(D){let F=_3.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(G3),$=E.lastIndexOf(L0);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(`${L0}(\\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+G3.length,H=E.substring(q,$).trim();F.result=H.substring(H.indexOf(`
35
+ `)+1).trim(),_3.set(D,F)}return F}function r5(){return i5.type==="fish"?`${L0}$status`:`${L0}$?`}async function n8(D,F,E=120000){let B=R0().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 O(`send-keys -t '${D}' '${Y.replace(/'/g,"'\\''")}' Enter`);try{await Promise.race([O(`wait-for ${Q}`),new Promise((_,G)=>setTimeout(()=>G(Error("Command timed out")),E))])}catch(_){if(_.message==="Command timed out"){try{await O(`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 U=await _(X,"utf-8");H=parseInt(U.trim(),10)||0,await G($).catch(()=>{}),await G(X).catch(()=>{})}catch(_){console.error("Failed to read command output:",_)}return{output:q,exitCode:H}}var{$:ND}=globalThis.Bun;import{mkdir as r8,rm as a8,access as U3,readFile as a5,writeFile as o5}from"fs/promises";import{join as A2,basename as s5}from"path";function O0(D){return D.replace(/\//g,"-").replace(/\\/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function t5(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 C2{baseDir;repoPath;metadataPath;constructor(D){this.baseDir=D.baseDir,this.repoPath=D.repoPath,this.metadataPath=A2(this.baseDir,".metadata.json")}async loadMetadata(){try{let D=await a5(this.metadataPath,"utf-8");return JSON.parse(D)}catch{return{worktrees:{}}}}async saveMetadata(D){await r8(this.baseDir,{recursive:!0}),await o5(this.metadataPath,JSON.stringify(D,null,2))}async createWorktree(D,F=!1,E){let B=O0(D),$=A2(this.baseDir,B);await r8(this.baseDir,{recursive:!0});try{throw await U3($),Error(`Worktree already exists at ${$}`)}catch(J){if(J.code!=="ENOENT")throw J}if(F)if(E)await ND`git -C ${this.repoPath} worktree add -b ${D} ${$} ${E}`.quiet();else await ND`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 ND`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=O0(D),E=A2(this.baseDir,F);try{await ND`git -C ${this.repoPath} worktree remove ${E} --force`.quiet()}catch{try{await a8(E,{recursive:!0,force:!0})}catch{}}try{await U3(E),await a8(E,{recursive:!0,force:!0})}catch{}let B=await this.loadMetadata();delete B.worktrees[F],await this.saveMetadata(B)}async listWorktrees(){let F=(await ND`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=s5(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=t5(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 ND`git -C ${this.repoPath} worktree prune`.quiet()}async getDiskUsage(D){try{let E=(await ND`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=O0(D);return A2(this.baseDir,F)}async worktreeExists(D){let F=O0(D),E=A2(this.baseDir,F);try{return await U3(E),!0}catch{return!1}}async branchExists(D){try{return await ND`git -C ${this.repoPath} rev-parse --verify ${D}`.quiet(),!0}catch{return!1}}async getCommitHash(D){return(await ND`git -C ${D} rev-parse HEAD`.quiet()).stdout.toString().trim()}}function z2(D){let F=D?.baseDir||A2(process.cwd(),".worktrees"),E=D?.repoPath||process.cwd();return new C2({baseDir:F,repoPath:E})}import{mkdir as e5,readFile as D7,writeFile as F7,access as E7}from"fs/promises";import{join as o8}from"path";import{homedir as B7}from"os";var s8=o8(B7(),".config","term"),A3=o8(s8,"sessions.json");async function $7(){await e5(s8,{recursive:!0})}async function C3(){try{await E7(A3);let D=await D7(A3,"utf-8");return JSON.parse(D)}catch{return{sessions:{}}}}async function t8(D){await $7(),await F7(A3,JSON.stringify(D,null,2))}async function e8(D,F){let E=await C3();E.sessions[D]={...F,createdAt:new Date().toISOString()},await t8(E)}async function D6(D){return(await C3()).sessions[D]||null}async function F6(D){let F=await C3();delete F.sessions[D],await t8(F)}async function E6(D,F={}){try{if(await v(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=z2({baseDir:X7(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 nD(D))console.error(`\u274C Failed to create session "${D}"`),process.exit(1);if(await O(`send-keys -t '${D}' 'cd ${B}' Enter`),$)await e8(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 B6(D={}){try{let F=await W3();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 Y7}from"child_process";import{promisify as q7}from"util";var H7=q7(Y7);async function $6(D){try{if(!await v(D))console.error(`\u274C Session "${D}" not found`),process.exit(1);console.log(`\uD83D\uDCCE Attaching to session "${D}"...`),await H7(`tmux attach -t "${D}"`)}catch(F){console.error(`\u274C Error attaching to session: ${F.message}`),process.exit(1)}}import{join as G7}from"path";async function X6(D,F={}){try{let E=await v(D);if(!E)console.error(`\u274C Session "${D}" not found`),process.exit(1);let B=await D6(D);if(await M0(E.id),B?.worktreePath&&B?.workspace&&!F.keepWorktree)await z2({baseDir:G7(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 F6(D)}catch(E){console.error(`\u274C Error removing session: ${E.message}`),process.exit(1)}}function n2(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 Q6(D,F={}){let E=await v(D);if(!E)throw Error(`Session "${D}" not found`);let B=await x(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await h(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 n2(Y)}if(F.from!==void 0&&F.to!==void 0){let Y=await p(X,1e4),_=n2(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(`
43
+ `);return _}if(F.search||F.grep){let Y=F.search||F.grep,q=await p(X,1e4),_=n2(q).split(`
44
+ `);try{let G=new RegExp(Y,"i"),U=_.filter((z)=>G.test(z));if(F.reverse)return U.reverse().join(`
45
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(`
46
+ `)}catch(G){throw Error(`Invalid regex pattern: ${G.message}`)}}let Q=F.lines||100,J=await p(X,Q);if(J=n2(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 J6(D,F){let E=await v(D);if(!E)throw Error(`Session "${D}" not found`);let B=await x(E.id);if(!B||B.length===0)throw Error(`No windows found in session "${D}"`);let $=await h(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=n2(q);if(H!==Q){let _=H.split(`
49
+ `),G=Q.split(`
50
+ `),U=G.length>0?G.length-1:0;_.slice(U).forEach((R)=>{if(R&&R!==G[G.length-1])F(R)}),Q=H}}catch(q){clearInterval(Y),J=!1}},500);return()=>{J=!1,clearInterval(Y)}}import{existsSync as f0,mkdirSync as Z9,readFileSync as R6,writeFileSync as I9}from"fs";import{homedir as L6}from"os";import{join as j6}from"path";var w={};N8(w,{void:()=>t7,util:()=>Z,unknown:()=>o7,union:()=>E9,undefined:()=>n7,tuple:()=>X9,transformer:()=>A9,symbol:()=>i7,string:()=>C6,strictObject:()=>F9,setErrorMap:()=>z7,set:()=>Y9,record:()=>Q9,quotelessJson:()=>A7,promise:()=>U9,preprocess:()=>V9,pipeline:()=>K9,ostring:()=>R9,optional:()=>C9,onumber:()=>L9,oboolean:()=>j9,objectUtil:()=>z3,object:()=>D9,number:()=>z6,nullable:()=>z9,null:()=>r7,never:()=>s7,nativeEnum:()=>W9,nan:()=>c7,map:()=>J9,makeIssue:()=>r2,literal:()=>_9,lazy:()=>H9,late:()=>l7,isValid:()=>xD,isDirty:()=>S0,isAsync:()=>K2,isAborted:()=>N0,intersection:()=>$9,instanceof:()=>m7,getParsedType:()=>AD,getErrorMap:()=>V2,function:()=>q9,enum:()=>G9,effect:()=>A9,discriminatedUnion:()=>B9,defaultErrorMap:()=>SD,datetimeRegex:()=>W6,date:()=>d7,custom:()=>A6,coerce:()=>M9,boolean:()=>V6,bigint:()=>p7,array:()=>e7,any:()=>a7,addIssueToContext:()=>C,ZodVoid:()=>o2,ZodUnknown:()=>kD,ZodUnion:()=>N2,ZodUndefined:()=>M2,ZodType:()=>f,ZodTuple:()=>zD,ZodTransformer:()=>_D,ZodSymbol:()=>a2,ZodString:()=>JD,ZodSet:()=>sD,ZodSchema:()=>f,ZodRecord:()=>s2,ZodReadonly:()=>I2,ZodPromise:()=>tD,ZodPipeline:()=>D0,ZodParsedType:()=>A,ZodOptional:()=>qD,ZodObject:()=>g,ZodNumber:()=>yD,ZodNullable:()=>bD,ZodNull:()=>O2,ZodNever:()=>CD,ZodNativeEnum:()=>P2,ZodNaN:()=>e2,ZodMap:()=>t2,ZodLiteral:()=>b2,ZodLazy:()=>T2,ZodIssueCode:()=>W,ZodIntersection:()=>S2,ZodFunction:()=>L2,ZodFirstPartyTypeKind:()=>S,ZodError:()=>e,ZodEnum:()=>gD,ZodEffects:()=>_D,ZodDiscriminatedUnion:()=>T0,ZodDefault:()=>f2,ZodDate:()=>aD,ZodCatch:()=>Z2,ZodBranded:()=>b0,ZodBoolean:()=>j2,ZodBigInt:()=>hD,ZodArray:()=>YD,ZodAny:()=>oD,Schema:()=>f,ParseStatus:()=>a,OK:()=>o,NEVER:()=>O9,INVALID:()=>N,EMPTY_PATH:()=>V7,DIRTY:()=>rD,BRAND:()=>g7});var Z;(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}})(Z||(Z={}));var z3;(function(D){D.mergeShapes=(F,E)=>{return{...F,...E}}})(z3||(z3={}));var A=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),AD=(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=Z.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"]),A7=(D)=>{return JSON.stringify(D,null,2).replace(/"([^"]+)":/g,"$1:")};class e 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 e))throw Error(`Not a ZodError: ${D}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.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()}}e.create=(D)=>{return new e(D)};var C7=(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,Z.jsonStringifyReplacer)}`;break;case W.unrecognized_keys:E=`Unrecognized key(s) in object: ${Z.joinValues(D.keys,", ")}`;break;case W.invalid_union:E="Invalid input";break;case W.invalid_union_discriminator:E=`Invalid discriminator value. Expected ${Z.joinValues(D.options)}`;break;case W.invalid_enum_value:E=`Invalid enum value. Expected ${Z.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 Z.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,Z.assertNever(D)}return{message:E}},SD=C7;var Y6=SD;function z7(D){Y6=D}function V2(){return Y6}var r2=(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}},V7=[];function C(D,F){let E=V2(),B=r2({issueData:F,data:D.data,path:D.path,errorMaps:[D.common.contextualErrorMap,D.schemaErrorMap,E,E===SD?void 0:SD].filter(($)=>!!$)});D.common.issues.push(B)}class a{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 N;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 a.mergeObjectSync(D,E)}static mergeObjectSync(D,F){let E={};for(let B of F){let{key:$,value:X}=B;if($.status==="aborted")return N;if(X.status==="aborted")return N;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 N=Object.freeze({status:"aborted"}),rD=(D)=>({status:"dirty",value:D}),o=(D)=>({status:"valid",value:D}),N0=(D)=>D.status==="aborted",S0=(D)=>D.status==="dirty",xD=(D)=>D.status==="valid",K2=(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 HD{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 q6=(D,F)=>{if(xD(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 e(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 AD(D.data)}_getOrReturnCtx(D,F){return F||{common:D.parent.common,data:D.data,parsedType:AD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}_processInputParams(D){return{status:new a,ctx:{common:D.parent.common,data:D.data,parsedType:AD(D.data),schemaErrorMap:this._def.errorMap,path:D.path,parent:D.parent}}}_parseSync(D){let F=this._parse(D);if(K2(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:AD(D)},B=this._parseSync({data:D,path:E.path,parent:E});return q6(E,B)}"~validate"(D){let F={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:D,parsedType:AD(D)};if(!this["~standard"].async)try{let E=this._parseSync({data:D,path:[],parent:F});return xD(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)=>xD(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:AD(D)},B=this._parse({data:D,path:E.path,parent:E}),$=await(K2(B)?B:Promise.resolve(B));return q6(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 _D({schema:this,typeName:S.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 qD.create(this,this._def)}nullable(){return bD.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return YD.create(this)}promise(){return tD.create(this,this._def)}or(D){return N2.create([this,D],this._def)}and(D){return S2.create(this,D,this._def)}transform(D){return new _D({...T(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:D}})}default(D){let F=typeof D==="function"?D:()=>D;return new f2({...T(this._def),innerType:this,defaultValue:F,typeName:S.ZodDefault})}brand(){return new b0({typeName:S.ZodBranded,type:this,...T(this._def)})}catch(D){let F=typeof D==="function"?D:()=>D;return new Z2({...T(this._def),innerType:this,catchValue:F,typeName:S.ZodCatch})}describe(D){return new this.constructor({...this._def,description:D})}pipe(D){return D0.create(this,D)}readonly(){return I2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var K7=/^c[^\s-]{8,}$/i,R7=/^[0-9a-z]+$/,L7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j7=/^[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,M7=/^[a-z0-9_-]{21}$/i,O7=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,N7=/^[-+]?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)?)??$/,S7=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,T7="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",V3,b7=/^(?:(?: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])$/,P7=/^(?:(?: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])$/,f7=/^(([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]))$/,Z7=/^(([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])$/,I7=/^([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}(=)?))?$/,_6="((\\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])))",v7=new RegExp(`^${_6}$`);function G6(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(`^${G6(D)}$`)}function W6(D){let F=`${_6}T${G6(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 x7(D,F){if((F==="v4"||!F)&&b7.test(D))return!0;if((F==="v6"||!F)&&f7.test(D))return!0;return!1}function k7(D,F){if(!O7.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 y7(D,F){if((F==="v4"||!F)&&P7.test(D))return!0;if((F==="v6"||!F)&&Z7.test(D))return!0;return!1}class JD extends f{_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}),N}let E=new a,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(!S7.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(!V3)V3=new RegExp(T7,"u");if(!V3.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(!j7.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(!M7.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(!K7.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(!R7.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(!L7.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(!W6($).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(!v7.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(!N7.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(!x7(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(!k7(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(!y7(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(!I7.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 Z.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 JD({...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 JD({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new JD({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new JD({...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}}JD.create=(D)=>{return new JD({checks:[],typeName:S.ZodString,coerce:D?.coerce??!1,...T(D)})};function h7(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 yD 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)!==A.number){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_type,expected:A.number,received:$.parsedType}),N}let E=void 0,B=new a;for(let $ of this._def.checks)if($.kind==="int"){if(!Z.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(h7(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 Z.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 yD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:V.toString(B)}]})}_addCheck(D){return new yD({...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"&&Z.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)}}yD.create=(D)=>{return new yD({checks:[],typeName:S.ZodNumber,coerce:D?.coerce||!1,...T(D)})};class hD 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)!==A.bigint)return this._getInvalidInput(D);let E=void 0,B=new a;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 Z.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}),N}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 hD({...this._def,checks:[...this._def.checks,{kind:D,value:F,inclusive:E,message:V.toString(B)}]})}_addCheck(D){return new hD({...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}}hD.create=(D)=>{return new hD({checks:[],typeName:S.ZodBigInt,coerce:D?.coerce??!1,...T(D)})};class j2 extends f{_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}),N}return o(D.data)}}j2.create=(D)=>{return new j2({typeName:S.ZodBoolean,coerce:D?.coerce||!1,...T(D)})};class aD extends f{_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}),N}if(Number.isNaN(D.data.getTime())){let $=this._getOrReturnCtx(D);return C($,{code:W.invalid_date}),N}let E=new a,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 Z.assertNever($);return{status:E.value,value:new Date(D.data.getTime())}}_addCheck(D){return new aD({...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}}aD.create=(D)=>{return new aD({checks:[],coerce:D?.coerce||!1,typeName:S.ZodDate,...T(D)})};class a2 extends f{_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}),N}return o(D.data)}}a2.create=(D)=>{return new a2({typeName:S.ZodSymbol,...T(D)})};class M2 extends f{_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}),N}return o(D.data)}}M2.create=(D)=>{return new M2({typeName:S.ZodUndefined,...T(D)})};class O2 extends f{_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}),N}return o(D.data)}}O2.create=(D)=>{return new O2({typeName:S.ZodNull,...T(D)})};class oD extends f{constructor(){super(...arguments);this._any=!0}_parse(D){return o(D.data)}}oD.create=(D)=>{return new oD({typeName:S.ZodAny,...T(D)})};class kD extends f{constructor(){super(...arguments);this._unknown=!0}_parse(D){return o(D.data)}}kD.create=(D)=>{return new kD({typeName:S.ZodUnknown,...T(D)})};class CD extends f{_parse(D){let F=this._getOrReturnCtx(D);return C(F,{code:W.invalid_type,expected:A.never,received:F.parsedType}),N}}CD.create=(D)=>{return new CD({typeName:S.ZodNever,...T(D)})};class o2 extends f{_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}),N}return o(D.data)}}o2.create=(D)=>{return new o2({typeName:S.ZodVoid,...T(D)})};class YD extends f{_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}),N;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 HD(F,X,F.path,Q))})).then((X)=>{return a.mergeArray(E,X)});let $=[...F.data].map((X,Q)=>{return B.type._parseSync(new HD(F,X,F.path,Q))});return a.mergeArray(E,$)}get element(){return this._def.type}min(D,F){return new YD({...this._def,minLength:{value:D,message:V.toString(F)}})}max(D,F){return new YD({...this._def,maxLength:{value:D,message:V.toString(F)}})}length(D,F){return new YD({...this._def,exactLength:{value:D,message:V.toString(F)}})}nonempty(D){return this.min(1,D)}}YD.create=(D,F)=>{return new YD({type:D,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...T(F)})};function R2(D){if(D instanceof g){let F={};for(let E in D.shape){let B=D.shape[E];F[E]=qD.create(R2(B))}return new g({...D._def,shape:()=>F})}else if(D instanceof YD)return new YD({...D._def,type:R2(D.element)});else if(D instanceof qD)return qD.create(R2(D.unwrap()));else if(D instanceof bD)return bD.create(R2(D.unwrap()));else if(D instanceof zD)return zD.create(D.items.map((F)=>R2(F)));else return D}class g 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=Z.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}),N}let{status:E,ctx:B}=this._processInputParams(D),{shape:$,keys:X}=this._getCached(),Q=[];if(!(this._def.catchall instanceof CD&&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 HD(B,H,B.path,Y)),alwaysSet:Y in B.data})}if(this._def.catchall instanceof CD){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 HD(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 a.mergeObjectSync(E,Y)});else return a.mergeObjectSync(E,J)}get shape(){return this._def.shape()}strict(D){return V.errToObj,new g({...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 g({...this._def,unknownKeys:"strip"})}passthrough(){return new g({...this._def,unknownKeys:"passthrough"})}extend(D){return new g({...this._def,shape:()=>({...this._def.shape(),...D})})}merge(D){return new g({unknownKeys:D._def.unknownKeys,catchall:D._def.catchall,shape:()=>({...this._def.shape(),...D._def.shape()}),typeName:S.ZodObject})}setKey(D,F){return this.augment({[D]:F})}catchall(D){return new g({...this._def,catchall:D})}pick(D){let F={};for(let E of Z.objectKeys(D))if(D[E]&&this.shape[E])F[E]=this.shape[E];return new g({...this._def,shape:()=>F})}omit(D){let F={};for(let E of Z.objectKeys(this.shape))if(!D[E])F[E]=this.shape[E];return new g({...this._def,shape:()=>F})}deepPartial(){return R2(this)}partial(D){let F={};for(let E of Z.objectKeys(this.shape)){let B=this.shape[E];if(D&&!D[E])F[E]=B;else F[E]=B.optional()}return new g({...this._def,shape:()=>F})}required(D){let F={};for(let E of Z.objectKeys(this.shape))if(D&&!D[E])F[E]=this.shape[E];else{let $=this.shape[E];while($ instanceof qD)$=$._def.innerType;F[E]=$}return new g({...this._def,shape:()=>F})}keyof(){return U6(Z.objectKeys(this.shape))}}g.create=(D,F)=>{return new g({shape:()=>D,unknownKeys:"strip",catchall:CD.create(),typeName:S.ZodObject,...T(F)})};g.strictCreate=(D,F)=>{return new g({shape:()=>D,unknownKeys:"strict",catchall:CD.create(),typeName:S.ZodObject,...T(F)})};g.lazycreate=(D,F)=>{return new g({shape:D,unknownKeys:"strip",catchall:CD.create(),typeName:S.ZodObject,...T(F)})};class N2 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 e(Q.ctx.common.issues));return C(F,{code:W.invalid_union,unionErrors:X}),N}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 e(J));return C(F,{code:W.invalid_union,unionErrors:Q}),N}}get options(){return this._def.options}}N2.create=(D,F)=>{return new N2({options:D,typeName:S.ZodUnion,...T(F)})};var TD=(D)=>{if(D instanceof T2)return TD(D.schema);else if(D instanceof _D)return TD(D.innerType());else if(D instanceof b2)return[D.value];else if(D instanceof gD)return D.options;else if(D instanceof P2)return Z.objectValues(D.enum);else if(D instanceof f2)return TD(D._def.innerType);else if(D instanceof M2)return[void 0];else if(D instanceof O2)return[null];else if(D instanceof qD)return[void 0,...TD(D.unwrap())];else if(D instanceof bD)return[null,...TD(D.unwrap())];else if(D instanceof b0)return TD(D.unwrap());else if(D instanceof I2)return TD(D.unwrap());else if(D instanceof Z2)return TD(D._def.innerType);else return[]};class T0 extends f{_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}),N;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]}),N;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=TD($.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 T0({typeName:S.ZodDiscriminatedUnion,discriminator:D,options:F,optionsMap:B,...T(E)})}}function K3(D,F){let E=AD(D),B=AD(F);if(D===F)return{valid:!0,data:D};else if(E===A.object&&B===A.object){let $=Z.objectKeys(F),X=Z.objectKeys(D).filter((J)=>$.indexOf(J)!==-1),Q={...D,...F};for(let J of X){let Y=K3(D[J],F[J]);if(!Y.valid)return{valid:!1};Q[J]=Y.data}return{valid:!0,data:Q}}else if(E===A.array&&B===A.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=K3(Q,J);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 S2 extends f{_parse(D){let{status:F,ctx:E}=this._processInputParams(D),B=($,X)=>{if(N0($)||N0(X))return N;let Q=K3($.value,X.value);if(!Q.valid)return C(E,{code:W.invalid_intersection_types}),N;if(S0($)||S0(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}))}}S2.create=(D,F,E)=>{return new S2({left:D,right:F,typeName:S.ZodIntersection,...T(E)})};class zD extends f{_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}),N;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"}),N;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 HD(E,X,E.path,Q))}).filter((X)=>!!X);if(E.common.async)return Promise.all($).then((X)=>{return a.mergeArray(F,X)});else return a.mergeArray(F,$)}get items(){return this._def.items}rest(D){return new zD({...this._def,rest:D})}}zD.create=(D,F)=>{if(!Array.isArray(D))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new zD({items:D,typeName:S.ZodTuple,rest:null,...T(F)})};class s2 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!==A.object)return C(E,{code:W.invalid_type,expected:A.object,received:E.parsedType}),N;let B=[],$=this._def.keyType,X=this._def.valueType;for(let Q in E.data)B.push({key:$._parse(new HD(E,Q,E.path,Q)),value:X._parse(new HD(E,E.data[Q],E.path,Q)),alwaysSet:Q in E.data});if(E.common.async)return a.mergeObjectAsync(F,B);else return a.mergeObjectSync(F,B)}get element(){return this._def.valueType}static create(D,F,E){if(F instanceof f)return new s2({keyType:D,valueType:F,typeName:S.ZodRecord,...T(E)});return new s2({keyType:JD.create(),valueType:D,typeName:S.ZodRecord,...T(F)})}}class t2 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!==A.map)return C(E,{code:W.invalid_type,expected:A.map,received:E.parsedType}),N;let B=this._def.keyType,$=this._def.valueType,X=[...E.data.entries()].map(([Q,J],Y)=>{return{key:B._parse(new HD(E,Q,E.path,[Y,"key"])),value:$._parse(new HD(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 N;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 N;if(Y.status==="dirty"||q.status==="dirty")F.dirty();Q.set(Y.value,q.value)}return{status:F.value,value:Q}}}}t2.create=(D,F,E)=>{return new t2({valueType:F,keyType:D,typeName:S.ZodMap,...T(E)})};class sD extends f{_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}),N;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 N;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 HD(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 sD({...this._def,minSize:{value:D,message:V.toString(F)}})}max(D,F){return new sD({...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)}}sD.create=(D,F)=>{return new sD({valueType:D,minSize:null,maxSize:null,typeName:S.ZodSet,...T(F)})};class L2 extends f{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}),N;function E(Q,J){return r2({data:Q,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,V2(),SD].filter((Y)=>!!Y),issueData:{code:W.invalid_arguments,argumentsError:J}})}function B(Q,J){return r2({data:Q,path:F.path,errorMaps:[F.common.contextualErrorMap,F.schemaErrorMap,V2(),SD].filter((Y)=>!!Y),issueData:{code:W.invalid_return_type,returnTypeError:J}})}let $={errorMap:F.common.contextualErrorMap},X=F.data;if(this._def.returns instanceof tD){let Q=this;return o(async function(...J){let Y=new e([]),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 e([E(J,Y.error)]);let q=Reflect.apply(X,this,Y.data),H=Q._def.returns.safeParse(q,$);if(!H.success)throw new e([B(q,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...D){return new L2({...this._def,args:zD.create(D).rest(kD.create())})}returns(D){return new L2({...this._def,returns:D})}implement(D){return this.parse(D)}strictImplement(D){return this.parse(D)}static create(D,F,E){return new L2({args:D?D:zD.create([]).rest(kD.create()),returns:F||kD.create(),typeName:S.ZodFunction,...T(E)})}}class T2 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})}}T2.create=(D,F)=>{return new T2({getter:D,typeName:S.ZodLazy,...T(F)})};class b2 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}),N}return{status:"valid",value:D.data}}get value(){return this._def.value}}b2.create=(D,F)=>{return new b2({value:D,typeName:S.ZodLiteral,...T(F)})};function U6(D,F){return new gD({values:D,typeName:S.ZodEnum,...T(F)})}class gD extends f{_parse(D){if(typeof D.data!=="string"){let F=this._getOrReturnCtx(D),E=this._def.values;return C(F,{expected:Z.joinValues(E),received:F.parsedType,code:W.invalid_type}),N}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}),N}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 gD.create(D,{...this._def,...F})}exclude(D,F=this._def){return gD.create(this.options.filter((E)=>!D.includes(E)),{...this._def,...F})}}gD.create=U6;class P2 extends f{_parse(D){let F=Z.getValidEnumValues(this._def.values),E=this._getOrReturnCtx(D);if(E.parsedType!==A.string&&E.parsedType!==A.number){let B=Z.objectValues(F);return C(E,{expected:Z.joinValues(B),received:E.parsedType,code:W.invalid_type}),N}if(!this._cache)this._cache=new Set(Z.getValidEnumValues(this._def.values));if(!this._cache.has(D.data)){let B=Z.objectValues(F);return C(E,{received:E.data,code:W.invalid_enum_value,options:B}),N}return o(D.data)}get enum(){return this._def.values}}P2.create=(D,F)=>{return new P2({values:D,typeName:S.ZodNativeEnum,...T(F)})};class tD extends f{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}),N;let E=F.parsedType===A.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})}))}}tD.create=(D,F)=>{return new tD({type:D,typeName:S.ZodPromise,...T(F)})};class _D extends f{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.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 N;let J=await this._def.schema._parseAsync({data:Q,path:E.path,parent:E});if(J.status==="aborted")return N;if(J.status==="dirty")return rD(J.value);if(F.value==="dirty")return rD(J.value);return J});else{if(F.value==="aborted")return N;let Q=this._def.schema._parseSync({data:X,path:E.path,parent:E});if(Q.status==="aborted")return N;if(Q.status==="dirty")return rD(Q.value);if(F.value==="dirty")return rD(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 N;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 N;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(!xD(X))return N;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(!xD(X))return N;return Promise.resolve(B.transform(X.value,$)).then((Q)=>({status:F.value,value:Q}))});Z.assertNever(B)}}_D.create=(D,F,E)=>{return new _D({schema:D,typeName:S.ZodEffects,effect:F,...T(E)})};_D.createWithPreprocess=(D,F,E)=>{return new _D({schema:F,effect:{type:"preprocess",transform:D},typeName:S.ZodEffects,...T(E)})};class qD extends f{_parse(D){if(this._getType(D)===A.undefined)return o(void 0);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}qD.create=(D,F)=>{return new qD({innerType:D,typeName:S.ZodOptional,...T(F)})};class bD extends f{_parse(D){if(this._getType(D)===A.null)return o(null);return this._def.innerType._parse(D)}unwrap(){return this._def.innerType}}bD.create=(D,F)=>{return new bD({innerType:D,typeName:S.ZodNullable,...T(F)})};class f2 extends f{_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}}f2.create=(D,F)=>{return new f2({innerType:D,typeName:S.ZodDefault,defaultValue:typeof F.default==="function"?F.default:()=>F.default,...T(F)})};class Z2 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(K2(B))return B.then(($)=>{return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new e(E.common.issues)},input:E.data})}});else return{status:"valid",value:B.status==="valid"?B.value:this._def.catchValue({get error(){return new e(E.common.issues)},input:E.data})}}removeCatch(){return this._def.innerType}}Z2.create=(D,F)=>{return new Z2({innerType:D,typeName:S.ZodCatch,catchValue:typeof F.catch==="function"?F.catch:()=>F.catch,...T(F)})};class e2 extends f{_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}),N}return{status:"valid",value:D.data}}}e2.create=(D)=>{return new e2({typeName:S.ZodNaN,...T(D)})};var g7=Symbol("zod_brand");class b0 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 D0 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 N;if($.status==="dirty")return F.dirty(),rD($.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 N;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 D0({in:D,out:F,typeName:S.ZodPipeline})}}class I2 extends f{_parse(D){let F=this._def.innerType._parse(D),E=(B)=>{if(xD(B))B.value=Object.freeze(B.value);return B};return K2(F)?F.then((B)=>E(B)):E(F)}unwrap(){return this._def.innerType}}I2.create=(D,F)=>{return new I2({innerType:D,typeName:S.ZodReadonly,...T(F)})};function H6(D,F){let E=typeof D==="function"?D(F):typeof D==="string"?{message:D}:D;return typeof E==="string"?{message:E}:E}function A6(D,F={},E){if(D)return oD.create().superRefine((B,$)=>{let X=D(B);if(X instanceof Promise)return X.then((Q)=>{if(!Q){let J=H6(F,B),Y=J.fatal??E??!0;$.addIssue({code:"custom",...J,fatal:Y})}});if(!X){let Q=H6(F,B),J=Q.fatal??E??!0;$.addIssue({code:"custom",...Q,fatal:J})}return});return oD.create()}var l7={object:g.lazycreate},S;(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"})(S||(S={}));var m7=(D,F={message:`Input not instance of ${D.name}`})=>A6((E)=>E instanceof D,F),C6=JD.create,z6=yD.create,c7=e2.create,p7=hD.create,V6=j2.create,d7=aD.create,i7=a2.create,n7=M2.create,r7=O2.create,a7=oD.create,o7=kD.create,s7=CD.create,t7=o2.create,e7=YD.create,D9=g.create,F9=g.strictCreate,E9=N2.create,B9=T0.create,$9=S2.create,X9=zD.create,Q9=s2.create,J9=t2.create,Y9=sD.create,q9=L2.create,H9=T2.create,_9=b2.create,G9=gD.create,W9=P2.create,U9=tD.create,A9=_D.create,C9=qD.create,z9=bD.create,V9=_D.createWithPreprocess,K9=D0.create,R9=()=>C6().optional(),L9=()=>z6().optional(),j9=()=>V6().optional(),M9={string:(D)=>JD.create({...D,coerce:!0}),number:(D)=>yD.create({...D,coerce:!0}),boolean:(D)=>j2.create({...D,coerce:!0}),bigint:(D)=>hD.create({...D,coerce:!0}),date:(D)=>aD.create({...D,coerce:!0})};var O9=N;var N9=w.object({name:w.string().default("genie"),defaultWindow:w.string().default("shell"),autoCreate:w.boolean().default(!0)}),S9=w.object({execTimeout:w.number().default(120000),readLines:w.number().default(100),worktreeBase:w.string().default(".worktrees")}),T9=w.object({tmuxDebug:w.boolean().default(!1),verbose:w.boolean().default(!1)}),b9=w.object({preference:w.enum(["auto","zsh","bash","fish"]).default("auto")}),P9=w.object({tmuxInstalled:w.boolean().default(!1),shellInstalled:w.boolean().default(!1)}),f9=w.object({enabled:w.boolean().default(!1)}),GD=w.object({version:w.number().default(2),session:N9.default({}),terminal:S9.default({}),logging:T9.default({}),shell:b9.default({}),shortcuts:P9.default({}),claudio:f9.optional(),installMethod:w.enum(["source","npm","bun"]).optional(),setupComplete:w.boolean().default(!1),lastSetupAt:w.string().optional()}),K6=w.object({session:w.object({name:w.string().default("genie"),defaultWindow:w.string().default("shell")}).default({}),logging:w.object({tmuxDebug:w.boolean().default(!1)}).default({}),installMethod:w.enum(["source","npm","bun"]).optional()});var P0=j6(L6(),".genie"),eD=j6(P0,"config.json"),R3=2;function m$(){return P0}function c$(){return eD}function w9(){return f0(eD)}function v9(){if(!f0(P0))Z9(P0,{recursive:!0})}function M6(D){let F=K6.safeParse(D);if(F.success){let E=F.data;return GD.parse({version:R3,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 GD.parse({})}async function O6(){if(!f0(eD))return GD.parse({});try{let D=R6(eD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<R3){let E=M6(F);return await Z0(E),E}return GD.parse(F)}catch(D){return console.warn(`Warning: Invalid genie config, using defaults: ${D.message}`),GD.parse({})}}async function Z0(D){v9();try{let F=GD.parse(D),E=JSON.stringify(F,null,2);I9(eD,E,"utf-8")}catch(F){throw Error(`Failed to save genie config: ${F.message}`)}}function u9(){return GD.parse({})}function N6(){if(!f0(eD))return GD.parse({});try{let D=R6(eD,"utf-8"),F=JSON.parse(D);if(!F.version||F.version<R3)return M6(F);return GD.parse(F)}catch{return GD.parse({})}}function p$(D){let F=L6();if(D.startsWith(F+"/"))return"~"+D.slice(F.length);if(D===F)return"~";return D}function I0(){return N6().terminal}function d$(){if(!w9())return!1;return N6().setupComplete??!1}async function i$(){let D=await O6();D.setupComplete=!0,D.lastSetupAt=new Date().toISOString(),await Z0(D)}async function n$(){let D=u9();await Z0(D)}async function r$(D){let F=await O6();F.shortcuts={...F.shortcuts,...D},await Z0(F)}async function S6(D,F){try{let B=I0().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 J6(D,(J)=>{console.log(J)});process.on("SIGINT",()=>{Q(),console.log(`
51
+ Stopped following`),process.exit(0)}),await new Promise(()=>{});return}let X=await Q6(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 T6(D,F,E={}){let[B,$]=D.includes(":")?D.split(":"):[D,"shell"];try{let X=await v(B);if(!X){if(!E.quiet)console.error(`Session "${B}" not found, creating...`);if(X=await nD(B),!X)console.error(`Failed to create session "${B}"`),process.exit(1)}let J=(await x(X.id)).find((U)=>U.name===$);if(!J){if(!E.quiet)console.error(`Window "${$}" not found, creating...`);if(J=await j0(X.id,$),!J)console.error(`Failed to create window "${$}"`),process.exit(1)}let Y=await h(J.id);if(!Y||Y.length===0)console.error(`No panes found in window "${$}"`),process.exit(1);let q=I0(),H=E.timeout??q.execTimeout,{output:_,exitCode:G}=await n8(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 b6(D,F,E={}){try{let B=await v(D);if(!B)console.error(`\u274C Session "${D}" not found`),process.exit(1);let $;if(E.pane)$=E.pane.startsWith("%")?E.pane:`%${E.pane}`;else{let J=await x(B.id);if(!J||J.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let Y=await h(J[0].id);if(!Y||Y.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);$=Y[0].id}let X=E.enter!==!1,Q=F.replace(/'/g,"'\\''");if(X)await O(`send-keys -t '${$}' '${Q}' Enter`);else await O(`send-keys -t '${$}' '${Q}'`);console.log(`\u2705 Keys sent to session "${D}"${X?" (with Enter)":""}`)}catch(B){console.error(`\u274C Error sending keys: ${B.message}`),process.exit(1)}}import{join as h9}from"path";async function P6(D,F,E={}){try{let B=await v(D);if(!B)console.error(`\u274C Session "${D}" not found`),process.exit(1);let $=await x(B.id);if(!$||$.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let X=$.find((U)=>U.active)||$[0],Q=await h(X.id);if(!Q||Q.length===0)console.error(`\u274C No panes found in session "${D}"`),process.exit(1);let Y=(Q.find((U)=>U.active)||Q[0]).id,q=F==="h"?"horizontal":"vertical",H=await O(`display-message -p -t '${Y}' '#{pane_current_path}'`),_;if(E.worktree){if(!E.workspace)console.error("\u274C --worktree requires --workspace"),process.exit(1);let U=z2({baseDir:h9(E.workspace,".worktrees"),repoPath:E.workspace});if(!await U.worktreeExists(E.worktree)){let R=await U.createWorktree(E.worktree,!0);console.log(`\u2705 Worktree created at ${R.path}`)}_=U.getWorktreePath(E.worktree)}else if(E.workspace)_=E.workspace;else _=H.trim()||void 0;let G=await U2(Y,q,void 0,_);if(!G)console.error("\u274C Failed to split pane"),process.exit(1);if(_)await O(`send-keys -t '${G.id}' 'cd ${_.replace(/'/g,"'\\''")} && clear' Enter`);if(console.log(`\u2705 Pane split ${q}ly in session "${D}"`),_)console.log(` Working directory: ${_}`)}catch(B){console.error(`\u274C Error splitting pane: ${B.message}`),process.exit(1)}}async function f6(D,F){await O(`set-hook -g ${D} '${F.replace(/'/g,"'\\''")}'`)}async function Z6(D){await O(`set-hook -gu ${D}`)}async function I6(){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 O(`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 w6(D,F){try{await f6(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 v6(){try{let D=await I6();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 u6(D){try{await Z6(D),console.log(`\u2705 Hook removed: ${D}`)}catch(F){console.error(`\u274C Error removing hook: ${F.message}`),process.exit(1)}}async function x6(D,F={}){try{let E=await v(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await x(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 v(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await j0(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 y6(D){try{await d8(D),console.log(`Window removed: ${D}`)}catch(F){console.error(`Error removing window: ${F.message}`),process.exit(1)}}async function h6(D,F={}){try{let E=await v(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await x(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 h(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 g6(D){try{await W2(D),console.log(`Pane removed: ${D}`)}catch(F){console.error(`Error removing pane: ${F.message}`),process.exit(1)}}async function l6(D,F={}){try{if(F.command){await d9(F.command,F.json);return}let E=await v(D);if(!E)console.error(`Session "${D}" not found`),process.exit(1);let B=await x(E.id),$=0;for(let J of B){let Y=await h(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 d9(D,F){try{let E=await i8(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 m6}from"os";import{join as WD}from"path";import{existsSync as D2,readFileSync as c6,writeFileSync as n9,mkdirSync as r9,appendFileSync as L3}from"fs";import*as p6 from"readline";function d6(){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 i6(){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 a9(){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 o9(){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,85 @@ 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 w2(D){let F=p6.createInterface({input:process.stdin,output:process.stdout});return new Promise((E)=>{F.question(D,(B)=>{F.close(),E(B.trim().toLowerCase())})})}function F2(D,F){if(!D2(D))return!1;return c6(D,"utf-8").includes(F)}async function s9(){let D=m6(),F="generated by genie-cli";console.log(`Installing Warp-like shortcuts...
128
+ `);let E=WD(D,".tmux.conf");if(F2(E,"generated by genie-cli"))console.log("\u2713 tmux.conf already has genie shortcuts");else if(await w2(`Add shortcuts to ${E}? [Y/n] `)!=="n"){let Y=`
129
+ `+d6();L3(E,Y),console.log(`\u2705 Added to ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=D2(WD(D,".zshrc"))?WD(D,".zshrc"):WD(D,".bashrc");if(F2(B,"generated by genie-cli"))console.log(`\u2713 ${B} already has genie shortcuts`);else if(await w2(`Add shell functions to ${B}? [Y/n] `)!=="n"){let Y=`
130
+ `+a9();L3(B,Y),console.log(`\u2705 Added to ${B}`)}else console.log(`\u23ED\uFE0F Skipped ${B}`);let $=WD(D,".termux"),X=WD($,"termux.properties"),Q=D2($)||process.env.TERMUX_VERSION;if(Q)if(F2(X,"generated by genie-cli"))console.log("\u2713 termux.properties already has genie shortcuts");else if(await w2(`Add extra keys to ${X}? [Y/n] `)!=="n"){if(!D2($))r9($,{recursive:!0});let Y=`
131
+ `+i6();L3(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 $X(D){return F2(D,"generated by genie-cli")}function j3(D,F){if(!D2(D))return!1;let E=c6(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 n9(D,J),!0}async function XX(){let D=m6(),F="generated by genie-cli";console.log(`Uninstalling Warp-like shortcuts...
137
+ `);let E=WD(D,".tmux.conf");if(!F2(E,"generated by genie-cli"))console.log("\u2713 tmux.conf has no genie shortcuts");else if(await w2(`Remove shortcuts from ${E}? [Y/n] `)!=="n"){if(j3(E,"generated by genie-cli"))console.log(`\u2705 Removed from ${E}`)}else console.log("\u23ED\uFE0F Skipped tmux.conf");let B=WD(D,".zshrc"),$=WD(D,".bashrc");for(let Y of[B,$]){if(!D2(Y))continue;if(!F2(Y,"generated by genie-cli"))console.log(`\u2713 ${Y} has no genie shortcuts`);else if(await w2(`Remove shell functions from ${Y}? [Y/n] `)!=="n"){if(j3(Y,"generated by genie-cli"))console.log(`\u2705 Removed from ${Y}`)}else console.log(`\u23ED\uFE0F Skipped ${Y}`)}let X=WD(D,".termux"),Q=WD(X,"termux.properties"),J=D2(X)||process.env.TERMUX_VERSION;if(J)if(!F2(Q,"generated by genie-cli"))console.log("\u2713 termux.properties has no genie shortcuts");else if(await w2(`Remove extra keys from ${Q}? [Y/n] `)!=="n"){if(j3(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 n6(D){if(D.tmux)console.log(d6());else if(D.termux)console.log(i6());else if(D.install)await s9();else o9()}var v2=[{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}],w0=[{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}],r6=[{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]})}],a6=[{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}],o6=[{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/}],s6=[{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}],t6=[{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]})}],e9=[{type:"claude_plan_file",pattern:/(~\/\.claude\/plans\/[\w-]+\.md|\/[^\s]+\/\.claude\/plans\/[\w-]+\.md)/,extract:(D)=>({path:D[1]})}];function ED(D){return D.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}function e6(D){let F=ED(D),E=u2(F,e9);if(E?.extracted?.path){let B=E.extracted.path;if(B.startsWith("~"))B=B.replace("~",process.env.HOME||"");return B}return null}function F0(D,F){let E=ED(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 E0(D,F){return F0(D,F).length>0}function u2(D,F){let E=F0(D,F);return E.length>0?E[0]:null}function BD(D,F={}){let{linesToAnalyze:E=50,minConfidence:B=0.3}=F,$=D.split(`
140
+ `),X=$.slice(-E).join(`
141
+ `),Q=ED(X),Y={timestamp:Date.now(),rawOutput:X},q=u2(Q,v2);if(q)return{...Y,type:"permission",detail:q.type.replace("_permission",""),confidence:0.9};let H=E0(Q,w0.filter((m)=>m.type==="claude_code_plan_approval")),_=$.slice(-15).join(`
142
+ `),G=ED(_),U=F0(G,w0);if(U.length>0||H){let m=U.filter((n)=>n.type==="claude_code_numbered_options"&&n.extracted?.option).map((n)=>n.extracted.option);if(m.length>=2||H)return{...Y,type:"question",options:m.length>0?m:void 0,detail:H?"plan_approval":void 0,confidence:0.85};let d=U.filter((n)=>n.extracted?.option&&n.type!=="claude_code_numbered_options").map((n)=>n.extracted.option);if(d.length>=2)return{...Y,type:"question",options:d,confidence:0.85}}let z=U.find((m)=>m.type==="yes_no_question");if(z)return{...Y,type:"question",options:["Yes","No"],detail:`default: ${z.extracted?.default||"y"}`,confidence:0.85};let R=u2(Q,r6);if(R)return{...Y,type:"error",detail:R.extracted?.message||R.match[0],confidence:0.8};let L=u2(Q,t6);if(L)return{...Y,type:"tool_use",detail:`${L.type}: ${L.extracted?.command||L.extracted?.file||L.extracted?.query||""}`,confidence:0.75};if(E0(Q,o6))return{...Y,type:"working",confidence:0.7};if(E0(Q,a6))return{...Y,type:"complete",confidence:0.6};let j=$.slice(-5).join(`
143
+ `),M=ED(j);if(E0(M,s6))return{...Y,type:"idle",confidence:0.7};let I=M.trim();if(I.endsWith(">")||I.match(/>\s*$/))return{...Y,type:"idle",detail:"prompt detected",confidence:0.65};return{...Y,type:"unknown",confidence:B}}function D1(D,F){let E=BD(D),B=BD(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 F1(D){let F=ED(D),E=u2(F,v2);if(!E)return null;let B=F.split(`
144
+ `),$=B.findIndex((J)=>J.match(v2[0].pattern)||J.match(v2[1].pattern)||J.match(v2[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 M3(D){let F=ED(D),E=F0(F,w0),B=[];for(let $ of E)if($.extracted?.option)B.push($.extracted.option);return B}import{EventEmitter as D4}from"events";class VD extends D4{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 v(this.sessionName);if(!D)throw Error(`Session "${this.sessionName}" not found`);let F=await x(D.id);if(!F||F.length===0)throw Error(`No windows found in session "${this.sessionName}"`);let E=await h(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.pollTimer.unref(),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=BD(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 $=D1(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 E1(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 B1(D,F={}){let{silenceMs:E=3000,timeoutMs:B=120000,requireIdle:$=!0}=F;return new Promise((X,Q)=>{let J=setTimeout(()=>{U(),Q(Error("Timeout waiting for completion"))},B),Y=Date.now(),q=null,H=(z)=>{if(z.state)U(),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")U(),X({state:z.state,reason:"idle state"});if(z.state?.type==="error")U(),X({state:z.state,reason:"error"})},U=()=>{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,R=D.getCurrentState();if(z>=E){if(R&&(R.type==="idle"||R.type==="complete"||R.type==="error"))U(),X({state:R,reason:`silence (${z}ms)`});else if(!$)U(),X({state:R||{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 E2(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 E1(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 v0(){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 B1(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 O3(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 u0(){return O3(v0(),E2(5000),{primaryTimeoutMs:30000,fallbackTimeoutMs:90000})}var B0={"silence-3s":()=>E2(3000),"silence-5s":()=>E2(5000),"silence-10s":()=>E2(1e4),"state-detection":()=>v0(),hybrid:()=>u0(),"aggressive-hybrid":()=>O3(v0(),E2(2000),{primaryTimeoutMs:1e4,fallbackTimeoutMs:30000}),"conservative-hybrid":()=>O3(v0(),E2(1e4),{primaryTimeoutMs:60000,fallbackTimeoutMs:120000})};function N3(D){if(D in B0)return B0[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 E2($)}return u0()}async function x2(D,F){let E=await v(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 x(E.id);if(!B||B.length===0)console.error(`\u274C No windows found in session "${D}"`),process.exit(1);let $=await h(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 $1(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 X1(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 Q1(D,F={}){try{let E=await v(D);if(!E){if(E=await nD(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 x(E.id);B=(await h(X[0].id))[0].id}let $=F.command||"claude";if(await QD(B,$,!1,!1),console.log(`\u2705 Started "${$}" in session "${D}"`),F.monitor){console.log("\u2139\uFE0F Starting event monitor...");let X=new VD(D,{pollIntervalMs:500,paneId:F.pane});X.on("event",(Q)=>{if(F.json)console.log(JSON.stringify(Q));else console.log(X1(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 J1(D,F,E={}){try{let{paneId:B}=await x2(D,E.pane),$=F.replace(/'/g,"'\\''");if(await O(`send-keys -t '${B}' '${$}' Enter`),E.noWait){console.log(`\u2705 Message sent to session "${D}"`);return}let X=new VD(D,{pollIntervalMs:250,paneId:E.pane});await X.start();let Q=E.method?N3(E.method):u0(),J=E.timeout||120000;console.log(`\u2139\uFE0F Waiting for completion using "${Q.name}"...`);try{let Y=await Q.detect(X,J);if(X.stop(),E.json)console.log(JSON.stringify(Y,null,2));else if(console.log(`\u2705 Completion detected: ${Y.reason}`),console.log(` Latency: ${Y.latencyMs}ms`),Y.state)console.log(` State: ${$1(Y.state)}`);let q=await p(B,100);console.log(`
152
+ --- Response ---`),console.log(ED(q).trim())}catch(Y){X.stop(),console.error(`\u274C Completion detection failed: ${Y.message}`),process.exit(1)}}catch(B){console.error(`\u274C Error: ${B.message}`),process.exit(1)}}async function Y1(D,F={}){try{let{paneId:E}=await x2(D,F.pane),B=await p(E,100),$=BD(B),X=null,Q=[],J=null;if($.type==="permission")X=F1(B);else if($.type==="question"){if(Q=M3(B),$.detail==="plan_approval")J=e6(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=ED(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}"
165
-
166
- Read the issue details with: bd show ${$}
167
-
168
- When you're done, commit your changes and let me know.`;if(await e(H,U,!1,!1),await T2($,"working"),L9($,X,H),F.focus!==!1)await S(`select-pane -t '${H}'`);if(console.log(`
169
- \u2705 Worker started for ${$}`),console.log(` Pane: ${H}`),console.log(` Session: ${X}`),q)console.log(` Worktree: ${q}`);console.log(`
170
- Commands:`),console.log(" term workers - Check worker status"),console.log(` term approve ${$} - Approve permissions`),console.log(` term close ${$} - Close issue when done`),console.log(` term kill ${$} - Force kill worker`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var{$:P6}=globalThis.Bun;sD();async function O9(D){try{return await p(D,1),!0}catch{return!1}}async function N9(D){try{let F=await p(D,30),E=FD(F);switch(E.type){case"working":case"tool_use":return"working";case"idle":return"idle";case"permission":return"\u26A0\uFE0F perm";case"question":return"\u26A0\uFE0F question";case"error":return"\u274C error";case"complete":return"\u2705 done";default:return E.type}}catch{return"unknown"}}async function S9(){let D=[],F=[];try{let B=(await P6`bd ready --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)D.push(`${J.id}`)}catch{let $=B.split(`
171
- `).filter((J)=>J.trim());for(let J of $){let X=J.match(/^(bd-\d+)/);if(X)D.push(X[1])}}}catch{}try{let B=(await P6`bd list --json`.quiet()).stdout.toString().trim();if(B)try{let $=JSON.parse(B);for(let J of $)if(J.blockedBy&&J.blockedBy.length>0)F.push(`${J.id} (blocked by ${J.blockedBy.join(", ")})`)}catch{}}catch{}return{ready:D,blocked:F}}function T9(D){let F=new Date(D).getTime(),E=Date.now()-F,B=Math.floor(E/60000),$=Math.floor(B/60);if($>0)return`${$}h ${B%60}m`;else if(B>0)return`${B}m`;return"<1m"}async function I6(D={}){try{let F=await aD(),E=[];for(let Q of F){let Y=await O9(Q.paneId),q=Q.state;if(Y){q=await N9(Q.paneId);let _=b9(q);if(_&&_!==Q.state)await T2(Q.id,_)}else q="\uD83D\uDC80 dead";E.push({name:Q.id,pane:Q.paneId,task:Q.taskTitle?`"${Q.taskTitle.substring(0,25)}${Q.taskTitle.length>25?"...":""}"`:Q.taskId,state:q,time:T9(Q.startedAt),alive:Y})}let B=await S9(),$=F.filter((Q)=>E.find((Y)=>Y.name===Q.id&&Y.alive)).map((Q)=>Q.taskId),J=B.ready.filter((Q)=>!$.includes(Q));if(D.json){console.log(JSON.stringify({workers:E,queue:{ready:J,blocked:B.blocked}},null,2));return}if(console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 WORKERS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2524"),console.log("\u2502 Name \u2502 Pane \u2502 Task \u2502 State \u2502Time\u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2524"),E.length===0)console.log("\u2502 (no workers) \u2502");else for(let Q of E){let Y=Q.name.padEnd(8).substring(0,8),q=Q.pane.padEnd(8).substring(0,8),_=Q.task.padEnd(25).substring(0,25),H=Q.state.padEnd(8).substring(0,8),G=Q.time.padStart(4).substring(0,4);console.log(`\u2502 ${Y} \u2502 ${q} \u2502 ${_} \u2502 ${H} \u2502${G}\u2502`)}if(console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"),B.blocked.length>0)console.log(`
172
- Blocked: ${B.blocked.slice(0,5).join(", ")}${B.blocked.length>5?"...":""}`);if(J.length>0)console.log(`Ready: ${J.slice(0,5).join(", ")}${J.length>5?"...":""}`);else if(E.length>0)console.log(`
173
- Ready: (none - all assigned or blocked)`);let X=E.filter((Q)=>!Q.alive);if(X.length>0)console.log(`
174
- \u26A0\uFE0F ${X.length} dead worker(s) detected. Run \`term kill <name>\` to clean up.`)}catch(F){console.error(`\u274C Error: ${F.message}`),process.exit(1)}}function b9(D){if(D==="working")return"working";if(D==="idle")return"idle";if(D==="\u26A0\uFE0F perm")return"permission";if(D==="\u26A0\uFE0F question")return"question";if(D==="\u274C error")return"error";if(D==="\u2705 done")return"done";return null}var{$:T0}=globalThis.Bun;var i2=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",V0=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n";var q3=(D)=>D.name==="backspace",tD=(D)=>D.name==="tab";var OD=(D)=>D.name==="enter"||D.name==="return";class _3 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class H3 extends Error{name="CancelPromptError";message="Prompt was canceled"}class R0 extends Error{name="ExitPromptError"}class W3 extends Error{name="HookError"}class G3 extends Error{name="ValidationError"}import{AsyncResource as f9}from"async_hooks";import{AsyncLocalStorage as P9,AsyncResource as I9}from"async_hooks";var u6=new P9;function u9(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function f6(D,F){let E=u9(D);return u6.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function eD(){let D=u6.getStore();if(!D)throw new W3("[Inquirer] Hook functions can only be called from within a prompt");return D}function A3(){return eD().rl}function U3(D){let F=(...E)=>{let B=eD(),$=!1,J=B.handleChange;B.handleChange=()=>{$=!0};let X=D(...E);if($)J();return B.handleChange=J,X};return I9.bind(F)}function b2(D){let F=eD(),{index:E}=F,B={get(){return F.hooks[E]},set(J){F.hooks[E]=J},initialized:E in F.hooks},$=D(B);return F.index++,$}function Z6(){eD().handleChange()}var D2={queue(D){let F=eD(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(A3());if(B!=null&&typeof B!=="function")throw new G3("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=eD();U3(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=eD();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function x(D){return b2((F)=>{let E=f9.bind(function(J){if(F.get()!==J)F.set(J),Z6()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function ND(D,F){b2((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((J,X)=>!Object.is(J,B[X])))D2.queue(D);E.set(F)})}var ED=xD(K0(),1);import zD from"process";function v9(){if(zD.platform!=="win32")return zD.env.TERM!=="linux";return Boolean(zD.env.WT_SESSION)||Boolean(zD.env.TERMINUS_SUBLIME)||zD.env.ConEmuTask==="{cmd::Cmder}"||zD.env.TERM_PROGRAM==="Terminus-Sublime"||zD.env.TERM_PROGRAM==="vscode"||zD.env.TERM==="xterm-256color"||zD.env.TERM==="alacritty"||zD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var v6={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},x6={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},x9={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},y9={...v6,...x6},h9={...v6,...x9},g9=v9(),l9=g9?y9:h9,w2=l9,Z$=Object.entries(x6);var y6={prefix:{idle:ED.default.blue("?"),done:ED.default.green(w2.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>ED.default.yellow(D))},style:{answer:ED.default.cyan,message:ED.default.bold,error:(D)=>ED.default.red(`> ${D}`),defaultAnswer:(D)=>ED.default.dim(`(${D})`),help:ED.default.dim,highlight:ED.default.cyan,key:(D)=>ED.default.cyan(ED.default.bold(`<${D}>`))}};function h6(D){if(typeof D!=="object"||D===null)return!1;let F=D;while(Object.getPrototypeOf(F)!==null)F=Object.getPrototypeOf(F);return Object.getPrototypeOf(D)===F}function g6(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let J=F[B];F[B]=h6(J)&&h6($)?g6(J,$):$}return F}function HD(...D){let F=[y6,...D.filter((E)=>E!=null)];return g6(...F)}function SD({status:D="idle",theme:F}){let[E,B]=x(!1),[$,J]=x(0),{prefix:X,spinner:Q}=HD(F);if(ND(()=>{if(D==="loading"){let q,_=-1,H=setTimeout(()=>{B(!0),q=setInterval(()=>{_=_+1,J(_%Q.frames.length)},Q.interval)},300);return()=>{clearTimeout(H),clearInterval(q)}}else B(!1)},[D]),E)return Q.frames[$];return typeof X==="string"?X:X[D==="loading"?"idle":D]??X.idle}function C3(D,F){return b2((E)=>{let B=E.get();if(!B||B.dependencies.length!==F.length||B.dependencies.some(($,J)=>$!==F[J])){let $=D();return E.set({value:$,dependencies:F}),$}return B.value})}function j0(D){return x({current:D})[0]}function TD(D){let F=j0(D);F.current=D,ND((E)=>{let B=!1,$=U3((J,X)=>{if(B)return;F.current(X,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var U1=xD(m6(),1),C1=xD(A1(),1);function a2(D,F){return D.split(`
175
- `).flatMap((E)=>C1.default(E,F,{trim:!1,hard:!0}).split(`
157
+ Last output:`),q.forEach((H)=>console.log(` ${H}`))}}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}async function S3(D,F={}){try{let E=new VD(D,{pollIntervalMs:F.poll||500,paneId:F.pane});E.on("event",($)=>{if(F.json)console.log(JSON.stringify($));else console.log(X1($))}),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: ${$1(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 T3(D,F={}){try{let{paneId:E}=await x2(D,F.pane),B=await p(E,50),$=BD(B);if($.type!=="permission"&&!F.auto){console.log(`\u2139\uFE0F No permission request pending (state: ${$.type})`);return}if(F.deny)await O(`send-keys -t '${E}' Down`),await KD(100);if(await O(`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 VD(D,{pollIntervalMs:250,paneId:F.pane});X.on("permission",async(Q)=>{try{let{paneId:J}=await x2(D,F.pane),Y=F.deny?"n":"y";await QD(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 b3(D,F,E={}){try{let{paneId:B}=await x2(D,E.pane),$=await p(B,50),X=BD($);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 O(`send-keys -t '${B}' End`),await KD(100),await O(`send-keys -t '${B}' Enter`),await KD(100),await O(`send-keys -t '${B}' ${F4(Q)}`),await KD(100),await O(`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=ED($).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 O(`send-keys -t '${B}' Down`),await KD(50);else if(H<0)for(let _=0;_<Math.abs(H);_++)await O(`send-keys -t '${B}' Up`),await KD(50);await KD(100),await O(`send-keys -t '${B}' Enter`),console.log(`\u2705 Selected option ${Q} in session "${D}"`)}else await O(`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 F4(D){return`"${D.replace(/"/g,"\\\"").replace(/\$/g,"\\$")}"`}function KD(D){return new Promise((F)=>setTimeout(F,D))}async function q1(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 $=N3(D),X=[],Q=`orc-experiment-${Date.now()}`,J=await nD(Q);if(!J)console.error("\u274C Failed to create test session"),process.exit(1);try{let Y=await x(J.id),H=(await h(Y[0].id))[0].id;for(let L=0;L<E;L++){console.log(`
161
+ Run ${L+1}/${E}...`),await QD(H,"clear",!1,!1),await new Promise((I)=>setTimeout(I,500));let j=new VD(Q,{pollIntervalMs:100});await j.start(),await QD(H,B,!1,!1);let M=await $.detect(j,30000);if(j.stop(),X.push({run:L+1,latencyMs:M.latencyMs,complete:M.complete,reason:M.reason}),console.log(` Complete: ${M.complete}`),console.log(` Latency: ${M.latencyMs}ms`),console.log(` Reason: ${M.reason}`),L<E-1)await new Promise((I)=>setTimeout(I,1000))}let _=X.filter((L)=>L.complete),G=_.reduce((L,j)=>L+j.latencyMs,0)/_.length||0,U=Math.min(..._.map((L)=>L.latencyMs))||0,z=Math.max(..._.map((L)=>L.latencyMs))||0,R={method:D,totalRuns:E,successfulRuns:_.length,successRate:_.length/E*100,avgLatencyMs:Math.round(G),minLatencyMs:U,maxLatencyMs:z,results:X};if(console.log(`
162
+ --- Summary ---`),F.json)console.log(JSON.stringify(R,null,2));else console.log(`Method: ${R.method}`),console.log(`Success Rate: ${R.successRate.toFixed(1)}%`),console.log(`Avg Latency: ${R.avgLatencyMs}ms`),console.log(`Min Latency: ${R.minLatencyMs}ms`),console.log(`Max Latency: ${R.maxLatencyMs}ms`)}finally{await M0(J.id),console.log(`
163
+ \u2705 Cleaned up test session`)}}async function H1(){console.log("Available completion methods:"),console.log("");for(let D of Object.keys(B0)){let F=B0[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 P3(D,F,E={}){try{let{paneId:B}=await x2(D,E.pane),$=E.timeout||300000;await QD(B,F,!1,!1),console.log(`\u2705 Sent task: "${F.substring(0,50)}${F.length>50?"...":""}"`);let X=new VD(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=BD(_);if(G.type!==J){let U=((Date.now()-Q)/1000).toFixed(1);console.log(`[${U}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 O(`send-keys -t '${B}' Enter`),await KD(200),!1;if(G.type==="question"){if(G.detail==="plan_approval"&&E.autoApprove)return console.log(" \u21B3 Auto-approving plan..."),await O(`send-keys -t '${B}' Enter`),await KD(200),!1;console.log("\u26A0\uFE0F Question requires manual input");let U=M3(_);if(U.length>0)console.log(" Options:"),U.forEach((z,R)=>console.log(` [${R+1}] ${z}`));return!0}if(G.type==="idle"){let U=((Date.now()-Q)/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,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 KD(q)}if(X.stop(),E.json){let _=await p(B,30),G=BD(_);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{$:g3}=globalThis.Bun;import{randomUUID as K4}from"crypto";mD();var{$:A4}=globalThis.Bun;var u3="gt:agent";function jD(){return process.env.TERM_USE_BEADS_REGISTRY!=="false"}async function s(D){try{let F=await A4`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 X0(D){if(!D)return null;try{return JSON.parse(D)}catch{return null}}async function C4(D,F){let E=`Worker: ${D}`,{stdout:B,exitCode:$}=await s(["create",`--title=${E}`,"--type=agent",`--label=${u3}`,`--label=worker:${D}`,"--json"]);if($!==0)throw Error(`Failed to create agent bead: ${B}`);let X=X0(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,claudeSessionId:F.claudeSessionId,startedAt:new Date().toISOString()});return await s(["update",X.id,`--metadata=${Q}`]),X.id}async function k0(D,F){let E=await $2(D);if(E)return E.id;return C4(D,F)}async function $2(D){let{stdout:F,exitCode:E}=await s(["list",`--label=${u3}`,`--label=worker:${D}`,"--json"]);if(E!==0||!F)return null;return X0(F)?.[0]||null}async function Q0(D){let{exitCode:F}=await s(["delete",D]);if(F===0)return!0;let E=await $2(D);if(E)return{exitCode:F}=await s(["delete",E.id]),F===0;return!1}function z4(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 V4(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 DD(D,F){let E=await $2(D);if(!E)throw Error(`Agent not found for worker ${D}`);let B=z4(F),{exitCode:$,stderr:X}=await s(["agent","state",E.id,B]);if($!==0)throw Error(`Failed to set agent state: ${X}`)}async function x3(D){let F=await $2(D);if(!F)return;await s(["agent","heartbeat",F.id])}async function y0(D,F){let E=await $2(D);if(!E)throw Error(`Agent not found for worker ${D}`);let{exitCode:B,stderr:$}=await s(["slot","set",E.id,"hook",F]);if(B!==0)throw Error(`Failed to bind work: ${$}`)}async function J0(D){let F=await $2(D);if(!F)return;await s(["slot","clear",F.id,"hook"])}function G1(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:V4(D.state||"idle"),lastStateChange:new Date().toISOString(),repoPath:F.repoPath,claudeSessionId:F.claudeSessionId}}async function k3(D){let F=await $2(D);if(!F)return null;let{stdout:E,exitCode:B}=await s(["show",F.id,"--json"]);if(B!==0||!E)return null;let $=X0(E);if(!$?.metadata)return null;return G1($,$.metadata)}async function y3(){let{stdout:D,exitCode:F}=await s(["list",`--label=${u3}`,"--json"]);if(F!==0||!D)return[];let E=X0(D);if(!E)return[];let B=[];for(let $ of E)if($.metadata)B.push(G1($,$.metadata));return B}async function W1(D){let F=await y3(),E=D.startsWith("%")?D:`%${D}`;return F.find((B)=>B.paneId===E)||null}async function cD(D){return k3(D)}async function pD(){let{stdout:D,exitCode:F}=await s(["daemon","status","--json"]);if(F!==0)return{running:!1};return X0(D)||{running:!1}}async function Y0(D){let F=["daemon","start"];if(D?.autoCommit)F.push("--auto-commit");if(D?.autoPush)F.push("--auto-push");let{exitCode:E}=await s(F);return E===0}async function h3(){let{exitCode:D}=await s(["daemon","stop"]);return D===0}async function h0(D){let{exitCode:F}=await s(["worktree","remove",D]);return F===0}async function U1(D){await J0(D),await Q0(D)}async function g0(D,F){await DD(D,F),await x3(D)}import{join as X2}from"path";var dD=jD(),R4=".genie/worktrees";async function l3(D){try{return{stdout:(await g3`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function V1(D){let{stdout:F,exitCode:E}=await l3(["show",D,"--json"]);if(E!==0||!F)return null;try{let B=JSON.parse(F),$=Array.isArray(B)?B[0]:B;if(!$)return null;return{id:$.id,title:$.title||$.description?.substring(0,50)||"Untitled",status:$.status,description:$.description,blockedBy:$.blockedBy||[]}}catch{return null}}async function L4(){let{stdout:D,exitCode:F}=await l3(["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,description:B.description,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 V1(B[1])}return null}}async function j4(D){let{exitCode:F}=await l3(["update",D,"--status","in_progress"]);return F===0}async function A1(){try{return(await O("display-message -p '#{session_name}'")).trim()||null}catch{return null}}async function M4(D,F){let E=await import("fs/promises"),B=X2(F,R4),$=X2(B,D);try{await E.mkdir(B,{recursive:!0})}catch{}try{if((await E.stat($)).isDirectory())return console.log(`\u2139\uFE0F Worktree for ${D} already exists`),$}catch{}let X=`work/${D}`;try{try{await g3`git -C ${F} branch ${X}`.quiet()}catch{}await g3`git -C ${F} worktree add ${$} ${X}`.quiet();let Q=X2($,".genie");return await E.mkdir(Q,{recursive:!0}),await E.writeFile(X2(Q,"redirect"),X2(F,".genie")),$}catch(Q){return console.error(`\u26A0\uFE0F Failed to create worktree: ${Q.message}`),null}}async function C1(D,F){try{let E=await v(D);if(!E)return console.error(`\u274C Session "${D}" not found`),null;let B=await x(E.id);if(!B||B.length===0)return console.error(`\u274C No windows in session "${D}"`),null;let $=B.find((Y)=>Y.active)||B[0],X=await h($.id);if(!X||X.length===0)return console.error(`\u274C No panes in window "${$.name}"`),null;let Q=X.find((Y)=>Y.active)||X[0],J=await U2(Q.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 z1(D,F,E){let B=new VD(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(dD)await g0(D,X);await PD(D,X)}catch{}}),B.on("poll_error",()=>{if(dD)U1(D).catch(()=>{});B2(D).catch(()=>{}),B.stop()}),B.start().catch(()=>{})}async function K1(D,F={}){try{let E=process.cwd();if(dD){if(!(await pD()).running)if(console.log("\uD83D\uDD04 Starting beads daemon for auto-sync..."),await Y0({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 L4(),!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 V1(D),!B)console.error(`\u274C Issue "${D}" not found. Run \`bd list\` to see issues.`),process.exit(1);let $=B.id,X=dD?await cD($):null;if(!X)X=await LD($);if(X){if(X.claudeSessionId&&F.resume!==!1){console.log(`\uD83D\uDCCB Found existing worker for ${$} with resumable session`),console.log(` Session ID: ${X.claudeSessionId}`),console.log(" Resuming previous Claude session...");let M=F.session||await A1();if(!M)console.error("\u274C Not in a tmux session. Attach to a session first or use --session."),process.exit(1);let I=X.worktree||X.repoPath;console.log("\uD83D\uDE80 Spawning worker pane...");let m=await C1(M,I);if(!m)process.exit(1);let{paneId:d}=m;if(await w3(X.id,{paneId:d,session:M,state:"spawning",lastStateChange:new Date().toISOString()}),dD)await DD(X.id,"spawning").catch(()=>{});let n=X2(X.repoPath,".genie"),C0=I.replace(/'/g,"'\\''");if(await QD(d,`cd '${C0}' && BEADS_DIR='${n}' claude --resume '${X.claudeSessionId}'`,!0,!1),dD)await DD(X.id,"working").catch(()=>{});if(await PD(X.id,"working"),z1(X.id,M,d),F.focus===!0)await O(`select-pane -t '${d}'`);console.log(`
165
+ \u2705 Resumed worker for ${$}`),console.log(` Pane: ${d}`),console.log(` Session: ${M}`),console.log(` Claude Session: ${X.claudeSessionId}`),console.log(`
166
+ 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`);return}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 A1();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 j4($))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 M4($,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 C1(Q,Y);if(!H)process.exit(1);let{paneId:_}=H,G=K4(),U={id:$,paneId:_,session:Q,worktree:q,taskId:$,taskTitle:B.title,startedAt:new Date().toISOString(),state:"spawning",lastStateChange:new Date().toISOString(),repoPath:E,claudeSessionId:G};if(dD)try{let M=await k0($,{paneId:_,session:Q,worktree:q,repoPath:E,taskId:$,taskTitle:B.title,claudeSessionId:G});await y0($,$),await DD($,"spawning")}catch(M){console.log(`\u26A0\uFE0F Beads registration failed: ${M.message} (non-fatal)`)}await $0(U);let R=(F.prompt||`Work on beads issue ${$}: "${B.title}"
167
+
168
+ ## Description
169
+ ${B.description||"No description provided."}
170
+
171
+ When you're done, commit your changes and let me know.`).replace(/'/g,"'\\''"),L=X2(E,".genie"),j=Y.replace(/'/g,"'\\''");if(await QD(_,`cd '${j}' && BEADS_DIR='${L}' claude --session-id '${G}' '${R}'`,!0,!1),console.log(` Session ID: ${G}`),dD)await DD($,"working").catch(()=>{});if(await PD($,"working"),z1($,Q,_),F.focus===!0)await O(`select-pane -t '${_}'`);if(console.log(`
172
+ \u2705 Worker started for ${$}`),console.log(` Pane: ${_}`),console.log(` Session: ${Q}`),q)console.log(` Worktree: ${q}`);console.log(`
173
+ 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{$:R1}=globalThis.Bun;mD();var m3=jD();async function N4(D){try{return await p(D,1),!0}catch{return!1}}async function S4(D){try{let F=await p(D,30),E=BD(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 T4(){let D=[],F=[];try{let B=(await R1`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(`
174
+ `).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 R1`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 b4(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 L1(D={}){try{let F=[];if(m3)try{F=await y3()}catch{F=await RD()}else F=await RD();let E=await RD(),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 N4(q.paneId),_=q.state;if(H){_=await S4(q.paneId);let G=P4(_);if(G&&G!==q.state){if(m3)await g0(q.id,G).catch(()=>{});await PD(q.id,G)}else if(m3)await x3(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:b4(q.startedAt),alive:H})}let X=await T4(),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),U=q.state.padEnd(8).substring(0,8),z=q.time.padStart(4).substring(0,4);console.log(`\u2502 ${H} \u2502 ${_} \u2502 ${G} \u2502 ${U} \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(`
175
+ 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(`
176
+ Ready: (none - all assigned or blocked)`);let Y=$.filter((q)=>!q.alive);if(Y.length>0)console.log(`
177
+ \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 P4(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{$:U0}=globalThis.Bun;var q0=(D,F=[])=>D.name==="up"||F.includes("vim")&&D.name==="k"||F.includes("emacs")&&D.ctrl&&D.name==="p",l0=(D,F=[])=>D.name==="down"||F.includes("vim")&&D.name==="j"||F.includes("emacs")&&D.ctrl&&D.name==="n";var c3=(D)=>D.name==="backspace",Q2=(D)=>D.name==="tab";var fD=(D)=>D.name==="enter"||D.name==="return";class p3 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class d3 extends Error{name="CancelPromptError";message="Prompt was canceled"}class m0 extends Error{name="ExitPromptError"}class i3 extends Error{name="HookError"}class n3 extends Error{name="ValidationError"}import{AsyncResource as v4}from"async_hooks";import{AsyncLocalStorage as Z4,AsyncResource as I4}from"async_hooks";var j1=new Z4;function w4(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function M1(D,F){let E=w4(D);return j1.run(E,()=>{function B($){E.handleChange=()=>{E.index=0,$()},E.handleChange()}return F(B)})}function J2(){let D=j1.getStore();if(!D)throw new i3("[Inquirer] Hook functions can only be called from within a prompt");return D}function r3(){return J2().rl}function a3(D){let F=(...E)=>{let B=J2(),$=!1,X=B.handleChange;B.handleChange=()=>{$=!0};let Q=D(...E);if($)X();return B.handleChange=X,Q};return I4.bind(F)}function h2(D){let F=J2(),{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 O1(){J2().handleChange()}var Y2={queue(D){let F=J2(),{index:E}=F;F.hooksEffect.push(()=>{F.hooksCleanup[E]?.();let B=D(r3());if(B!=null&&typeof B!=="function")throw new n3("useEffect return value must be a cleanup function or nothing.");F.hooksCleanup[E]=B})},run(){let D=J2();a3(()=>{D.hooksEffect.forEach((F)=>{F()}),D.hooksEffect.length=0})()},clearAll(){let D=J2();D.hooksCleanup.forEach((F)=>{F?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function y(D){return h2((F)=>{let E=v4.bind(function(X){if(F.get()!==X)F.set(X),O1()});if(F.initialized)return[F.get(),E];let B=typeof D==="function"?D():D;return F.set(B),[B,E]})}function ZD(D,F){h2((E)=>{let B=E.get();if(!Array.isArray(B)||F.some((X,Q)=>!Object.is(X,B[Q])))Y2.queue(D);E.set(F)})}var $D=iD(c0(),1);import MD from"process";function k4(){if(MD.platform!=="win32")return MD.env.TERM!=="linux";return Boolean(MD.env.WT_SESSION)||Boolean(MD.env.TERMINUS_SUBLIME)||MD.env.ConEmuTask==="{cmd::Cmder}"||MD.env.TERM_PROGRAM==="Terminus-Sublime"||MD.env.TERM_PROGRAM==="vscode"||MD.env.TERM==="xterm-256color"||MD.env.TERM==="alacritty"||MD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var S1={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"},T1={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"},y4={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"},h4={...S1,...T1},g4={...S1,...y4},l4=k4(),m4=l4?h4:g4,g2=m4,oX=Object.entries(T1);var b1={prefix:{idle:$D.default.blue("?"),done:$D.default.green(g2.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map((D)=>$D.default.yellow(D))},style:{answer:$D.default.cyan,message:$D.default.bold,error:(D)=>$D.default.red(`> ${D}`),defaultAnswer:(D)=>$D.default.dim(`(${D})`),help:$D.default.dim,highlight:$D.default.cyan,key:(D)=>$D.default.cyan($D.default.bold(`<${D}>`))}};function P1(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 f1(...D){let F={};for(let E of D)for(let[B,$]of Object.entries(E)){let X=F[B];F[B]=P1(X)&&P1($)?f1(X,$):$}return F}function UD(...D){let F=[b1,...D.filter((E)=>E!=null)];return f1(...F)}function ID({status:D="idle",theme:F}){let[E,B]=y(!1),[$,X]=y(0),{prefix:Q,spinner:J}=UD(F);if(ZD(()=>{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 o3(D,F){return h2((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 p0(D){return y({current:D})[0]}function wD(D){let F=p0(D);F.current=D,ZD((E)=>{let B=!1,$=a3((X,Q)=>{if(B)return;F.current(Q,E)});return E.input.on("keypress",$),()=>{B=!0,E.input.removeListener("keypress",$)}},[])}var XF=iD(I1(),1),QF=iD($F(),1);function G0(D,F){return D.split(`
178
+ `).flatMap((E)=>QF.default(E,F,{trim:!1,hard:!0}).split(`
176
179
  `).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)
180
+ `)}function n0(){return XF.default({defaultWidth:80,output:r3().output})}function HE({active:D,renderedItems:F,pageSize:E,loop:B}){let $=p0({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,U)=>G+U.length,0);H=_<E-J?E-_:Math.min(q,J)}return $.current.lastPointer=H,$.current.lastActive=D,H}function X8({items:D,active:F,renderItem:E,pageSize:B,loop:$=!0}){let X=n0(),Q=(j)=>(j%D.length+D.length)%D.length,J=D.map((j,M)=>{if(j==null)return[];return G0(E({item:j,index:M,isActive:M===F}),X).split(`
181
+ `)}),Y=J.reduce((j,M)=>j+M.length,0),q=(j)=>J[j]??[],H=HE({active:F,renderedItems:J,pageSize:B,loop:$}),_=q(F).slice(0,B),G=H+_.length<=B?H:B-_.length,U=Array.from({length:B});U.splice(G,_.length,..._);let z=new Set([F]),R=G+_.length,L=Q(F+1);while(R<B&&!z.has(L)&&($&&Y>B?L!==F:L>F)){let M=q(L).slice(0,B-R);U.splice(R,M.length,...M),z.add(L),R+=M.length,L=Q(L+1)}R=G-1,L=Q(F-1);while(R>=0&&!z.has(L)&&($&&Y>B?L!==F:L<F)){let j=q(L),M=j.slice(Math.max(0,j.length-R-1));U.splice(R-M.length+1,M.length,...M),z.add(L),R-=M.length,L=Q(L-1)}return U.filter((j)=>typeof j==="string").join(`
182
+ `)}var KF=iD(qF(),1);import*as VF from"readline";import{AsyncResource as zE}from"async_hooks";var q2=[];q2.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")q2.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")q2.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var r0=(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",Q8=Symbol.for("signal-exit emitter"),J8=globalThis,GE=Object.defineProperty.bind(Object);class HF{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(J8[Q8])return J8[Q8];GE(J8,Q8,{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 q8{}var WE=(D)=>{return{onExit(F,E){return D.onExit(F,E)},load(){return D.load()},unload(){return D.unload()}}};class _F extends q8{onExit(){return()=>{}}load(){}unload(){}}class GF extends q8{#E=Y8.platform==="win32"?"SIGINT":"SIGHUP";#F=new HF;#D;#X;#Q;#$={};#B=!1;constructor(D){super();this.#D=D,this.#$={};for(let F of q2)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(!r0(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 q2)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,q2.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(!r0(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"&&r0(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 Y8=globalThis.process,{onExit:WF,load:vQ,unload:uQ}=WE(r0(Y8)?new GF(Y8):new _F);import{stripVTControlCharacters as AE}from"util";var UE="\x1B[G",AF="\x1B[?25l",CF="\x1B[?25h",H8=(D=1)=>D>0?`\x1B[${D}A`:"",_8=(D=1)=>D>0?`\x1B[${D}B`:"",G8=(D,F)=>{if(typeof F==="number"&&!Number.isNaN(F))return`\x1B[${F+1};${D+1}H`;return`\x1B[${D+1}G`},UF="\x1B[2K",W8=(D)=>D>0?(UF+H8(1)).repeat(D-1)+UF+UE:"";var zF=(D)=>D.split(`
183
+ `).length,CE=(D)=>D.split(`
184
+ `).pop()??"";class a0{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=CE(D),B=AE(E),$=B;if(this.rl.line.length>0)$=$.slice(0,-this.rl.line.length);this.rl.setPrompt($),this.cursorPos=this.rl.getCursorPos();let X=n0();if(D=G0(D,X),F=G0(F,X),B.length%X===0)D+=`
185
+ `;let Q=D+(F?`
186
+ `+F:""),Y=Math.floor(B.length/X)-this.cursorPos.rows+(F?zF(F):0);if(Y>0)Q+=H8(Y);Q+=G8(this.cursorPos.cols),this.write(_8(this.extraLinesUnderPrompt)+W8(this.height)+Q),this.extraLinesUnderPrompt=Y,this.height=zF(Q)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(G8(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let F=_8(this.extraLinesUnderPrompt);F+=D?W8(this.height):`
187
+ `,F+=CF,this.write(F),this.rl.close()}}class U8 extends Promise{static withResolver(){let D,F;return{promise:new Promise((B,$)=>{D=B,F=$}),resolve:D,reject:F}}}function VE(){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 vD(D){let F=VE();return(B,$={})=>{let{input:X=process.stdin,signal:Q}=$,J=new Set,Y=new KF.default;Y.pipe($.output??process.stdout);let q=VF.createInterface({terminal:!0,input:X,output:Y}),H=new a0(q),{promise:_,resolve:G,reject:U}=U8.withResolver(),z=()=>U(new d3);if(Q){let j=()=>U(new p3({cause:Q.reason}));if(Q.aborted)return j(),Object.assign(_,{cancel:z});Q.addEventListener("abort",j),J.add(()=>Q.removeEventListener("abort",j))}J.add(WF((j,M)=>{U(new m0(`User force closed the prompt with ${j} ${M}`))}));let R=()=>U(new m0("User force closed the prompt with SIGINT"));q.on("SIGINT",R),J.add(()=>q.removeListener("SIGINT",R));let L=()=>H.checkCursorPos();return q.input.on("keypress",L),J.add(()=>q.input.removeListener("keypress",L)),M1(q,(j)=>{let M=zE.bind(()=>Y2.clearAll());return q.on("close",M),J.add(()=>q.removeListener("close",M)),j(()=>{try{let I=D(B,(n)=>{setImmediate(()=>G(n))});if(I===void 0){let n=F[1]?.getFileName();throw Error(`Prompt functions must return a string.
188
+ at ${n}`)}let[m,d]=typeof I==="string"?[I]:I;H.render(m,d),Y2.run()}catch(I){U(I)}}),Object.assign(_.then((I)=>{return Y2.clearAll(),I},(I)=>{throw Y2.clearAll(),I}).finally(()=>{J.forEach((I)=>I()),H.done({clearContent:Boolean($.clearPromptOnDone)}),Y.end()}).then(()=>_),{cancel:z})})}}var RF=iD(c0(),1);class p2{separator=RF.default.dim(Array.from({length:15}).join(g2.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 LF(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 jF(D){return D?"Yes":"No"}var W0=vD((D,F)=>{let{transformer:E=jF}=D,[B,$]=y("idle"),[X,Q]=y(""),J=UD(D.theme),Y=ID({status:B,theme:J});wD((G,U)=>{if(B!=="idle")return;if(fD(G)){let z=LF(X,D.default);Q(E(z)),$("done"),F(z)}else if(Q2(G)){let z=jF(!LF(X,D.default));U.clearLine(0),U.write(z),Q(z)}else Q(U.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 KE={validationFailureMode:"keep"},RE=vD((D,F)=>{let{prefill:E="tab"}=D,B=UD(KE,D.theme),[$,X]=y("idle"),[Q="",J]=y(D.default),[Y,q]=y(),[H,_]=y(""),G=ID({status:$,theme:B});async function U(M){let{required:I,pattern:m,patternError:d="Invalid input"}=D;if(I&&!M)return"You must provide a value";if(m&&!m.test(M))return d;if(typeof D.validate==="function")return await D.validate(M)||"You must provide a valid value";return!0}wD(async(M,I)=>{if($!=="idle")return;if(fD(M)){let m=H||Q;X("loading");let d=await U(m);if(d===!0)_(m),X("done"),F(m);else{if(B.validationFailureMode==="clear")_("");else I.write(H);q(d),X("idle")}}else if(c3(M)&&!H)J(void 0);else if(Q2(M)&&!H)J(void 0),I.clearLine(0),I.write(Q),_(Q);else _(I.line),q(void 0)}),ZD((M)=>{if(E==="editable"&&Q)M.write(Q),_(Q)},[]);let z=B.style.message(D.message,$),R=H;if(typeof D.transformer==="function")R=D.transformer(H,{isFinal:$==="done"});else if($==="done")R=B.style.answer(H);let L;if(Q&&$!=="done"&&!H)L=B.style.defaultAnswer(Q);let j="";if(Y)j=B.style.error(Y);return[[G,z,L,R].filter((M)=>M!==void 0).join(" "),j]});var LE=vD((D,F)=>{let{validate:E=()=>!0}=D,B=UD(D.theme),[$,X]=y("idle"),[Q,J]=y(),[Y,q]=y(""),H=ID({status:$,theme:B});wD(async(R,L)=>{if($!=="idle")return;if(fD(R)){let j=Y;X("loading");let M=await E(j);if(M===!0)q(j),X("done"),F(j);else L.write(Y),J(M||"You must provide a valid value"),X("idle")}else q(L.line),J(void 0)});let _=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]")}${AF}`;if($==="done")G=B.style.answer(G);let z="";if(Q)z=B.style.error(Q);return[[H,_,D.mask?G:U].join(" "),z]});var H2=iD(c0(),1);var jE={icon:{cursor:g2.pointer},style:{disabled:(D)=>H2.default.dim(`- ${D}`),searchTerm:(D)=>H2.default.cyan(D),description:(D)=>H2.default.cyan(D),keysHelpTip:(D)=>D.map(([F,E])=>`${H2.default.bold(F)} ${H2.default.dim(E)}`).join(H2.default.dim(" \u2022 "))},helpMode:"always"};function A8(D){return!p2.isSeparator(D)&&!D.disabled}function ME(D){return D.map((F)=>{if(p2.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 C8=vD((D,F)=>{let{pageSize:E=7,validate:B=()=>!0}=D,$=UD(jE,D.theme),[X,Q]=y("loading"),[J,Y]=y(""),[q,H]=y([]),[_,G]=y(),U=ID({status:X,theme:$}),z=o3(()=>{let k=q.findIndex(A8),t=q.findLastIndex(A8);return{first:k,last:t}},[q]),[R=z.first,L]=y();ZD(()=>{let k=new AbortController;return Q("loading"),G(void 0),(async()=>{try{let XD=await D.source(J||void 0,{signal:k.signal});if(!k.signal.aborted)L(void 0),G(void 0),H(ME(XD)),Q("idle")}catch(XD){if(!k.signal.aborted&&XD instanceof Error)G(XD.message)}})(),()=>{k.abort()}},[J]);let j=q[R];wD(async(k,t)=>{if(fD(k))if(j){Q("loading");let XD=await B(j.value);if(Q("idle"),XD===!0)Q("done"),F(j.value);else if(j.name===J)G(XD||"You must provide a valid value");else t.write(j.name),Y(j.name)}else t.write(J);else if(Q2(k)&&j)t.clearLine(0),t.write(j.name),Y(j.name);else if(X!=="loading"&&(q0(k)||l0(k))){if(t.clearLine(0),q0(k)&&R!==z.first||l0(k)&&R!==z.last){let XD=q0(k)?-1:1,G2=R;do G2=(G2+XD+q.length)%q.length;while(!A8(q[G2]));L(G2)}}else Y(t.line)});let M=$.style.message(D.message,X),I;if($.helpMode!=="never")if(D.instructions){let{pager:k,navigation:t}=D.instructions;I=$.style.help(q.length>E?k:t)}else I=$.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]);let m=X8({items:q,active:R,renderItem({item:k,isActive:t}){if(p2.isSeparator(k))return` ${k.separator}`;if(k.disabled){let e0=typeof k.disabled==="string"?k.disabled:"(disabled)";return $.style.disabled(`${k.name} ${e0}`)}let XD=t?$.style.highlight:(e0)=>e0,G2=t?$.icon.cursor:" ";return XD(`${G2} ${k.name}`)},pageSize:E,loop:!1}),d;if(_)d=$.style.error(_);else if(q.length===0&&J!==""&&X==="idle")d=$.style.error("No results found");let n;if(X==="done"&&j)return[U,M,$.style.answer(j.short)].filter(Boolean).join(" ").trimEnd();else n=$.style.searchTerm(J);let C0=j?.description,yF=[U,M,n].filter(Boolean).join(" ").trimEnd(),hF=[d??m," ",C0?$.style.description(C0):"",I].filter(Boolean).join(`
189
+ `).trimEnd();return[yF,hF]});mD();import{join as MF}from"path";import{homedir as OE}from"os";var z8=jD(),NE=MF(OE(),".local","share","term","worktrees"),SE=".genie/worktrees";async function OF(D){try{return{stdout:(await U0`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function TE(D){let{exitCode:F}=await OF(["close",D]);return F===0}async function bE(){let{exitCode:D}=await OF(["sync"]);return D===0}async function PE(D,F){try{let B=(await U0`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 U0`git -C ${D} checkout ${B}`.quiet(),console.log(` Merging ${F}...`),await U0`git -C ${D} merge ${F} --no-edit`.quiet(),!0}catch(E){return console.error(`\u26A0\uFE0F Merge failed: ${E.message}`),!1}}async function fE(D,F){let E=MF(F,SE,D);try{return await U0`git -C ${F} worktree remove ${E} --force`.quiet(),!0}catch{}if(z8)try{if(await h0(D))return!0}catch{}try{let B=new C2({baseDir:NE,repoPath:F});if(await B.worktreeExists(D))return await B.removeWorktree(D),!0;return!0}catch(B){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${B.message}`),!1}}async function ZE(D){try{return await W2(D),!0}catch{return!1}}async function NF(D,F={}){try{let E=z8?await cD(D):null;if(!E)E=await LD(D);if(!E)console.log(`\u2139\uFE0F No active worker for ${D}. Closing issue only.`);if(!F.yes){if(!await W0({message:`Close ${D}${E?` and kill worker (pane ${E.paneId})`:""}?`,default:!0})){console.log("Cancelled.");return}}if(console.log(`\uD83D\uDCDD Closing ${D}...`),!await TE(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 bE())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 PE(E.repoPath,D))console.log(" \u2705 Merged to main")}if(console.log("\uD83C\uDF33 Removing worktree..."),await fE(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"),z8)try{await J0(E.id),await DD(E.id,"done"),await Q0(E.id)}catch{}await B2(E.id),console.log(" \u2705 Worker unregistered")}console.log(`
190
+ \u2705 ${D} closed successfully`)}catch(E){console.error(`\u274C Error: ${E.message}`),process.exit(1)}}var{$:wE}=globalThis.Bun;mD();import{join as SF}from"path";import{homedir as vE}from"os";var A0=jD(),uE=SF(vE(),".local","share","term","worktrees"),xE=".genie/worktrees";async function kE(D){try{return await W2(D),!0}catch{return!1}}async function yE(D,F){let E=SF(F,xE,D);try{return await wE`git -C ${F} worktree remove ${E} --force`.quiet(),!0}catch{}if(A0)try{if(await h0(D))return!0}catch{}try{let B=new C2({baseDir:uE,repoPath:F});if(await B.worktreeExists(D))return await B.removeWorktree(D),!0;return!0}catch(B){return console.error(`\u26A0\uFE0F Failed to remove worktree: ${B.message}`),!1}}async function TF(D,F={}){try{let E=await I3(D);if(!E&&A0)E=await k3(D);if(!E)E=await v3(D);if(!E&&A0)E=await W1(D);if(!E)E=await LD(D);if(!E&&A0)E=await cD(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 W0({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 kE(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 yE(E.taskId,E.repoPath))console.log(" \u2705 Worktree removed")}if(A0)try{await J0(E.id),await DD(E.id,"error"),await Q0(E.id)}catch{}await B2(E.id),console.log(" \u2705 Worker unregistered"),console.log(`
191
+ \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 bF(D={}){try{let F=await pD();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 Y0({autoCommit:D.autoCommit!==!1,autoPush:D.autoPush})){console.log(" \u2705 Daemon started");let B=await pD();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 PF(){try{if(!(await pD()).running){console.log("\u2139\uFE0F Daemon is not running");return}if(console.log("\uD83D\uDED1 Stopping beads daemon..."),await h3())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 fF(D={}){try{let F=await pD();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 ZF(D={}){try{if((await pD()).running)console.log("\uD83D\uDED1 Stopping beads daemon..."),await h3(),console.log(" \u2705 Stopped");if(console.log("\uD83D\uDE80 Starting beads daemon..."),await Y0({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{$:R8}=globalThis.Bun;import{randomUUID as dE}from"crypto";import{join as d2}from"path";mD();import{access as lE,readFile as V8}from"fs/promises";import{join as _2}from"path";import{homedir as IF}from"os";function mE(D){return[D,`genie-${D}`]}async function wF(D){try{return await lE(D),!0}catch{return!1}}async function o0(D,F){let E=mE(D),B=F||process.cwd(),$=[_2(B,".claude","skills"),_2(IF(),".claude","skills")];for(let X of $)for(let Q of E){let J=_2(X,Q),Y=_2(J,"SKILL.md");if(await wF(Y)){let q;try{let _=(await V8(Y,"utf-8")).match(/^---\n([\s\S]*?)\n---/);if(_){let G=_[1].match(/description:\s*["']?([^"'\n]+)["']?/);if(G)q=G[1]}}catch{}return{name:D,path:J,skillFile:Y,description:q}}}return null}async function vF(D,F){let E=await V8(D.skillFile,"utf-8"),B=[`You are running skill: ${D.name}`,"","## Skill Instructions","",E];if(F)B.push("","---","","## Additional Context","",F);return B.join(`
192
+ `)}async function cE(D,F){try{let B=(await V8(D,"utf-8")).match(/^---\n([\s\S]*?)\n---/);if(B){let $=B[1].match(/name:\s*["']?([^"'\n]+)["']?/);if($)return $[1].trim()}}catch{}return F.replace(/-/,":")}async function s0(D){let{readdir:F}=await import("fs/promises"),E=D||process.cwd(),B=[],$=[_2(E,".claude","skills"),_2(IF(),".claude","skills")];for(let X of $)try{let Q=await F(X,{withFileTypes:!0});for(let J of Q)if(J.isDirectory()){let Y=_2(X,J.name,"SKILL.md");if(await wF(Y)){let q=await cE(Y,J.name);if(!B.includes(q))B.push(q)}}}catch{}return B.sort()}var K8=jD(),iE=".genie/worktrees";async function nE(D){let F=await s0(D);if(F.length===0)return console.log("No skills found in .claude/skills/ or ~/.claude/skills/"),null;let E=[];for(let $ of F){let X=await o0($,D);if(X)E.push({name:$,info:X})}return await C8({message:"Select skill:",source:async($)=>{let X=($||"").toLowerCase();return E.filter((Q)=>Q.name.toLowerCase().includes(X)||(Q.info.description?.toLowerCase().includes(X)??!1)).map((Q)=>({name:Q.info.description?`${Q.name} - ${Q.info.description.substring(0,60)}${Q.info.description.length>60?"...":""}`:Q.name,value:Q.info}))}})}async function rE(D){try{return{stdout:(await R8`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||"",exitCode:F.exitCode||1}}}async function aE(D){let{stdout:F,exitCode:E}=await rE(["show",D,"--json"]);if(E!==0||!F)return null;try{let B=JSON.parse(F),$=Array.isArray(B)?B[0]:B;if(!$)return null;return{id:$.id,title:$.title||$.description?.substring(0,50)||"Untitled",description:$.description}}catch{return null}}async function oE(){try{return(await O("display-message -p '#{session_name}'")).trim()||null}catch{return null}}async function sE(D,F){let E=await import("fs/promises"),B=d2(F,iE),$=d2(B,D);try{await E.mkdir(B,{recursive:!0})}catch{}try{if((await E.stat($)).isDirectory())return console.log(` Worktree for ${D} already exists`),$}catch{}let X=`work/${D}`;try{try{await R8`git -C ${F} branch ${X}`.quiet()}catch{}await R8`git -C ${F} worktree add ${$} ${X}`.quiet();let Q=d2($,".genie");return await E.mkdir(Q,{recursive:!0}),await E.writeFile(d2(Q,"redirect"),d2(F,".genie")),$}catch(Q){return console.error(` Failed to create worktree: ${Q.message}`),null}}async function tE(D,F){try{let E=await v(D);if(!E)return console.error(`Session "${D}" not found`),null;let B=await x(E.id);if(!B||B.length===0)return console.error(`No windows in session "${D}"`),null;let $=B.find((Y)=>Y.active)||B[0],X=await h($.id);if(!X||X.length===0)return console.error(`No panes in window "${$.name}"`),null;let Q=X.find((Y)=>Y.active)||X[0],J=await U2(Q.id,"horizontal",50,F);if(!J)return console.error("Failed to create new pane"),null;return{paneId:J.id}}catch(E){return console.error(`Error spawning worker pane: ${E.message}`),null}}async function L8(D,F={}){let E=process.cwd(),B;if(!D){if(B=await nE(E),!B)process.exit(1)}else if(B=await o0(D,E),!B){let L=await s0(E);if(console.error(`Skill "${D}" not found.`),L.length>0){console.log(`
193
+ Available skills:`);for(let j of L)console.log(` - ${j}`)}else console.log(`
194
+ No skills found in .claude/skills/ or ~/.claude/skills/`);process.exit(1)}if(console.log(`Skill: ${B.name}`),B.description)console.log(` ${B.description}`);let $=F.session||await oE();if(!$)console.error("Not in a tmux session. Attach to a session first or use --session."),process.exit(1);let X=E,Q=null,J=null;if(F.taskId){if(J=await aE(F.taskId),!J)console.error(`Issue "${F.taskId}" not found. Run \`bd list\` to see issues.`),process.exit(1);let L=K8?await cD(F.taskId):await LD(F.taskId);if(L)console.error(`${F.taskId} already has a worker (pane ${L.paneId})`),console.log(` Run \`term kill ${L.id}\` first.`),process.exit(1);if(!F.noWorktree){if(console.log(`Creating worktree for ${F.taskId}...`),Q=await sE(F.taskId,E),Q)X=Q,console.log(` Created: ${Q}`)}}console.log("Spawning Claude pane...");let Y=await tE($,X);if(!Y)process.exit(1);let{paneId:q}=Y,H=await vF(B,F.prompt);if(J){if(H+=`
195
+
196
+ ---
197
+
198
+ Bound to beads issue ${J.id}: "${J.title}"`,J.description)H+=`
199
+
200
+ ${J.description}`}let _=F.taskId?dE():void 0;if(F.taskId&&J){let L={id:F.taskId,paneId:q,session:$,worktree:Q,taskId:F.taskId,taskTitle:J.title,startedAt:new Date().toISOString(),state:"spawning",lastStateChange:new Date().toISOString(),repoPath:E,claudeSessionId:_};if(K8)try{await k0(F.taskId,{paneId:q,session:$,worktree:Q,repoPath:E,taskId:F.taskId,taskTitle:J.title,claudeSessionId:_}),await y0(F.taskId,F.taskId),await DD(F.taskId,"spawning")}catch(j){console.log(` Beads registration failed: ${j.message} (non-fatal)`)}await $0(L)}let G=H.replace(/'/g,"'\\''"),U=d2(E,".genie"),z=X.replace(/'/g,"'\\''"),R=_?`--session-id '${_}' `:"";if(await QD(q,`cd '${z}' && BEADS_DIR='${U}' claude ${R}'${G}'`,!0,!1),F.taskId){if(K8)await DD(F.taskId,"working").catch(()=>{});await PD(F.taskId,"working")}if(F.focus!==!1)await O(`select-pane -t '${q}'`);if(console.log(`
201
+ Spawned Claude with skill: ${D}`),console.log(` Pane: ${q}`),console.log(` Session: ${$}`),Q)console.log(` Worktree: ${Q}`);if(F.taskId){if(console.log(` Task: ${F.taskId}`),_)console.log(` Claude Session: ${_}`);console.log(`
202
+ Commands:`),console.log(" term workers - Check worker status"),console.log(` term approve ${F.taskId} - Approve permissions`),console.log(` term close ${F.taskId} - Close issue when done`)}}async function uF(){let D=await s0();if(D.length===0){console.log("No skills found in .claude/skills/ or ~/.claude/skills/");return}console.log(`Available skills:
203
+ `);for(let F of D){let E=await o0(F);if(E?.description)console.log(` ${F}`),console.log(` ${E.description}
204
+ `);else console.log(` ${F}`)}}var{$:DB}=globalThis.Bun;async function j8(D){try{return{stdout:(await DB`bd ${D}`.quiet()).stdout.toString().trim(),exitCode:0}}catch(F){return{stdout:F.stdout?.toString().trim()||F.message,exitCode:F.exitCode||1}}}async function xF(D,F={}){let E=["create",D];if(F.description)E.push("--description",F.description);let{stdout:B,exitCode:$}=await j8(E);if($!==0)console.error(`Failed to create issue: ${B}`),process.exit(1);let X=B.match(/bd-\d+/),Q=X?X[0]:null;if(!Q){console.log(B);return}if(F.parent){let{exitCode:J}=await j8(["update",Q,"--blocked-by",F.parent]);if(J!==0)console.log(`Created ${Q} (failed to set parent dependency)`)}if(F.json){let{stdout:J}=await j8(["show",Q,"--json"]);console.log(J)}else{if(console.log(`Created: ${Q} - "${D}"`),F.parent)console.log(` Blocked by: ${F.parent}`);console.log(`
205
+ Next steps:`),console.log(` term work ${Q} - Start working on it`),console.log(` term spawn genie:wish -t ${Q} - Plan with wish skill`),console.log(` bd show ${Q} - View details`)}}var u=new l8;u.name("term").description(`AI-friendly terminal orchestration (tmux wrapper)
189
206
 
190
207
  Collaborative Usage:
191
208
  AI runs: term exec genie:shell '<command>'
@@ -195,9 +212,16 @@ Collaborative Usage:
195
212
  Workflow: new \u2192 exec \u2192 read \u2192 rm
196
213
  Full control: window new/ls/rm, pane ls/rm, split, status
197
214
 
215
+ Skill-Based Spawning:
216
+ term spawn - Pick skill interactively
217
+ term spawn <skill> - Spawn Claude with skill loaded
218
+ term skills - List available skills
219
+ term create <title> - Create beads issue
220
+
198
221
  Worker Orchestration:
199
222
  term work <bd-id> - Spawn worker bound to beads issue
200
223
  term work next - Work on next ready issue
201
224
  term workers - List all workers and states
202
225
  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();
226
+ term kill <worker> - Force kill a stuck worker
227
+ term daemon start - Start beads daemon for auto-sync`).version(m8);u.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 E6(D,F)});u.command("ls").description("List all tmux sessions").option("--json","Output as JSON").action(async(D)=>{await B6(D)});u.command("attach <name>").description("Attach to a tmux session").action(async(D)=>{await $6(D)});u.command("rm <name>").description("Remove a tmux session").option("--keep-worktree","Keep worktree folder when removing session").action(async(D,F)=>{await X6(D,F)});u.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 S6(D,F)});u.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 T6(D,F.join(" "),{quiet:E.quiet,timeout:E.timeout?parseInt(E.timeout,10):void 0})});u.command("send <session> <keys>").description("Send keys to a tmux session (appends Enter by default)").option("--no-enter","Send raw keys without appending Enter").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").action(async(D,F,E)=>{await b6(D,F,E)});u.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 P6(D,F,E)});u.command("info <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 l6(D,F)});var M8=u.command("window").description("Manage tmux windows");M8.command("new <session> <name>").description("Create a new window in session").action(async(D,F)=>{await k6(D,F)});M8.command("ls <session>").description("List windows in session").option("--json","Output as JSON").action(async(D,F)=>{await x6(D,F)});M8.command("rm <window-id>").description("Remove window by ID").action(async(D)=>{await y6(D)});var kF=u.command("pane").description("Manage tmux panes");kF.command("ls <session>").description("List all panes in session").option("--json","Output as JSON").action(async(D,F)=>{await h6(D,F)});kF.command("rm <pane-id>").description("Remove pane by ID").action(async(D)=>{await g6(D)});var O8=u.command("hook").description("Manage tmux hooks");O8.command("set <event> <command>").description("Set a tmux hook").action(async(D,F)=>{await w6(D,F)});O8.command("list").description("List all tmux hooks").action(async()=>{await v6()});O8.command("rm <event>").description("Remove a tmux hook").action(async(D)=>{await u6(D)});u.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 n6(D)});u.command("spawn [skill]").description("Spawn Claude with a skill (interactive picker if no skill specified)").option("-s, --session <name>","Target tmux session").option("--no-worktree","Skip worktree creation when taskId provided").option("--no-focus","Don't focus the new pane").option("-p, --prompt <message>","Additional context for the skill").option("-t, --task-id <id>","Bind to beads issue").action(async(D,F)=>{await L8(D,F)});u.command("skills").description("List available skills").action(async()=>{await uF()});u.command("brainstorm").description("Spawn Claude with brainstorm skill (idea \u2192 design \u2192 spec)").option("-s, --session <name>","Target tmux session").option("--no-focus","Don't focus the new pane").option("-p, --prompt <message>","Additional context").action(async(D)=>{await L8("brainstorm",D)});u.command("watch <session>").description("Watch session events in real-time").option("-p, --pane <id>","Target specific pane ID (e.g., %16)").option("--json","Output events as JSON").option("--poll <ms>","Poll interval in milliseconds").action(async(D,F)=>{await S3(D,F)});u.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 P3(D,F,E)});u.command("create <title>").description("Create a new beads issue").option("-d, --description <text>","Issue description").option("-p, --parent <id>","Parent issue ID (creates dependency)").option("--json","Output as JSON").action(async(D,F)=>{await xF(D,F)});u.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("--focus","Focus the worker pane after spawning").option("-p, --prompt <message>","Custom initial prompt").option("--no-resume","Start fresh session even if previous exists").action(async(D,F)=>{await K1(D,F)});u.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 L1(D)});u.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 NF(D,F)});u.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 TF(D,F)});u.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(() => (mD(),lD)),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 T3(B.session,{pane:B.paneId,deny:F.deny})});u.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(() => (mD(),lD)),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 b3(B.session,F,{pane:B.paneId})});var t0=u.command("daemon").description("Manage beads daemon for auto-sync");t0.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 bF(D)});t0.command("stop").description("Stop beads daemon").action(async()=>{await PF()});t0.command("status").description("Show daemon status").option("--json","Output as JSON").action(async(D)=>{await fF(D)});t0.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 ZF(D)});var uD=u.command("orc").description("Orchestrate Claude Code sessions");uD.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 Q1(D,F)});uD.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 J1(D,F,E)});uD.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 Y1(D,F)});uD.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 S3(D,F)});uD.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 T3(D,F)});uD.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 b3(D,F,E)});uD.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 q1(D,F)});uD.command("methods").description("List available completion detection methods").action(async()=>{await H1()});uD.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 P3(D,F,E)});u.parse();