@earlyai/cli 2.7.0 → 2.7.1

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 (2) hide show
  1. package/dist/index.cjs +2 -2
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -17,7 +17,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
17
17
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
18
  - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let o=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function l(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=l(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=l(d,`${n}-${e._name}`))}u=t||u}o=s.includes(r.extname(u));let f;a.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.execPath,t,{stdio:`inherit`})):o?(t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{a.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new c(e,`commander.executeSubCommandAsync`,`(close)`)):a.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)a.exit(1);else{let e=new c(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
19
19
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in a.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,a.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new f(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=p(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=p(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>s(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=r.basename(e,r.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(a.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
20
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:ne,createCommand:N,createArgument:P,createOption:F,CommanderError:I,InvalidArgumentError:re,InvalidOptionArgumentError:ie,Command:L,Argument:ae,Option:oe,Help:R}=u(s((e=>{let{Argument:t}=A(),{Command:n}=M(),{CommanderError:r,InvalidArgumentError:i}=k(),{Help:a}=ee(),{Option:o}=j();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var se=`2.7.0`,ce=s((e=>{let t=e=>e!=null,n=e=>typeof e==`object`&&!!e,r=e=>Array.isArray(e),i=e=>e instanceof Map,a=e=>e instanceof Set,o=e=>e instanceof Date,s=e=>typeof e==`number`,c=e=>typeof e==`string`,l=e=>typeof e==`boolean`,u=e=>e instanceof Error,d=e=>t(e)?c(e)||r(e)?e.length===0:i(e)||a(e)?e.size===0:o(e)?!1:n(e)?Object.keys(e).length===0:!1:!0,f=e=>u(e)?e.message:`error is not Instance of Error`,p=(e,t)=>{let n=new Set(e);for(let e of n)t.includes(e)||n.delete(e);return[...n]},m=async(e,t)=>{let n=await Promise.all(e.map(e=>t(e)));return e.filter((e,t)=>n[t])},h=(e,t)=>{let n=[];for(let r of e)n.some(e=>t(r,e))||n.push(r);return n},g=e=>[...new Set(e)],_=async e=>Promise.all(e.map(e=>new Promise((t,n)=>e().then(e=>e?t(e):n(e)).catch(e=>n(e))))).then(()=>!0).catch(e=>{if(!l(e))throw e;return e}),v=e=>e.trim().replaceAll(/([\da-z])([A-Z])/g,`$1-$2`).replaceAll(/([A-Z])([A-Z][\da-z])/g,`$1-$2`).replaceAll(/[\s_]+/g,`-`).toLowerCase(),y=e=>e.replaceAll(/[\s-]+/g,` `).split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),b=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n)??0;t=Math.trunc(t*31+r)}return t>>>0},x=(...e)=>{let n={};for(let r of e)for(let e in r)t(r[e])&&(n[e]=r[e]);return n},S=(e,t)=>r(e)?e.map(e=>S(e,t)):n(e)?Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)).map(([e,n])=>[e,S(n,t)])):e,C=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},w=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>{n=!1},t))}};var T=class{listeners=[];addListener(e){this.listeners.push(e)}notifyAll(e){for(let t of this.listeners)t(e)}clear(){this.listeners.length=0}},E=class{set=new Set;constructor(e=[]){for(let t of e)this.safeAdd(t)}safeAdd(e){return t(e)?(this.set.add(e),!0):!1}has(e){return t(e)?this.set.has(e):!1}delete(e){return t(e)?this.set.delete(e):!1}clear(){this.set.clear()}get size(){return this.set.size}values(){return this.set.values()}toSet(){return structuredClone(this.set)}[Symbol.iterator](){return this.set[Symbol.iterator]()}concatSet(e){for(let t of e)this.safeAdd(t)}};e.Observer=T,e.SafeSet=E,e.arePromiseFnsTruthy=_,e.debounce=C,e.fastHash=b,e.filterAsync=m,e.getErrorMessage=f,e.intersection=p,e.isArray=r,e.isBoolean=l,e.isDate=o,e.isDefined=t,e.isEmpty=d,e.isError=u,e.isMap=i,e.isNumber=s,e.isObject=n,e.isSet=a,e.isString=c,e.merge=x,e.removeNestedField=S,e.throttle=w,e.toCamelCase=y,e.toKebabCase=v,e.uniq=g,e.uniqWith=h})),z=ce();function le(e,t,n,{key:r=``,prefix:i=`EARLY`,parser:a,def:o,isRequired:s=!1,envName:c}={}){let l=new oe(t,n);a&&l.argParser(a),s&&l.makeOptionMandatory(!0);let u=c??(()=>{let n=[];for(let t=e;t&&(0,z.isDefined)(t.name());t=t.parent)t.parent&&n.unshift(t.name());return[i,...n,r||t.split(/[ ,|]/)[1].replace(/^--?/,``)].join(`_`).replaceAll(/[- ]/g,`_`).toUpperCase()})();return l.env(u),(0,z.isDefined)(o)&&l.default(o),e.addOption(l),l}function ue(e){return(typeof e==`object`&&!!e||typeof e==`function`)&&typeof e.then==`function`}function de(e){switch(typeof e){case`string`:case`symbol`:return e.toString();case`function`:return e.name;default:throw Error(`Unexpected ${typeof e} service id type`)}}const fe=Symbol.for(`@inversifyjs/common/islazyServiceIdentifier`);var pe=class{[fe];#e;constructor(e){this.#e=e,this[fe]=!0}static is(e){return typeof e==`object`&&!!e&&!0===e[fe]}unwrap(){return this.#e()}};function me(e,t,n){return Reflect.getOwnMetadata(t,e,n)}function he(e,t,n,r){Reflect.defineMetadata(t,n,e,r)}function ge(e,t,n,r,i){let a=r(me(e,t,i)??n());Reflect.defineMetadata(t,a,e,i)}function _e(e){return Object.getPrototypeOf(e.prototype)?.constructor}const ve=`@inversifyjs/container/bindingId`;function ye(){let e=me(Object,ve)??0;return e===2**53-1?he(Object,ve,-(2**53-1)):ge(Object,ve,()=>e,e=>e+1),e}const be={Request:`Request`,Singleton:`Singleton`,Transient:`Transient`},xe={ConstantValue:`ConstantValue`,DynamicValue:`DynamicValue`,Factory:`Factory`,Instance:`Instance`,Provider:`Provider`,ResolvedValue:`ResolvedValue`,ServiceRedirection:`ServiceRedirection`};function*Se(...e){for(let t of e)yield*t}var Ce=class e{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(let t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#a(e).push(t);for(let n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){let e=this.#r(),t=this.#i(),n=Reflect.ownKeys(this.#n),r=this._buildNewInstance(this.#n);this.#u(this.#e,r.#e,e,t);for(let t of n)this.#l(this.#t[t],r.#t[t],e);return r}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){let n=this.get(e,t);if(n===void 0)return;let r=new Set(n);for(let n of r){let r=this.#e.get(n);if(r===void 0)throw Error(`Expecting model relation, none found`);for(let i of r)i[e]===t&&this.#d(n,i);this.#e.delete(n)}}_buildNewInstance(t){return new e(t)}_cloneModel(e){return e}_cloneRelation(e){return e}#r(){let e=new Map;for(let t of this.#e.keys()){let n=this._cloneModel(t);e.set(t,n)}return e}#i(){let e=new Map;for(let t of this.#e.values())for(let n of t){let t=this._cloneRelation(n);e.set(n,t)}return e}#a(e){let t=this.#e.get(e);return t===void 0&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return n===void 0&&(n=[],this.#t[e].set(t,n)),n}#s(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting model to be cloned, none found`);return n}#c(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting relation to be cloned, none found`);return n}#l(e,t,n){for(let[r,i]of e){let e=[];for(let t of i)e.push(this.#s(t,n));t.set(r,e)}}#u(e,t,n,r){for(let[i,a]of e){let e=[];for(let t of a)e.push(this.#c(t,r));t.set(this.#s(i,n),e)}}#d(e,t){for(let n of Reflect.ownKeys(t))this.#f(e,n,t[n])}#f(e,t,n){let r=this.#t[t].get(n);if(r!==void 0){let i=r.indexOf(e);i!==-1&&r.splice(i,1),r.length===0&&this.#t[t].delete(n)}}},we;(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(we||={});var Te=class e{#e;#t;constructor(e,t){this.#e=t??new Ce({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(we.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return Se(...t)}removeAllByModuleId(e){this.#e.removeByRelation(we.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(we.serviceId,e)}};const Ee=`@inversifyjs/core/classMetadataReflectKey`;function De(){return{constructorArguments:[],lifecycle:{postConstructMethodNames:new Set,preDestroyMethodNames:new Set},properties:new Map,scope:void 0}}const Oe=`@inversifyjs/core/pendingClassMetadataCountReflectKey`,ke=Symbol.for(`@inversifyjs/core/InversifyCoreError`);var Ae=class e extends Error{[ke];kind;constructor(e,t,n){super(t,n),this[ke]=!0,this.kind=e}static is(e){return typeof e==`object`&&!!e&&!0===e[ke]}static isErrorOfKind(t,n){return e.is(t)&&t.kind===n}},je,Me,Ne,Pe,Fe;function Ie(e){let t=me(e,Ee)??De();if(!function(e){let t=me(e,Oe);return t!==void 0&&t!==0}(e))return function(e,t){let n=[];if(t.length<e.length)throw new Ae(je.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)t[e]===void 0&&n.push(e);if(n.length>0)throw new Ae(je.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join(`", "`)}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(e,t.constructorArguments),t;(function(e,t){let n=[];for(let r=0;r<t.constructorArguments.length;++r){let i=t.constructorArguments[r];i!==void 0&&i.kind!==Me.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${r.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(let[r,i]of t.properties)i.kind===Me.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${r.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);throw n.length===0?new Ae(je.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`):new Ae(je.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join(`
20
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:ne,createCommand:N,createArgument:P,createOption:F,CommanderError:I,InvalidArgumentError:re,InvalidOptionArgumentError:ie,Command:L,Argument:ae,Option:oe,Help:R}=u(s((e=>{let{Argument:t}=A(),{Command:n}=M(),{CommanderError:r,InvalidArgumentError:i}=k(),{Help:a}=ee(),{Option:o}=j();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var se=`2.7.1`,ce=s((e=>{let t=e=>e!=null,n=e=>typeof e==`object`&&!!e,r=e=>Array.isArray(e),i=e=>e instanceof Map,a=e=>e instanceof Set,o=e=>e instanceof Date,s=e=>typeof e==`number`,c=e=>typeof e==`string`,l=e=>typeof e==`boolean`,u=e=>e instanceof Error,d=e=>t(e)?c(e)||r(e)?e.length===0:i(e)||a(e)?e.size===0:o(e)?!1:n(e)?Object.keys(e).length===0:!1:!0,f=e=>u(e)?e.message:`error is not Instance of Error`,p=(e,t)=>{let n=new Set(e);for(let e of n)t.includes(e)||n.delete(e);return[...n]},m=async(e,t)=>{let n=await Promise.all(e.map(e=>t(e)));return e.filter((e,t)=>n[t])},h=(e,t)=>{let n=[];for(let r of e)n.some(e=>t(r,e))||n.push(r);return n},g=e=>[...new Set(e)],_=async e=>Promise.all(e.map(e=>new Promise((t,n)=>e().then(e=>e?t(e):n(e)).catch(e=>n(e))))).then(()=>!0).catch(e=>{if(!l(e))throw e;return e}),v=e=>e.trim().replaceAll(/([\da-z])([A-Z])/g,`$1-$2`).replaceAll(/([A-Z])([A-Z][\da-z])/g,`$1-$2`).replaceAll(/[\s_]+/g,`-`).toLowerCase(),y=e=>e.replaceAll(/[\s-]+/g,` `).split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),b=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n)??0;t=Math.trunc(t*31+r)}return t>>>0},x=(...e)=>{let n={};for(let r of e)for(let e in r)t(r[e])&&(n[e]=r[e]);return n},S=(e,t)=>r(e)?e.map(e=>S(e,t)):n(e)?Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)).map(([e,n])=>[e,S(n,t)])):e,C=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},w=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>{n=!1},t))}};var T=class{listeners=[];addListener(e){this.listeners.push(e)}notifyAll(e){for(let t of this.listeners)t(e)}clear(){this.listeners.length=0}},E=class{set=new Set;constructor(e=[]){for(let t of e)this.safeAdd(t)}safeAdd(e){return t(e)?(this.set.add(e),!0):!1}has(e){return t(e)?this.set.has(e):!1}delete(e){return t(e)?this.set.delete(e):!1}clear(){this.set.clear()}get size(){return this.set.size}values(){return this.set.values()}toSet(){return structuredClone(this.set)}[Symbol.iterator](){return this.set[Symbol.iterator]()}concatSet(e){for(let t of e)this.safeAdd(t)}};e.Observer=T,e.SafeSet=E,e.arePromiseFnsTruthy=_,e.debounce=C,e.fastHash=b,e.filterAsync=m,e.getErrorMessage=f,e.intersection=p,e.isArray=r,e.isBoolean=l,e.isDate=o,e.isDefined=t,e.isEmpty=d,e.isError=u,e.isMap=i,e.isNumber=s,e.isObject=n,e.isSet=a,e.isString=c,e.merge=x,e.removeNestedField=S,e.throttle=w,e.toCamelCase=y,e.toKebabCase=v,e.uniq=g,e.uniqWith=h})),z=ce();function le(e,t,n,{key:r=``,prefix:i=`EARLY`,parser:a,def:o,isRequired:s=!1,envName:c}={}){let l=new oe(t,n);a&&l.argParser(a),s&&l.makeOptionMandatory(!0);let u=c??(()=>{let n=[];for(let t=e;t&&(0,z.isDefined)(t.name());t=t.parent)t.parent&&n.unshift(t.name());return[i,...n,r||t.split(/[ ,|]/)[1].replace(/^--?/,``)].join(`_`).replaceAll(/[- ]/g,`_`).toUpperCase()})();return l.env(u),(0,z.isDefined)(o)&&l.default(o),e.addOption(l),l}function ue(e){return(typeof e==`object`&&!!e||typeof e==`function`)&&typeof e.then==`function`}function de(e){switch(typeof e){case`string`:case`symbol`:return e.toString();case`function`:return e.name;default:throw Error(`Unexpected ${typeof e} service id type`)}}const fe=Symbol.for(`@inversifyjs/common/islazyServiceIdentifier`);var pe=class{[fe];#e;constructor(e){this.#e=e,this[fe]=!0}static is(e){return typeof e==`object`&&!!e&&!0===e[fe]}unwrap(){return this.#e()}};function me(e,t,n){return Reflect.getOwnMetadata(t,e,n)}function he(e,t,n,r){Reflect.defineMetadata(t,n,e,r)}function ge(e,t,n,r,i){let a=r(me(e,t,i)??n());Reflect.defineMetadata(t,a,e,i)}function _e(e){return Object.getPrototypeOf(e.prototype)?.constructor}const ve=`@inversifyjs/container/bindingId`;function ye(){let e=me(Object,ve)??0;return e===2**53-1?he(Object,ve,-(2**53-1)):ge(Object,ve,()=>e,e=>e+1),e}const be={Request:`Request`,Singleton:`Singleton`,Transient:`Transient`},xe={ConstantValue:`ConstantValue`,DynamicValue:`DynamicValue`,Factory:`Factory`,Instance:`Instance`,Provider:`Provider`,ResolvedValue:`ResolvedValue`,ServiceRedirection:`ServiceRedirection`};function*Se(...e){for(let t of e)yield*t}var Ce=class e{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(let t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#a(e).push(t);for(let n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){let e=this.#r(),t=this.#i(),n=Reflect.ownKeys(this.#n),r=this._buildNewInstance(this.#n);this.#u(this.#e,r.#e,e,t);for(let t of n)this.#l(this.#t[t],r.#t[t],e);return r}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){let n=this.get(e,t);if(n===void 0)return;let r=new Set(n);for(let n of r){let r=this.#e.get(n);if(r===void 0)throw Error(`Expecting model relation, none found`);for(let i of r)i[e]===t&&this.#d(n,i);this.#e.delete(n)}}_buildNewInstance(t){return new e(t)}_cloneModel(e){return e}_cloneRelation(e){return e}#r(){let e=new Map;for(let t of this.#e.keys()){let n=this._cloneModel(t);e.set(t,n)}return e}#i(){let e=new Map;for(let t of this.#e.values())for(let n of t){let t=this._cloneRelation(n);e.set(n,t)}return e}#a(e){let t=this.#e.get(e);return t===void 0&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return n===void 0&&(n=[],this.#t[e].set(t,n)),n}#s(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting model to be cloned, none found`);return n}#c(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting relation to be cloned, none found`);return n}#l(e,t,n){for(let[r,i]of e){let e=[];for(let t of i)e.push(this.#s(t,n));t.set(r,e)}}#u(e,t,n,r){for(let[i,a]of e){let e=[];for(let t of a)e.push(this.#c(t,r));t.set(this.#s(i,n),e)}}#d(e,t){for(let n of Reflect.ownKeys(t))this.#f(e,n,t[n])}#f(e,t,n){let r=this.#t[t].get(n);if(r!==void 0){let i=r.indexOf(e);i!==-1&&r.splice(i,1),r.length===0&&this.#t[t].delete(n)}}},we;(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(we||={});var Te=class e{#e;#t;constructor(e,t){this.#e=t??new Ce({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(we.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return Se(...t)}removeAllByModuleId(e){this.#e.removeByRelation(we.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(we.serviceId,e)}};const Ee=`@inversifyjs/core/classMetadataReflectKey`;function De(){return{constructorArguments:[],lifecycle:{postConstructMethodNames:new Set,preDestroyMethodNames:new Set},properties:new Map,scope:void 0}}const Oe=`@inversifyjs/core/pendingClassMetadataCountReflectKey`,ke=Symbol.for(`@inversifyjs/core/InversifyCoreError`);var Ae=class e extends Error{[ke];kind;constructor(e,t,n){super(t,n),this[ke]=!0,this.kind=e}static is(e){return typeof e==`object`&&!!e&&!0===e[ke]}static isErrorOfKind(t,n){return e.is(t)&&t.kind===n}},je,Me,Ne,Pe,Fe;function Ie(e){let t=me(e,Ee)??De();if(!function(e){let t=me(e,Oe);return t!==void 0&&t!==0}(e))return function(e,t){let n=[];if(t.length<e.length)throw new Ae(je.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)t[e]===void 0&&n.push(e);if(n.length>0)throw new Ae(je.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join(`", "`)}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(e,t.constructorArguments),t;(function(e,t){let n=[];for(let r=0;r<t.constructorArguments.length;++r){let i=t.constructorArguments[r];i!==void 0&&i.kind!==Me.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${r.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(let[r,i]of t.properties)i.kind===Me.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${r.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);throw n.length===0?new Ae(je.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`):new Ae(je.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join(`
21
21
 
22
22
  `)}`)})(e,t)}function Le(e,t){let n=Ie(t).scope??e.scope;return{cache:{isRight:!1,value:void 0},id:ye(),implementationType:t,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:n,serviceIdentifier:t,type:xe.Instance}}function Re(e){return e.isRight?{isRight:!0,value:e.value}:e}function ze(e){switch(e.type){case xe.ConstantValue:case xe.DynamicValue:return function(e){return{cache:Re(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type,value:e.value}}(e);case xe.Factory:return function(e){return{cache:Re(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case xe.Instance:return function(e){return{cache:Re(e.cache),id:e.id,implementationType:e.implementationType,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case xe.Provider:return function(e){return{cache:Re(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,provider:e.provider,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case xe.ResolvedValue:return function(e){return{cache:Re(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,metadata:e.metadata,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case xe.ServiceRedirection:return function(e){return{id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,serviceIdentifier:e.serviceIdentifier,targetServiceIdentifier:e.targetServiceIdentifier,type:e.type}}(e)}}(function(e){e[e.injectionDecoratorConflict=0]=`injectionDecoratorConflict`,e[e.missingInjectionDecorator=1]=`missingInjectionDecorator`,e[e.planning=2]=`planning`,e[e.resolution=3]=`resolution`,e[e.unknown=4]=`unknown`})(je||={}),function(e){e[e.unknown=32]=`unknown`}(Me||={}),function(e){e.id=`id`,e.moduleId=`moduleId`,e.serviceId=`serviceId`}(Ne||={});var Be=class e extends Ce{_buildNewInstance(t){return new e(t)}_cloneModel(e){return ze(e)}},Ve=class e{#e;#t;#n;constructor(e,t,n){this.#t=n??new Be({id:{isOptional:!1},moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#n=e,this.#e=t}static build(t,n){return new e(t,n)}clone(){return new e(this.#n,this.#e,this.#t.clone())}get(e){let t=this.getNonParentBindings(e)??this.#n()?.get(e);if(t!==void 0)return t;let n=this.#r(e);return n===void 0?n:[n]}*getChained(e){let t=this.getNonParentBindings(e);t!==void 0&&(yield*t);let n=this.#n();if(n===void 0){if(t===void 0){let t=this.#r(e);t!==void 0&&(yield t)}}else yield*n.getChained(e)}getBoundServices(){let e=new Set(this.#t.getAllKeys(Ne.serviceId)),t=this.#n();if(t!==void 0)for(let n of t.getBoundServices())e.add(n);return e}getById(e){return this.#t.get(Ne.id,e)??this.#n()?.getById(e)}getByModuleId(e){return this.#t.get(Ne.moduleId,e)??this.#n()?.getByModuleId(e)}getNonParentBindings(e){return this.#t.get(Ne.serviceId,e)}getNonParentBoundServices(){return this.#t.getAllKeys(Ne.serviceId)}removeById(e){this.#t.removeByRelation(Ne.id,e)}removeAllByModuleId(e){this.#t.removeByRelation(Ne.moduleId,e)}removeAllByServiceId(e){this.#t.removeByRelation(Ne.serviceId,e)}set(e){let t={[Ne.id]:e.id,[Ne.serviceId]:e.serviceIdentifier};e.moduleId!==void 0&&(t[Ne.moduleId]=e.moduleId),this.#t.add(e,t)}#r(e){if(this.#e===void 0||typeof e!=`function`)return;let t=Le(this.#e,e);return this.set(t),t}};(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(Pe||={});var He=class e{#e;#t;constructor(e,t){this.#e=t??new Ce({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(Pe.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return Se(...t)}removeAllByModuleId(e){this.#e.removeByRelation(Pe.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(Pe.serviceId,e)}};function Ue(){return 0}function B(e){return t=>{t!==void 0&&t.kind===Me.unknown&&ge(e,Oe,Ue,e=>e-1)}}function We(e,t){return(...n)=>r=>{if(r===void 0)return e(...n);if(r.kind===Fe.unmanaged)throw new Ae(je.injectionDecoratorConflict,`Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found`);return t(r,...n)}}function Ge(e){if(e.kind!==Me.unknown&&!0!==e.isFromTypescriptParamType)throw new Ae(je.injectionDecoratorConflict,`Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found`)}(function(e){e[e.multipleInjection=0]=`multipleInjection`,e[e.singleInjection=1]=`singleInjection`,e[e.unmanaged=2]=`unmanaged`})(Fe||={});const Ke=We(function(e,t,n){return e===Fe.multipleInjection?{chained:n?.chained??!1,kind:e,name:void 0,optional:!1,tags:new Map,value:t}:{kind:e,name:void 0,optional:!1,tags:new Map,value:t}},function(e,t,n,r){return Ge(e),t===Fe.multipleInjection?{...e,chained:r?.chained??!1,kind:t,value:n}:{...e,kind:t,value:n}});function qe(e,t){return n=>{let r=n.properties.get(t);return n.properties.set(t,e(r)),n}}var Je;function Ye(e,t,n,r){if(Ae.isErrorOfKind(r,je.injectionDecoratorConflict)){let i=function(e,t,n){if(n===void 0){if(t===void 0)throw new Ae(je.unknown,`Unexpected undefined property and index values`);return{kind:Je.property,property:t,targetClass:e.constructor}}return typeof n==`number`?{index:n,kind:Je.parameter,targetClass:e}:{kind:Je.method,method:t,targetClass:e}}(e,t,n);throw new Ae(je.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${r.message}\n\nDetails\n\n${function(e){switch(e.kind){case Je.method:return`[class: "${e.targetClass.name}", method: "${e.method.toString()}"]`;case Je.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case Je.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:r})}throw r}function Xe(e,t){return(n,r,i)=>{try{i===void 0?function(e,t){let n=Ze(e,t);return(e,t)=>{ge(e.constructor,Ee,De,qe(n(e),t))}}(e,t)(n,r):typeof i==`number`?function(e,t){let n=Ze(e,t);return(e,t,r)=>{if(!function(e,t){return typeof e==`function`&&t===void 0}(e,t))throw new Ae(je.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${t?.toString()??``}" at class "${e.constructor.name}"`);ge(e,Ee,De,function(e,t){return n=>{let r=n.constructorArguments[t];return n.constructorArguments[t]=e(r),n}}(n(e),r))}}(e,t)(n,r,i):function(e,t){let n=Ze(e,t);return(e,t,r)=>{if(!function(e){return e.set!==void 0}(r))throw new Ae(je.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${t.toString()}" at class "${e.constructor.name}"`);ge(e.constructor,Ee,De,qe(n(e),t))}}(e,t)(n,r,i)}catch(e){Ye(n,r,i,e)}}}function Ze(e,t){return n=>{let r=t(n);return t=>(r(t),e(t))}}function Qe(e){return Xe(Ke(Fe.singleInjection,e),B)}(function(e){e[e.method=0]=`method`,e[e.parameter=1]=`parameter`,e[e.property=2]=`property`})(Je||={});const $e=`@inversifyjs/core/classIsInjectableFlagReflectKey`,et=[Array,BigInt,Boolean,Function,Number,Object,String];function V(e){let t=me(e,`design:paramtypes`);t!==void 0&&ge(e,Ee,De,function(e){return t=>(e.forEach((e,n)=>{var r;t.constructorArguments[n]!==void 0||(r=e,et.includes(r))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:Fe.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))}),t)}(t))}function tt(e){return t=>{(function(e){if(me(e,$e)!==void 0)throw new Ae(je.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${e.name}"`);he(e,$e,!0)})(t),V(t),e!==void 0&&ge(t,Ee,De,t=>({...t,scope:e}))}}function nt(e,t,n){let r;return e.extendConstructorArguments??!0?(r=[...t.constructorArguments],n.constructorArguments.map((e,t)=>{r[t]=e})):r=n.constructorArguments,r}function rt(e,t,n){return e?new Set([...t,...n]):n}function it(e,t,n){let r=e.lifecycle?.extendPostConstructMethods??!0,i=rt(e.lifecycle?.extendPreDestroyMethods??!0,t.lifecycle.preDestroyMethodNames,n.lifecycle.preDestroyMethodNames);return{postConstructMethodNames:rt(r,t.lifecycle.postConstructMethodNames,n.lifecycle.postConstructMethodNames),preDestroyMethodNames:i}}function at(e,t,n){let r;return r=e.extendProperties??!0?new Map(Se(t.properties,n.properties)):n.properties,r}function ot(e){return t=>{ge(t,Ee,De,function(e,t){return n=>({constructorArguments:nt(e,t,n),lifecycle:it(e,t,n),properties:at(e,t,n),scope:n.scope})}(e,Ie(e.type)))}}function st(e){return t=>{let n=_e(t);if(n===void 0)throw new Ae(je.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);ot({...e,type:n})(t)}}function ct(e){return t=>{let n=[],r=_e(t);for(;r!==void 0&&r!==Object;){let e=r;n.push(e),r=_e(e)}n.reverse();for(let r of n)ot({...e,type:r})(t)}}function H(e){return t=>{t===void 0&&ge(e,Oe,Ue,e=>e+1)}}function lt(e){return t=>{let n=t??{kind:Me.unknown,name:void 0,optional:!1,tags:new Map};if(n.kind===Fe.unmanaged)throw new Ae(je.injectionDecoratorConflict,`Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections`);return e(n)}}function ut(e){if(e.optional)throw new Ae(je.injectionDecoratorConflict,`Unexpected duplicated optional decorator`);return e.optional=!0,e}function dt(){return Xe(lt(ut),H)}var ft;function pt(e){return e instanceof Error?e instanceof RangeError&&/stack space|call stack|too much recursion/i.test(e.message)||e.name===`InternalError`&&/too much recursion/.test(e.message):!1}function mt(e,t){if(pt(t)){let n=function(e){let t=[...e];return t.length===0?`(No dependency trace)`:t.map(de).join(` -> `)}(function(e){let t=new Set;for(let n of e.servicesBranch){if(t.has(n))return[...t,n];t.add(n)}return[...t]}(e));throw new Ae(je.planning,`Circular dependency found: ${n}`,{cause:t})}throw t}(function(e){e[e.multipleInjection=0]=`multipleInjection`,e[e.singleInjection=1]=`singleInjection`})(ft||={});const ht=Symbol.for(`@inversifyjs/core/LazyPlanServiceNode`);var gt=class{[ht];_serviceIdentifier;_serviceNode;constructor(e,t){this[ht]=!0,this._serviceNode=e,this._serviceIdentifier=t}get bindings(){return this._getNode().bindings}get isContextFree(){return this._getNode().isContextFree}get serviceIdentifier(){return this._serviceIdentifier}set bindings(e){this._getNode().bindings=e}set isContextFree(e){this._getNode().isContextFree=e}static is(e){return typeof e==`object`&&!!e&&!0===e[ht]}invalidate(){this._serviceNode=void 0}isExpanded(){return this._serviceNode!==void 0}_getNode(){return this._serviceNode===void 0&&(this._serviceNode=this._buildPlanServiceNode()),this._serviceNode}},_t=class e{#e;constructor(e){this.#e=e}get name(){return this.#e.elem.name}get serviceIdentifier(){return this.#e.elem.serviceIdentifier}get tags(){return this.#e.elem.tags}getAncestor(){if(this.#e.elem.getAncestorsCalled=!0,this.#e.previous!==void 0)return new e(this.#e.previous)}};function vt(e,t,n){let r=n?.customServiceIdentifier??t.serviceIdentifier,i=(!0===n?.chained?[...e.operations.getBindingsChained(r)]:[...e.operations.getBindings(r)??[]]).filter(e=>e.isSatisfiedBy(t));if(i.length===0&&e.autobindOptions!==void 0&&typeof r==`function`){let n=Le(e.autobindOptions,r);e.operations.setBinding(n),n.isSatisfiedBy(t)&&i.push(n)}return i}var yt=class e{last;constructor(e){this.last=e}concat(t){return new e({elem:t,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(e===void 0)return{done:!0,value:void 0};let t=e.elem;return e=e.previous,{done:!1,value:t}}}}};function bt(e){let t=new Map;return e.rootConstraints.tag!==void 0&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value),new yt({elem:{getAncestorsCalled:!1,name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0})}function xt(e){return e.redirections!==void 0}function St(e,t,n,r){let i=n.elem.serviceIdentifier,a=n.previous?.elem.serviceIdentifier;Array.isArray(e)?function(e,t,n,r,i,a){if(e.length!==0){let t=`Ambiguous bindings found for service: "${de(a[a.length-1]??n)}".${Et(a)}\n\nRegistered bindings:\n\n${e.map(e=>function(e){switch(e.type){case xe.Instance:return`[ type: "${e.type}", serviceIdentifier: "${de(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case xe.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${de(e.serviceIdentifier)}", redirection: "${de(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${de(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding)).join(`
23
23
  `)}\n\nTrying to resolve bindings for "${wt(n,r)}".${Tt(i)}`;throw new Ae(je.planning,t)}t||Ct(n,r,i,a)}(e,t,i,a,n.elem,r):function(e,t,n,r,i,a){e!==void 0||t||Ct(n,r,i,a)}(e,t,i,a,n.elem,r)}function Ct(e,t,n,r){let i=`No bindings found for service: "${de(r[r.length-1]??e)}".\n\nTrying to resolve bindings for "${wt(e,t)}".${Et(r)}${Tt(n)}`;throw new Ae(je.planning,i)}function wt(e,t){return t===void 0?`${de(e)} (Root service)`:de(t)}function Tt(e){let t=e.tags.size===0?``:`\n- tags:\n - ${[...e.tags.keys()].map(e=>e.toString()).join(`
@@ -32408,7 +32408,7 @@ var n=require(`buffer`),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.fr
32408
32408
  `),c=s.byteLength,l=Array.from(e.entries()).map(([e,t])=>{let n=new w1(e,t);return c+=n.size,n});c+=o.byteLength*l.length,c=x$.toFiniteNumber(c);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(c)&&(u[`Content-Length`]=c),t&&t(u),D.Readable.from((async function*(){for(let e of l)yield o,yield*e.encode();yield s})())};var E1=class extends D.default.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,n)}};const D1=(e,t)=>x$.isAsyncFn(e)?function(...n){let r=n.pop();e.apply(this,n).then(e=>{try{t?r(null,...t(e)):r(null,e)}catch(e){r(e)}},r)}:e;function O1(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function k1(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}const A1=(e,t,n=3)=>{let r=0,i=O1(50,250);return k1(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},j1=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},M1=e=>(...t)=>x$.asap(()=>e(...t));function N1(e){if(!e||typeof e!=`string`||!e.startsWith(`data:`))return 0;let t=e.indexOf(`,`);if(t<0)return 0;let n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let e=r.length,t=r.length;for(let n=0;n<t;n++)if(r.charCodeAt(n)===37&&n+2<t){let t=r.charCodeAt(n+1),i=r.charCodeAt(n+2);(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)&&(i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102)&&(e-=2,n+=2)}let n=0,i=t-1,a=e=>e>=2&&r.charCodeAt(e-2)===37&&r.charCodeAt(e-1)===51&&(r.charCodeAt(e)===68||r.charCodeAt(e)===100);i>=0&&(r.charCodeAt(i)===61?(n++,i--):a(i)&&(n++,i-=3)),n===1&&i>=0&&(r.charCodeAt(i)===61||a(i))&&n++;let o=Math.floor(e/4)*3-(n||0);return o>0?o:0}return Buffer.byteLength(r,`utf8`)}const P1={flush:O.default.constants.Z_SYNC_FLUSH,finishFlush:O.default.constants.Z_SYNC_FLUSH},F1={flush:O.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:O.default.constants.BROTLI_OPERATION_FLUSH},I1=x$.isFunction(O.default.createBrotliDecompress),{http:L1,https:R1}=f1.default,z1=/https:?/,B1=Y$.protocols.map(e=>e+`:`),V1=(e,[t,n])=>(e.on(`end`,n).on(`error`,n),t);function Cte(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function H1(e,t,n){let r=t;if(!r&&r!==!1){let e=p1.getProxyForUrl(n);e&&(r=new URL(e))}if(r){if(r.username&&(r.auth=(r.username||``)+`:`+(r.password||``)),r.auth){(r.auth.username||r.auth.password)&&(r.auth=(r.auth.username||``)+`:`+(r.auth.password||``));let t=Buffer.from(r.auth,`utf8`).toString(`base64`);e.headers[`Proxy-Authorization`]=`Basic `+t}e.headers.host=e.hostname+(e.port?`:`+e.port:``);let t=r.hostname||r.host;e.hostname=t,e.host=t,e.port=r.port,e.path=n,r.protocol&&(e.protocol=r.protocol.includes(`:`)?r.protocol:`${r.protocol}:`)}e.beforeRedirects.proxy=function(e){H1(e,t,e.href)}}const U1=typeof process<`u`&&x$.kindOf(process)===`process`,W1=e=>new Promise((t,n)=>{let r,i,a=(e,t)=>{i||(i=!0,r&&r(e,t))},o=e=>{a(e),t(e)},s=e=>{a(e,!0),n(e)};e(o,s,e=>r=e).catch(s)}),G1=({address:e,family:t})=>{if(!x$.isString(e))throw TypeError(`address must be a string`);return{address:e,family:t||(e.indexOf(`.`)<0?6:4)}},K1=(e,t)=>G1(x$.isObject(e)?e:{address:e,family:t});var q1=U1&&function(e){return W1(async function(t,n,r){let{data:i,lookup:a,family:o}=e,{responseType:s,responseEncoding:c}=e,l=e.method.toUpperCase(),u,d=!1,f;if(a){let e=D1(a,e=>x$.isArray(e)?e:[e]);a=(t,n,r)=>{e(t,n,(e,t,i)=>{if(e)return r(e);let a=x$.isArray(t)?t.map(e=>K1(e)):[K1(t,i)];n.all?r(e,a):r(e,a[0].address,a[0].family)})}}let p=new E.EventEmitter,m=()=>{e.cancelToken&&e.cancelToken.unsubscribe(h),e.signal&&e.signal.removeEventListener(`abort`,h),p.removeAllListeners()};r((e,t)=>{u=!0,t&&(d=!0,m())});function h(t){p.emit(`abort`,!t||t.type?new s1(null,e,f):t)}p.once(`abort`,n),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(h),e.signal&&(e.signal.aborted?h():e.signal.addEventListener(`abort`,h)));let g=d1(e.baseURL,e.url,e.allowAbsoluteUrls),_=new URL(g,Y$.hasBrowserEnv?Y$.origin:void 0),v=_.protocol||B1[0];if(v===`data:`){if(e.maxContentLength>-1&&N1(String(e.url||g||``))>e.maxContentLength)return n(new S$(`maxContentLength size of `+e.maxContentLength+` exceeded`,S$.ERR_BAD_RESPONSE,e));let r;if(l!==`GET`)return c1(t,n,{status:405,statusText:`method not allowed`,headers:{},config:e});try{r=_1(e.url,s===`blob`,{Blob:e.env&&e.env.Blob})}catch(t){throw S$.from(t,S$.ERR_BAD_REQUEST,e)}return s===`text`?(r=r.toString(c),(!c||c===`utf8`)&&(r=x$.stripBOM(r))):s===`stream`&&(r=D.default.Readable.from(r)),c1(t,n,{data:r,status:200,statusText:`OK`,headers:new i1,config:e})}if(B1.indexOf(v)===-1)return n(new S$(`Unsupported protocol `+v,S$.ERR_BAD_REQUEST,e));let y=i1.from(e.headers).normalize();y.set(`User-Agent`,`axios/`+m1,!1);let{onUploadProgress:x,onDownloadProgress:S}=e,T=e.maxRate,k,A;if(x$.isSpecCompliantForm(i)){let e=y.getContentType(/boundary=([-_\w\d]{10,70})/i);i=T1(i,e=>{y.set(e)},{tag:`axios-${m1}-boundary`,boundary:e&&e[1]||void 0})}else if(x$.isFormData(i)&&x$.isFunction(i.getHeaders)){if(y.set(i.getHeaders()),!y.hasContentLength())try{let e=await b.default.promisify(i.getLength).call(i);Number.isFinite(e)&&e>=0&&y.setContentLength(e)}catch{}}else if(x$.isBlob(i)||x$.isFile(i))i.size&&y.setContentType(i.type||`application/octet-stream`),y.setContentLength(i.size||0),i=D.default.Readable.from(x1(i));else if(i&&!x$.isStream(i)){if(!Buffer.isBuffer(i))if(x$.isArrayBuffer(i))i=Buffer.from(new Uint8Array(i));else if(x$.isString(i))i=Buffer.from(i,`utf-8`);else return n(new S$(`Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream`,S$.ERR_BAD_REQUEST,e));if(y.setContentLength(i.length,!1),e.maxBodyLength>-1&&i.length>e.maxBodyLength)return n(new S$(`Request body larger than maxBodyLength limit`,S$.ERR_BAD_REQUEST,e))}let ee=x$.toFiniteNumber(y.getContentLength());x$.isArray(T)?(k=T[0],A=T[1]):k=A=T,i&&(x||k)&&(x$.isStream(i)||(i=D.default.Readable.from(i,{objectMode:!1})),i=D.default.pipeline([i,new y1({maxRate:x$.toFiniteNumber(k)})],x$.noop),x&&i.on(`progress`,V1(i,j1(ee,A1(M1(x),!1,3)))));let j;if(e.auth){let t=e.auth.username||``,n=e.auth.password||``;j=t+`:`+n}if(!j&&_.username){let e=_.username,t=_.password;j=e+`:`+t}j&&y.delete(`authorization`);let te;try{te=I$(_.pathname+_.search,e.params,e.paramsSerializer).replace(/^\?/,``)}catch(t){let r=Error(t.message);return r.config=e,r.url=e.url,r.exists=!0,n(r)}y.set(`Accept-Encoding`,`gzip, compress, deflate`+(I1?`, br`:``),!1);let M={path:te,method:l,headers:y.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:j,protocol:v,family:o,beforeRedirect:Cte,beforeRedirects:{}};!x$.isUndefined(a)&&(M.lookup=a),e.socketPath?M.socketPath=e.socketPath:(M.hostname=_.hostname.startsWith(`[`)?_.hostname.slice(1,-1):_.hostname,M.port=_.port,H1(M,e.proxy,v+`//`+_.hostname+(_.port?`:`+_.port:``)+M.path));let ne,N=z1.test(M.protocol);if(M.agent=N?e.httpsAgent:e.httpAgent,e.transport?ne=e.transport:e.maxRedirects===0?ne=N?w.default:C.default:(e.maxRedirects&&(M.maxRedirects=e.maxRedirects),e.beforeRedirect&&(M.beforeRedirects.config=e.beforeRedirect),ne=N?R1:L1),e.maxBodyLength>-1?M.maxBodyLength=e.maxBodyLength:M.maxBodyLength=1/0,e.insecureHTTPParser&&(M.insecureHTTPParser=e.insecureHTTPParser),f=ne.request(M,function(r){if(f.destroyed)return;let i=[r],a=+r.headers[`content-length`];if(S||A){let e=new y1({maxRate:x$.toFiniteNumber(A)});S&&e.on(`progress`,V1(e,j1(a,A1(M1(S),!0,3)))),i.push(e)}let o=r,u=r.req||f;if(e.decompress!==!1&&r.headers[`content-encoding`])switch((l===`HEAD`||r.statusCode===204)&&delete r.headers[`content-encoding`],(r.headers[`content-encoding`]||``).toLowerCase()){case`gzip`:case`x-gzip`:case`compress`:case`x-compress`:i.push(O.default.createUnzip(P1)),delete r.headers[`content-encoding`];break;case`deflate`:i.push(new E1),i.push(O.default.createUnzip(P1)),delete r.headers[`content-encoding`];break;case`br`:I1&&(i.push(O.default.createBrotliDecompress(F1)),delete r.headers[`content-encoding`])}o=i.length>1?D.default.pipeline(i,x$.noop):i[0];let h=D.default.finished(o,()=>{h(),m()}),g={status:r.statusCode,statusText:r.statusMessage,headers:new i1(r.headers),config:e,request:u};if(s===`stream`)g.data=o,c1(t,n,g);else{let r=[],i=0;o.on(`data`,function(t){r.push(t),i+=t.length,e.maxContentLength>-1&&i>e.maxContentLength&&(d=!0,o.destroy(),n(new S$(`maxContentLength size of `+e.maxContentLength+` exceeded`,S$.ERR_BAD_RESPONSE,e,u)))}),o.on(`aborted`,function(){if(d)return;let t=new S$(`stream has been aborted`,S$.ERR_BAD_RESPONSE,e,u);o.destroy(t),n(t)}),o.on(`error`,function(t){f.destroyed||n(S$.from(t,null,e,u))}),o.on(`end`,function(){try{let e=r.length===1?r[0]:Buffer.concat(r);s!==`arraybuffer`&&(e=e.toString(c),(!c||c===`utf8`)&&(e=x$.stripBOM(e))),g.data=e}catch(t){return n(S$.from(t,null,e,g.request,g))}c1(t,n,g)})}p.once(`abort`,e=>{o.destroyed||(o.emit(`error`,e),o.destroy())})}),p.once(`abort`,e=>{n(e),f.destroy(e)}),f.on(`error`,function(t){n(S$.from(t,null,e,f))}),f.on(`socket`,function(e){e.setKeepAlive(!0,1e3*60)}),e.timeout){let t=parseInt(e.timeout,10);if(Number.isNaN(t)){n(new S$("error trying to parse `config.timeout` to int",S$.ERR_BAD_OPTION_VALUE,e,f));return}f.setTimeout(t,function(){if(u)return;let t=e.timeout?`timeout of `+e.timeout+`ms exceeded`:`timeout exceeded`,r=e.transitional||R$;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new S$(t,r.clarifyTimeoutError?S$.ETIMEDOUT:S$.ECONNABORTED,e,f)),h()})}if(x$.isStream(i)){let t=!1,n=!1;i.on(`end`,()=>{t=!0}),i.once(`error`,e=>{n=!0,f.destroy(e)}),i.on(`close`,()=>{!t&&!n&&h(new s1(`Request stream has been aborted`,e,f))}),i.pipe(f)}else f.end(i)})},J1=Y$.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Y$.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Y$.origin),Y$.navigator&&/(msie|trident)/i.test(Y$.navigator.userAgent)):()=>!0,Y1=Y$.hasStandardBrowserEnv?{write(e,t,n,r,i,a){let o=[e+`=`+encodeURIComponent(t)];x$.isNumber(n)&&o.push(`expires=`+new Date(n).toGMTString()),x$.isString(r)&&o.push(`path=`+r),x$.isString(i)&&o.push(`domain=`+i),a===!0&&o.push(`secure`),document.cookie=o.join(`; `)},read(e){let t=document.cookie.match(RegExp(`(^|;\\s*)(`+e+`)=([^;]*)`));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,``,Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};const X1=e=>e instanceof i1?{...e}:e;function Z1(e,t){t||={};let n={};function r(e,t,n,r){return x$.isPlainObject(e)&&x$.isPlainObject(t)?x$.merge.call({caseless:r},e,t):x$.isPlainObject(t)?x$.merge({},t):x$.isArray(t)?t.slice():t}function i(e,t,n,i){if(!x$.isUndefined(t))return r(e,t,n,i);if(!x$.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!x$.isUndefined(t))return r(void 0,t)}function o(e,t){if(!x$.isUndefined(t))return r(void 0,t);if(!x$.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(X1(e),X1(t),n,!0)};return x$.forEach(Object.keys({...e,...t}),function(r){let a=c[r]||i,o=a(e[r],t[r],r);x$.isUndefined(o)&&a!==s||(n[r]=o)}),n}var Q1=e=>{let t=Z1({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=i1.from(o),t.url=I$(d1(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),x$.isFormData(n)){if(Y$.hasStandardBrowserEnv||Y$.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(x$.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(Y$.hasStandardBrowserEnv&&(r&&x$.isFunction(r)&&(r=r(t)),r||r!==!1&&J1(t.url))){let e=i&&a&&Y1.read(a);e&&o.set(i,e)}return t},$1=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Q1(e),i=r.data,a=i1.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=i1.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());c1(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new S$(`Request aborted`,S$.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new S$(t&&t.message?t.message:`Network Error`,S$.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||R$;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new S$(t,i.clarifyTimeoutError?S$.ETIMEDOUT:S$.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&x$.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),x$.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=A1(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=A1(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new s1(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=h1(r.url);if(_&&Y$.protocols.indexOf(_)===-1){n(new S$(`Unsupported protocol `+_+`:`,S$.ERR_BAD_REQUEST,e));return}h.send(i||null)})};const e0=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof S$?t:new s1(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new S$(`timeout ${t} of ms exceeded`,S$.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>x$.asap(o),s}},t0=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},n0=async function*(e,t){for await(let n of r0(e))yield*t0(n,t)},r0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},i0=(e,t,n,r)=>{let i=n0(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},a0=64*1024,{isFunction:o0}=x$,s0=(({Request:e,Response:t})=>({Request:e,Response:t}))(x$.global),{ReadableStream:c0,TextEncoder:l0}=x$.global,u0=(e,...t)=>{try{return!!e(...t)}catch{return!1}},d0=e=>{e=x$.merge.call({skipUndefined:!0},s0,e);let{fetch:t,Request:n,Response:r}=e,i=t?o0(t):typeof fetch==`function`,a=o0(n),o=o0(r);if(!i)return!1;let s=i&&o0(c0),c=i&&(typeof l0==`function`?(e=>t=>e.encode(t))(new l0):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&u0(()=>{let e=!1,t=new n(Y$.origin,{body:new c0,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return e&&!t}),u=o&&s&&u0(()=>x$.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new S$(`Response type '${e}' is not supported`,S$.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(x$.isBlob(e))return e.size;if(x$.isSpecCompliantForm(e))return(await new n(Y$.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(x$.isArrayBufferView(e)||x$.isArrayBuffer(e))return e.byteLength;if(x$.isURLSearchParams(e)&&(e+=``),x$.isString(e))return(await c(e)).byteLength},p=async(e,t)=>x$.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=Q1(e),x=t||fetch;_=_?(_+``).toLowerCase():`text`;let S=e0([c,f&&f.toAbortSignal()],m),C=null,w=S&&S.unsubscribe&&(()=>{S.unsubscribe()}),T;try{if(g&&l&&o!==`get`&&o!==`head`&&(T=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(x$.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=j1(T,A1(M1(g)));s=i0(e.body,a0,t,n)}}x$.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:S,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};C=a&&new n(i,c);let f=await(a?x(C,b):x(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&w)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=x$.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&j1(t,A1(M1(h),!0))||[];f=new r(i0(f.body,a0,n,()=>{i&&i(),w&&w()}),e)}_||=`text`;let E=await d[x$.findKey(d,_)||`text`](f,e);return!m&&w&&w(),await new Promise((t,n)=>{c1(t,n,{data:E,headers:i1.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:C})})}catch(t){throw w&&w(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new S$(`Network Error`,S$.ERR_NETWORK,e,C),{cause:t.cause||t}):S$.from(t,t&&t.code,e,C)}}},f0=new Map,p0=e=>{let t=e?e.env:{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=f0;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:d0(t)),l=c;return c};p0();const m0={http:q1,xhr:$1,fetch:{get:p0}};x$.forEach(m0,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});const h0=e=>`- ${e}`,g0=e=>x$.isFunction(e)||e===null||e===!1;var _0={getAdapter:(e,t)=>{e=x$.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!g0(r)&&(i=m0[(n=String(r)).toLowerCase()],i===void 0))throw new S$(`Unknown adapter '${n}'`);if(i&&(x$.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new S$(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
32409
32409
  `+e.map(h0).join(`
32410
32410
  `):` `+h0(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i},adapters:m0};function v0(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s1(null,e)}function y0(e){return v0(e),e.headers=i1.from(e.headers),e.data=a1.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),_0.getAdapter(e.adapter||e1.adapter,e)(e).then(function(t){return v0(e),t.data=a1.call(e,e.transformResponse,t),t.headers=i1.from(t.headers),t},function(t){return o1(t)||(v0(e),t&&t.response&&(t.response.data=a1.call(e,e.transformResponse,t.response),t.response.headers=i1.from(t.response.headers))),Promise.reject(t)})}const b0={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{b0[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});const x0={};b0.transitional=function(e,t,n){function r(e,t){return`[Axios v`+m1+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new S$(r(i,` has been removed`+(t?` in `+t:``)),S$.ERR_DEPRECATED);return t&&!x0[i]&&(x0[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},b0.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function S0(e,t,n){if(typeof e!=`object`)throw new S$(`options must be an object`,S$.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new S$(`option `+a+` must be `+n,S$.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new S$(`Unknown option `+a,S$.ERR_BAD_OPTION)}}var C0={assertOptions:S0,validators:b0};const w0=C0.validators;var T0=class{constructor(e){this.defaults=e||{},this.interceptors={request:new L$,response:new L$}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=t.stack?t.stack.replace(/^.+\n/,``):``;try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,``))&&(e.stack+=`
32411
- `+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=Z1(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&C0.assertOptions(n,{silentJSONParsing:w0.transitional(w0.boolean),forcedJSONParsing:w0.transitional(w0.boolean),clarifyTimeoutError:w0.transitional(w0.boolean)},!1),r!=null&&(x$.isFunction(r)?t.paramsSerializer={serialize:r}:C0.assertOptions(r,{encode:w0.function,serialize:w0.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),C0.assertOptions(t,{baseUrl:w0.spelling(`baseURL`),withXsrfToken:w0.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&x$.merge(i.common,i[t.method]);i&&x$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=i1.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){typeof e.runWhen==`function`&&e.runWhen(t)===!1||(s&&=e.synchronous,o.unshift(e.fulfilled,e.rejected))});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[y0.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=y0.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=Z1(this.defaults,e),I$(d1(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};x$.forEach([`delete`,`get`,`head`,`options`],function(e){T0.prototype[e]=function(t,n){return this.request(Z1(n||{},{method:e,url:t,data:(n||{}).data}))}}),x$.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(Z1(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}T0.prototype[e]=t(),T0.prototype[e+`Form`]=t(!0)});var E0=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new s1(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function D0(e){return function(t){return e.apply(null,t)}}function O0(e){return x$.isObject(e)&&e.isAxiosError===!0}const k0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(k0).forEach(([e,t])=>{k0[t]=e});function A0(e){let t=new T0(e),n=CQ(T0.prototype.request,t);return x$.extend(n,T0.prototype,t,{allOwnKeys:!0}),x$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return A0(Z1(e,t))},n}const j0=A0(e1);j0.Axios=T0,j0.CanceledError=s1,j0.CancelToken=E0,j0.isCancel=o1,j0.VERSION=m1,j0.toFormData=j$,j0.AxiosError=S$,j0.Cancel=j0.CanceledError,j0.all=function(e){return Promise.all(e)},j0.spread=D0,j0.isAxiosError=O0,j0.mergeConfig=Z1,j0.AxiosHeaders=i1,j0.formToJSON=e=>$$(x$.isHTMLForm(e)?new FormData(e):e),j0.getAdapter=_0.getAdapter,j0.HttpStatusCode=k0,j0.default=j0;const{Axios:M0,AxiosError:N0,CanceledError:P0,isCancel:F0,CancelToken:I0,VERSION:wte,all:Tte,Cancel:L0,isAxiosError:R0,spread:z0,toFormData:B0,AxiosHeaders:V0,HttpStatusCode:H0,formToJSON:Ete,getAdapter:U0,mergeConfig:W0}=j0;let G0=class extends gQ{async postSummaryToPr(){let e=this.summaryService.generateMarkdownSummary();await j0.post(`https://api.bitbucket.org/2.0/repositories/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pullrequests/${this.configService.getConfigValue(`prNumber`)}/comments`,{content:{raw:e}},{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})}async getPullRequestInfo(){let e=this.configService.getConfigValue(`gitOrg`),t=this.configService.getConfigValue(`gitRepo`),n=this.configService.getConfigValue(`prNumber`),r=`https://api.bitbucket.org/2.0/repositories/${e}/${t}/pullrequests/${n}`,i=`https://api.bitbucket.org/2.0/repositories/${e}/${t}/pullrequests/${n}/diffstat`,a={Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`},[o,s]=await Promise.all([j0.get(r,{headers:a}),j0.get(i,{headers:a})]);return{number:o.data.id,title:o.data.title,url:o.data.links.html.href,changedFiles:s.data.size,baseRef:o.data.destination.branch.name,headRef:o.data.source.branch.name,contributorAvatarUrl:o.data.author?.links?.avatar?.href}}getGitOrigin(){return this.logger.info(`BitbucketHostService: Getting Git origin`),{origin:`origin`}}async getChangedFilesPR(){return(await this.getChangedFilesWithStatus()).map(e=>e.filePath)}async getChangedFilesWithStatus(){return(await j0.get(`https://api.bitbucket.org/2.0/repositories/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pullrequests/${this.configService.getConfigValue(`prNumber`)}/diffstat`,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.values.filter(e=>[`commit_file`,`modified`].includes(e.status)).map(e=>({filePath:e.new?.path??e.old?.path??``,status:e.status===`commit_file`?pQ.Added:pQ.Modified})).filter(e=>e.filePath.length>0)}async getContributorAvatarUrl(){let e=this.configService.getConfigValue(`commitHash`),t=this.configService.getConfigValue(`gitOrg`),n=this.configService.getConfigValue(`gitRepo`);if(!(!(0,z.isDefined)(e)||!(0,z.isDefined)(t)||!(0,z.isDefined)(n)))try{let r=`https://api.bitbucket.org/2.0/repositories/${t}/${n}/commit/${e}`;return(await j0.get(r,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.author?.user?.links?.avatar?.href}catch(e){this.logger.warn(`BitbucketHostService: Failed to get contributor avatar: ${e instanceof Error?e.message:`Unknown error`}`);return}}getGitCommiterInfo(){return{name:this.configService.getConfigValue(`gitUserName`)??`early-agent[bot]`,email:this.configService.getConfigValue(`gitUserEmail`)??`early-agent[bot]@startearly.ai`}}async setupGit(){let e=this.configService.getConfigValueOrThrow(`token`),t=Buffer.from(`x-token-auth:${e}`).toString(`base64`);try{await yQ(`git remote set-url origin https://x-token-auth@bitbucket.org/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}.git`),await yQ(`git config --local http.https://bitbucket.org/.extraheader "AUTHORIZATION: basic ${t}"`)}catch{this.logger.error(`Failed to setup Git for Bitbucket`)}}async teardownGit(){try{await yQ(`git config --local --unset http.https://bitbucket.org/.extraheader`)}catch{this.logger.warn(`Failed to tear down Git configuration for Bitbucket`)}}};G0=aQ([tt(),st({extendConstructorArguments:!0,extendProperties:!0})],G0);let K0=class extends gQ{async setupGit(){let e=Buffer.from(`oauth2:${this.configService.getConfigValue(`token`)}`).toString(`base64`);try{await yQ(`git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${e}"`)}catch{this.logger.error(`Failed to setup Git`)}try{await yQ(`git fetch --unshallow`)}catch{}}async getPullRequestInfo(){let e=`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pulls/${this.configService.getConfigValue(`prNumber`)}`,t=await j0.get(e,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}});return{title:t.data.title,number:t.data.number,url:t.data.html_url,changedFiles:t.data.changed_files,baseRef:t.data.base.ref,headRef:t.data.head.ref,contributorAvatarUrl:t.data.user?.avatar_url}}async teardownGit(){await yQ(`git config --local --unset http.https://github.com/.extraheader`)}async postSummaryToPr(){let e=this.summaryService.generateMarkdownSummary();await j0.post(`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/issues/${this.configService.getConfigValue(`prNumber`)}/comments`,{body:e},{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})}async getChangedFilesPR(){return(await this.getChangedFilesWithStatus()).map(e=>e.filePath)}async getChangedFilesWithStatus(){let e=`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pulls/${this.configService.getConfigValue(`prNumber`)}/files`,t=[];for(let n=1;n<=3;n+=1){let r=await j0.get(e,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`},params:{per_page:100,page:n}});if(t.push(...r.data),r.data.length<100)break}return t.filter(e=>[`added`,`modified`].includes(e.status)).map(e=>({filePath:e.filename,status:e.status===`added`?pQ.Added:pQ.Modified})).filter(e=>e.filePath.length>0)}async getContributorAvatarUrl(){let e=this.configService.getConfigValue(`gitOrg`),t=this.configService.getConfigValue(`gitRepo`),n=this.configService.getConfigValue(`commitHash`);if(!(!(0,z.isDefined)(e)||!(0,z.isDefined)(t)||!(0,z.isDefined)(n)))try{let r=`https://api.github.com/repos/${e}/${t}/commits/${n}`;return(await j0.get(r,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.author?.avatar_url}catch(e){this.logger.warn(`GithubHostService: Failed to get contributor avatar: ${e instanceof Error?e.message:`Unknown error`}`);return}}getGitOrigin(){return{origin:`origin`}}getGitCommiterInfo(){return{name:this.configService.getConfigValue(`gitUserName`)??`early-agent[bot]`,email:this.configService.getConfigValue(`gitUserEmail`)??`217573370+Early-Agent[bot]@users.noreply.github.com`}}};K0=aQ([tt(),st({extendConstructorArguments:!0,extendProperties:!0})],K0);const q0=new fr({defaultScope:`Singleton`,autobind:!0});q0.bind(sQ).toSelf().inSingletonScope(),q0.bind(cQ).toDynamicValue(e=>new cQ(q0.get(cW.CliOptions),e.get(sQ))).inSingletonScope(),q0.bind(K0).toSelf().inSingletonScope(),q0.bind(G0).toSelf().inSingletonScope(),q0.bind(cW.SCMHostService).toDynamicValue(e=>{let t=e.get(cQ),n=e.get(sQ),r=t.getConfigValue(`SCMProvider`);n.info(`SCMHostService: Selecting provider based on config: ${r}`);let i;switch(r.toLowerCase()){case`github`:i=e.get(K0);break;case`bitbucket`:i=e.get(G0);break;default:n.warn(`Unknown SCM provider: `+r+`, defaulting to github`),i=e.get(K0);break}return i}).inSingletonScope(),q0.bind(cW.TSAgent).toDynamicValue(async e=>{let t=e.get(cQ),n=await e.getAsync(SQ),r=e.get(cW.SCMHostService);await n.hydrateConfig();let i=await n.getGitInfo();await r.setupGit();let a=q0.get(sQ);return(0,sW.createTSAgent)({...t.getConfig(),includeEarlyTests:!0,context:{git:i},progressLogger:a})}).inSingletonScope();var J0=class extends Error{constructor(e,t){super(t),this.statusCode=e}},Y0=class extends J0{},X0=class extends J0{},Dte,Ote;let Z0=class{constructor(e,t,n){this.tsAgent=e,this.configService=t,this.logger=n}async calculateCoverage(e){let{changedSourceFiles:t,successTestFiles:n=[]}=e;try{this.logger.debug(`Coverage: changedSourceFiles: ${JSON.stringify(t)}`),this.logger.debug(`Coverage: successTestFiles: ${JSON.stringify(n)}`);let e=this.configService.getConfigValue(`rootPath`),r=n.map(t=>lW.default.isAbsolute(t)?t:lW.default.resolve(e,t)),i=new Set(r.map(e=>lW.default.normalize(e))),a=await this.tsAgent.getTestableFileMap(t),o=this.extractTestPaths(a).filter(e=>!i.has(lW.default.normalize(e)));this.logger.verbose(`Coverage (before): running with ${o.length} test files`);for(let e of o)this.logger.debug(` [before] test file: ${e}`);await this.tsAgent.generateCoverage(o);let s=await this.tsAgent.getCoverageForFiles(t);if((0,z.isEmpty)(r))return this.logger.verbose(`Coverage: no new test files, before and after are the same`),{success:!0,before:{prCoverage:s},after:{prCoverage:s}};let c=[...o,...r];this.logger.verbose(`Coverage (after): running with ${c.length} test files`);for(let e of c)this.logger.debug(` [after] test file: ${e}`);await this.tsAgent.generateCoverage(c);let l=await this.tsAgent.getCoverageForFiles(t);return this.logger.debug(`Coverage complete: before=${s.percentage??`null`}%, after=${l.percentage??`null`}%`),{success:!0,before:{prCoverage:s},after:{prCoverage:l}}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return this.logger.warn(`Post-commit coverage failed: `+t),{success:!1,reason:t}}}extractTestPaths(e){let t=[];for(let n of Object.values(e))for(let e of n)(0,z.isDefined)(e.testPath)&&t.push(e.testPath);return[...new Set(t)]}};Z0=aQ([tt(),iQ(0,Qe(cW.TSAgent)),iQ(1,Qe(cQ)),iQ(2,Qe(sQ)),rQ(`design:paramtypes`,[typeof(Dte=sW.TSAgent!==void 0&&sW.TSAgent)==`function`?Dte:Object,typeof(Ote=cQ!==void 0&&cQ)==`function`?Ote:Object,Object])],Z0);var Q0=u(sH(),1);const $0=`axios-retry`;function e2(e){return e.response||!e.code||[`ERR_CANCELED`,`ECONNABORTED`].includes(e.code)?!1:(0,Q0.default)(e)}const t2=[`get`,`head`,`options`],n2=t2.concat([`put`,`delete`]);function r2(e){return e.code!==`ECONNABORTED`&&(!e.response||e.response.status===429||e.response.status>=500&&e.response.status<=599)}function i2(e){return e.config?.method?r2(e)&&t2.indexOf(e.config.method)!==-1:!1}function a2(e){return e.config?.method?r2(e)&&n2.indexOf(e.config.method)!==-1:!1}function o2(e){return e2(e)||a2(e)}function s2(e=void 0){let t=e?.response?.headers[`retry-after`];if(!t)return 0;let n=(Number(t)||0)*1e3;return n===0&&(n=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,n)}function c2(e=0,t=void 0){return Math.max(0,s2(t))}function l2(e=0,t=void 0,n=100){let r=2**e*n,i=Math.max(r,s2(t));return i+i*.2*Math.random()}function u2(e=100){return(t=0,n=void 0)=>{let r=t*e;return Math.max(r,s2(n))}}const d2={retries:3,retryCondition:o2,retryDelay:c2,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function f2(e,t){return{...d2,...t,...e[$0]}}function p2(e,t,n=!1){let r=f2(e,t||{});return r.retryCount=r.retryCount||0,(!r.lastRequestTime||n)&&(r.lastRequestTime=Date.now()),e[$0]=r,r}function m2(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function h2(e,t){let{retries:n,retryCondition:r}=e,i=(e.retryCount||0)<n&&r(t);if(typeof i==`object`)try{return await i!==!1}catch{return!1}return i}async function g2(e,t,n,r){t.retryCount+=1;let{retryDelay:i,shouldResetTimeout:a,onRetry:o}=t,s=i(t.retryCount,n);if(m2(e,r),!a&&r.timeout&&t.lastRequestTime){let e=Date.now()-t.lastRequestTime,i=r.timeout-e-s;if(i<=0)return Promise.reject(n);r.timeout=i}return r.transformRequest=[e=>e],await o(t.retryCount,n,r),r.signal?.aborted?Promise.resolve(e(r)):new Promise(t=>{let n=()=>{clearTimeout(i),t(e(r))},i=setTimeout(()=>{t(e(r)),r.signal?.removeEventListener&&r.signal.removeEventListener(`abort`,n)},s);r.signal?.addEventListener&&r.signal.addEventListener(`abort`,n,{once:!0})})}async function _2(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}const v2=(e,t)=>({requestInterceptorId:e.interceptors.request.use(e=>(p2(e,t,!0),e[$0]?.validateResponse&&(e.validateStatus=()=>!1),e)),responseInterceptorId:e.interceptors.response.use(null,async n=>{let{config:r}=n;if(!r)return Promise.reject(n);let i=p2(r,t);return n.response&&i.validateResponse?.(n.response)?n.response:await h2(i,n)?g2(e,i,n,r):(await _2(i,n),Promise.reject(n))})});v2.isNetworkError=e2,v2.isSafeRequestError=i2,v2.isIdempotentRequestError=a2,v2.isNetworkOrIdempotentRequestError=o2,v2.exponentialDelay=l2,v2.linearDelay=u2,v2.isRetryableError=r2;const y2=Error(`request for lock canceled`);var kte=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},b2=class{constructor(e,t=y2){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=x2(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return kte(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ate(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function Ate(e,t){let n=x2(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function x2(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var S2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},C2=class{constructor(e){this._semaphore=new b2(1,e)}acquire(){return S2(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};new TextEncoder;const w2=new TextDecoder;function T2(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function E2(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:w2.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=w2.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``);try{return T2(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var jte=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},D2=class extends jte{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`};Symbol.asyncIterator;function O2(e){return typeof e==`object`&&!!e}var k2=e=>{if(!O2(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t};function A2(e){if(typeof e!=`string`)throw new D2(`JWTs must use Compact JWS serialization, JWT must be a string`);let{1:t,length:n}=e.split(`.`);if(n===5)throw new D2(`Only JWTs using Compact JWS serialization can be decoded`);if(n!==3)throw new D2(`Invalid JWT`);if(!t)throw new D2(`JWTs must contain a payload`);let r;try{r=E2(t)}catch{throw new D2(`Failed to base64url decode the payload`)}let i;try{i=JSON.parse(w2.decode(r))}catch{throw new D2(`Failed to parse the decoded payload as JSON`)}if(!k2(i))throw new D2(`Invalid JWT Claims Set`);return i}const j2=e=>{let t=A2(e).exp;return(0,z.isDefined)(t)?t*1e3:null},M2=e=>{if(!(0,z.isDefined)(e))return!0;let t=j2(e);return(0,z.isDefined)(t)?t>Date.now():!0};let N2=class{jwtToken=null;refreshTokenCallback=null;observer=new z.Observer;refreshTokenMutex=new C2;setJWTToken(e){this.jwtToken=e,this.observer.notifyAll(e)}async getJWTToken(){return(0,z.isDefined)(this.jwtToken)?(this.isTokenValid()||await this.refreshTokenMutex.runExclusive(async()=>{if((0,z.isDefined)(this.refreshTokenCallback))return await this.refreshTokenCallback(),this.jwtToken}),this.jwtToken):null}onJWTTokenSave(e){this.observer.addListener(e)}isTokenValid(){return M2(this.jwtToken)}setRefreshTokenCallback(e){this.refreshTokenCallback=e}};N2=aQ([tt(`Singleton`)],N2);var P2,F2;let I2=class{axiosInstance;constructor(e,t,n){this.configService=e,this.authStorage=t,this.logger=n,this.configService=e,this.axiosInstance=j0.create({baseURL:this.configService.getConfigValueOrThrow(`backendURL`),headers:{"Content-Type":`application/json`}}),v2(this.axiosInstance,{retries:3,retryDelay:v2.exponentialDelay,retryCondition:e=>j0.isAxiosError(e)&&v2.isNetworkOrIdempotentRequestError(e)||j0.isAxiosError(e)&&e.response?.status!==void 0&&e.response.status>=500||!1})}async getAuthHeaders(){let e={"x-request-source":sW.RequestSource.CLI},t=await this.authStorage.getJWTToken();return(0,z.isDefined)(t)&&(e.authorization=`Bearer ${t}`),e}async apiCall({url:e,method:t,data:n,config:r}){let i=new V0(await this.getAuthHeaders());if(r?.headers)for(let[e,t]of Object.entries(r.headers))i.set(e,t);let a={...r,method:t,url:e,data:n,headers:i};try{return await this.axiosInstance.request(a)}catch(t){this.handleError(e,t)}}async get(e,t){return(await this.apiCall({url:e,method:`GET`,config:t})).data}async post(e,t,n){return(await this.apiCall({url:e,method:`POST`,data:t,config:n})).data}async put(e,t,n){return(await this.apiCall({url:e,method:`PUT`,data:t,config:n})).data}async delete(e,t){return(await this.apiCall({url:e,method:`DELETE`,config:t})).data}async patch(e,t,n){return(await this.apiCall({url:e,method:`PATCH`,data:t,config:n})).data}async head(e,t){return this.apiCall({url:e,method:`HEAD`,config:t})}async options(e,t){return this.apiCall({url:e,method:`OPTIONS`,config:t})}handleCustomErrors(e,t){if(e===H0.Conflict){if(t===`workflow_is_cancelled`)throw this.logger.warn(`Agent flow canceled`),new Y0(H0.Conflict,t);if(t===`duplicated_by_sha_workflow`)throw this.logger.warn(`Duplicated SHA workflow`),new X0(H0.Conflict,t)}}handleError(e,t){if(j0.isAxiosError(t))if((0,z.isDefined)(t.response)){let{status:e,statusText:n,data:r}=t.response;throw this.handleCustomErrors(e,r.message),new J0(e,`API request failed: ${e} ${n} - ${JSON.stringify(r)}`)}else if((0,z.isDefined)(t.request))throw Error(`API request failed: No response received from ${e}`);else throw Error(`API request failed: ${t instanceof Error?t.message:`Unknown error`}`);else if(t instanceof Error)throw TypeError(`API request failed: ${t.message}`);else throw TypeError(`API request failed: Unknown error occurred`)}};I2=aQ([tt(),iQ(0,Qe(cQ)),iQ(1,Qe(N2)),iQ(2,Qe(sQ)),rQ(`design:paramtypes`,[typeof(P2=cQ!==void 0&&cQ)==`function`?P2:Object,typeof(F2=N2!==void 0&&N2)==`function`?F2:Object,Object])],I2);let L2=function(e){return e.PR=`PR`,e.COMMIT=`COMMIT`,e.PROJECT=`PROJECT`,e.COVERAGE=`COVERAGE`,e}({});var R2,z2;let B2=class{constructor(e,t){this.apiService=e,this.configService=t}mapCommandToType(e){switch(e){case uW.PR:return L2.PR;case uW.COMMIT:return L2.COMMIT;case uW.PROJECT:return L2.PROJECT;case uW.COVERAGE:return L2.COVERAGE}}async logStartOperation(e){let t=this.configService.getConfig(),n={type:this.mapCommandToType(t.command),owner:e.owner,repo:e.repository,sourceRef:e.ref_name,commitSha:e.sha,commitDate:e.commitDate,traceId:this.configService.getConfigValue(`traceId`),config:this.configService.maskedConfig(),operationStartedAt:new Date().toISOString(),version:t.cliVersion};return(await this.apiService.post(`api/v1/workflows/open`,n)).id}async logEndOperation(e,t,n,r){await this.apiService.patch(`api/v1/workflows/close/${e}`,{operationEndedAt:new Date().toISOString(),failureReason:t,runOutput:n,resultCommitSha:r})}async saveCoverageToWorkflow(e,t,{coverage:n,prCoverage:r,methodsAffected:i,committedFiles:a}){await this.apiService.patch(`api/v1/workflows/${e}/coverage`,{type:t,coverage:n,prCoverage:r,methodsAffected:i,committedFiles:a})}async getCoverageFromWorkflowOrUndefined(e){if(!this.configService.getConfigValue(`reuseCoverage`)||!(0,z.isDefined)(e))return;let t=this.configService.getConfigValue(`reuseCoverageMaxRuns`),n=await this.apiService.post(`api/v1/workflows/${e}/reuse-coverage`,{limit:t});if((0,z.isDefined)(n.coverageBefore))return n.coverageBefore}};B2=aQ([tt(),iQ(0,Qe(I2)),iQ(1,Qe(cQ)),rQ(`design:paramtypes`,[typeof(R2=I2!==void 0&&I2)==`function`?R2:Object,typeof(z2=cQ!==void 0&&cQ)==`function`?z2:Object])],B2);var Mte,V2,H2,U2,W2;let G2=class{constructor(e,t,n,r,i,a){this.gitService=e,this.configService=t,this.summaryService=n,this.scmHostService=r,this.workflowService=i,this.logger=a}async cleanupBlankEarlyFiles(){let e=await this.gitService.getEarlyFiles({absolute:!0}),t=[];for(let n of e)try{(await g.readFile(n,`utf8`)).trim().length===0&&(await g.unlink(n),t.push(n))}catch{this.logger.debug(`Could not read or remove file: ${n}`)}return t}async autoCommit(){if(!this.configService.getConfigValue(`autoCommit`))return this.logger.info(`Auto-commit is disabled — skipping commit step`),{committedFiles:[],error:``};let e=this.configService.getConfigValue(`refName`);return await this.gitService.commitFiles(e)}async finalize(e){if(this.summaryService.setTestGenerationData({generated:e.testResults.generated,succeeded:e.testResults.succeeded,failed:e.testResults.failed,successMethodsCount:e.testResults.successMethodsCount,committedFilesCount:e.committedFilesCount,greenTests:e.testResults.greenTests,redTests:e.testResults.redTests,skippedMethods:e.testResults.skippedMethods}),this.summaryService.setAutoCommitStatus(this.configService.getConfigValue(`autoCommit`)),await this.scmHostService.safePostSummaryToPr(),(0,z.isDefined)(e.workflowRunId))try{let t=this.summaryService.getWorkflowRunOutput();await this.workflowService.logEndOperation(e.workflowRunId,e.failureReason,t,e.resultCommitSha),this.logger.debug(`Successfully logged workflow end`)}catch(e){this.logger.warn(`Failed to log workflow end: ${e instanceof Error?e.message:`Unknown error`}`)}}};G2=aQ([tt(),iQ(0,Qe(SQ)),iQ(1,Qe(cQ)),iQ(2,Qe(dQ)),iQ(3,Qe(cW.SCMHostService)),iQ(4,Qe(B2)),iQ(5,Qe(sQ)),rQ(`design:paramtypes`,[typeof(Mte=SQ!==void 0&&SQ)==`function`?Mte:Object,typeof(V2=cQ!==void 0&&cQ)==`function`?V2:Object,typeof(H2=dQ!==void 0&&dQ)==`function`?H2:Object,typeof(U2=gQ!==void 0&&gQ)==`function`?U2:Object,typeof(W2=B2!==void 0&&B2)==`function`?W2:Object,Object])],G2);let K2=class{constructor(e){this.logger=e}detectChanges(e,t,n,r,i){try{return!(0,z.isDefined)(r)||(0,z.isEmpty)(r)?this.handleNewFile(e,n):this.compareMethodLists(e,t,n,r,i)}catch(t){return this.logger.warn(`Failed to detect changes in file ${e}: ${t instanceof Error?t.message:`Unknown error`}`),[]}}handleNewFile(e,t){return t.map(t=>({name:t.name,type:t.type,parentName:`parentName`in t?t.parentName:void 0,changeType:`added`,filePath:e,canCreateTests:t.canCreateTests}))}compareMethodLists(e,t,n,r,i){let a=[];for(let o of n){let n=this.findMatchingMethod(t,o);(0,z.isDefined)(n)?this.hasMethodChanged(n,o,r,i)&&a.push(this.createChangedMethod(e,o,`modified`)):a.push(this.createChangedMethod(e,o,`added`))}for(let r of t)this.findMatchingMethod(n,r)||a.push(this.createChangedMethod(e,r,`deleted`));return a}findMatchingMethod(e,t){return e.find(e=>{let n=e.name===t.name,r=e.type===t.type,i=(`parentName`in e?e.parentName:void 0)===(`parentName`in t?t.parentName:void 0);return n&&r&&i})}hasMethodChanged(e,t,n,r){let i=this.extractMethodText(e,n),a=this.extractMethodText(t,r);return i.replaceAll(`\r
32411
+ `+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=Z1(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&C0.assertOptions(n,{silentJSONParsing:w0.transitional(w0.boolean),forcedJSONParsing:w0.transitional(w0.boolean),clarifyTimeoutError:w0.transitional(w0.boolean)},!1),r!=null&&(x$.isFunction(r)?t.paramsSerializer={serialize:r}:C0.assertOptions(r,{encode:w0.function,serialize:w0.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),C0.assertOptions(t,{baseUrl:w0.spelling(`baseURL`),withXsrfToken:w0.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&x$.merge(i.common,i[t.method]);i&&x$.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=i1.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){typeof e.runWhen==`function`&&e.runWhen(t)===!1||(s&&=e.synchronous,o.unshift(e.fulfilled,e.rejected))});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[y0.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=y0.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=Z1(this.defaults,e),I$(d1(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};x$.forEach([`delete`,`get`,`head`,`options`],function(e){T0.prototype[e]=function(t,n){return this.request(Z1(n||{},{method:e,url:t,data:(n||{}).data}))}}),x$.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(Z1(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}T0.prototype[e]=t(),T0.prototype[e+`Form`]=t(!0)});var E0=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new s1(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function D0(e){return function(t){return e.apply(null,t)}}function O0(e){return x$.isObject(e)&&e.isAxiosError===!0}const k0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(k0).forEach(([e,t])=>{k0[t]=e});function A0(e){let t=new T0(e),n=CQ(T0.prototype.request,t);return x$.extend(n,T0.prototype,t,{allOwnKeys:!0}),x$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return A0(Z1(e,t))},n}const j0=A0(e1);j0.Axios=T0,j0.CanceledError=s1,j0.CancelToken=E0,j0.isCancel=o1,j0.VERSION=m1,j0.toFormData=j$,j0.AxiosError=S$,j0.Cancel=j0.CanceledError,j0.all=function(e){return Promise.all(e)},j0.spread=D0,j0.isAxiosError=O0,j0.mergeConfig=Z1,j0.AxiosHeaders=i1,j0.formToJSON=e=>$$(x$.isHTMLForm(e)?new FormData(e):e),j0.getAdapter=_0.getAdapter,j0.HttpStatusCode=k0,j0.default=j0;const{Axios:M0,AxiosError:N0,CanceledError:P0,isCancel:F0,CancelToken:I0,VERSION:wte,all:Tte,Cancel:L0,isAxiosError:R0,spread:z0,toFormData:B0,AxiosHeaders:V0,HttpStatusCode:H0,formToJSON:Ete,getAdapter:U0,mergeConfig:W0}=j0;let G0=class extends gQ{async postSummaryToPr(){let e=this.summaryService.generateMarkdownSummary();await j0.post(`https://api.bitbucket.org/2.0/repositories/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pullrequests/${this.configService.getConfigValue(`prNumber`)}/comments`,{content:{raw:e}},{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})}async getPullRequestInfo(){let e=this.configService.getConfigValue(`gitOrg`),t=this.configService.getConfigValue(`gitRepo`),n=this.configService.getConfigValue(`prNumber`),r=`https://api.bitbucket.org/2.0/repositories/${e}/${t}/pullrequests/${n}`,i=`https://api.bitbucket.org/2.0/repositories/${e}/${t}/pullrequests/${n}/diffstat`,a={Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`},[o,s]=await Promise.all([j0.get(r,{headers:a}),j0.get(i,{headers:a})]);return{number:o.data.id,title:o.data.title,url:o.data.links.html.href,changedFiles:s.data.size,baseRef:o.data.destination.branch.name,headRef:o.data.source.branch.name,contributorAvatarUrl:o.data.author?.links?.avatar?.href}}getGitOrigin(){return this.logger.info(`BitbucketHostService: Getting Git origin`),{origin:`origin`}}async getChangedFilesPR(){return(await this.getChangedFilesWithStatus()).map(e=>e.filePath)}async getChangedFilesWithStatus(){return(await j0.get(`https://api.bitbucket.org/2.0/repositories/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pullrequests/${this.configService.getConfigValue(`prNumber`)}/diffstat`,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.values.filter(e=>[`commit_file`,`modified`].includes(e.status)).map(e=>({filePath:e.new?.path??e.old?.path??``,status:e.status===`commit_file`?pQ.Added:pQ.Modified})).filter(e=>e.filePath.length>0)}async getContributorAvatarUrl(){let e=this.configService.getConfigValue(`commitHash`),t=this.configService.getConfigValue(`gitOrg`),n=this.configService.getConfigValue(`gitRepo`);if(!(!(0,z.isDefined)(e)||!(0,z.isDefined)(t)||!(0,z.isDefined)(n)))try{let r=`https://api.bitbucket.org/2.0/repositories/${t}/${n}/commit/${e}`;return(await j0.get(r,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.author?.user?.links?.avatar?.href}catch(e){this.logger.warn(`BitbucketHostService: Failed to get contributor avatar: ${e instanceof Error?e.message:`Unknown error`}`);return}}getGitCommiterInfo(){return{name:this.configService.getConfigValue(`gitUserName`)??`early-agent[bot]`,email:this.configService.getConfigValue(`gitUserEmail`)??`early-agent[bot]@startearly.ai`}}async setupGit(){let e=this.configService.getConfigValueOrThrow(`token`),t=Buffer.from(`x-token-auth:${e}`).toString(`base64`);try{await yQ(`git remote set-url origin https://x-token-auth@bitbucket.org/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}.git`),await yQ(`git config --local http.https://bitbucket.org/.extraheader "AUTHORIZATION: basic ${t}"`)}catch{this.logger.error(`Failed to setup Git for Bitbucket`)}}async teardownGit(){try{await yQ(`git config --local --unset http.https://bitbucket.org/.extraheader`)}catch{this.logger.warn(`Failed to tear down Git configuration for Bitbucket`)}}};G0=aQ([tt(),st({extendConstructorArguments:!0,extendProperties:!0})],G0);let K0=class extends gQ{async setupGit(){let e=Buffer.from(`oauth2:${this.configService.getConfigValue(`token`)}`).toString(`base64`);try{await yQ(`git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${e}"`)}catch{this.logger.error(`Failed to setup Git`)}try{await yQ(`git fetch --unshallow`)}catch{}}async getPullRequestInfo(){let e=`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pulls/${this.configService.getConfigValue(`prNumber`)}`,t=await j0.get(e,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}});return{title:t.data.title,number:t.data.number,url:t.data.html_url,changedFiles:t.data.changed_files,baseRef:t.data.base.ref,headRef:t.data.head.ref,contributorAvatarUrl:t.data.user?.avatar_url}}async teardownGit(){await yQ(`git config --local --unset http.https://github.com/.extraheader`)}async postSummaryToPr(){let e=this.summaryService.generateMarkdownSummary();await j0.post(`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/issues/${this.configService.getConfigValue(`prNumber`)}/comments`,{body:e},{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})}async getChangedFilesPR(){return(await this.getChangedFilesWithStatus()).map(e=>e.filePath)}async getChangedFilesWithStatus(){let e=`https://api.github.com/repos/${this.configService.getConfigValue(`gitOrg`)}/${this.configService.getConfigValue(`gitRepo`)}/pulls/${this.configService.getConfigValue(`prNumber`)}/files`,t=[];for(let n=1;n<=3;n+=1){let r=await j0.get(e,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`},params:{per_page:100,page:n}});if(t.push(...r.data),r.data.length<100)break}return t.filter(e=>[`added`,`modified`].includes(e.status)).map(e=>({filePath:e.filename,status:e.status===`added`?pQ.Added:pQ.Modified})).filter(e=>e.filePath.length>0)}async getContributorAvatarUrl(){let e=this.configService.getConfigValue(`gitOrg`),t=this.configService.getConfigValue(`gitRepo`),n=this.configService.getConfigValue(`commitHash`);if(!(!(0,z.isDefined)(e)||!(0,z.isDefined)(t)||!(0,z.isDefined)(n)))try{let r=`https://api.github.com/repos/${e}/${t}/commits/${n}`;return(await j0.get(r,{headers:{Authorization:`Bearer ${this.configService.getConfigValue(`token`)}`}})).data.author?.avatar_url}catch(e){this.logger.warn(`GithubHostService: Failed to get contributor avatar: ${e instanceof Error?e.message:`Unknown error`}`);return}}getGitOrigin(){return{origin:`origin`}}getGitCommiterInfo(){return{name:this.configService.getConfigValue(`gitUserName`)??`early-agent[bot]`,email:this.configService.getConfigValue(`gitUserEmail`)??`217573370+Early-Agent[bot]@users.noreply.github.com`}}};K0=aQ([tt(),st({extendConstructorArguments:!0,extendProperties:!0})],K0);const q0=new fr({defaultScope:`Singleton`,autobind:!0});q0.bind(sQ).toSelf().inSingletonScope(),q0.bind(cQ).toDynamicValue(e=>new cQ(q0.get(cW.CliOptions),e.get(sQ))).inSingletonScope(),q0.bind(K0).toSelf().inSingletonScope(),q0.bind(G0).toSelf().inSingletonScope(),q0.bind(cW.SCMHostService).toDynamicValue(e=>{let t=e.get(cQ),n=e.get(sQ),r=t.getConfigValue(`SCMProvider`);n.info(`SCMHostService: Selecting provider based on config: ${r}`);let i;switch(r.toLowerCase()){case`github`:i=e.get(K0);break;case`bitbucket`:i=e.get(G0);break;default:n.warn(`Unknown SCM provider: `+r+`, defaulting to github`),i=e.get(K0);break}return i}).inSingletonScope(),q0.bind(cW.TSAgent).toDynamicValue(async e=>{let t=e.get(cQ),n=await e.getAsync(SQ),r=e.get(cW.SCMHostService);await n.hydrateConfig();let i=await n.getGitInfo();await r.setupGit();let a=q0.get(sQ);return(0,sW.createTSAgent)({...t.getConfig(),includeEarlyTests:!0,context:{git:i},progressLogger:a})}).inSingletonScope();var J0=class extends Error{constructor(e,t){super(t),this.statusCode=e}},Y0=class extends J0{},X0=class extends J0{},Dte,Ote;let Z0=class{constructor(e,t,n){this.tsAgent=e,this.configService=t,this.logger=n}async calculateCoverage(e){let{changedSourceFiles:t,successTestFiles:n=[]}=e;try{this.logger.debug(`Coverage: changedSourceFiles: ${JSON.stringify(t)}`),this.logger.debug(`Coverage: successTestFiles: ${JSON.stringify(n)}`);let e=this.configService.getConfigValue(`rootPath`),r=n.map(t=>lW.default.isAbsolute(t)?t:lW.default.resolve(e,t)),i=new Set(r.map(e=>lW.default.normalize(e))),a=await this.tsAgent.getTestableFileMap(t),o=this.extractTestPaths(a).filter(e=>!i.has(lW.default.normalize(e))),s=[...o,...r];if((0,z.isEmpty)(o)&&(0,z.isEmpty)(s))return this.logger.verbose(`Coverage: no test files found, skipping coverage generation`),{success:!0,before:{prCoverage:{percentage:null,totalStatements:0,coveredStatements:0}},after:{prCoverage:{percentage:null,totalStatements:0,coveredStatements:0}}};let c;if((0,z.isEmpty)(o))this.logger.verbose(`Coverage (before): no existing test files, using zero coverage`),c={percentage:null,totalStatements:0,coveredStatements:0};else{this.logger.verbose(`Coverage (before): running with ${o.length} test files`);for(let e of o)this.logger.debug(` [before] test file: ${e}`);await this.tsAgent.generateCoverage(o),c=await this.tsAgent.getCoverageForFiles(t)}if((0,z.isEmpty)(r))return this.logger.verbose(`Coverage: no new test files, before and after are the same`),{success:!0,before:{prCoverage:c},after:{prCoverage:c}};this.logger.verbose(`Coverage (after): running with ${s.length} test files`);for(let e of s)this.logger.debug(` [after] test file: ${e}`);await this.tsAgent.generateCoverage(s);let l=await this.tsAgent.getCoverageForFiles(t);return this.logger.debug(`Coverage complete: before=${c.percentage??`null`}%, after=${l.percentage??`null`}%`),{success:!0,before:{prCoverage:c},after:{prCoverage:l}}}catch(e){let t=e instanceof Error?e.message:`Unknown error`;return this.logger.warn(`Post-commit coverage failed: `+t),{success:!1,reason:t}}}extractTestPaths(e){let t=[];for(let n of Object.values(e))for(let e of n)(0,z.isDefined)(e.testPath)&&t.push(e.testPath);return[...new Set(t)]}};Z0=aQ([tt(),iQ(0,Qe(cW.TSAgent)),iQ(1,Qe(cQ)),iQ(2,Qe(sQ)),rQ(`design:paramtypes`,[typeof(Dte=sW.TSAgent!==void 0&&sW.TSAgent)==`function`?Dte:Object,typeof(Ote=cQ!==void 0&&cQ)==`function`?Ote:Object,Object])],Z0);var Q0=u(sH(),1);const $0=`axios-retry`;function e2(e){return e.response||!e.code||[`ERR_CANCELED`,`ECONNABORTED`].includes(e.code)?!1:(0,Q0.default)(e)}const t2=[`get`,`head`,`options`],n2=t2.concat([`put`,`delete`]);function r2(e){return e.code!==`ECONNABORTED`&&(!e.response||e.response.status===429||e.response.status>=500&&e.response.status<=599)}function i2(e){return e.config?.method?r2(e)&&t2.indexOf(e.config.method)!==-1:!1}function a2(e){return e.config?.method?r2(e)&&n2.indexOf(e.config.method)!==-1:!1}function o2(e){return e2(e)||a2(e)}function s2(e=void 0){let t=e?.response?.headers[`retry-after`];if(!t)return 0;let n=(Number(t)||0)*1e3;return n===0&&(n=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,n)}function c2(e=0,t=void 0){return Math.max(0,s2(t))}function l2(e=0,t=void 0,n=100){let r=2**e*n,i=Math.max(r,s2(t));return i+i*.2*Math.random()}function u2(e=100){return(t=0,n=void 0)=>{let r=t*e;return Math.max(r,s2(n))}}const d2={retries:3,retryCondition:o2,retryDelay:c2,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function f2(e,t){return{...d2,...t,...e[$0]}}function p2(e,t,n=!1){let r=f2(e,t||{});return r.retryCount=r.retryCount||0,(!r.lastRequestTime||n)&&(r.lastRequestTime=Date.now()),e[$0]=r,r}function m2(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}async function h2(e,t){let{retries:n,retryCondition:r}=e,i=(e.retryCount||0)<n&&r(t);if(typeof i==`object`)try{return await i!==!1}catch{return!1}return i}async function g2(e,t,n,r){t.retryCount+=1;let{retryDelay:i,shouldResetTimeout:a,onRetry:o}=t,s=i(t.retryCount,n);if(m2(e,r),!a&&r.timeout&&t.lastRequestTime){let e=Date.now()-t.lastRequestTime,i=r.timeout-e-s;if(i<=0)return Promise.reject(n);r.timeout=i}return r.transformRequest=[e=>e],await o(t.retryCount,n,r),r.signal?.aborted?Promise.resolve(e(r)):new Promise(t=>{let n=()=>{clearTimeout(i),t(e(r))},i=setTimeout(()=>{t(e(r)),r.signal?.removeEventListener&&r.signal.removeEventListener(`abort`,n)},s);r.signal?.addEventListener&&r.signal.addEventListener(`abort`,n,{once:!0})})}async function _2(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}const v2=(e,t)=>({requestInterceptorId:e.interceptors.request.use(e=>(p2(e,t,!0),e[$0]?.validateResponse&&(e.validateStatus=()=>!1),e)),responseInterceptorId:e.interceptors.response.use(null,async n=>{let{config:r}=n;if(!r)return Promise.reject(n);let i=p2(r,t);return n.response&&i.validateResponse?.(n.response)?n.response:await h2(i,n)?g2(e,i,n,r):(await _2(i,n),Promise.reject(n))})});v2.isNetworkError=e2,v2.isSafeRequestError=i2,v2.isIdempotentRequestError=a2,v2.isNetworkOrIdempotentRequestError=o2,v2.exponentialDelay=l2,v2.linearDelay=u2,v2.isRetryableError=r2;const y2=Error(`request for lock canceled`);var kte=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},b2=class{constructor(e,t=y2){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=x2(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return kte(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ate(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function Ate(e,t){let n=x2(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function x2(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var S2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},C2=class{constructor(e){this._semaphore=new b2(1,e)}acquire(){return S2(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}};new TextEncoder;const w2=new TextDecoder;function T2(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function E2(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:w2.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=w2.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``);try{return T2(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var jte=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},D2=class extends jte{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`};Symbol.asyncIterator;function O2(e){return typeof e==`object`&&!!e}var k2=e=>{if(!O2(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t};function A2(e){if(typeof e!=`string`)throw new D2(`JWTs must use Compact JWS serialization, JWT must be a string`);let{1:t,length:n}=e.split(`.`);if(n===5)throw new D2(`Only JWTs using Compact JWS serialization can be decoded`);if(n!==3)throw new D2(`Invalid JWT`);if(!t)throw new D2(`JWTs must contain a payload`);let r;try{r=E2(t)}catch{throw new D2(`Failed to base64url decode the payload`)}let i;try{i=JSON.parse(w2.decode(r))}catch{throw new D2(`Failed to parse the decoded payload as JSON`)}if(!k2(i))throw new D2(`Invalid JWT Claims Set`);return i}const j2=e=>{let t=A2(e).exp;return(0,z.isDefined)(t)?t*1e3:null},M2=e=>{if(!(0,z.isDefined)(e))return!0;let t=j2(e);return(0,z.isDefined)(t)?t>Date.now():!0};let N2=class{jwtToken=null;refreshTokenCallback=null;observer=new z.Observer;refreshTokenMutex=new C2;setJWTToken(e){this.jwtToken=e,this.observer.notifyAll(e)}async getJWTToken(){return(0,z.isDefined)(this.jwtToken)?(this.isTokenValid()||await this.refreshTokenMutex.runExclusive(async()=>{if((0,z.isDefined)(this.refreshTokenCallback))return await this.refreshTokenCallback(),this.jwtToken}),this.jwtToken):null}onJWTTokenSave(e){this.observer.addListener(e)}isTokenValid(){return M2(this.jwtToken)}setRefreshTokenCallback(e){this.refreshTokenCallback=e}};N2=aQ([tt(`Singleton`)],N2);var P2,F2;let I2=class{axiosInstance;constructor(e,t,n){this.configService=e,this.authStorage=t,this.logger=n,this.configService=e,this.axiosInstance=j0.create({baseURL:this.configService.getConfigValueOrThrow(`backendURL`),headers:{"Content-Type":`application/json`}}),v2(this.axiosInstance,{retries:3,retryDelay:v2.exponentialDelay,retryCondition:e=>j0.isAxiosError(e)&&v2.isNetworkOrIdempotentRequestError(e)||j0.isAxiosError(e)&&e.response?.status!==void 0&&e.response.status>=500||!1})}async getAuthHeaders(){let e={"x-request-source":sW.RequestSource.CLI},t=await this.authStorage.getJWTToken();return(0,z.isDefined)(t)&&(e.authorization=`Bearer ${t}`),e}async apiCall({url:e,method:t,data:n,config:r}){let i=new V0(await this.getAuthHeaders());if(r?.headers)for(let[e,t]of Object.entries(r.headers))i.set(e,t);let a={...r,method:t,url:e,data:n,headers:i};try{return await this.axiosInstance.request(a)}catch(t){this.handleError(e,t)}}async get(e,t){return(await this.apiCall({url:e,method:`GET`,config:t})).data}async post(e,t,n){return(await this.apiCall({url:e,method:`POST`,data:t,config:n})).data}async put(e,t,n){return(await this.apiCall({url:e,method:`PUT`,data:t,config:n})).data}async delete(e,t){return(await this.apiCall({url:e,method:`DELETE`,config:t})).data}async patch(e,t,n){return(await this.apiCall({url:e,method:`PATCH`,data:t,config:n})).data}async head(e,t){return this.apiCall({url:e,method:`HEAD`,config:t})}async options(e,t){return this.apiCall({url:e,method:`OPTIONS`,config:t})}handleCustomErrors(e,t){if(e===H0.Conflict){if(t===`workflow_is_cancelled`)throw this.logger.warn(`Agent flow canceled`),new Y0(H0.Conflict,t);if(t===`duplicated_by_sha_workflow`)throw this.logger.warn(`Duplicated SHA workflow`),new X0(H0.Conflict,t)}}handleError(e,t){if(j0.isAxiosError(t))if((0,z.isDefined)(t.response)){let{status:e,statusText:n,data:r}=t.response;throw this.handleCustomErrors(e,r.message),new J0(e,`API request failed: ${e} ${n} - ${JSON.stringify(r)}`)}else if((0,z.isDefined)(t.request))throw Error(`API request failed: No response received from ${e}`);else throw Error(`API request failed: ${t instanceof Error?t.message:`Unknown error`}`);else if(t instanceof Error)throw TypeError(`API request failed: ${t.message}`);else throw TypeError(`API request failed: Unknown error occurred`)}};I2=aQ([tt(),iQ(0,Qe(cQ)),iQ(1,Qe(N2)),iQ(2,Qe(sQ)),rQ(`design:paramtypes`,[typeof(P2=cQ!==void 0&&cQ)==`function`?P2:Object,typeof(F2=N2!==void 0&&N2)==`function`?F2:Object,Object])],I2);let L2=function(e){return e.PR=`PR`,e.COMMIT=`COMMIT`,e.PROJECT=`PROJECT`,e.COVERAGE=`COVERAGE`,e}({});var R2,z2;let B2=class{constructor(e,t){this.apiService=e,this.configService=t}mapCommandToType(e){switch(e){case uW.PR:return L2.PR;case uW.COMMIT:return L2.COMMIT;case uW.PROJECT:return L2.PROJECT;case uW.COVERAGE:return L2.COVERAGE}}async logStartOperation(e){let t=this.configService.getConfig(),n={type:this.mapCommandToType(t.command),owner:e.owner,repo:e.repository,sourceRef:e.ref_name,commitSha:e.sha,commitDate:e.commitDate,traceId:this.configService.getConfigValue(`traceId`),config:this.configService.maskedConfig(),operationStartedAt:new Date().toISOString(),version:t.cliVersion};return(await this.apiService.post(`api/v1/workflows/open`,n)).id}async logEndOperation(e,t,n,r){await this.apiService.patch(`api/v1/workflows/close/${e}`,{operationEndedAt:new Date().toISOString(),failureReason:t,runOutput:n,resultCommitSha:r})}async saveCoverageToWorkflow(e,t,{coverage:n,prCoverage:r,methodsAffected:i,committedFiles:a}){await this.apiService.patch(`api/v1/workflows/${e}/coverage`,{type:t,coverage:n,prCoverage:r,methodsAffected:i,committedFiles:a})}async getCoverageFromWorkflowOrUndefined(e){if(!this.configService.getConfigValue(`reuseCoverage`)||!(0,z.isDefined)(e))return;let t=this.configService.getConfigValue(`reuseCoverageMaxRuns`),n=await this.apiService.post(`api/v1/workflows/${e}/reuse-coverage`,{limit:t});if((0,z.isDefined)(n.coverageBefore))return n.coverageBefore}};B2=aQ([tt(),iQ(0,Qe(I2)),iQ(1,Qe(cQ)),rQ(`design:paramtypes`,[typeof(R2=I2!==void 0&&I2)==`function`?R2:Object,typeof(z2=cQ!==void 0&&cQ)==`function`?z2:Object])],B2);var Mte,V2,H2,U2,W2;let G2=class{constructor(e,t,n,r,i,a){this.gitService=e,this.configService=t,this.summaryService=n,this.scmHostService=r,this.workflowService=i,this.logger=a}async cleanupBlankEarlyFiles(){let e=await this.gitService.getEarlyFiles({absolute:!0}),t=[];for(let n of e)try{(await g.readFile(n,`utf8`)).trim().length===0&&(await g.unlink(n),t.push(n))}catch{this.logger.debug(`Could not read or remove file: ${n}`)}return t}async autoCommit(){if(!this.configService.getConfigValue(`autoCommit`))return this.logger.info(`Auto-commit is disabled — skipping commit step`),{committedFiles:[],error:``};let e=this.configService.getConfigValue(`refName`);return await this.gitService.commitFiles(e)}async finalize(e){if(this.summaryService.setTestGenerationData({generated:e.testResults.generated,succeeded:e.testResults.succeeded,failed:e.testResults.failed,successMethodsCount:e.testResults.successMethodsCount,committedFilesCount:e.committedFilesCount,greenTests:e.testResults.greenTests,redTests:e.testResults.redTests,skippedMethods:e.testResults.skippedMethods}),this.summaryService.setAutoCommitStatus(this.configService.getConfigValue(`autoCommit`)),await this.scmHostService.safePostSummaryToPr(),(0,z.isDefined)(e.workflowRunId))try{let t=this.summaryService.getWorkflowRunOutput();await this.workflowService.logEndOperation(e.workflowRunId,e.failureReason,t,e.resultCommitSha),this.logger.debug(`Successfully logged workflow end`)}catch(e){this.logger.warn(`Failed to log workflow end: ${e instanceof Error?e.message:`Unknown error`}`)}}};G2=aQ([tt(),iQ(0,Qe(SQ)),iQ(1,Qe(cQ)),iQ(2,Qe(dQ)),iQ(3,Qe(cW.SCMHostService)),iQ(4,Qe(B2)),iQ(5,Qe(sQ)),rQ(`design:paramtypes`,[typeof(Mte=SQ!==void 0&&SQ)==`function`?Mte:Object,typeof(V2=cQ!==void 0&&cQ)==`function`?V2:Object,typeof(H2=dQ!==void 0&&dQ)==`function`?H2:Object,typeof(U2=gQ!==void 0&&gQ)==`function`?U2:Object,typeof(W2=B2!==void 0&&B2)==`function`?W2:Object,Object])],G2);let K2=class{constructor(e){this.logger=e}detectChanges(e,t,n,r,i){try{return!(0,z.isDefined)(r)||(0,z.isEmpty)(r)?this.handleNewFile(e,n):this.compareMethodLists(e,t,n,r,i)}catch(t){return this.logger.warn(`Failed to detect changes in file ${e}: ${t instanceof Error?t.message:`Unknown error`}`),[]}}handleNewFile(e,t){return t.map(t=>({name:t.name,type:t.type,parentName:`parentName`in t?t.parentName:void 0,changeType:`added`,filePath:e,canCreateTests:t.canCreateTests}))}compareMethodLists(e,t,n,r,i){let a=[];for(let o of n){let n=this.findMatchingMethod(t,o);(0,z.isDefined)(n)?this.hasMethodChanged(n,o,r,i)&&a.push(this.createChangedMethod(e,o,`modified`)):a.push(this.createChangedMethod(e,o,`added`))}for(let r of t)this.findMatchingMethod(n,r)||a.push(this.createChangedMethod(e,r,`deleted`));return a}findMatchingMethod(e,t){return e.find(e=>{let n=e.name===t.name,r=e.type===t.type,i=(`parentName`in e?e.parentName:void 0)===(`parentName`in t?t.parentName:void 0);return n&&r&&i})}hasMethodChanged(e,t,n,r){let i=this.extractMethodText(e,n),a=this.extractMethodText(t,r);return i.replaceAll(`\r
32412
32412
  `,`
32413
32413
  `)!==a.replaceAll(`\r
32414
32414
  `,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earlyai/cli",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "early cli",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {