skilless 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +32 -32
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{execFile as t,execFileSync as n,spawn as r,spawnSync as i}from"node:child_process";import a from"node:fs";import o from"node:process";import s from"node:os";import c from"node:crypto";import{stripVTControlCharacters as
|
|
2
|
+
import{createRequire as e}from"node:module";import{execFile as t,execFileSync as n,spawn as r,spawnSync as i}from"node:child_process";import a from"node:fs";import o from"node:process";import s from"node:os";import c,{createHash as l}from"node:crypto";import{stripVTControlCharacters as u}from"node:util";import d from"node:tty";import f from"node:http";var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,ee=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ee(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e},ne=(e,t,n)=>(n=e==null?{}:p(g(e)),te(t||!e||!e.__esModule?m(n,`default`,{value:e,enumerable:!0}):n,e)),y=e(import.meta.url),re=v((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),ie=v((e=>{let{InvalidArgumentError:t}=re();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ae=v((e=>{let{humanReadableArgName:t}=ie();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
3
3
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
4
4
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
5
5
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),oe=v((e=>{let{InvalidArgumentError:t}=re();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -8,7 +8,7 @@ import{createRequire as e}from"node:module";import{execFile as t,execFileSync as
|
|
|
8
8
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
|
|
9
9
|
- too many short flags`):i.test(t)?Error(`${n}
|
|
10
10
|
- too many long flags`):Error(`${n}
|
|
11
|
-
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),se=v((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),ce=v((e=>{let t=
|
|
11
|
+
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),se=v((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),ce=v((e=>{let t=y(`node:events`).EventEmitter,n=y(`node:child_process`),r=y(`node:path`),i=y(`node:fs`),a=y(`node:process`),{Argument:o,humanReadableArgName:s}=ie(),{CommanderError:c}=re(),{Help:l,stripColor:u}=ae(),{Option:d,DualOptions:f}=oe(),{suggestSimilar:p}=se();var m=class e extends t{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>a.stdout.write(e),writeErr:e=>a.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:void 0,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:void 0,getOutHasColors:()=>ee()??(a.stdout.isTTY&&a.stdout.hasColors?.()),getErrHasColors:()=>ee()??(a.stderr.isTTY&&a.stderr.hasColors?.()),stripColor:e=>u(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new l,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
|
|
12
12
|
- specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new o(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
13
|
Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new c(e,t,n)),a.exit(e)}action(e){return this._actionHandler=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)},this}createOption(e,t){return new d(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
14
14
|
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,`default`)}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{r(t,`error: option '${e.flags}' argument '${t}' is invalid.`,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{r(t,`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof d)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){a.versions?.electron&&(t.from=`electron`);let e=a.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=a.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:a.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
@@ -17,9 +17,9 @@ 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*\.\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:le,createCommand:ue,createArgument:de,createOption:fe,CommanderError:pe,InvalidArgumentError:me,InvalidOptionArgumentError:he,Command:y,Argument:ge,Option:_e,Help:ve}=te(v((e=>{let{Argument:t}=ie(),{Command:n}=ce(),{CommanderError:r,InvalidArgumentError:i}=re(),{Help:a}=ae(),{Option:o}=oe();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;let ye=()=>{var e=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of n(a))!r.call(i,c)&&c!==o&&e(i,c,{get:()=>a[c],enumerable:!(s=t(a,c))||s.enumerable});return i},o=t=>a(e({},`__esModule`,{value:!0}),t),s={};i(s,{default:()=>Xe});var c=e=>Array.isArray(e),l=e=>typeof e==`function`,u=e=>e.length===0,d=e=>typeof e==`number`,f=e=>typeof e==`object`&&!!e,p=e=>e instanceof RegExp,m=e=>typeof e==`string`,h=e=>e===void 0,g=e=>{let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=e(n);return t.set(n,i),i}},_=(e,t,n={})=>{let r={cache:{},input:e,index:0,indexMax:0,options:n,output:[]};if(fe(t)(r)&&r.index===e.length)return r.output;throw Error(`Failed to parse at index ${r.indexMax}`)},v=(e,t)=>c(e)?ee(e,t):m(e)?ne(e,t):te(e,t),ee=(e,t)=>{let n={};for(let t of e){if(t.length!==1)throw Error(`Invalid character: "${t}"`);let e=t.charCodeAt(0);n[e]=!0}return e=>{let r=e.index,i=e.input;for(;e.index<i.length&&i.charCodeAt(e.index)in n;)e.index+=1;let a=e.index;if(a>r){if(!h(t)&&!e.options.silent){let n=e.input.slice(r,a),o=l(t)?t(n,i,String(r)):t;h(o)||e.output.push(o)}e.indexMax=Math.max(e.indexMax,e.index)}return!0}},te=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return ue(e=>{i.lastIndex=e.index;let n=i.exec(e.input);if(n){if(!h(t)&&!e.options.silent){let r=l(t)?t(...n,e.input,String(e.index)):t;h(r)||e.output.push(r)}return e.index+=n[0].length,e.indexMax=Math.max(e.indexMax,e.index),!0}else return!1})},ne=(e,t)=>n=>{if(n.input.startsWith(e,n.index)){if(!h(t)&&!n.options.silent){let r=l(t)?t(e,n.input,String(n.index)):t;h(r)||n.output.push(r)}return n.index+=e.length,n.indexMax=Math.max(n.indexMax,n.index),!0}else return!1},re=(e,t,n,r)=>{let i=fe(e);return ue(le(ce(e=>{let r=0;for(;r<n;){let t=e.index;if(!i(e)||(r+=1,e.index===t))break}return r>=t})))},ie=(e,t)=>re(e,0,1),ae=(e,t)=>re(e,0,1/0),oe=(e,t)=>{let n=e.map(fe);return ue(le(ce(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},se=(e,t)=>{let n=e.map(fe);return ue(le(e=>{for(let t=0,r=n.length;t<r;t++)if(n[t](e))return!0;return!1}))},ce=(e,t=!1)=>{let n=fe(e);return e=>{let r=e.index,i=e.output.length,a=n(e);return(!a||t)&&(e.index=r,e.output.length!==i&&(e.output.length=i)),a}},le=(e,t)=>fe(e),ue=(()=>{let e=0;return t=>{let n=fe(t),r=e+=1;return e=>{var t;if(e.options.memoization===!1)return n(e);let i=e.index,a=(t=e.cache)[r]||(t[r]=new Map),o=a.get(i);if(o===!1)return!1;if(d(o))return e.index=o,!0;if(o)return e.index=o.index,o.output?.length&&e.output.push(...o.output),!0;{let t=e.output.length;if(n(e)){let n=e.index,r=e.output.length;if(r>t){let o=e.output.slice(t,r);a.set(i,{index:n,output:o})}else a.set(i,n);return!0}else return a.set(i,!1),!1}}}})(),de=e=>{let t;return n=>(t||=fe(e()),t(n))},fe=g(e=>{if(l(e))return u(e)?de(e):e;if(m(e)||p(e))return v(e);if(c(e))return oe(e);if(f(e))return se(Object.values(e));throw Error(`Invalid rule`)}),pe=`abcdefghijklmnopqrstuvwxyz`,me=e=>{let t=``;for(;e>0;)t=pe[(e-1)%26]+t,e=Math.floor((e-1)/26);return t},he=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t=t*26+pe.indexOf(e[n])+1;return t},y=(e,t)=>{if(t<e)return y(t,e);let n=[];for(;e<=t;)n.push(e++);return n},ge=(e,t,n)=>y(e,t).map(e=>String(e).padStart(n,`0`)),_e=(e,t)=>y(he(e),he(t)).map(me),ve=e=>e,ye=e=>be(t=>_(t,e,{memoization:!1}).join(``)),be=e=>{let t={};return n=>t[n]??(t[n]=e(n))},xe=v(/^\*\*\/\*$/,`.*`),Se=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),Ce=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),we=v(/\\./,ve),Te=v(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=v(/./,ve),De=se([v(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${b(t)}$).*?`),v(/^(!!)+/,``)]),Oe=se([v(/\/(\*\*\/)+/,`(?:/.+/|/)`),v(/^(\*\*\/)+/,`(?:^|.*/)`),v(/\/(\*\*)$/,`(?:/.*|$)`),v(/\*\*/,`.*`)]),ke=se([v(/\*\/(?!\*\*\/)/,`[^/]*/`),v(/\*/,`[^/]*`)]),Ae=v(`?`,`[^/]`),je=v(`[`,ve),Me=v(`]`,ve),Ne=v(/[!^]/,`^/`),Pe=v(/[a-z]-[a-z]|[0-9]-[0-9]/i,ve),Fe=se([we,v(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Pe,v(/[^\]]/,ve)]),Ie=oe([je,ie(Ne),ae(Fe),Me]),Le=v(`{`,`(?:`),Re=v(`}`,`)`),ze=oe([Le,se([v(/(\d+)\.\.(\d+)/,(e,t,n)=>ge(+t,+n,Math.min(t.length,n.length)).join(`|`)),v(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>_e(t,n).join(`|`)),v(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>_e(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Re]),Be=v(`{`,`(?:`),Ve=v(`}`,`)`),He=v(`,`,`|`),Ue=v(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),We=v(/[^}]/,ve),Ge=oe([Be,ae(se([Oe,ke,Ae,Ie,ze,de(()=>Ge),we,Ue,He,We])),Ve]),b=ye(ae(se([xe,Se,Ce,De,Oe,ke,Ae,Ie,ze,Ge,we,Te,Ee]))),Ke=v(/\\./,ve),qe=v(/./,ve),Je=ye(ae(se([Ke,v(/\*\*\*+/,`*`),v(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),v(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),qe]))),Ye=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(Ye.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};Ye.compile=e=>RegExp(`^${b(Je(e))}$`,`s`);var Xe=Ye;return o(s)})();return e.default||e},be;const xe=(e,t)=>(be||(be=ye(),ye=null),be(e,t)),Se=/^[A-Za-z]:\//;function Ce(e=``){return e&&e.replace(/\\/g,`/`).replace(Se,e=>e.toUpperCase())}const we=/^[/\\]{2}/,Te=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Ee=/^[A-Za-z]:$/,De=/^\/([A-Za-z]:)?$/,Oe=/.(\.[^./]+|\.)$/,ke=/^[/\\]|^[a-zA-Z]:[/\\]/,Ae=function(e){if(e.length===0)return`.`;e=Ce(e);let t=e.match(we),n=Fe(e),r=e[e.length-1]===`/`;return e=Pe(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Ee.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Fe(e)?`/${e}`:e)},je=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return Ae(t)};function Me(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Ne=function(...e){e=e.map(e=>Ce(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Me();!i||i.length===0||(t=`${i}/${t}`,n=Fe(i))}return t=Pe(t,!n),n&&!Fe(t)?`/${t}`:t.length>0?t:`.`};function Pe(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const Fe=function(e){return Te.test(e)},Ie=function(e){return Ce(e)},Le=function(e){if(e===`..`)return``;let t=Oe.exec(Ce(e));return t&&t[1]||``},Re=function(e,t){let n=Ne(e).replace(De,`$1`).split(`/`),r=Ne(t).replace(De,`$1`).split(`/`);if(r[0][1]===`:`&&n[0][1]===`:`&&n[0]!==r[0])return r.join(`/`);let i=[...n];for(let e of i){if(r[0]!==e)break;n.shift(),r.shift()}return[...n.map(()=>`..`),...r].join(`/`)},ze=function(e){let t=Ce(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Ee.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Fe(e)?`/`:`.`)},Be=function(e){let t=e.ext?e.ext.startsWith(`.`)?e.ext:`.${e.ext}`:``,n=[e.root,e.dir,e.base??(e.name??``)+t].filter(Boolean);return Ce(e.root?Ne(...n):n.join(`/`))},Ve=function(e,t){let n=Ce(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},He={__proto__:null,basename:Ve,dirname:ze,extname:Le,format:Be,isAbsolute:Fe,join:je,matchesGlob:(e,t)=>xe(t,Ae(e)),normalize:Ae,normalizeString:Pe,parse:function(e){let t=ke.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=Ve(e),r=Le(n);return{root:t,dir:ze(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Re,resolve:Ne,sep:`/`,toNamespacedPath:Ie},Ue=globalThis.process?.platform===`win32`?`;`:`:`,We={posix:void 0,win32:void 0},Ge=(e=Ue)=>new Proxy(He,{get(t,n){return n===`delimiter`?e:n===`posix`?b:n===`win32`?Ke:We[n]||He[n]}}),b=Ge(`:`),Ke=Ge(`;`);function qe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Je(e,t=`|`){return e.map(e=>vt(e)).join(t)}function Ye(e,t){return typeof t==`bigint`?t.toString():t}var Xe=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Ze(e){return new Xe(e)}function Qe(e){return e==null}function $e(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function et(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function tt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function nt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function rt(e){return nt(e._zod.def)??e._zod.def.shape}function it(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return tt(this,t,e),e},enumerable:!0,configurable:!0})}function at(e,t,n){t in e?tt(e,t,n):e[t]=n}function ot(e,t,n,r){let i=rt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?it(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):at(e,a,r?r(n.value,a):n.value))}}function st(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?it(e,n,()=>t[n]):at(e,n,r.value))}}function x(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ct(e){return JSON.stringify(e)}function lt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const ut=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ft=Ze(()=>{if(on.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pt(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(dt(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function mt(e){return pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const ht=new Set([`string`,`number`,`symbol`]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _t(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function S(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function vt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function yt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const bt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},xt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function St(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return ot(i,e,Ct(e,t)),_t(e,x(n,{shape:i,checks:[]}))}function Ct(e,t){let n=rt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function wt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Ct(e,t)),a={};return ot(a,e,Reflect.ownKeys(rt(e)).filter(e=>!i.has(e))),_t(e,x(n,{shape:a,checks:[]}))}function Tt(e,t){if(!pt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=rt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _t(e,x(e._zod.def,{shape:Et(e,t)}))}function Et(e,t){let n={};return ot(n,e,Reflect.ownKeys(rt(e))),st(n,t),n}function Dt(e,t){if(!pt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _t(e,x(e._zod.def,{shape:Et(e,t)}))}function Ot(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return ot(n,e,Reflect.ownKeys(rt(e))),ot(n,t,Reflect.ownKeys(rt(t))),_t(e,x(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function kt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ct(t,n)):void 0,o={};return ot(o,t,Reflect.ownKeys(rt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),_t(t,x(t._zod.def,{shape:o,checks:[]}))}function At(e,t,n){let r=n?new Set(Ct(t,n)):void 0,i={};return ot(i,t,Reflect.ownKeys(rt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),_t(t,x(t._zod.def,{shape:i}))}function jt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Mt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Nt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Pt(e){return typeof e==`string`?e:e?.message}function Ft(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function It(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Pt(e.inst?._zod.def?.error?.(e))??Pt(a?.(e))??Pt(t?.error?.(e))??Pt(n.customError?.(e))??Pt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t===`inst`||t===`schema`||t===`continue`||t===`input`||t===`__proto__`||(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const Lt=/[\uD800-\uDBFF]/;function Rt(e){let t=e.length;if(!Lt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function zt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Bt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Vt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Ht(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Kt(e,n,r.value)}}function Ut(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Wt(e,t,n){return Ut(e,t,n,!1)}function Gt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ut(this,n,r(this))},set(e){Ut(this,n,e)}})}return t}function Kt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ut(this,t,n.bind(this))},set(e){Ut(this,t,e)}})}function qt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Jt,Yt=!1;const Xt={configurable:!0,get(){Yt=!0}};function C(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Jt!==e._zod){Jt=void 0;return}Jt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Xt);let e=Yt;Yt=!1;try{let r=n(this);return Yt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Yt||=e,r}catch(n){throw delete this[t],Yt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Zt(e,t,n,r){let i=qt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Qt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var $t;const en={value:void 0,enumerable:!1};let tn=`captureStackTrace`in Error?Error:null;function nn(e){let t=tn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return tn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function w(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{en.value=new a(r);try{Object.defineProperty(n,`_zod`,en)}finally{en.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Ht(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,`name`,{value:e});function d(e){let t=r?.Parent?nn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,`init`,{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,`name`,{value:e}),d}var rn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},an=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};($t=globalThis).__zod_globalConfig??($t.__zod_globalConfig={});const on=globalThis.__zod_globalConfig;function sn(e){return e&&Object.assign(on,e),on}function cn(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ye,2),e.message}function ln(e){this._zod.message=e}const un={get:cn,set:ln,enumerable:!0,configurable:!0},dn={value:void 0,enumerable:!1},fn=new WeakSet([Object.prototype,Error.prototype]),pn=(e,t)=>{e.name=`$ZodError`,dn.value=t,Object.defineProperty(e,`issues`,dn),dn.value=void 0,Object.defineProperty(e,`message`,un);let n=Object.getPrototypeOf(e);fn.has(n)||(fn.add(n),Object.defineProperty(n,`toString`,{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0})}}))},mn=w(`$ZodError`,pn);w(`$ZodError`,pn,void 0,{Parent:Error});function hn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function gn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?hn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _n(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function vn(e,t){return{callee:t?.callee??e,Err:t?.Err}}const yn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rn;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>It(e,o,sn())));throw ut(n,a?.callee??t),n}return s.value};return t},bn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>It(e,o,sn())));throw ut(n,a?.callee??t),n}return s.value};return t},xn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new rn;return a.issues.length?Sn(e,a.issues,i):{success:!0,data:a.value}};function Sn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>It(e,n,sn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Cn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Sn(e,a.issues,i):{success:!0,data:a.value}},wn=Symbol.for(`zod.compile.invalid`),Tn=Symbol.for(`zod.compile.fallback`),En=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==wn)return!0;if(r.definite===!0&&n===void 0)return!1}return Dn(e,t,n)});function Dn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Tn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new rn;return a.issues.length===0}const On=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},kn=e=>{let t=yn(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},vn(n,a));return n},An=e=>{let t=yn(e),n=(e,r,i,a)=>t(e,r,i,vn(n,a));return n},jn=e=>{let t=bn(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},vn(n,a));return n},Mn=e=>{let t=bn(e),n=async(e,r,i,a)=>await t(e,r,i,vn(n,a));return n},Nn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xn(e)(t,n,i)},Pn=e=>(t,n,r)=>xn(e)(t,n,r),Fn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cn(e)(t,n,i)},In=e=>async(t,n,r)=>Cn(e)(t,n,r),Ln=/^[cC][0-9a-z]{6,}$/,Rn=/^[0-9a-z]+$/,zn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bn=/^[0-9a-vA-V]{20}$/,Vn=/^[A-Za-z0-9]{27}$/,Hn=/^[a-zA-Z0-9_-]{21}$/;function Un(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Wn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Jn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Zn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$n=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,er=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,tr=/^https?$/,nr=/^\+[1-9]\d{6,14}$/,rr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function ir(e){return RegExp(`^${e}$`)}const ar=ir(rr);function or(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function sr(e){return RegExp(`^${or(e)}$`)}function cr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${or({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${or({precision:e.precision})}`:n;return RegExp(`^${rr}T(?:${r})$`)}const lr=/^[\s\S]{0,}$/,ur=/^-?\d+(?:\.\d+)?$/,dr=/^(?:true|false)$/i,fr=/^[^A-Z]*$/,pr=/^[^a-z]*$/,T=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mr=e=>{let t=e.value;return!Qe(t)&&t.length!==void 0},hr={number:`number`,bigint:`bigint`,object:`date`},gr=w(`$ZodCheckLessThan`,(e,t)=>{T.init(e,t);let n=hr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:hr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_r=w(`$ZodCheckGreaterThan`,(e,t)=>{T.init(e,t);let n=hr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:hr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vr=w(`$ZodCheckMultipleOf`,(e,t)=>{T.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):et(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yr=w(`$ZodCheckNumberFormat`,(e,t)=>{T.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=bt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),br=w(`$ZodCheckMaxLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Rt(r):i)<=t.maximum)return;let a=zt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xr=w(`$ZodCheckMinLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Rt(r):i)>=t.minimum)return;let a=zt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sr=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Rt(r):i;if(a===t.length)return;let o=zt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cr=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;T.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),wr=w(`$ZodCheckRegex`,(e,t)=>{Cr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Tr=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=fr,Cr.init(e,t)}),Er=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=pr,Cr.init(e,t)}),Dr=w(`$ZodCheckIncludes`,(e,t)=>{T.init(e,t);let n=gt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Or=w(`$ZodCheckStartsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`^${gt(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),kr=w(`$ZodCheckEndsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`.*${gt(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ar=w(`$ZodCheckOverwrite`,(e,t)=>{T.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var jr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
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 ee(){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=ee}));const{program:le,createCommand:ue,createArgument:de,createOption:fe,CommanderError:pe,InvalidArgumentError:me,InvalidOptionArgumentError:he,Command:b,Argument:ge,Option:x,Help:_e}=ne(v((e=>{let{Argument:t}=ie(),{Command:n}=ce(),{CommanderError:r,InvalidArgumentError:i}=re(),{Help:a}=ae(),{Option:o}=oe();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;let ve=()=>{var e=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of n(a))!r.call(i,c)&&c!==o&&e(i,c,{get:()=>a[c],enumerable:!(s=t(a,c))||s.enumerable});return i},o=t=>a(e({},`__esModule`,{value:!0}),t),s={};i(s,{default:()=>Je});var c=e=>Array.isArray(e),l=e=>typeof e==`function`,u=e=>e.length===0,d=e=>typeof e==`number`,f=e=>typeof e==`object`&&!!e,p=e=>e instanceof RegExp,m=e=>typeof e==`string`,h=e=>e===void 0,ee=e=>{let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=e(n);return t.set(n,i),i}},g=(e,t,n={})=>{let r={cache:{},input:e,index:0,indexMax:0,options:n,output:[]};if(de(t)(r)&&r.index===e.length)return r.output;throw Error(`Failed to parse at index ${r.indexMax}`)},_=(e,t)=>c(e)?v(e,t):m(e)?ne(e,t):te(e,t),v=(e,t)=>{let n={};for(let t of e){if(t.length!==1)throw Error(`Invalid character: "${t}"`);let e=t.charCodeAt(0);n[e]=!0}return e=>{let r=e.index,i=e.input;for(;e.index<i.length&&i.charCodeAt(e.index)in n;)e.index+=1;let a=e.index;if(a>r){if(!h(t)&&!e.options.silent){let n=e.input.slice(r,a),o=l(t)?t(n,i,String(r)):t;h(o)||e.output.push(o)}e.indexMax=Math.max(e.indexMax,e.index)}return!0}},te=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return le(e=>{i.lastIndex=e.index;let n=i.exec(e.input);if(n){if(!h(t)&&!e.options.silent){let r=l(t)?t(...n,e.input,String(e.index)):t;h(r)||e.output.push(r)}return e.index+=n[0].length,e.indexMax=Math.max(e.indexMax,e.index),!0}else return!1})},ne=(e,t)=>n=>{if(n.input.startsWith(e,n.index)){if(!h(t)&&!n.options.silent){let r=l(t)?t(e,n.input,String(n.index)):t;h(r)||n.output.push(r)}return n.index+=e.length,n.indexMax=Math.max(n.indexMax,n.index),!0}else return!1},y=(e,t,n,r)=>{let i=de(e);return le(ce(se(e=>{let r=0;for(;r<n;){let t=e.index;if(!i(e)||(r+=1,e.index===t))break}return r>=t})))},re=(e,t)=>y(e,0,1),ie=(e,t)=>y(e,0,1/0),ae=(e,t)=>{let n=e.map(de);return le(ce(se(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},oe=(e,t)=>{let n=e.map(de);return le(ce(e=>{for(let t=0,r=n.length;t<r;t++)if(n[t](e))return!0;return!1}))},se=(e,t=!1)=>{let n=de(e);return e=>{let r=e.index,i=e.output.length,a=n(e);return(!a||t)&&(e.index=r,e.output.length!==i&&(e.output.length=i)),a}},ce=(e,t)=>de(e),le=(()=>{let e=0;return t=>{let n=de(t),r=e+=1;return e=>{var t;if(e.options.memoization===!1)return n(e);let i=e.index,a=(t=e.cache)[r]||(t[r]=new Map),o=a.get(i);if(o===!1)return!1;if(d(o))return e.index=o,!0;if(o)return e.index=o.index,o.output?.length&&e.output.push(...o.output),!0;{let t=e.output.length;if(n(e)){let n=e.index,r=e.output.length;if(r>t){let o=e.output.slice(t,r);a.set(i,{index:n,output:o})}else a.set(i,n);return!0}else return a.set(i,!1),!1}}}})(),ue=e=>{let t;return n=>(t||=de(e()),t(n))},de=ee(e=>{if(l(e))return u(e)?ue(e):e;if(m(e)||p(e))return _(e);if(c(e))return ae(e);if(f(e))return oe(Object.values(e));throw Error(`Invalid rule`)}),fe=`abcdefghijklmnopqrstuvwxyz`,pe=e=>{let t=``;for(;e>0;)t=fe[(e-1)%26]+t,e=Math.floor((e-1)/26);return t},me=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t=t*26+fe.indexOf(e[n])+1;return t},he=(e,t)=>{if(t<e)return he(t,e);let n=[];for(;e<=t;)n.push(e++);return n},b=(e,t,n)=>he(e,t).map(e=>String(e).padStart(n,`0`)),ge=(e,t)=>he(me(e),me(t)).map(pe),x=e=>e,_e=e=>ve(t=>g(t,e,{memoization:!1}).join(``)),ve=e=>{let t={};return n=>t[n]??(t[n]=e(n))},ye=_(/^\*\*\/\*$/,`.*`),be=_(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),xe=_(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),Se=_(/\\./,x),Ce=_(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),we=_(/./,x),Te=oe([_(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${We(t)}$).*?`),_(/^(!!)+/,``)]),Ee=oe([_(/\/(\*\*\/)+/,`(?:/.+/|/)`),_(/^(\*\*\/)+/,`(?:^|.*/)`),_(/\/(\*\*)$/,`(?:/.*|$)`),_(/\*\*/,`.*`)]),De=oe([_(/\*\/(?!\*\*\/)/,`[^/]*/`),_(/\*/,`[^/]*`)]),Oe=_(`?`,`[^/]`),ke=_(`[`,x),Ae=_(`]`,x),je=_(/[!^]/,`^/`),Me=_(/[a-z]-[a-z]|[0-9]-[0-9]/i,x),Ne=oe([Se,_(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Me,_(/[^\]]/,x)]),Pe=ae([ke,re(je),ie(Ne),Ae]),Fe=_(`{`,`(?:`),Ie=_(`}`,`)`),Le=ae([Fe,oe([_(/(\d+)\.\.(\d+)/,(e,t,n)=>b(+t,+n,Math.min(t.length,n.length)).join(`|`)),_(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ge(t,n).join(`|`)),_(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ge(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Ie]),Re=_(`{`,`(?:`),ze=_(`}`,`)`),Be=_(`,`,`|`),Ve=_(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),He=_(/[^}]/,x),Ue=ae([Re,ie(oe([Ee,De,Oe,Pe,Le,ue(()=>Ue),Se,Ve,Be,He])),ze]),We=_e(ie(oe([ye,be,xe,Te,Ee,De,Oe,Pe,Le,Ue,Se,Ce,we]))),S=_(/\\./,x),Ge=_(/./,x),Ke=_e(ie(oe([S,_(/\*\*\*+/,`*`),_(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),_(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),Ge]))),qe=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(qe.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};qe.compile=e=>RegExp(`^${We(Ke(e))}$`,`s`);var Je=qe;return o(s)})();return e.default||e},ye;const be=(e,t)=>(ye||(ye=ve(),ve=null),ye(e,t)),xe=/^[A-Za-z]:\//;function Se(e=``){return e&&e.replace(/\\/g,`/`).replace(xe,e=>e.toUpperCase())}const Ce=/^[/\\]{2}/,we=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Te=/^[A-Za-z]:$/,Ee=/^\/([A-Za-z]:)?$/,De=/.(\.[^./]+|\.)$/,Oe=/^[/\\]|^[a-zA-Z]:[/\\]/,ke=function(e){if(e.length===0)return`.`;e=Se(e);let t=e.match(Ce),n=Pe(e),r=e[e.length-1]===`/`;return e=Ne(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Te.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Pe(e)?`/${e}`:e)},Ae=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return ke(t)};function je(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Me=function(...e){e=e.map(e=>Se(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:je();!i||i.length===0||(t=`${i}/${t}`,n=Pe(i))}return t=Ne(t,!n),n&&!Pe(t)?`/${t}`:t.length>0?t:`.`};function Ne(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const Pe=function(e){return we.test(e)},Fe=function(e){return Se(e)},Ie=function(e){if(e===`..`)return``;let t=De.exec(Se(e));return t&&t[1]||``},Le=function(e,t){let n=Me(e).replace(Ee,`$1`).split(`/`),r=Me(t).replace(Ee,`$1`).split(`/`);if(r[0][1]===`:`&&n[0][1]===`:`&&n[0]!==r[0])return r.join(`/`);let i=[...n];for(let e of i){if(r[0]!==e)break;n.shift(),r.shift()}return[...n.map(()=>`..`),...r].join(`/`)},Re=function(e){let t=Se(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Te.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Pe(e)?`/`:`.`)},ze=function(e){let t=e.ext?e.ext.startsWith(`.`)?e.ext:`.${e.ext}`:``,n=[e.root,e.dir,e.base??(e.name??``)+t].filter(Boolean);return Se(e.root?Me(...n):n.join(`/`))},Be=function(e,t){let n=Se(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},Ve={__proto__:null,basename:Be,dirname:Re,extname:Ie,format:ze,isAbsolute:Pe,join:Ae,matchesGlob:(e,t)=>be(t,ke(e)),normalize:ke,normalizeString:Ne,parse:function(e){let t=Oe.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=Be(e),r=Ie(n);return{root:t,dir:Re(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Le,resolve:Me,sep:`/`,toNamespacedPath:Fe},He=globalThis.process?.platform===`win32`?`;`:`:`,Ue={posix:void 0,win32:void 0},We=(e=He)=>new Proxy(Ve,{get(t,n){return n===`delimiter`?e:n===`posix`?S:n===`win32`?Ge:Ue[n]||Ve[n]}}),S=We(`:`),Ge=We(`;`);function Ke(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function qe(e,t=`|`){return e.map(e=>_t(e)).join(t)}function Je(e,t){return typeof t==`bigint`?t.toString():t}var Ye=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Xe(e){return new Ye(e)}function Ze(e){return e==null}function Qe(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function $e(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function et(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function tt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function nt(e){return tt(e._zod.def)??e._zod.def.shape}function rt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return et(this,t,e),e},enumerable:!0,configurable:!0})}function it(e,t,n){t in e?et(e,t,n):e[t]=n}function at(e,t,n,r){let i=nt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?rt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):it(e,a,r?r(n.value,a):n.value))}}function ot(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?rt(e,n,()=>t[n]):it(e,n,r.value))}}function C(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function st(e){return JSON.stringify(e)}function ct(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const lt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const dt=Xe(()=>{if(an.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ft(e){if(ut(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ut(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function pt(e){return ft(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const mt=new Set([`string`,`number`,`symbol`]);function ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function gt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function _t(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function vt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const yt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},bt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return at(i,e,St(e,t)),gt(e,C(n,{shape:i,checks:[]}))}function St(e,t){let n=nt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ct(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(St(e,t)),a={};return at(a,e,Reflect.ownKeys(nt(e)).filter(e=>!i.has(e))),gt(e,C(n,{shape:a,checks:[]}))}function wt(e,t){if(!ft(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=nt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return gt(e,C(e._zod.def,{shape:Tt(e,t)}))}function Tt(e,t){let n={};return at(n,e,Reflect.ownKeys(nt(e))),ot(n,t),n}function Et(e,t){if(!ft(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return gt(e,C(e._zod.def,{shape:Tt(e,t)}))}function Dt(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return at(n,e,Reflect.ownKeys(nt(e))),at(n,t,Reflect.ownKeys(nt(t))),gt(e,C(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ot(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(St(t,n)):void 0,o={};return at(o,t,Reflect.ownKeys(nt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),gt(t,C(t._zod.def,{shape:o,checks:[]}))}function kt(e,t,n){let r=n?new Set(St(t,n)):void 0,i={};return at(i,t,Reflect.ownKeys(nt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),gt(t,C(t._zod.def,{shape:i}))}function At(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function jt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Mt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Nt(e){return typeof e==`string`?e:e?.message}function Pt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ft(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Nt(e.inst?._zod.def?.error?.(e))??Nt(a?.(e))??Nt(t?.error?.(e))??Nt(n.customError?.(e))??Nt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t===`inst`||t===`schema`||t===`continue`||t===`input`||t===`__proto__`||(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const It=/[\uD800-\uDBFF]/;function Lt(e){let t=e.length;if(!It.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Rt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function zt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Bt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Vt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Gt(e,n,r.value)}}function Ht(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ut(e,t,n){return Ht(e,t,n,!1)}function Wt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ht(this,n,r(this))},set(e){Ht(this,n,e)}})}return t}function Gt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ht(this,t,n.bind(this))},set(e){Ht(this,t,e)}})}function Kt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let qt,Jt=!1;const Yt={configurable:!0,get(){Jt=!0}};function T(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&qt!==e._zod){qt=void 0;return}qt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Yt);let e=Jt;Jt=!1;try{let r=n(this);return Jt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Jt||=e,r}catch(n){throw delete this[t],Jt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Xt(e,t,n,r){let i=Kt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Zt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Qt;const $t={value:void 0,enumerable:!1};let en=`captureStackTrace`in Error?Error:null;function tn(e){let t=en;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return en=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function E(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{$t.value=new a(r);try{Object.defineProperty(n,`_zod`,$t)}finally{$t.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Vt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,`name`,{value:e});function d(e){let t=r?.Parent?tn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,`init`,{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,`name`,{value:e}),d}var nn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},rn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Qt=globalThis).__zod_globalConfig??(Qt.__zod_globalConfig={});const an=globalThis.__zod_globalConfig;function on(e){return e&&Object.assign(an,e),an}function sn(){let e=this._zod;return e.message??=JSON.stringify(e.def,Je,2),e.message}function cn(e){this._zod.message=e}const ln={get:sn,set:cn,enumerable:!0,configurable:!0},un={value:void 0,enumerable:!1},dn=new WeakSet([Object.prototype,Error.prototype]),fn=(e,t)=>{e.name=`$ZodError`,un.value=t,Object.defineProperty(e,`issues`,un),un.value=void 0,Object.defineProperty(e,`message`,ln);let n=Object.getPrototypeOf(e);dn.has(n)||(dn.add(n),Object.defineProperty(n,`toString`,{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0})}}))},pn=E(`$ZodError`,fn);E(`$ZodError`,fn,void 0,{Parent:Error});function mn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function hn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?mn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function gn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function _n(e,t){return{callee:t?.callee??e,Err:t?.Err}}const vn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new nn;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Ft(e,o,on())));throw lt(n,a?.callee??t),n}return s.value};return t},yn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Ft(e,o,on())));throw lt(n,a?.callee??t),n}return s.value};return t},bn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new nn;return a.issues.length?xn(e,a.issues,i):{success:!0,data:a.value}};function xn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Ft(e,n,on()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Sn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?xn(e,a.issues,i):{success:!0,data:a.value}},Cn=Symbol.for(`zod.compile.invalid`),wn=Symbol.for(`zod.compile.fallback`),Tn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Cn)return!0;if(r.definite===!0&&n===void 0)return!1}return En(e,t,n)});function En(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[wn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new nn;return a.issues.length===0}const Dn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},On=e=>{let t=vn(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},_n(n,a));return n},kn=e=>{let t=vn(e),n=(e,r,i,a)=>t(e,r,i,_n(n,a));return n},An=e=>{let t=yn(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},_n(n,a));return n},jn=e=>{let t=yn(e),n=async(e,r,i,a)=>await t(e,r,i,_n(n,a));return n},Mn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return bn(e)(t,n,i)},Nn=e=>(t,n,r)=>bn(e)(t,n,r),Pn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Sn(e)(t,n,i)},Fn=e=>async(t,n,r)=>Sn(e)(t,n,r),In=/^[cC][0-9a-z]{6,}$/,Ln=/^[0-9a-z]+$/,Rn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,zn=/^[0-9a-vA-V]{20}$/,Bn=/^[A-Za-z0-9]{27}$/,Vn=/^[a-zA-Z0-9_-]{21}$/;function Hn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Un=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Gn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Kn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function qn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Jn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Yn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Xn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Zn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$n=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,er=/^https?$/,tr=/^\+[1-9]\d{6,14}$/,nr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function rr(e){return RegExp(`^${e}$`)}const ir=rr(nr);function ar(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function or(e){return RegExp(`^${ar(e)}$`)}function sr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ar({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ar({precision:e.precision})}`:n;return RegExp(`^${nr}T(?:${r})$`)}const cr=/^[\s\S]{0,}$/,lr=/^-?\d+(?:\.\d+)?$/,ur=/^(?:true|false)$/i,dr=/^[^A-Z]*$/,fr=/^[^a-z]*$/,D=E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),pr=e=>{let t=e.value;return!Ze(t)&&t.length!==void 0},mr={number:`number`,bigint:`bigint`,object:`date`},hr=E(`$ZodCheckLessThan`,(e,t)=>{D.init(e,t);let n=mr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:mr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gr=E(`$ZodCheckGreaterThan`,(e,t)=>{D.init(e,t);let n=mr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:mr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_r=E(`$ZodCheckMultipleOf`,(e,t)=>{D.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):$e(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),vr=E(`$ZodCheckNumberFormat`,(e,t)=>{D.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=yt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),yr=E(`$ZodCheckMaxLength`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=pr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Lt(r):i)<=t.maximum)return;let a=Rt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),br=E(`$ZodCheckMinLength`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=pr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Lt(r):i)>=t.minimum)return;let a=Rt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xr=E(`$ZodCheckLengthEquals`,(e,t)=>{var n;D.init(e,t),(n=e._zod.def).when??(n.when=pr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Lt(r):i;if(a===t.length)return;let o=Rt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Sr=E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;D.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Cr=E(`$ZodCheckRegex`,(e,t)=>{Sr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wr=E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=dr,Sr.init(e,t)}),Tr=E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=fr,Sr.init(e,t)}),Er=E(`$ZodCheckIncludes`,(e,t)=>{D.init(e,t);let n=ht(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Dr=E(`$ZodCheckStartsWith`,(e,t)=>{D.init(e,t);let n=RegExp(`^${ht(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Or=E(`$ZodCheckEndsWith`,(e,t)=>{D.init(e,t);let n=RegExp(`.*${ht(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),kr=E(`$ZodCheckOverwrite`,(e,t)=>{D.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ar=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
21
21
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
22
|
-
`)}\n};`)(...Object.values(this.closed))}};const Mr={major:4,minor:6,patch:5},E=w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=jt(t),a;for(let o of n){if(o._zod.def.when){if(Mt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new rn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ft(t.issues,n,e),i||=jt(t,n))});else{if(t.issues.length===n)continue;Ft(t.issues,n,e),i||=jt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(jt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new rn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new rn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Wt(this,`~standard`,Fr(this))},set"~standard"(e){Ut(this,`~standard`,e)}}),Nr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>It(e,t,sn()))}:{value:e.value};async function Pr(e,t){let n={async:!0};return Nr(await e._zod.run({value:t,issues:[]},n),n)}function Fr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Nr(r,n)}catch{}return Pr(e,t)},vendor:`zod`,version:1}}const Ir=w(`$ZodString`,(e,t)=>{E.init(e,t),e._zod.pattern=t.pattern??lr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),D=w(`$ZodStringFormat`,(e,t)=>{Cr.init(e,t),Ir.init(e,t)}),Lr=w(`$ZodGUID`,(e,t)=>{t.pattern??=Gn,D.init(e,t)}),Rr=w(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Kn(e)}else t.pattern??=Kn();D.init(e,t)}),zr=w(`$ZodEmail`,(e,t)=>{t.pattern??=qn,D.init(e,t)});function Br(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Vr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Br(e)||2:Hr(e,t)}function Hr(e,t){if(!t.normalize&&t.protocol?.source===tr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const Ur=/[\t\n\r]/g;function Wr(e){return e.replace(Ur,``)}function Gr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Kr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const qr=w(`$ZodURL`,(e,t)=>{D.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Vr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Wr(r);return}t.hostname&&!Gr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Kr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Wr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Jr=w(`$ZodEmoji`,(e,t)=>{t.pattern??=Jn(),D.init(e,t)}),Yr=w(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Hn:Un(t.length),D.init(e,t)}),Xr=w(`$ZodCUID`,(e,t)=>{t.pattern??=Ln,D.init(e,t)}),Zr=w(`$ZodCUID2`,(e,t)=>{t.pattern??=Rn,D.init(e,t)}),Qr=w(`$ZodULID`,(e,t)=>{t.pattern??=zn,D.init(e,t)}),$r=w(`$ZodXID`,(e,t)=>{t.pattern??=Bn,D.init(e,t)}),ei=w(`$ZodKSUID`,(e,t)=>{t.pattern??=Vn,D.init(e,t)}),ti=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=cr(t),D.init(e,t)}),ni=w(`$ZodISODate`,(e,t)=>{t.pattern??=ar,D.init(e,t)}),ri=w(`$ZodISOTime`,(e,t)=>{t.pattern??=sr(t),D.init(e,t)}),ii=w(`$ZodISODuration`,(e,t)=>{t.pattern??=Wn,D.init(e,t)}),ai=w(`$ZodIPv4`,(e,t)=>{t.pattern??=Yn,D.init(e,t)}),oi=/^[0-9a-fA-F:.]+$/;function si(e){return oi.test(e)?Br(`http://[${e}]`):!1}const ci=w(`$ZodIPv6`,(e,t)=>{t.pattern??=Xn,D.init(e,t),e._zod.check=n=>{si(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),li=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Zn,D.init(e,t)});function ui(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:si(n)}const di=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Qn,D.init(e,t),e._zod.check=n=>{ui(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function fi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const pi=/^[0-9a-zA-Z+/]*={0,2}$/,mi=w(`$ZodBase64`,(e,t)=>{t.pattern??=pi,D.init(e,t),e._zod.check=n=>{fi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),hi=/^[A-Za-z0-9_-]*$/;function gi(e){if(!hi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return fi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const _i=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=hi,D.init(e,t),e._zod.check=n=>{gi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),vi=w(`$ZodE164`,(e,t)=>{t.pattern??=nr,D.init(e,t)});function yi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const bi=w(`$ZodJWT`,(e,t)=>{D.init(e,t),e._zod.check=n=>{yi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),xi=w(`$ZodNumber`,(e,t)=>{E.init(e,t),e._zod.pattern=ur,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Si=w(`$ZodNumberFormat`,(e,t)=>{yr.init(e,t),xi.init(e,t)}),Ci=w(`$ZodBoolean`,(e,t)=>{E.init(e,t),e._zod.pattern=dr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),wi=w(`$ZodUnknown`,(e,t)=>{E.init(e,t),e._zod.parse=e=>e}),Ti=w(`$ZodNever`,(e,t)=>{E.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ei(e,t,n){e.issues.length&&t.issues.push(...Nt(n,e.issues)),t.value[n]=e.value}const Di=w(`$ZodArray`,(e,t)=>{E.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ei(t,r,e)));else if(Ei(c,r,e),s&&c.issues.length!==0&&jt(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Oi(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Nt(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const ki=[];function Ai(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ki,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=yt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ji(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(jt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Oi(e,n,i,t,d,f))):Oi(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Mi=w(`$ZodObject`,(e,t)=>{E.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,`shape`,{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,`shape`,{get:e})}let i=Ze(()=>Ai(t));C(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||tt(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=dt,o=t.catchall,s,c=on.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(jt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Oi(n,t,e,r,a,o))):Oi(s,t,e,r,a,o)}return o?ji(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ni=w(`$ZodObjectJIT`,(e,t)=>{Mi.init(e,t);let n=e._zod.parse,r=Ze(()=>Ai(t)),i=on.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new jr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
22
|
+
`)}\n};`)(...Object.values(this.closed))}};const jr={major:4,minor:6,patch:5},O=E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=At(t),a;for(let o of n){if(o._zod.def.when){if(jt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new nn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Pt(t.issues,n,e),i||=At(t,n))});else{if(t.issues.length===n)continue;Pt(t.issues,n,e),i||=At(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(At(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new nn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new nn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Ut(this,`~standard`,Pr(this))},set"~standard"(e){Ht(this,`~standard`,e)}}),Mr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Ft(e,t,on()))}:{value:e.value};async function Nr(e,t){let n={async:!0};return Mr(await e._zod.run({value:t,issues:[]},n),n)}function Pr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Mr(r,n)}catch{}return Nr(e,t)},vendor:`zod`,version:1}}const Fr=E(`$ZodString`,(e,t)=>{O.init(e,t),e._zod.pattern=t.pattern??cr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),k=E(`$ZodStringFormat`,(e,t)=>{Sr.init(e,t),Fr.init(e,t)}),Ir=E(`$ZodGUID`,(e,t)=>{t.pattern??=Wn,k.init(e,t)}),Lr=E(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Gn(e)}else t.pattern??=Gn();k.init(e,t)}),Rr=E(`$ZodEmail`,(e,t)=>{t.pattern??=Kn,k.init(e,t)});function zr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Br(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?zr(e)||2:Vr(e,t)}function Vr(e,t){if(!t.normalize&&t.protocol?.source===er.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const Hr=/[\t\n\r]/g;function Ur(e){return e.replace(Hr,``)}function Wr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Gr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Kr=E(`$ZodURL`,(e,t)=>{k.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Br(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Ur(r);return}t.hostname&&!Wr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Gr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Ur(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),qr=E(`$ZodEmoji`,(e,t)=>{t.pattern??=qn(),k.init(e,t)}),Jr=E(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Vn:Hn(t.length),k.init(e,t)}),Yr=E(`$ZodCUID`,(e,t)=>{t.pattern??=In,k.init(e,t)}),Xr=E(`$ZodCUID2`,(e,t)=>{t.pattern??=Ln,k.init(e,t)}),Zr=E(`$ZodULID`,(e,t)=>{t.pattern??=Rn,k.init(e,t)}),Qr=E(`$ZodXID`,(e,t)=>{t.pattern??=zn,k.init(e,t)}),$r=E(`$ZodKSUID`,(e,t)=>{t.pattern??=Bn,k.init(e,t)}),ei=E(`$ZodISODateTime`,(e,t)=>{t.pattern??=sr(t),k.init(e,t)}),ti=E(`$ZodISODate`,(e,t)=>{t.pattern??=ir,k.init(e,t)}),ni=E(`$ZodISOTime`,(e,t)=>{t.pattern??=or(t),k.init(e,t)}),ri=E(`$ZodISODuration`,(e,t)=>{t.pattern??=Un,k.init(e,t)}),ii=E(`$ZodIPv4`,(e,t)=>{t.pattern??=Jn,k.init(e,t)}),ai=/^[0-9a-fA-F:.]+$/;function oi(e){return ai.test(e)?zr(`http://[${e}]`):!1}const si=E(`$ZodIPv6`,(e,t)=>{t.pattern??=Yn,k.init(e,t),e._zod.check=n=>{oi(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),ci=E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Xn,k.init(e,t)});function li(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:oi(n)}const ui=E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Zn,k.init(e,t),e._zod.check=n=>{li(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function di(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const fi=/^[0-9a-zA-Z+/]*={0,2}$/,pi=E(`$ZodBase64`,(e,t)=>{t.pattern??=fi,k.init(e,t),e._zod.check=n=>{di(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),mi=/^[A-Za-z0-9_-]*$/;function hi(e){if(!mi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return di(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const gi=E(`$ZodBase64URL`,(e,t)=>{t.pattern??=mi,k.init(e,t),e._zod.check=n=>{hi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),_i=E(`$ZodE164`,(e,t)=>{t.pattern??=tr,k.init(e,t)});function vi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const yi=E(`$ZodJWT`,(e,t)=>{k.init(e,t),e._zod.check=n=>{vi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),bi=E(`$ZodNumber`,(e,t)=>{O.init(e,t),e._zod.pattern=lr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),xi=E(`$ZodNumberFormat`,(e,t)=>{vr.init(e,t),bi.init(e,t)}),Si=E(`$ZodBoolean`,(e,t)=>{O.init(e,t),e._zod.pattern=ur,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ci=E(`$ZodUnknown`,(e,t)=>{O.init(e,t),e._zod.parse=e=>e}),wi=E(`$ZodNever`,(e,t)=>{O.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ti(e,t,n){e.issues.length&&t.issues.push(...Mt(n,e.issues)),t.value[n]=e.value}const Ei=E(`$ZodArray`,(e,t)=>{O.init(e,t);let n=an.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ti(t,r,e)));else if(Ti(c,r,e),s&&c.issues.length!==0&&At(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Di(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Mt(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const Oi=[];function ki(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Oi,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=vt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Ai(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(At(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Di(e,n,i,t,d,f))):Di(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const ji=E(`$ZodObject`,(e,t)=>{O.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,`shape`,{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,`shape`,{get:e})}let i=Xe(()=>ki(t));T(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||et(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=ut,o=t.catchall,s,c=an.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(At(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Di(n,t,e,r,a,o))):Di(s,t,e,r,a,o)}return o?Ai(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Mi=E(`$ZodObjectJIT`,(e,t)=>{ji.init(e,t);let n=e._zod.parse,r=Xe(()=>ki(t)),i=an.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Ar([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
23
23
|
let ${e}_ab = false;
|
|
24
24
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
25
25
|
const iss = ${e}.issues[i];
|
|
@@ -30,7 +30,7 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
|
|
|
30
30
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
31
31
|
payload.value = newResult;
|
|
32
32
|
return payload;
|
|
33
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
33
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:st(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
34
34
|
const ${n}_present = ${i};
|
|
35
35
|
if (!${n}.issues.length || ${n}_present) {
|
|
36
36
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -69,57 +69,57 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
|
|
|
69
69
|
newResult[${r}] = ${n}.value;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=dt,c=!on.jitless,l=c&&ft.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ji([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Pi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!jt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>It(e,r,sn())))}),t)}const Fi=w(`$ZodUnion`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),C(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),C(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),C(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>$e(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Pi(t,r,e,i)):Pi(o,r,e,i)}}),Ii=w(`$ZodIntersection`,(e,t)=>{E.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ri(e,t,n)):Ri(e,i,a)}});function Li(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pt(e)&&pt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Li(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Li(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ri(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Li(t.value,n.value);if(!c.valid){if(jt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const zi=w(`$ZodEnum`,(e,t)=>{E.init(e,t);let n=qe(t.entries),r=new Set(n);e._zod.values=r,C(e,`pattern`,e=>{let t=qe(e.def.entries).filter(e=>ht.has(typeof e));return RegExp(t.length?`^(${t.map(e=>gt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Bi=w(`$ZodTransform`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,on.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new an(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new rn;return n.value=i,n}});function Vi(e,t){return e.value=t.issues.length?void 0:t.value,e}const Hi=w(`$ZodOptional`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,C(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),C(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${$e(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Vi(e,t)):Vi(e,r)}return t.innerType._zod.run(e,n)}}),Ui=w(`$ZodExactOptional`,(e,t)=>{Hi.init(e,t),C(e,`values`,e=>e.def.innerType._zod.values),C(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Wi=w(`$ZodNullable`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin),C(e,`optout`,e=>e.def.innerType._zod.optout),C(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${$e(t.source)}|null)$`):void 0}),C(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Gi=w(`$ZodDefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ki(e,t)):Ki(r,t)}});function Ki(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const qi=w(`$ZodPrefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ji=w(`$ZodNonOptional`,(e,t)=>{E.init(e,t),C(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Yi(t,e)):Yi(i,e)}});function Yi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Xi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>It(e,r,sn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Zi=w(`$ZodCatch`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),C(e,`optout`,e=>e.def.innerType._zod.optout),C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Xi(e,r,t,n)):Xi(e,r,t,n)}}),Qi=w(`$ZodPipe`,(e,t)=>{E.init(e,t),C(e,`values`,e=>e.def.in._zod.values),C(e,`optin`,e=>e.def.in._zod.optin),C(e,`optout`,e=>e.def.out._zod.optout),C(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>$i(e,t.in,n)):$i(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>$i(e,t.out,n)):$i(r,t.out,n)}});function $i(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ea=w(`$ZodReadonly`,(e,t)=>{E.init(e,t),C(e,`propValues`,e=>e.def.innerType._zod.propValues),C(e,`values`,e=>e.def.innerType._zod.values),C(e,`optin`,e=>e.def.innerType?._zod?.optin),C(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ta):ta(r)}});function ta(e){return e.memo||(e.value=Object.freeze(e.value)),e}const na=w(`$ZodCustom`,(e,t)=>{T.init(e,t),E.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ra(t,n,r,e));ra(i,n,r,e)}});function ra(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Vt(e))}}var ia=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const aa=`~memo`,oa=[];function sa(e){return typeof e==`object`&&!!e}function ca(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const la=new WeakMap;function ua(e,t,n){let r=la.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=ua(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?ua(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=nt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ua(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),da(e,i)}function da(e,t){return t!==1&&la.set(e,t===2),t}function fa(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let pa;const ma=[],ha={alloc(e,t,n){let r=pa;if(!r)return n;pa=void 0;let i={value:n,issues:null};return r.set(t.value,i),ma.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&_a(n,e.value))throw new ia;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ua(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!sa(l))return t(s,c);let u=c[aa];u||(u={buckets:new WeakMap,backEdges:void 0},c[aa]=u);let d;i===c?d=a:(d=fa(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ca(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;pa=d;let p=ma.length,m=t(s,c);pa=void 0;let h=ma.length>p?ma.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ca(e.issues):oa),e)):(h&&(h.issues=m.issues.length?ca(m.issues):oa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ga(){return ha}function _a(e,t){let n=e[aa]?.backEdges;return n!==void 0&&sa(t)&&n.has(t)}const va=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Bt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${vt(e.values[0])}`:`Invalid option: expected one of ${Je(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Je(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ya(){return{localeError:va()}}var ba,xa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Sa(){return new xa}(ba=globalThis).__zod_globalRegistry??(ba.__zod_globalRegistry=Sa());const Ca=globalThis.__zod_globalRegistry;function wa(e){return e.checks&&=[...e.checks],e}function Ta(e,t){return new e(wa({type:`string`,...S(t)}))}function Ea(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...S(t)})}function Da(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...S(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...S(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...S(t)})}function Aa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...S(t)})}function ja(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...S(t)})}function Ma(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...S(t)})}function Na(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...S(t)})}function Pa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...S(t)})}function Fa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...S(t)})}function Ia(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...S(t)})}function La(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...S(t)})}function Ra(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...S(t)})}function za(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...S(t)})}function Ba(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...S(t)})}function Va(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...S(t)})}function Ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...S(t)})}function Ua(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...S(t)})}function Wa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...S(t)})}function Ga(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...S(t)})}function Ka(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...S(t)})}function qa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...S(t)})}function Ja(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...S(t)})}function Ya(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...S(t)})}function Xa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...S(t)})}function Za(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...S(t)})}function Qa(e,t){return new e(wa({type:`number`,checks:[],...S(t)}))}function $a(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...S(t)})}function eo(e,t){return new e({type:`boolean`,...S(t)})}function to(e){return new e({type:`unknown`})}function no(e,t){return new e({type:`never`,...S(t)})}function ro(e,t){return new gr({check:`less_than`,...S(t),value:e,inclusive:!1})}function io(e,t){return new gr({check:`less_than`,...S(t),value:e,inclusive:!0})}function ao(e,t){return new _r({check:`greater_than`,...S(t),value:e,inclusive:!1})}function oo(e,t){return new _r({check:`greater_than`,...S(t),value:e,inclusive:!0})}function so(e,t){return new vr({check:`multiple_of`,...S(t),value:e})}function co(e,t){return new br({check:`max_length`,...S(t),maximum:e})}function lo(e,t){return new xr({check:`min_length`,...S(t),minimum:e})}function uo(e,t){return new Sr({check:`length_equals`,...S(t),length:e})}function fo(e,t){return new wr({check:`string_format`,format:`regex`,...S(t),pattern:e})}function po(e){return new Tr({check:`string_format`,format:`lowercase`,...S(e)})}function mo(e){return new Er({check:`string_format`,format:`uppercase`,...S(e)})}function ho(e,t){return new Dr({check:`string_format`,format:`includes`,...S(t),includes:e})}function go(e,t){return new Or({check:`string_format`,format:`starts_with`,...S(t),prefix:e})}function _o(e,t){return new kr({check:`string_format`,format:`ends_with`,...S(t),suffix:e})}function vo(e){return new Ar({check:`overwrite`,tx:e})}function yo(e){return vo(t=>t.normalize(e))}function bo(){return vo(e=>e.trim())}function xo(){return vo(e=>e.toLowerCase())}function So(){return vo(e=>e.toUpperCase())}function Co(){return vo(e=>lt(e))}function wo(e,t,n){return new e({type:`array`,element:t,...S(n)})}function To(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...S(n)})}function Eo(e,t){let n=Do(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Vt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Vt(r))}},e(t.value,t)),t);return n}function Do(e,t){let n=new T({check:`custom`,...S(t)});return n._zod.check=e,n}function Oo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&tt(e,t,n[t]);return e}function ko(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ca,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Ao(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function O(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,O(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Oo(o.schema,c),t.io===`input`&&k(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function jo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Mo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${jo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+jo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
72
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=ut,c=!an.jitless,l=c&&dt.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Ai([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ni(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!At(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ft(e,r,on())))}),t)}const Pi=E(`$ZodUnion`,(e,t)=>{O.init(e,t),T(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),T(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),T(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Qe(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ni(t,r,e,i)):Ni(o,r,e,i)}}),Fi=E(`$ZodIntersection`,(e,t)=>{O.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Li(e,t,n)):Li(e,i,a)}});function Ii(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ft(e)&&ft(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ii(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ii(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Li(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ii(t.value,n.value);if(!c.valid){if(At(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Ri=E(`$ZodEnum`,(e,t)=>{O.init(e,t);let n=Ke(t.entries),r=new Set(n);e._zod.values=r,T(e,`pattern`,e=>{let t=Ke(e.def.entries).filter(e=>mt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>ht(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),zi=E(`$ZodTransform`,(e,t)=>{O.init(e,t),e._zod.optin=`optional`,an.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new nn;return n.value=i,n}});function Bi(e,t){return e.value=t.issues.length?void 0:t.value,e}const Vi=E(`$ZodOptional`,(e,t)=>{O.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Qe(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Bi(e,t)):Bi(e,r)}return t.innerType._zod.run(e,n)}}),Hi=E(`$ZodExactOptional`,(e,t)=>{Vi.init(e,t),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ui=E(`$ZodNullable`,(e,t)=>{O.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Qe(t.source)}|null)$`):void 0}),T(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Wi=E(`$ZodDefault`,(e,t)=>{O.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Gi(e,t)):Gi(r,t)}});function Gi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ki=E(`$ZodPrefault`,(e,t)=>{O.init(e,t),e._zod.optin=`defaulted`,T(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),qi=E(`$ZodNonOptional`,(e,t)=>{O.init(e,t),T(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ji(t,e)):Ji(i,e)}});function Ji(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Yi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Ft(e,r,on()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Xi=E(`$ZodCatch`,(e,t)=>{O.init(e,t),T(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),T(e,`optout`,e=>e.def.innerType._zod.optout),T(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Yi(e,r,t,n)):Yi(e,r,t,n)}}),Zi=E(`$ZodPipe`,(e,t)=>{O.init(e,t),T(e,`values`,e=>e.def.in._zod.values),T(e,`optin`,e=>e.def.in._zod.optin),T(e,`optout`,e=>e.def.out._zod.optout),T(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Qi(e,t.in,n)):Qi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Qi(e,t.out,n)):Qi(r,t.out,n)}});function Qi(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const $i=E(`$ZodReadonly`,(e,t)=>{O.init(e,t),T(e,`propValues`,e=>e.def.innerType._zod.propValues),T(e,`values`,e=>e.def.innerType._zod.values),T(e,`optin`,e=>e.def.innerType?._zod?.optin),T(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ea):ea(r)}});function ea(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ta=E(`$ZodCustom`,(e,t)=>{D.init(e,t),O.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>na(t,n,r,e));na(i,n,r,e)}});function na(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Bt(e))}}var ra=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const ia=`~memo`,aa=[];function oa(e){return typeof e==`object`&&!!e}function sa(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const ca=new WeakMap;function la(e,t,n){let r=ca.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=la(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?la(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=tt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?la(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ua(e,i)}function ua(e,t){return t!==1&&ca.set(e,t===2),t}function da(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let fa;const pa=[],ma={alloc(e,t,n){let r=fa;if(!r)return n;fa=void 0;let i={value:n,issues:null};return r.set(t.value,i),pa.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&ga(n,e.value))throw new ra;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=la(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!oa(l))return t(s,c);let u=c[ia];u||(u={buckets:new WeakMap,backEdges:void 0},c[ia]=u);let d;i===c?d=a:(d=da(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...sa(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;fa=d;let p=pa.length,m=t(s,c);fa=void 0;let h=pa.length>p?pa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?sa(e.issues):aa),e)):(h&&(h.issues=m.issues.length?sa(m.issues):aa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ha(){return ma}function ga(e,t){let n=e[ia]?.backEdges;return n!==void 0&&oa(t)&&n.has(t)}const _a=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(zt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${_t(e.values[0])}`:`Invalid option: expected one of ${qe(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${qe(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function va(){return{localeError:_a()}}var ya,ba=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function xa(){return new ba}(ya=globalThis).__zod_globalRegistry??(ya.__zod_globalRegistry=xa());const Sa=globalThis.__zod_globalRegistry;function Ca(e){return e.checks&&=[...e.checks],e}function wa(e,t){return new e(Ca({type:`string`,...w(t)}))}function Ta(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...w(t)})}function Ea(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...w(t)})}function Da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...w(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...w(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...w(t)})}function Aa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...w(t)})}function ja(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...w(t)})}function Ma(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...w(t)})}function Na(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...w(t)})}function Pa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...w(t)})}function Fa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...w(t)})}function Ia(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...w(t)})}function La(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...w(t)})}function Ra(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...w(t)})}function za(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...w(t)})}function Ba(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...w(t)})}function Va(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...w(t)})}function Ha(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...w(t)})}function Ua(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...w(t)})}function Wa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...w(t)})}function Ga(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...w(t)})}function Ka(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...w(t)})}function qa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...w(t)})}function Ja(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...w(t)})}function Ya(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...w(t)})}function Xa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...w(t)})}function Za(e,t){return new e(Ca({type:`number`,checks:[],...w(t)}))}function Qa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...w(t)})}function $a(e,t){return new e({type:`boolean`,...w(t)})}function eo(e){return new e({type:`unknown`})}function to(e,t){return new e({type:`never`,...w(t)})}function no(e,t){return new hr({check:`less_than`,...w(t),value:e,inclusive:!1})}function ro(e,t){return new hr({check:`less_than`,...w(t),value:e,inclusive:!0})}function io(e,t){return new gr({check:`greater_than`,...w(t),value:e,inclusive:!1})}function ao(e,t){return new gr({check:`greater_than`,...w(t),value:e,inclusive:!0})}function oo(e,t){return new _r({check:`multiple_of`,...w(t),value:e})}function so(e,t){return new yr({check:`max_length`,...w(t),maximum:e})}function co(e,t){return new br({check:`min_length`,...w(t),minimum:e})}function lo(e,t){return new xr({check:`length_equals`,...w(t),length:e})}function uo(e,t){return new Cr({check:`string_format`,format:`regex`,...w(t),pattern:e})}function fo(e){return new wr({check:`string_format`,format:`lowercase`,...w(e)})}function po(e){return new Tr({check:`string_format`,format:`uppercase`,...w(e)})}function mo(e,t){return new Er({check:`string_format`,format:`includes`,...w(t),includes:e})}function ho(e,t){return new Dr({check:`string_format`,format:`starts_with`,...w(t),prefix:e})}function go(e,t){return new Or({check:`string_format`,format:`ends_with`,...w(t),suffix:e})}function _o(e){return new kr({check:`overwrite`,tx:e})}function vo(e){return _o(t=>t.normalize(e))}function yo(){return _o(e=>e.trim())}function bo(){return _o(e=>e.toLowerCase())}function xo(){return _o(e=>e.toUpperCase())}function So(){return _o(e=>ct(e))}function Co(e,t,n){return new e({type:`array`,element:t,...w(n)})}function wo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}function To(e,t){let n=Eo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Bt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Bt(r))}},e(t.value,t)),t);return n}function Eo(e,t){let n=new D({check:`custom`,...w(t)});return n._zod.check=e,n}function Do(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&et(e,t,n[t]);return e}function Oo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Sa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function ko(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function A(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,A(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Do(o.schema,c),t.io===`input`&&j(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ao(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function jo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ao(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ao(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
73
73
|
|
|
74
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function No(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;No(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Po=new Set([`type`,`properties`,`required`,`additionalProperties`]),Fo=[`oneOf`,`anyOf`];function Io(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Lo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Po.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Io(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}tt(n,r,e.length===1?e[0]:Lo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Io(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ro(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Po)if(t in e)return;let n=t.filter(e=>Fo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Lo(t);else{let e=n[0],i=Fo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Lo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Oo(e,r))}function zo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Oo(i,s),Oo(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())No(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ro(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Oo(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,tt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Vo(t,`input`,e.processors),output:Vo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k(r.element,n);if(r.type===`set`)return k(r.valueType,n);if(r.type===`lazy`)return k(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`||r.type===`catch`)return k(r.innerType,n);if(r.type===`intersection`)return k(r.left,n)||k(r.right,n);if(r.type===`record`||r.type===`map`)return k(r.keyType,n)||k(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:k(r.in,n)||k(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k(e,n))return!0;return!!(r.rest&&k(r.rest,n))}return!1}const Bo=(e,t={})=>n=>{let r=ko({...n,processors:t});return O(e,r),Mo(r,e),zo(r,e)},Vo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ko({...i??{},target:a,io:t,processors:n});return O(e,o),Mo(o,e),zo(o,e)},Ho=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Uo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Wo=(e,t)=>{Ho(e,`minimum`,t),Uo(e,`maximum`,t)},Go=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ko=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},qo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Jo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Yo=(e,t)=>Ho(e,`minimum`,t.minimum),Xo=(e,t)=>Uo(e,`maximum`,t.maximum),Zo=e=>(t,n)=>{Jo(t,n.format);let[r,i]=e[n.format];Ho(t,`minimum`,r),Uo(t,`maximum`,i)},Qo={greater_than:(e,t)=>Ho(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Uo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Go(e,t.value),number_format:Zo(bt),bigint_format:Zo(xt),min_length:Yo,max_length:Xo,length_equals:(e,t)=>Wo(e,t.length),min_size:Yo,max_size:Xo,size_equals:(e,t)=>Wo(e,t.size),string_format:(e,t)=>{Jo(e,t.format),t.pattern&&Ko(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>qo(e,t.mime)};function $o(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Qo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ho(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ho(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Uo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Uo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Go(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&qo(t,i.mime);for(let e of i.patterns??[])Ko(t,e);return t}const es={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ts=new Map([[pi,$n],[hi,er]]),ns=e=>ts.get(e)??e,rs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=$o(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=es[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ns);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},is=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=$o(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ao(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},as=(e,t,n,r)=>{n.type=`boolean`},os=(e,t,n,r)=>{n.not={}},ss=(e,t,n,r)=>{let i=e._zod.def,a=qe(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},cs=(e,t,n,r)=>{Ao(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{Ao(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=$o(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=O(a.element,t,{...r,path:[...r.path,`items`]})};function ds(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ds(t.out):t.type===`catch`?ds(t.innerType):e._zod.optin}const fs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ao(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)tt(i.properties,e,O(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ds(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=O(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>O(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ms=(e,t,n,r)=>{let i=e._zod.def,a=O(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=O(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},hs=(e,t,n,r)=>{let i=e._zod.def,a=O(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},gs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_s=Symbol();function vs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ao(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),_s):JSON.parse(o)}const ys=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=vs(i.defaultValue,e,t,n,r);o!==_s&&(n.default=o)},bs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=vs(i.defaultValue,e,t,n,r);o!==_s&&(n._prefault=o)},xs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ao(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ss=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;O(o,t,r);let s=t.seen.get(e);s.ref=o},Cs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ws=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ts=new WeakSet([Object.prototype,Error.prototype]);function Es(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Ds=w(`ZodError`,(e,t)=>{mn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Ts.has(n)||(Ts.add(n),Es(n,`format`,e=>t=>_n(e,t)),Es(n,`flatten`,e=>t=>gn(e,t)),Es(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ye,2)}),Es(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ye,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Os=yn(Ds),ks=bn(Ds),As=xn(Ds),js=Cn(Ds),Ms=kn(Ds),Ns=An(Ds),Ps=jn(Ds),Fs=Mn(Ds),Is=Nn(Ds),Ls=Pn(Ds),Rs=Fn(Ds),zs=In(Ds);function Bs(){on.localeError||sn(ya())}function Vs(){on.memoizer||sn({memoizer:ga()})}const A=w(`ZodType`,(e,t)=>(Bs(),E.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(x(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _t(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($c(e,t))},superRefine(e,t){return this.check(el(e,t))},overwrite(e){return this.check(vo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return Cc(this)},or(e){return Dc([this,e])},and(e){return kc(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Zc(this)},describe(e){let t=this.clone();return Ca.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ca.get(this);let t=this.clone();return Ca.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Wt(this,`~standard`,{...Fr(this),jsonSchema:{input:Vo(this,`input`),output:Vo(this,`output`)}})},set"~standard"(e){Ut(this,`~standard`,e)},parse:function e(t,n){return Os(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ks(this,t,n,{callee:e})},safeParse(e,t){return As(this,e,t)},async safeParseAsync(e,t){return js(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ut(this,`spa`,e)},validate(e,t){return En(this,e,t)},validateAsync(e,t){return On(this,e,t)},encode:function e(t,n){return Ms(this,t,n,{callee:e})},decode:function e(t,n){return Ns(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ps(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Fs(this,t,n,{callee:e})},safeEncode(e,t){return Is(this,e,t)},safeDecode(e,t){return Ls(this,e,t)},async safeEncodeAsync(e,t){return Rs(this,e,t)},async safeDecodeAsync(e,t){return zs(this,e,t)},toJSONSchema(e){return Bo(this,{})(e)},get description(){return Ca.get(this)?.description},get _def(){return this._zod.def}}),Hs=w(`_ZodString`,(e,t)=>{Ir.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)},Gt({format:e=>$o(e).format??null,minLength:e=>$o(e).minimum??null,maxLength:e=>$o(e).maximum??null},{regex(...e){return this.check(fo(...e))},includes(...e){return this.check(ho(...e))},startsWith(...e){return this.check(go(...e))},endsWith(...e){return this.check(_o(...e))},min(...e){return this.check(lo(...e))},max(...e){return this.check(co(...e))},length(...e){return this.check(uo(...e))},nonempty(...e){return this.check(lo(1,...e))},lowercase(e){return this.check(po(e))},uppercase(e){return this.check(mo(e))},trim(){return this.check(bo())},normalize(...e){return this.check(yo(...e))},toLowerCase(){return this.check(xo())},toUpperCase(){return this.check(So())},slugify(){return this.check(Co())}})),Us=w(`ZodString`,(e,t)=>{Ir.init(e,t),Hs.init(e,t)},{email(e){return this.check(Ea(Js,e))},url(e){return this.check(Ma(Zs,e))},jwt(e){return this.check(qa(fc,e))},emoji(e){return this.check(Na(Qs,e))},guid(e){return this.check(Da(Ys,e))},uuid(e){return this.check(Oa(Xs,e))},uuidv4(e){return this.check(ka(Xs,e))},uuidv6(e){return this.check(Aa(Xs,e))},uuidv7(e){return this.check(ja(Xs,e))},nanoid(e){return this.check(Pa($s,e))},cuid(e){return this.check(Fa(ec,e))},cuid2(e){return this.check(Ia(tc,e))},ulid(e){return this.check(La(nc,e))},base64(e){return this.check(Wa(lc,e))},base64url(e){return this.check(Ga(uc,e))},xid(e){return this.check(Ra(rc,e))},ksuid(e){return this.check(za(ic,e))},ipv4(e){return this.check(Ba(ac,e))},ipv6(e){return this.check(Va(oc,e))},cidrv4(e){return this.check(Ha(sc,e))},cidrv6(e){return this.check(Ua(cc,e))},e164(e){return this.check(Ka(dc,e))},datetime(e){return this.check(Ja(Ws,e))},date(e){return this.check(Ya(Gs,e))},time(e){return this.check(Xa(Ks,e))},duration(e){return this.check(Za(qs,e))}});function j(e){return Ta(Us,e)}const M=w(`ZodStringFormat`,(e,t)=>{D.init(e,t),Hs.init(e,t)}),Ws=w(`ZodISODateTime`,(e,t)=>{ti.init(e,t),M.init(e,t)}),Gs=w(`ZodISODate`,(e,t)=>{ni.init(e,t),M.init(e,t)}),Ks=w(`ZodISOTime`,(e,t)=>{ri.init(e,t),M.init(e,t)}),qs=w(`ZodISODuration`,(e,t)=>{ii.init(e,t),M.init(e,t)}),Js=w(`ZodEmail`,(e,t)=>{zr.init(e,t),M.init(e,t)}),Ys=w(`ZodGUID`,(e,t)=>{Lr.init(e,t),M.init(e,t)}),Xs=w(`ZodUUID`,(e,t)=>{Rr.init(e,t),M.init(e,t)}),Zs=w(`ZodURL`,(e,t)=>{qr.init(e,t),M.init(e,t)}),Qs=w(`ZodEmoji`,(e,t)=>{Jr.init(e,t),M.init(e,t)}),$s=w(`ZodNanoID`,(e,t)=>{Yr.init(e,t),M.init(e,t)}),ec=w(`ZodCUID`,(e,t)=>{Xr.init(e,t),M.init(e,t)}),tc=w(`ZodCUID2`,(e,t)=>{Zr.init(e,t),M.init(e,t)}),nc=w(`ZodULID`,(e,t)=>{Qr.init(e,t),M.init(e,t)}),rc=w(`ZodXID`,(e,t)=>{$r.init(e,t),M.init(e,t)}),ic=w(`ZodKSUID`,(e,t)=>{ei.init(e,t),M.init(e,t)}),ac=w(`ZodIPv4`,(e,t)=>{ai.init(e,t),M.init(e,t)}),oc=w(`ZodIPv6`,(e,t)=>{ci.init(e,t),M.init(e,t)}),sc=w(`ZodCIDRv4`,(e,t)=>{li.init(e,t),M.init(e,t)}),cc=w(`ZodCIDRv6`,(e,t)=>{di.init(e,t),M.init(e,t)}),lc=w(`ZodBase64`,(e,t)=>{mi.init(e,t),M.init(e,t)}),uc=w(`ZodBase64URL`,(e,t)=>{_i.init(e,t),M.init(e,t)}),dc=w(`ZodE164`,(e,t)=>{vi.init(e,t),M.init(e,t)}),fc=w(`ZodJWT`,(e,t)=>{bi.init(e,t),M.init(e,t)}),pc=w(`ZodNumber`,(e,t)=>{xi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.isFinite=!0},Gt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=$o(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=$o(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=$o(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>$o(e).format??null},{gt(e,t){return this.check(ao(e,t))},gte(e,t){return this.check(oo(e,t))},min(e,t){return this.check(oo(e,t))},lt(e,t){return this.check(ro(e,t))},lte(e,t){return this.check(io(e,t))},max(e,t){return this.check(io(e,t))},int(e){return this.check(gc(e))},safe(e){return this.check(gc(e))},positive(e){return this.check(ao(0,e))},nonnegative(e){return this.check(oo(0,e))},negative(e){return this.check(ro(0,e))},nonpositive(e){return this.check(io(0,e))},multipleOf(e,t){return this.check(so(e,t))},step(e,t){return this.check(so(e,t))},finite(){return this}}));function mc(e){return Qa(pc,e)}const hc=w(`ZodNumberFormat`,(e,t)=>{Si.init(e,t),pc.init(e,t)});function gc(e){return $a(hc,e)}const _c=w(`ZodBoolean`,(e,t)=>{Ci.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function N(e){return eo(_c,e)}const vc=w(`ZodUnknown`,(e,t)=>{wi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function yc(){return to(vc)}const bc=w(`ZodNever`,(e,t)=>{Ti.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function xc(e){return no(bc,e)}const Sc=w(`ZodArray`,(e,t)=>{Vs(),Di.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.element=t.element},{min(e,t){return this.check(lo(e,t))},nonempty(e){return this.check(lo(1,e))},max(e,t){return this.check(co(e,t))},length(e,t){return this.check(uo(e,t))},unwrap(){return this.element}});function Cc(e,t){return wo(Sc,e,t)}const wc=w(`ZodObject`,(e,t)=>{Vs(),Ni.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),Zt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return jc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(x(this._zod.def,{catchall:e}))},passthrough(){return this.clone(x(this._zod.def,{catchall:yc()}))},loose(){return this.clone(x(this._zod.def,{catchall:yc()}))},strict(){return this.clone(x(this._zod.def,{catchall:xc()}))},strip(){return this.clone(x(this._zod.def,{catchall:void 0}))},extend(e){return Tt(this,e)},safeExtend(e){return Dt(this,e)},merge(e){return Ot(this,e)},pick(e){return St(this,e)},omit(e){return wt(this,e)},partial(...e){return kt(Pc,this,e[0])},exactPartial(...e){return kt(Ic,this,e[0],`exactPartial`)},required(...e){return At(Wc,this,e[0])}});function Tc(e,t){return new wc({type:`object`,shape:e??{},...S(t)})}const Ec=w(`ZodUnion`,(e,t)=>{Fi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.options=t.options});function Dc(e,t){return new Ec({type:`union`,options:e,...S(t)})}const Oc=w(`ZodIntersection`,(e,t)=>{Ii.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function kc(e,t){return new Oc({type:`intersection`,left:e,right:t})}const Ac=w(`ZodEnum`,(e,t)=>{zi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ac({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ac({...t,checks:[],...S(r),entries:i})}});function jc(e,t){return new Ac({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...S(t)})}const Mc=w(`ZodTransform`,(e,t)=>{Vs(),Bi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new an(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Vt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Vt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}const Pc=w(`ZodOptional`,(e,t)=>{Hi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}const Ic=w(`ZodExactOptional`,(e,t)=>{Ui.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}const Rc=w(`ZodNullable`,(e,t)=>{Wi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}const Bc=w(`ZodDefault`,(e,t)=>{Gi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}const Hc=w(`ZodPrefault`,(e,t)=>{qi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}const Wc=w(`ZodNonOptional`,(e,t)=>{Ji.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...S(t)})}const Kc=w(`ZodCatch`,(e,t)=>{Zi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Qt(t)})}const Jc=w(`ZodPipe`,(e,t)=>{Qi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}const Xc=w(`ZodReadonly`,(e,t)=>{ea.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`readonly`,innerType:e})}const Qc=w(`ZodCustom`,(e,t)=>{na.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r)});function $c(e,t={}){return To(Qc,e,t)}function el(e,t){return Eo(e,t)}var P=class extends Error{suggestion;constructor(e,t){super(e,{cause:t?.cause}),this.name=`SkillessError`,this.suggestion=t?.suggestion}toString(){return this.suggestion?`${this.message}\n${this.suggestion}`:this.message}},tl=class extends P{constructor(){super(`You are not signed in.`,{suggestion:"Run `skilless auth` to sign in, or set SKILLESS_TOKEN."})}},nl=class extends P{constructor(){super(`This directory has no git remote, so it has no project key.`,{suggestion:`skilless identifies a project by its git remote. Add one, or pass --project <key>.`})}},rl=class extends P{url;constructor(e,t){super(`Couldn't reach ${e}.`,{suggestion:`Check your connection, or set SKILLESS_API_URL to point elsewhere.`,cause:t}),this.url=e}};function F(e){try{return a.lstatSync(e),!0}catch{return!1}}function il(e){try{return a.lstatSync(e).isSymbolicLink()}catch{return!1}}function al(e){a.mkdirSync(e,{recursive:!0})}function I(e){if(F(e)){if(il(e)){try{a.unlinkSync(e)}catch{a.rmdirSync(e)}return}a.rmSync(e,{recursive:!0,force:!0})}}function ol(e,t){let n=[],r=(e,i)=>{let o=a.readdirSync(e,{withFileTypes:!0});for(let a of o){if(t(a.name))continue;let o=i?b.join(i,a.name):a.name,s=b.join(e,a.name);a.isDirectory()?r(s,o):a.isFile()&&n.push(o)}};return r(e,``),n.sort()}function sl(e,t){al(b.dirname(e)),a.writeFileSync(e,t,`utf8`)}function cl(e,t){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return t}}function ll(e,t,n){al(b.dirname(e)),a.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function ul(e,t){al(t),a.cpSync(e,t,{recursive:!0,dereference:!0})}function dl(e,t){try{return n(`git`,e,{cwd:t,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function fl(e){let t=dl([`rev-parse`,`--show-toplevel`],e);return t?b.normalize(t):null}function pl(e){return dl([`remote`,`get-url`,`origin`],e)}function ml(e){let t=e.trim().replace(/\.git$/i,``);if(!t)return null;let n,r,i=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(t);if(i&&!t.includes(`://`))n=i[1]??``,r=i[2]??``;else{t.includes(`://`)||(t=`https://${t}`);let e;try{e=new URL(t)}catch{return null}n=e.hostname,r=e.pathname}return n=n.replace(/:\d+$/,``).toLowerCase(),r=r.replace(/^\/+|\/+$/g,``).toLowerCase(),!n||!r?null:`${n}/${r}`}function hl(e){let t=pl(e);return t?ml(t):null}function gl(e){let t=dl([`rev-parse`,`--git-common-dir`],e);return t?b.isAbsolute(t)?b.normalize(t):b.resolve(e,t):null}function _l(e){let t=gl(e);return t?b.join(t,`info`,`exclude`):null}function vl(e,t){return dl([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function yl(e,t){let n=_l(e);if(!n)return!1;let r=F(n)?a.readFileSync(n,`utf8`):``,i=new Set(r.split(`
|
|
74
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Mo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Mo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const No=new Set([`type`,`properties`,`required`,`additionalProperties`]),Po=[`oneOf`,`anyOf`];function Fo(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Io(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!No.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Fo(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}et(n,r,e.length===1?e[0]:Io(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Fo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Lo(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of No)if(t in e)return;let n=t.filter(e=>Po.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Io(t);else{let e=n[0],i=Po.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Io([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Do(e,r))}function Ro(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Do(i,s),Do(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Mo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Lo(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Do(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,et(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Bo(t,`input`,e.processors),output:Bo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function j(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return j(r.element,n);if(r.type===`set`)return j(r.valueType,n);if(r.type===`lazy`)return j(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`||r.type===`catch`)return j(r.innerType,n);if(r.type===`intersection`)return j(r.left,n)||j(r.right,n);if(r.type===`record`||r.type===`map`)return j(r.keyType,n)||j(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:j(r.in,n)||j(r.out,n);if(r.type===`object`){for(let e in r.shape)if(j(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(j(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(j(e,n))return!0;return!!(r.rest&&j(r.rest,n))}return!1}const zo=(e,t={})=>n=>{let r=Oo({...n,processors:t});return A(e,r),jo(r,e),Ro(r,e)},Bo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Oo({...i??{},target:a,io:t,processors:n});return A(e,o),jo(o,e),Ro(o,e)},Vo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ho=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Uo=(e,t)=>{Vo(e,`minimum`,t),Ho(e,`maximum`,t)},Wo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Go=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Ko=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},qo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Jo=(e,t)=>Vo(e,`minimum`,t.minimum),Yo=(e,t)=>Ho(e,`maximum`,t.maximum),Xo=e=>(t,n)=>{qo(t,n.format);let[r,i]=e[n.format];Vo(t,`minimum`,r),Ho(t,`maximum`,i)},Zo={greater_than:(e,t)=>Vo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ho(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Wo(e,t.value),number_format:Xo(yt),bigint_format:Xo(bt),min_length:Jo,max_length:Yo,length_equals:(e,t)=>Uo(e,t.length),min_size:Jo,max_size:Yo,size_equals:(e,t)=>Uo(e,t.size),string_format:(e,t)=>{qo(e,t.format),t.pattern&&Go(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Ko(e,t.mime)};function Qo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Zo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Vo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Vo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ho(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ho(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Wo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Ko(t,i.mime);for(let e of i.patterns??[])Go(t,e);return t}const $o={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},es=new Map([[fi,Qn],[mi,$n]]),ts=e=>es.get(e)??e,ns=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Qo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=$o[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ts);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},rs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Qo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):ko(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},is=(e,t,n,r)=>{n.type=`boolean`},as=(e,t,n,r)=>{n.not={}},os=(e,t,n,r)=>{let i=e._zod.def,a=Ke(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ss=(e,t,n,r)=>{ko(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},cs=(e,t,n,r)=>{ko(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Qo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=A(a.element,t,{...r,path:[...r.path,`items`]})};function us(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?us(t.out):t.type===`catch`?us(t.innerType):e._zod.optin}const ds=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&ko(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)et(i.properties,e,A(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?us(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=A(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},fs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>A(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ps=(e,t,n,r)=>{let i=e._zod.def,a=A(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=A(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},ms=(e,t,n,r)=>{let i=e._zod.def,a=A(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},hs=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gs=Symbol();function _s(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(ko(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),gs):JSON.parse(o)}const vs=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=_s(i.defaultValue,e,t,n,r);o!==gs&&(n.default=o)},ys=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=_s(i.defaultValue,e,t,n,r);o!==gs&&(n._prefault=o)},bs=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{ko(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},xs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;A(o,t,r);let s=t.seen.get(e);s.ref=o},Ss=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Cs=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ws=new WeakSet([Object.prototype,Error.prototype]);function Ts(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const M=E(`ZodError`,(e,t)=>{pn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ws.has(n)||(ws.add(n),Ts(n,`format`,e=>t=>gn(e,t)),Ts(n,`flatten`,e=>t=>hn(e,t)),Ts(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Je,2)}),Ts(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Je,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Es=vn(M),Ds=yn(M),Os=bn(M),ks=Sn(M),As=On(M),js=kn(M),Ms=An(M),Ns=jn(M),Ps=Mn(M),Fs=Nn(M),Is=Pn(M),Ls=Fn(M);function Rs(){an.localeError||on(va())}function zs(){an.memoizer||on({memoizer:ha()})}const N=E(`ZodType`,(e,t)=>(Rs(),O.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(C(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return gt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Zc(e,t))},superRefine(e,t){return this.check(Qc(e,t))},overwrite(e){return this.check(_o(e))},optional(){return Nc(this)},exactOptional(){return Fc(this)},nullable(){return Lc(this)},nullish(){return Nc(Lc(this))},nonoptional(e){return Uc(this,e)},array(){return xc(this)},or(e){return Tc([this,e])},and(e){return Dc(this,e)},transform(e){return qc(this,jc(e))},default(e){return zc(this,e)},prefault(e){return Vc(this,e)},catch(e){return Gc(this,e)},pipe(e){return qc(this,e)},readonly(){return Yc(this)},describe(e){let t=this.clone();return Sa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Sa.get(this);let t=this.clone();return Sa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ut(this,`~standard`,{...Pr(this),jsonSchema:{input:Bo(this,`input`),output:Bo(this,`output`)}})},set"~standard"(e){Ht(this,`~standard`,e)},parse:function e(t,n){return Es(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ds(this,t,n,{callee:e})},safeParse(e,t){return Os(this,e,t)},async safeParseAsync(e,t){return ks(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ht(this,`spa`,e)},validate(e,t){return Tn(this,e,t)},validateAsync(e,t){return Dn(this,e,t)},encode:function e(t,n){return As(this,t,n,{callee:e})},decode:function e(t,n){return js(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ms(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ns(this,t,n,{callee:e})},safeEncode(e,t){return Ps(this,e,t)},safeDecode(e,t){return Fs(this,e,t)},async safeEncodeAsync(e,t){return Is(this,e,t)},async safeDecodeAsync(e,t){return Ls(this,e,t)},toJSONSchema(e){return zo(this,{})(e)},get description(){return Sa.get(this)?.description},get _def(){return this._zod.def}}),Bs=E(`_ZodString`,(e,t)=>{Fr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r)},Wt({format:e=>Qo(e).format??null,minLength:e=>Qo(e).minimum??null,maxLength:e=>Qo(e).maximum??null},{regex(...e){return this.check(uo(...e))},includes(...e){return this.check(mo(...e))},startsWith(...e){return this.check(ho(...e))},endsWith(...e){return this.check(go(...e))},min(...e){return this.check(co(...e))},max(...e){return this.check(so(...e))},length(...e){return this.check(lo(...e))},nonempty(...e){return this.check(co(1,...e))},lowercase(e){return this.check(fo(e))},uppercase(e){return this.check(po(e))},trim(){return this.check(yo())},normalize(...e){return this.check(vo(...e))},toLowerCase(){return this.check(bo())},toUpperCase(){return this.check(xo())},slugify(){return this.check(So())}})),Vs=E(`ZodString`,(e,t)=>{Fr.init(e,t),Bs.init(e,t)},{email(e){return this.check(Ta(Ks,e))},url(e){return this.check(ja(Ys,e))},jwt(e){return this.check(Ka(uc,e))},emoji(e){return this.check(Ma(Xs,e))},guid(e){return this.check(Ea(qs,e))},uuid(e){return this.check(Da(Js,e))},uuidv4(e){return this.check(Oa(Js,e))},uuidv6(e){return this.check(ka(Js,e))},uuidv7(e){return this.check(Aa(Js,e))},nanoid(e){return this.check(Na(Zs,e))},cuid(e){return this.check(Pa(Qs,e))},cuid2(e){return this.check(Fa($s,e))},ulid(e){return this.check(Ia(ec,e))},base64(e){return this.check(Ua(sc,e))},base64url(e){return this.check(Wa(cc,e))},xid(e){return this.check(La(tc,e))},ksuid(e){return this.check(Ra(nc,e))},ipv4(e){return this.check(za(rc,e))},ipv6(e){return this.check(Ba(ic,e))},cidrv4(e){return this.check(Va(ac,e))},cidrv6(e){return this.check(Ha(oc,e))},e164(e){return this.check(Ga(lc,e))},datetime(e){return this.check(qa(Hs,e))},date(e){return this.check(Ja(Us,e))},time(e){return this.check(Ya(Ws,e))},duration(e){return this.check(Xa(Gs,e))}});function P(e){return wa(Vs,e)}const F=E(`ZodStringFormat`,(e,t)=>{k.init(e,t),Bs.init(e,t)}),Hs=E(`ZodISODateTime`,(e,t)=>{ei.init(e,t),F.init(e,t)}),Us=E(`ZodISODate`,(e,t)=>{ti.init(e,t),F.init(e,t)}),Ws=E(`ZodISOTime`,(e,t)=>{ni.init(e,t),F.init(e,t)}),Gs=E(`ZodISODuration`,(e,t)=>{ri.init(e,t),F.init(e,t)}),Ks=E(`ZodEmail`,(e,t)=>{Rr.init(e,t),F.init(e,t)}),qs=E(`ZodGUID`,(e,t)=>{Ir.init(e,t),F.init(e,t)}),Js=E(`ZodUUID`,(e,t)=>{Lr.init(e,t),F.init(e,t)}),Ys=E(`ZodURL`,(e,t)=>{Kr.init(e,t),F.init(e,t)}),Xs=E(`ZodEmoji`,(e,t)=>{qr.init(e,t),F.init(e,t)}),Zs=E(`ZodNanoID`,(e,t)=>{Jr.init(e,t),F.init(e,t)}),Qs=E(`ZodCUID`,(e,t)=>{Yr.init(e,t),F.init(e,t)}),$s=E(`ZodCUID2`,(e,t)=>{Xr.init(e,t),F.init(e,t)}),ec=E(`ZodULID`,(e,t)=>{Zr.init(e,t),F.init(e,t)}),tc=E(`ZodXID`,(e,t)=>{Qr.init(e,t),F.init(e,t)}),nc=E(`ZodKSUID`,(e,t)=>{$r.init(e,t),F.init(e,t)}),rc=E(`ZodIPv4`,(e,t)=>{ii.init(e,t),F.init(e,t)}),ic=E(`ZodIPv6`,(e,t)=>{si.init(e,t),F.init(e,t)}),ac=E(`ZodCIDRv4`,(e,t)=>{ci.init(e,t),F.init(e,t)}),oc=E(`ZodCIDRv6`,(e,t)=>{ui.init(e,t),F.init(e,t)}),sc=E(`ZodBase64`,(e,t)=>{pi.init(e,t),F.init(e,t)}),cc=E(`ZodBase64URL`,(e,t)=>{gi.init(e,t),F.init(e,t)}),lc=E(`ZodE164`,(e,t)=>{_i.init(e,t),F.init(e,t)}),uc=E(`ZodJWT`,(e,t)=>{yi.init(e,t),F.init(e,t)}),dc=E(`ZodNumber`,(e,t)=>{bi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.isFinite=!0},Wt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Qo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Qo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Qo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Qo(e).format??null},{gt(e,t){return this.check(io(e,t))},gte(e,t){return this.check(ao(e,t))},min(e,t){return this.check(ao(e,t))},lt(e,t){return this.check(no(e,t))},lte(e,t){return this.check(ro(e,t))},max(e,t){return this.check(ro(e,t))},int(e){return this.check(mc(e))},safe(e){return this.check(mc(e))},positive(e){return this.check(io(0,e))},nonnegative(e){return this.check(ao(0,e))},negative(e){return this.check(no(0,e))},nonpositive(e){return this.check(ro(0,e))},multipleOf(e,t){return this.check(oo(e,t))},step(e,t){return this.check(oo(e,t))},finite(){return this}}));function fc(e){return Za(dc,e)}const pc=E(`ZodNumberFormat`,(e,t)=>{xi.init(e,t),dc.init(e,t)});function mc(e){return Qa(pc,e)}const hc=E(`ZodBoolean`,(e,t)=>{Si.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function I(e){return $a(hc,e)}const gc=E(`ZodUnknown`,(e,t)=>{Ci.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _c(){return eo(gc)}const vc=E(`ZodNever`,(e,t)=>{wi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function yc(e){return to(vc,e)}const bc=E(`ZodArray`,(e,t)=>{zs(),Ei.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.element=t.element},{min(e,t){return this.check(co(e,t))},nonempty(e){return this.check(co(1,e))},max(e,t){return this.check(so(e,t))},length(e,t){return this.check(lo(e,t))},unwrap(){return this.element}});function xc(e,t){return Co(bc,e,t)}const Sc=E(`ZodObject`,(e,t)=>{zs(),Mi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),Xt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return kc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C(this._zod.def,{catchall:_c()}))},loose(){return this.clone(C(this._zod.def,{catchall:_c()}))},strict(){return this.clone(C(this._zod.def,{catchall:yc()}))},strip(){return this.clone(C(this._zod.def,{catchall:void 0}))},extend(e){return wt(this,e)},safeExtend(e){return Et(this,e)},merge(e){return Dt(this,e)},pick(e){return xt(this,e)},omit(e){return Ct(this,e)},partial(...e){return Ot(Mc,this,e[0])},exactPartial(...e){return Ot(Pc,this,e[0],`exactPartial`)},required(...e){return kt(Hc,this,e[0])}});function Cc(e,t){return new Sc({type:`object`,shape:e??{},...w(t)})}const wc=E(`ZodUnion`,(e,t)=>{Pi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.options=t.options});function Tc(e,t){return new wc({type:`union`,options:e,...w(t)})}const Ec=E(`ZodIntersection`,(e,t)=>{Fi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r)});function Dc(e,t){return new Ec({type:`intersection`,left:e,right:t})}const Oc=E(`ZodEnum`,(e,t)=>{Ri.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Oc({...t,checks:[],...w(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Oc({...t,checks:[],...w(r),entries:i})}});function kc(e,t){return new Oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...w(t)})}const Ac=E(`ZodTransform`,(e,t)=>{zs(),zi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Bt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Bt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function jc(e){return new Ac({type:`transform`,transform:e})}const Mc=E(`ZodOptional`,(e,t)=>{Vi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nc(e){return new Mc({type:`optional`,innerType:e})}const Pc=E(`ZodExactOptional`,(e,t)=>{Hi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}const Ic=E(`ZodNullable`,(e,t)=>{Ui.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`nullable`,innerType:e})}const Rc=E(`ZodDefault`,(e,t)=>{Wi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zc(e,t){return new Rc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():pt(t)}})}const Bc=E(`ZodPrefault`,(e,t)=>{Ki.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vc(e,t){return new Bc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():pt(t)}})}const Hc=E(`ZodNonOptional`,(e,t)=>{qi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`nonoptional`,innerType:e,...w(t)})}const Wc=E(`ZodCatch`,(e,t)=>{Xi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gc(e,t){return new Wc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Zt(t)})}const Kc=E(`ZodPipe`,(e,t)=>{Zi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.in=t.in,e.out=t.out});function qc(e,t){return new Kc({type:`pipe`,in:e,out:t})}const Jc=E(`ZodReadonly`,(e,t)=>{$i.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`readonly`,innerType:e})}const Xc=E(`ZodCustom`,(e,t)=>{ta.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r)});function Zc(e,t={}){return wo(Xc,e,t)}function Qc(e,t){return To(e,t)}var L=class extends Error{suggestion;constructor(e,t){super(e,{cause:t?.cause}),this.name=`SkillessError`,this.suggestion=t?.suggestion}toString(){return this.suggestion?`${this.message}\n${this.suggestion}`:this.message}},$c=class extends L{constructor(){super(`You are not signed in.`,{suggestion:"Run `skilless auth` to sign in, or set SKILLESS_TOKEN."})}},el=class extends L{constructor(){super(`This directory has no git remote, so it has no project key.`,{suggestion:`skilless identifies a project by its git remote. Add one, or pass --project <key>.`})}},tl=class extends L{url;constructor(e,t){super(`Couldn't reach ${e}.`,{suggestion:`Check your connection, or set SKILLESS_API_URL to point elsewhere.`,cause:t}),this.url=e}};function R(e){try{return a.lstatSync(e),!0}catch{return!1}}function nl(e){try{return a.lstatSync(e).isSymbolicLink()}catch{return!1}}function rl(e){a.mkdirSync(e,{recursive:!0})}function z(e){if(R(e)){if(nl(e)){try{a.unlinkSync(e)}catch{a.rmdirSync(e)}return}a.rmSync(e,{recursive:!0,force:!0})}}function il(e,t){let n=[],r=(e,i)=>{let o=a.readdirSync(e,{withFileTypes:!0});for(let a of o){if(t(a.name))continue;let o=i?S.join(i,a.name):a.name,s=S.join(e,a.name);a.isDirectory()?r(s,o):a.isFile()&&n.push(o)}};return r(e,``),n.sort()}function al(e,t){rl(S.dirname(e)),a.writeFileSync(e,t,`utf8`)}function ol(e,t){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return t}}function sl(e,t,n){rl(S.dirname(e)),a.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function cl(e,t){rl(t),a.cpSync(e,t,{recursive:!0,dereference:!0})}function ll(e,t){try{return n(`git`,e,{cwd:t,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function ul(e){let t=ll([`rev-parse`,`--show-toplevel`],e);return t?S.normalize(t):null}function dl(e){return ll([`remote`,`get-url`,`origin`],e)}function fl(e){let t=e.trim().replace(/\.git$/i,``);if(!t)return null;let n,r,i=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(t);if(i&&!t.includes(`://`))n=i[1]??``,r=i[2]??``;else{t.includes(`://`)||(t=`https://${t}`);let e;try{e=new URL(t)}catch{return null}n=e.hostname,r=e.pathname}return n=n.replace(/:\d+$/,``).toLowerCase(),r=r.replace(/^\/+|\/+$/g,``).toLowerCase(),!n||!r?null:`${n}/${r}`}function pl(e){let t=dl(e);return t?fl(t):null}function ml(e){let t=ll([`rev-parse`,`--git-common-dir`],e);return t?S.isAbsolute(t)?S.normalize(t):S.resolve(e,t):null}function hl(e){let t=ml(e);return t?S.join(t,`info`,`exclude`):null}function gl(e,t){return ll([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function _l(e,t){let n=hl(e);if(!n)return!1;let r=R(n)?a.readFileSync(n,`utf8`):``,i=new Set(r.split(`
|
|
75
75
|
`).map(e=>e.trim()).filter(Boolean)),o=t.filter(e=>!i.has(e));if(o.length===0)return!0;let s=r.includes(`# skilless`)?``:`
|
|
76
76
|
# skilless
|
|
77
77
|
`,c=r.length>0&&!r.endsWith(`
|
|
78
78
|
`)?`
|
|
79
|
-
`:``;return
|
|
80
|
-
`)}\n`,`utf8`),!0}function
|
|
79
|
+
`:``;return rl(S.dirname(n)),a.appendFileSync(n,`${c}${s}${o.join(`
|
|
80
|
+
`)}\n`,`utf8`),!0}function vl(e,t){let n=hl(e);if(!n||!R(n))return;let r=new Set(t),i=a.readFileSync(n,`utf8`).split(`
|
|
81
81
|
`).filter(e=>!r.has(e.trim()));a.writeFileSync(n,i.join(`
|
|
82
|
-
`),`utf8`)}const xl=process.env.SKILLESS_HOME?b.resolve(process.env.SKILLESS_HOME):b.join(s.homedir(),`.skilless`),Sl=b.join(xl,`skills`),Cl=b.join(xl,`auth.json`),wl=b.join(xl,`state.json`),Tl=b.join(xl,`cache.json`),El=b.join(xl,`sources.json`),Dl=b.join(xl,`pending.json`),Ol=b.join(xl,`config.json`),kl=b.join(xl,`conflicts`);function Al(e){return b.join(Sl,e)}const jl=`.agents/skills`,Ml=`.claude/skills`;function Nl(){return process.env.CLAUDE_CONFIG_DIR?b.resolve(process.env.CLAUDE_CONFIG_DIR):b.join(s.homedir(),`.claude`)}function Pl(){return b.join(s.homedir(),jl)}function Fl(){return b.join(Nl(),`skills`)}function Il(){let e=cl(Tl,{});return{version:1,library:e.library?.map(e=>({...e,source:e.source??null}))??null,projects:e.projects??{}}}function Ll(e){let t=Il();t.library=e.map(({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})=>({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})),ll(Tl,t)}function Rl(e,t){let n=Il();n.projects[e]=t.filter(e=>!e.global).map(e=>e.name),ll(Tl,n)}const zl=`SKILL.md`,Bl=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),Vl=/^[a-z0-9][a-z0-9._-]*$/;function Hl(e){return Bl.has(e)}function Ul(e){return e.length<=64&&Vl.test(e)}function Wl(e){if(!Ul(e))throw new P(`${e} is not a valid skill name.`,{suggestion:`Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit.`})}function Gl(e){let t=c.createHash(`sha256`);for(let n of[...e].sort((e,t)=>e.path.localeCompare(t.path)))t.update(n.path),t.update(`\0`),t.update(n.contents),t.update(`\0`);return t.digest(`hex`)}function Kl(e,t){if(!F(b.join(e,zl)))throw new P(`${t} has no ${zl}.`,{suggestion:`Every skill needs a ${zl} at its root.`});let n=ol(e,Hl),r=[],i=0,o=0;for(let s of n){let n=b.join(e,s),c=a.readFileSync(n);if(c.includes(0))throw new P(`${t}/${s} looks like a binary file.`,{suggestion:`v0 syncs text only. Remove the file or keep it outside the skill.`});if(o+=c.byteLength,o>1048576)throw new P(`${t} is larger than 1MB.`,{suggestion:`Skills are prose. Move large assets out of the skill directory.`});r.push({path:s,contents:c.toString(`utf8`)}),i=Math.max(i,a.statSync(n).mtimeMs)}return{name:t,dir:e,files:r,contentHash:Gl(r),editedAt:i}}function ql(e,t,n){let r=Al(e);I(r),al(r);for(let e of t)sl(b.join(r,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)a.utimesSync(b.join(r,n.path),e,e)}}function Jl(){return F(Sl)?a.readdirSync(Sl,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!Hl(e.name)).map(e=>e.name).sort():[]}function Yl(){return Jl().map(e=>Kl(Al(e),e))}function Xl(e){let t=Al(e);return F(t)?Kl(t,e):null}function Zl(e,t){return[{path:zl,contents:`---\nname: ${e}\ndescription: ${t}\n---\n\n# ${e}\n\nDescribe what this skill does and when an agent should reach for it.\n`}]}function Ql(e){return{agents:b.join(e,jl),claude:b.join(e,Ml),repo:e}}function $l(){return{agents:Pl(),claude:Fl(),repo:null}}function eu(e){return typeof e==`string`?Ql(e):e}const tu=`.agents/skills/.skilless.json`;function nu(e){let t;try{t=b.normalize(a.realpathSync(e))}catch{t=b.normalize(e)}return process.platform===`win32`?t.toLowerCase():t}function ru(e,t){try{return nu(b.resolve(b.dirname(e),a.readlinkSync(e)))===nu(t)}catch{return!1}}function iu(e,t){let n=b.join(e.agents,t);return ru(n,Al(t))?!0:ru(b.join(e.claude,t),n)}function au(e){let t=eu(e);return F(t.agents)?a.readdirSync(t.agents).filter(e=>!e.startsWith(`.`)).filter(e=>iu(t,e)).sort():[]}function ou(e){return F(e.claude)&&nu(e.claude)===nu(e.agents)}function su(e,t){let n=b.join(e.agents,t),r=b.join(e.claude,t),i=[];return F(n)&&!iu(e,t)&&i.push(n),!ou(e)&&F(r)&&!ru(r,n)&&i.push(r),i}function cu(e){return e.flatMap(e=>[`/${jl}/${e}`,`/${Ml}/${e}`])}function lu(e,t){process.platform===`win32`?a.symlinkSync(b.resolve(b.dirname(t),e),t,`junction`):a.symlinkSync(e,t,`dir`)}function uu(e,t,n){al(b.dirname(t));try{lu(e,t)}catch{n()}}function du(e,t,n){let r=eu(e),{repo:i}=r;i&&I(b.join(i,tu));let a=[],o=[];for(let e of t){if(i&&(vl(i,`${jl}/${e.name}`)||vl(i,`${Ml}/${e.name}`))){o.push({name:e.name,reason:`tracked`});continue}let t=su(r,e.name);if(t.length>0){o.push({name:e.name,reason:`occupied`,...i?{}:{user:!0},occupied:{paths:t,scope:r,skill:e}});continue}fu(r,e,n),a.push(e.name)}return i&&(bl(i,[`/${tu}`]),yl(i,cu(au(r)))),{written:a,skipped:o}}function fu(e,t,n){let r=b.join(e.agents,t.name),i=b.join(e.claude,t.name),a=!ou(e);if(I(r),a&&I(i),n.copy){al(r);for(let e of t.files??[])sl(b.join(r,e.path),e.contents)}else{let e=Al(t.name);uu(e,r,()=>ul(e,r))}a&&uu(b.relative(b.dirname(i),r),i,()=>ul(r,i))}function pu(e,t){if(!e.occupied)return;let{scope:n,skill:r,paths:i}=e.occupied;for(let e of i)I(e);fu(n,r,t),n.repo&&yl(n.repo,cu([r.name]))}function mu(e,t){let n=eu(e),r=[];for(let e of t){if(!iu(n,e))continue;let t=b.join(n.agents,e),i=b.join(n.claude,e);!ou(n)&&ru(i,t)&&I(i),I(t),r.push(e)}return n.repo&&bl(n.repo,cu(r)),r}function hu(e){let t=eu(e),n=au(t).filter(e=>!a.existsSync(b.join(t.agents,e)));return n.length===0?[]:mu(t,n)}function gu(e){return fl(e)??e}const _u={version:1,skills:{}};function vu(){return{version:1,skills:cl(wl,_u).skills??{}}}function yu(e){ll(wl,e)}function bu(e){return e??!F(Sl)}async function xu(e,t,n={}){let r=bu(n.copy),i=[];if(!r){let e=vu();for(let n of t)Xl(n.name)||(ql(n.name,n.files,n.editedAt),e.skills[n.name]={contentHash:n.contentHash,editedAt:n.editedAt,syncedAt:Date.now()},i.push(n.name));yu(e)}let a=du(e,t,{copy:r}),o=n.reconcile?mu(e,au(e).filter(e=>!t.some(t=>t.name===e))):[];return{...a,fetched:i,removed:o}}async function Su(e,t,n){let r=hu(e),i=new Set(au(e)),a=await xu(e,t,{copy:n.copy,reconcile:!0});return{...a,pruned:r,added:a.written.filter(e=>!i.has(e))}}async function Cu(e,t,n,r={}){let i=await e.getBindings(n);return Rl(n,i),wu(t,i,r)}async function wu(e,t,n={}){let r=await Su(e,t.filter(e=>!e.global),n),i=await Su($l(),t.filter(e=>e.global),n);return{project:r,user:i,skipped:[...r.skipped,...i.skipped],count:t.length}}function Tu(e){let t=$l(),n=hu(t),r=new Set(au(t)),i=du(t,e.filter(e=>F(Al(e))).map(e=>({name:e})),{copy:!1}),a=mu(t,au(t).filter(t=>!e.includes(t)));return{...i,fetched:[],removed:a,pruned:n,added:i.written.filter(e=>!r.has(e))}}function Eu(){let e=cl(Dl,{});return{version:1,projects:e.projects??{},globals:e.globals??{},sources:e.sources??{},deletes:e.deletes??[]}}function Du(e){if(Ou(e)){I(Dl);return}ll(Dl,e)}function Ou(e){return Object.keys(e.projects).length===0&&Object.keys(e.globals).length===0&&Object.keys(e.sources).length===0&&e.deletes.length===0}function ku(e,t){return e.projects[t]??={add:[],remove:[]},e.projects[t]}function Au(e,t){let n=Eu(),r=ku(n,e);r.add=[...new Set([...r.add,...t])],r.remove=r.remove.filter(e=>!t.includes(e)),Du(n)}function ju(e,t){let n=Eu(),r=ku(n,e);r.remove=[...new Set([...r.remove,...t])],r.add=r.add.filter(e=>!t.includes(e)),Du(n)}function Mu(e,t){let n=Eu();for(let r of e)n.globals[r]=t;Du(n)}function Nu(e,t){let n=Eu();n.sources[e]=t,Du(n)}function Pu(e){let t=Eu();t.deletes=[...new Set([...t.deletes,...e])];for(let n of e)delete t.globals[n],delete t.sources[n];for(let n of Object.values(t.projects))n.add=n.add.filter(t=>!e.includes(t));Du(t)}async function Fu(e){let t=Eu();if(Ou(t))return 0;let n=new Set((await e.listSkills()).map(e=>e.name)),r=e=>Jl().includes(e),i=0;for(let r of[...t.deletes])n.has(r)&&(await e.deleteSkill(r),n.delete(r),i++),t.deletes=t.deletes.filter(e=>e!==r),Du(t);for(let[a,o]of Object.entries(t.globals)){if(n.has(a))await e.setGlobal(a,o),i++;else if(r(a))continue;delete t.globals[a],Du(t)}for(let[a,o]of Object.entries(t.sources)){if(n.has(a))await e.setSource(a,o),i++;else if(r(a))continue;delete t.sources[a],Du(t)}for(let[n,a]of Object.entries(t.projects)){let o=(await e.getBindings(n)).filter(e=>!e.global).map(e=>e.name),s=[...new Set([...o,...a.add])].filter(e=>!a.remove.includes(e)),c=await e.setBindings(n,s),l=new Set(c.unknown);i+=a.add.filter(e=>!l.has(e)).length+a.remove.length,a.add=a.add.filter(e=>l.has(e)&&r(e)),a.remove=[],a.add.length===0&&delete t.projects[n],Du(t)}return i}function Iu(){return cl(El,{}).skills??{}}function Lu(e){if(Object.keys(e).length===0){I(El);return}ll(El,{version:1,skills:e})}function Ru(e,t){return e?.url===t?.url&&e?.ref===t?.ref&&e?.path===t?.path&&e?.hash===t?.hash}function zu(e,t){let n=Iu();Ru(n[e],t)||(t?n[e]=t:delete n[e],Lu(n),Nu(e,t))}function Bu(e){let t=Iu();for(let n of e)delete t[n];Lu(t)}function Vu(e){let t=Iu(),n=Eu().sources,r=new Set(e.map(e=>e.name)),i=new Set(Jl());for(let r of e)r.name in n||(r.source?t[r.name]=r.source:delete t[r.name]);for(let e of Object.keys(t))!r.has(e)&&!i.has(e)&&!(e in n)&&delete t[e];Lu(t)}async function L(e){await e.try(e=>Fu(e))}async function R(e){let t=await e.try(e=>e.listSkills());t&&(Ll(t),Vu(t));let n=t??Il().library??[],r=Eu(),i=vu(),a=Iu(),o=new Map(Yl().map(e=>[e.name,e])),s=new Map(n.map(e=>[e.name,e]));return{entries:[...new Set([...o.keys(),...s.keys()])].filter(e=>!r.deletes.includes(e)).sort().map(e=>{let t=o.get(e)??null,n=s.get(e)??null;return{name:e,global:r.globals[e]??n?.global??!1,local:t,remote:n,unsynced:t!==null&&i.skills[e]?.contentHash!==t.contentHash,source:a[e]??null}}),live:t!==void 0}}async function Hu(e,t){let n=await e.try(e=>e.getBindings(t));n&&Rl(t,n);let r=n?n.filter(e=>!e.global).map(e=>e.name):Il().projects[t]??[],i=Eu(),a=i.projects[t]??{add:[],remove:[]};return[...new Set([...r,...a.add])].filter(e=>!a.remove.includes(e)&&!i.deletes.includes(e)).sort()}function Uu(e,t){let n=new Set(t);return e.entries.filter(e=>e.global||n.has(e.name))}async function Wu(e,t,n,r={}){let i=await e.try(e=>e.getBindings(n));if(i)return Rl(n,i),{...await wu(t,i,{copy:r.copy}),missing:[]};let a=Uu(await R(e),await Hu(e,n)),o=a.filter(e=>!e.global),s=a.filter(e=>e.global),c=Eu(),l=new Set(c.deletes),u=e=>Gu(c,e),d=bu(r.copy),f=Ku(t,o,new Set([...c.projects[n]?.remove??[],...l,...u(!0)]),d),p=Ku($l(),s,new Set([...l,...u(!1)]),d);return{project:f,user:p,skipped:[...f.skipped,...p.skipped],missing:a.filter(e=>!e.local).map(e=>e.name)}}function Gu(e,t){return Object.entries(e.globals).filter(([,e])=>e===t).map(([e])=>e)}function Ku(e,t,n,r){let i=new Set(t.map(e=>e.name));hu(e);let a=mu(e,au(e).filter(e=>n.has(e)&&!i.has(e)));return{...du(e,t.flatMap(e=>e.local?[e.local]:[]),{copy:r}),removed:a}}async function qu(e){let t=await R(e),n=t.entries.filter(e=>e.global),r=n.filter(e=>!e.local).map(e=>e.name);if(t.live)return{...Tu(n.map(e=>e.name)),missing:r};let i=Eu(),a=new Set([...i.deletes,...Gu(i,!1)]);return{...Ku($l(),n,a,!1),missing:r}}async function Ju(e,t,n,r=new Map){let i=vu();for(let a of t){zu(a.name,r.get(a.name)??null),ql(a.name,a.files,a.editedAt);let t=await e.try(e=>e.putSkill(a.name,a.files,a.editedAt)),o=n.get(a.name)?.remote;t?i.skills[a.name]={contentHash:a.contentHash,editedAt:a.editedAt,syncedAt:Date.now()}:o?i.skills[a.name]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:Date.now()}:delete i.skills[a.name]}return yu(i),await L(e),t.map(e=>e.name)}var Yu=v(((e,t)=>{let n=typeof process<`u`&&process.env.TERM_PROGRAM===`Hyper`,r=typeof process<`u`&&process.platform===`win32`,i=typeof process<`u`&&process.platform===`linux`,a={ballotDisabled:`☒`,ballotOff:`☐`,ballotOn:`☑`,bullet:`•`,bulletWhite:`◦`,fullBlock:`█`,heart:`❤`,identicalTo:`≡`,line:`─`,mark:`※`,middot:`·`,minus:`-`,multiplication:`×`,obelus:`÷`,pencilDownRight:`✎`,pencilRight:`✏`,pencilUpRight:`✐`,percent:`%`,pilcrow2:`❡`,pilcrow:`¶`,plusMinus:`±`,question:`?`,section:`§`,starsOff:`☆`,starsOn:`★`,upDownArrow:`↕`},o=Object.assign({},a,{check:`√`,cross:`×`,ellipsisLarge:`...`,ellipsis:`...`,info:`i`,questionSmall:`?`,pointer:`>`,pointerSmall:`»`,radioOff:`( )`,radioOn:`(*)`,warning:`‼`}),s=Object.assign({},a,{ballotCross:`✘`,check:`✔`,cross:`✖`,ellipsisLarge:`⋯`,ellipsis:`…`,info:`ℹ`,questionFull:`?`,questionSmall:`﹖`,pointer:i?`▸`:`❯`,pointerSmall:i?`‣`:`›`,radioOff:`◯`,radioOn:`◉`,warning:`⚠`});t.exports=r&&!n?o:s,Reflect.defineProperty(t.exports,`common`,{enumerable:!1,value:a}),Reflect.defineProperty(t.exports,`windows`,{enumerable:!1,value:o}),Reflect.defineProperty(t.exports,`other`,{enumerable:!1,value:s})})),Xu=v(((e,t)=>{let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,i=()=>typeof process<`u`?process.env.FORCE_COLOR!==`0`:!1,a=()=>{let e={enabled:i(),visible:!0,styles:{},keys:{}},t=e=>{let t=e.open=`\u001b[${e.codes[0]}m`,n=e.close=`\u001b[${e.codes[1]}m`,r=e.regex=RegExp(`\\u001b\\[${e.codes[1]}m`,`g`);return e.wrap=(e,i)=>{e.includes(n)&&(e=e.replace(r,n+t));let a=t+e+n;return i?a.replace(/\r*\n/g,`${n}$&${t}`):a},e},a=(e,t,n)=>typeof e==`function`?e(t):e.wrap(t,n),o=(t,n)=>{if(t===``||t==null)return``;if(e.enabled===!1)return t;if(e.visible===!1)return``;let r=``+t,i=r.includes(`
|
|
83
|
-
`),o=n.length;for(o>0&&n.includes(`unstyle`)&&(n=[...new Set([`unstyle`,...n])].reverse());o-- >0;)r=a(e.styles[n[o]],r,i);return r},s=(n,r,i)=>{e.styles[n]=t({name:n,codes:r}),(e.keys[i]||(e.keys[i]=[])).push(n),Reflect.defineProperty(e,n,{configurable:!0,enumerable:!0,set(t){e.alias(n,t)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(n):[n],t}})};return s(`reset`,[0,0],`modifier`),s(`bold`,[1,22],`modifier`),s(`dim`,[2,22],`modifier`),s(`italic`,[3,23],`modifier`),s(`underline`,[4,24],`modifier`),s(`inverse`,[7,27],`modifier`),s(`hidden`,[8,28],`modifier`),s(`strikethrough`,[9,29],`modifier`),s(`black`,[30,39],`color`),s(`red`,[31,39],`color`),s(`green`,[32,39],`color`),s(`yellow`,[33,39],`color`),s(`blue`,[34,39],`color`),s(`magenta`,[35,39],`color`),s(`cyan`,[36,39],`color`),s(`white`,[37,39],`color`),s(`gray`,[90,39],`color`),s(`grey`,[90,39],`color`),s(`bgBlack`,[40,49],`bg`),s(`bgRed`,[41,49],`bg`),s(`bgGreen`,[42,49],`bg`),s(`bgYellow`,[43,49],`bg`),s(`bgBlue`,[44,49],`bg`),s(`bgMagenta`,[45,49],`bg`),s(`bgCyan`,[46,49],`bg`),s(`bgWhite`,[47,49],`bg`),s(`blackBright`,[90,39],`bright`),s(`redBright`,[91,39],`bright`),s(`greenBright`,[92,39],`bright`),s(`yellowBright`,[93,39],`bright`),s(`blueBright`,[94,39],`bright`),s(`magentaBright`,[95,39],`bright`),s(`cyanBright`,[96,39],`bright`),s(`whiteBright`,[97,39],`bright`),s(`bgBlackBright`,[100,49],`bgBright`),s(`bgRedBright`,[101,49],`bgBright`),s(`bgGreenBright`,[102,49],`bgBright`),s(`bgYellowBright`,[103,49],`bgBright`),s(`bgBlueBright`,[104,49],`bgBright`),s(`bgMagentaBright`,[105,49],`bgBright`),s(`bgCyanBright`,[106,49],`bgBright`),s(`bgWhiteBright`,[107,49],`bgBright`),e.ansiRegex=r,e.hasColor=e.hasAnsi=t=>(e.ansiRegex.lastIndex=0,typeof t==`string`&&t!==``&&e.ansiRegex.test(t)),e.alias=(t,n)=>{let r=typeof n==`string`?e[n]:n;if(typeof r!=`function`)throw TypeError(`Expected alias to be the name of an existing color (string) or a function`);r.stack||=(Reflect.defineProperty(r,`name`,{value:t}),e.styles[t]=r,[t]),Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,set(n){e.alias(t,n)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(r.stack):r.stack,t}})},e.theme=t=>{if(!n(t))throw TypeError(`Expected theme to be an object`);for(let n of Object.keys(t))e.alias(n,t[n]);return e},e.alias(`unstyle`,t=>typeof t==`string`&&t!==``?(e.ansiRegex.lastIndex=0,t.replace(e.ansiRegex,``)):``),e.alias(`noop`,e=>e),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=
|
|
84
|
-
`+n,width:i=80}=t,a=(r+n).match(/[^\S\n]/g)||[];i-=a.length;let o=`.{1,${i}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,s=e.trim(),c=new RegExp(o,`g`),l=s.match(c)||[];return l=l.map(e=>e.replace(/\n$/,``)),t.padEnd&&(l=l.map(e=>e.padEnd(i,` `))),t.padStart&&(l=l.map(e=>e.padStart(i,` `))),n+l.join(r)},e.unmute=e=>{let t=e.stack.find(e=>n.keys.color.includes(e));return t?n[t]:e.stack.find(e=>e.slice(2)===`bg`)?n[t.slice(2)]:e=>e},e.pascal=e=>e?e[0].toUpperCase()+e.slice(1):``,e.inverse=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e));if(r){let i=n[`bg`+e.pascal(r)];return i?i.black:t}let i=t.stack.find(e=>e.slice(0,2)===`bg`);return i?n[i.slice(2).toLowerCase()]||t:n.none},e.complement=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e)),i=t.stack.find(e=>e.slice(0,2)===`bg`);if(r&&!i)return n[a[r]||r];if(i){let r=a[i.slice(2).toLowerCase()];return r&&n[`bg`+e.pascal(r)]||t}return n.none},e.meridiem=e=>{let t=e.getHours(),n=e.getMinutes(),r=t>=12?`pm`:`am`;t%=12;let i=t===0?12:t,a=n<10?`0`+n:n;return i+`:`+a+` `+r},e.set=(t={},n=``,r)=>n.split(`.`).reduce((t,n,i,a)=>{let o=a.length-1>i?t[n]||{}:r;return!e.isObject(o)&&i<a.length-1&&(o={}),t[n]=o},t),e.get=(e={},t=``,n)=>(e[t]==null?t.split(`.`).reduce((e,t)=>e&&e[t],e):e[t])??n,e.mixin=(t,n)=>{if(!o(t))return n;if(!o(n))return t;for(let r of Object.keys(n)){let i=Object.getOwnPropertyDescriptor(n,r);if(hasOwnProperty.call(i,`value`))if(hasOwnProperty.call(t,r)&&o(i.value)){let a=Object.getOwnPropertyDescriptor(t,r);o(a.value)&&a.value!==i.value?t[r]=e.merge({},t[r],n[r]):Reflect.defineProperty(t,r,i)}else Reflect.defineProperty(t,r,i);else Reflect.defineProperty(t,r,i)}return t},e.merge=(...t)=>{let n={};for(let r of t)e.mixin(n,r);return n},e.mixinEmitter=(t,n)=>{let r=n.constructor.prototype;for(let i of Object.keys(r)){let a=r[i];typeof a==`function`?e.define(t,i,a.bind(n)):e.define(t,i,a)}};let s=(e,t)=>{r||(r=!0,i.forEach(e=>e()),e===!0&&process.exit(128+t))},c=s.bind(null,!0,15),l=s.bind(null,!0,2);e.onExit=e=>(i.size===0&&(process.once(`SIGTERM`,c),process.once(`SIGINT`,l),process.once(`exit`,s)),i.add(e),()=>{i.delete(e),i.size===0&&(process.off(`SIGTERM`,c),process.off(`SIGINT`,l),process.off(`exit`,s))}),e.define=(e,t,n)=>{Reflect.defineProperty(e,t,{value:n})},e.defineExport=(e,t,n)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(e){r=e},get(){return r?r():n()}})}})),
|
|
85
|
-
`)r.name=`enter`;else if(e===` `)r.name=`tab`;else if(e===`\b`||e===``||e===`\x1B`||e===`\x1B\b`)r.name=`backspace`,r.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)r.name=`escape`,r.meta=e.length===2;else if(e===` `||e===`\x1B `)r.name=`space`,r.meta=e.length===2;else if(e<=``)r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)r.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)r.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)r.name=e.toLowerCase(),r.shift=!0;else if(n=a.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=o.exec(e)){let t=[...e];t[0]===`\x1B`&&t[1]===`\x1B`&&(r.option=!0);let i=[n[1],n[2],n[4],n[6]].filter(Boolean).join(``),a=(n[3]||n[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=s[i],r.shift=c(i)||r.shift,r.ctrl=l(i)||r.ctrl}return r};u.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw Error(`Invalid stream passed`);let a=n.createInterface({terminal:!0,input:r});n.emitKeypressEvents(r,a);let o=new i((e,n)=>t(e,u(e,n),a)),s=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on(`keypress`,o.enqueue),a.resume(),()=>{r.isTTY&&r.setRawMode(s),r.removeListener(`keypress`,o.enqueue),o.destroy(),a.pause(),a.close()}},u.action=(e,t,n)=>{let i={...r,...n};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)},t.exports=u})),
|
|
82
|
+
`),`utf8`)}const yl=process.env.SKILLESS_HOME?S.resolve(process.env.SKILLESS_HOME):S.join(s.homedir(),`.skilless`),bl=S.join(yl,`skills`),xl=S.join(yl,`auth.json`),Sl=S.join(yl,`state.json`),Cl=S.join(yl,`cache.json`),wl=S.join(yl,`sources.json`),Tl=S.join(yl,`pending.json`),El=S.join(yl,`config.json`),Dl=S.join(yl,`conflicts`);function Ol(e){return S.join(bl,e)}const kl=`.agents/skills`,Al=`.claude/skills`;function jl(){return process.env.CLAUDE_CONFIG_DIR?S.resolve(process.env.CLAUDE_CONFIG_DIR):S.join(s.homedir(),`.claude`)}function Ml(){return S.join(s.homedir(),kl)}function Nl(){return S.join(jl(),`skills`)}function Pl(){let e=ol(Cl,{});return{version:1,library:e.library?.map(e=>({...e,source:e.source??null}))??null,projects:e.projects??{}}}function Fl(e){let t=Pl();t.library=e.map(({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})=>({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})),sl(Cl,t)}function Il(e,t){let n=Pl();n.projects[e]=t.filter(e=>!e.global).map(e=>e.name),sl(Cl,n)}const Ll=`SKILL.md`,Rl=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),zl=/^[a-z0-9][a-z0-9._-]*$/;function Bl(e){return Rl.has(e)}function Vl(e){return e.length<=64&&zl.test(e)}function Hl(e){if(!Vl(e))throw new L(`${e} is not a valid skill name.`,{suggestion:`Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit.`})}function Ul(e){let t=c.createHash(`sha256`);for(let n of[...e].sort((e,t)=>e.path.localeCompare(t.path)))t.update(n.path),t.update(`\0`),t.update(n.contents),t.update(`\0`);return t.digest(`hex`)}function Wl(e,t){if(!R(S.join(e,Ll)))throw new L(`${t} has no ${Ll}.`,{suggestion:`Every skill needs a ${Ll} at its root.`});let n=il(e,Bl),r=[],i=0,o=0;for(let s of n){let n=S.join(e,s),c=a.readFileSync(n);if(c.includes(0))throw new L(`${t}/${s} looks like a binary file.`,{suggestion:`v0 syncs text only. Remove the file or keep it outside the skill.`});if(o+=c.byteLength,o>1048576)throw new L(`${t} is larger than 1MB.`,{suggestion:`Skills are prose. Move large assets out of the skill directory.`});r.push({path:s,contents:c.toString(`utf8`)}),i=Math.max(i,a.statSync(n).mtimeMs)}return{name:t,dir:e,files:r,contentHash:Ul(r),editedAt:i}}function Gl(e,t,n){let r=Ol(e);z(r),rl(r);for(let e of t)al(S.join(r,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)a.utimesSync(S.join(r,n.path),e,e)}}function Kl(){return R(bl)?a.readdirSync(bl,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!Bl(e.name)).map(e=>e.name).sort():[]}function ql(){return Kl().map(e=>Wl(Ol(e),e))}function Jl(e){let t=Ol(e);return R(t)?Wl(t,e):null}function Yl(e,t){return[{path:Ll,contents:`---\nname: ${e}\ndescription: ${t}\n---\n\n# ${e}\n\nDescribe what this skill does and when an agent should reach for it.\n`}]}function Xl(e){return{agents:S.join(e,kl),claude:S.join(e,Al),repo:e}}function Zl(){return{agents:Ml(),claude:Nl(),repo:null}}function Ql(e){return typeof e==`string`?Xl(e):e}const $l=`.agents/skills/.skilless.json`;function eu(e){let t;try{t=S.normalize(a.realpathSync(e))}catch{t=S.normalize(e)}return process.platform===`win32`?t.toLowerCase():t}function tu(e,t){try{return eu(S.resolve(S.dirname(e),a.readlinkSync(e)))===eu(t)}catch{return!1}}function nu(e,t){let n=S.join(e.agents,t);return tu(n,Ol(t))?!0:tu(S.join(e.claude,t),n)}function ru(e){let t=Ql(e);return R(t.agents)?a.readdirSync(t.agents).filter(e=>!e.startsWith(`.`)).filter(e=>nu(t,e)).sort():[]}function iu(e){return R(e.claude)&&eu(e.claude)===eu(e.agents)}function au(e,t){let n=S.join(e.agents,t),r=S.join(e.claude,t),i=[];return R(n)&&!nu(e,t)&&i.push(n),!iu(e)&&R(r)&&!tu(r,n)&&i.push(r),i}function ou(e){return e.flatMap(e=>[`/${kl}/${e}`,`/${Al}/${e}`])}function su(e,t){process.platform===`win32`?a.symlinkSync(S.resolve(S.dirname(t),e),t,`junction`):a.symlinkSync(e,t,`dir`)}function cu(e,t,n){rl(S.dirname(t));try{su(e,t)}catch{n()}}function lu(e,t,n){let r=Ql(e),{repo:i}=r;i&&z(S.join(i,$l));let a=[],o=[];for(let e of t){if(i&&(gl(i,`${kl}/${e.name}`)||gl(i,`${Al}/${e.name}`))){o.push({name:e.name,reason:`tracked`});continue}let t=au(r,e.name);if(t.length>0){o.push({name:e.name,reason:`occupied`,...i?{}:{user:!0},occupied:{paths:t,scope:r,skill:e}});continue}uu(r,e,n),a.push(e.name)}return i&&(vl(i,[`/${$l}`]),_l(i,ou(ru(r)))),{written:a,skipped:o}}function uu(e,t,n){let r=S.join(e.agents,t.name),i=S.join(e.claude,t.name),a=!iu(e);if(z(r),a&&z(i),n.copy){rl(r);for(let e of t.files??[])al(S.join(r,e.path),e.contents)}else{let e=Ol(t.name);cu(e,r,()=>cl(e,r))}a&&cu(S.relative(S.dirname(i),r),i,()=>cl(r,i))}function du(e,t){if(!e.occupied)return;let{scope:n,skill:r,paths:i}=e.occupied;for(let e of i)z(e);uu(n,r,t),n.repo&&_l(n.repo,ou([r.name]))}function fu(e,t){let n=Ql(e),r=[];for(let e of t){if(!nu(n,e))continue;let t=S.join(n.agents,e),i=S.join(n.claude,e);!iu(n)&&tu(i,t)&&z(i),z(t),r.push(e)}return n.repo&&vl(n.repo,ou(r)),r}function pu(e){let t=Ql(e),n=ru(t).filter(e=>!a.existsSync(S.join(t.agents,e)));return n.length===0?[]:fu(t,n)}function mu(e){return ul(e)??e}function hu(){return process.env.SKILLESS_TOKEN||ol(xl,{}).token}function gu(e){sl(xl,{token:e},384)}function _u(){z(xl)}function vu(){return(process.env.SKILLESS_API_URL??`https://skilless.dev`).replace(/\/$/,``)}function yu(){let e=hu()??``,t=l(`sha256`).update(e).digest(`hex`).slice(0,16);return`${vu()}#${t}`}function bu(){let e=ol(Sl,{}),t=yu();return e.remote===t?{version:1,remote:t,skills:e.skills??{}}:{version:1,remote:t,skills:{}}}function xu(e){sl(Sl,{...e,remote:yu()})}function Su(e){return e??!R(bl)}async function Cu(e,t,n={}){let r=Su(n.copy),i=[];if(!r){let e=bu();for(let n of t)Jl(n.name)||(Gl(n.name,n.files,n.editedAt),e.skills[n.name]={contentHash:n.contentHash,editedAt:n.editedAt,syncedAt:Date.now()},i.push(n.name));xu(e)}let a=lu(e,t,{copy:r}),o=n.reconcile?fu(e,ru(e).filter(e=>!t.some(t=>t.name===e))):[];return{...a,fetched:i,removed:o}}async function wu(e,t,n){let r=pu(e),i=new Set(ru(e)),a=await Cu(e,t,{copy:n.copy,reconcile:!0});return{...a,pruned:r,added:a.written.filter(e=>!i.has(e))}}async function Tu(e,t,n,r={}){let i=await e.getBindings(n);return Il(n,i),Eu(t,i,r)}async function Eu(e,t,n={}){let r=await wu(e,t.filter(e=>!e.global),n),i=await wu(Zl(),t.filter(e=>e.global),n);return{project:r,user:i,skipped:[...r.skipped,...i.skipped],count:t.length}}function Du(e){let t=Zl(),n=pu(t),r=new Set(ru(t)),i=lu(t,e.filter(e=>R(Ol(e))).map(e=>({name:e})),{copy:!1}),a=fu(t,ru(t).filter(t=>!e.includes(t)));return{...i,fetched:[],removed:a,pruned:n,added:i.written.filter(e=>!r.has(e))}}function Ou(){let e=ol(Tl,{});return{version:1,projects:e.projects??{},globals:e.globals??{},sources:e.sources??{},deletes:e.deletes??[]}}function ku(e){if(Au(e)){z(Tl);return}sl(Tl,e)}function Au(e){return Object.keys(e.projects).length===0&&Object.keys(e.globals).length===0&&Object.keys(e.sources).length===0&&e.deletes.length===0}function ju(e,t){return e.projects[t]??={add:[],remove:[]},e.projects[t]}function Mu(e,t){let n=Ou(),r=ju(n,e);r.add=[...new Set([...r.add,...t])],r.remove=r.remove.filter(e=>!t.includes(e)),ku(n)}function Nu(e,t){let n=Ou(),r=ju(n,e);r.remove=[...new Set([...r.remove,...t])],r.add=r.add.filter(e=>!t.includes(e)),ku(n)}function Pu(e,t){let n=Ou();for(let r of e)n.globals[r]=t;ku(n)}function Fu(e,t){let n=Ou();n.sources[e]=t,ku(n)}function Iu(e){let t=Ou();t.deletes=[...new Set([...t.deletes,...e])];for(let n of e)delete t.globals[n],delete t.sources[n];for(let n of Object.values(t.projects))n.add=n.add.filter(t=>!e.includes(t));ku(t)}async function Lu(e){let t=Ou();if(Au(t))return 0;let n=new Set((await e.listSkills()).map(e=>e.name)),r=e=>Kl().includes(e),i=0;for(let r of[...t.deletes])n.has(r)&&(await e.deleteSkill(r),n.delete(r),i++),t.deletes=t.deletes.filter(e=>e!==r),ku(t);for(let[a,o]of Object.entries(t.globals)){if(n.has(a))await e.setGlobal(a,o),i++;else if(r(a))continue;delete t.globals[a],ku(t)}for(let[a,o]of Object.entries(t.sources)){if(n.has(a))await e.setSource(a,o),i++;else if(r(a))continue;delete t.sources[a],ku(t)}for(let[n,a]of Object.entries(t.projects)){let o=(await e.getBindings(n)).filter(e=>!e.global).map(e=>e.name),s=[...new Set([...o,...a.add])].filter(e=>!a.remove.includes(e)),c=await e.setBindings(n,s),l=new Set(c.unknown);i+=a.add.filter(e=>!l.has(e)).length+a.remove.length,a.add=a.add.filter(e=>l.has(e)&&r(e)),a.remove=[],a.add.length===0&&delete t.projects[n],ku(t)}return i}function Ru(){return ol(wl,{}).skills??{}}function zu(e){if(Object.keys(e).length===0){z(wl);return}sl(wl,{version:1,skills:e})}function Bu(e,t){return e?.url===t?.url&&e?.ref===t?.ref&&e?.path===t?.path&&e?.hash===t?.hash}function Vu(e,t){let n=Ru();Bu(n[e],t)||(t?n[e]=t:delete n[e],zu(n),Fu(e,t))}function Hu(e){let t=Ru();for(let n of e)delete t[n];zu(t)}function Uu(e){let t=Ru(),n=Ou().sources,r=new Set(e.map(e=>e.name)),i=new Set(Kl());for(let r of e)r.name in n||(r.source?t[r.name]=r.source:delete t[r.name]);for(let e of Object.keys(t))!r.has(e)&&!i.has(e)&&!(e in n)&&delete t[e];zu(t)}async function B(e){await e.try(e=>Lu(e))}async function Wu(e){let t=await e.try(e=>e.listSkills());t&&(Fl(t),Uu(t));let n=t??Pl().library??[],r=Ou(),i=bu(),a=Ru(),o=new Map(ql().map(e=>[e.name,e])),s=new Map(n.map(e=>[e.name,e]));return{entries:[...new Set([...o.keys(),...s.keys()])].filter(e=>!r.deletes.includes(e)).sort().map(e=>{let t=o.get(e)??null,n=s.get(e)??null;return{name:e,global:r.globals[e]??n?.global??!1,local:t,remote:n,unsynced:t!==null&&i.skills[e]?.contentHash!==t.contentHash,source:a[e]??null}}),live:t!==void 0}}async function Gu(e,t){let n=await e.try(e=>e.getBindings(t));n&&Il(t,n);let r=n?n.filter(e=>!e.global).map(e=>e.name):Pl().projects[t]??[],i=Ou(),a=i.projects[t]??{add:[],remove:[]};return[...new Set([...r,...a.add])].filter(e=>!a.remove.includes(e)&&!i.deletes.includes(e)).sort()}function Ku(e,t){let n=new Set(t);return e.entries.filter(e=>e.global||n.has(e.name))}async function qu(e,t,n,r={}){let i=await e.try(e=>e.getBindings(n));if(i)return Il(n,i),{...await Eu(t,i,{copy:r.copy}),missing:[]};let a=Ku(await Wu(e),await Gu(e,n)),o=a.filter(e=>!e.global),s=a.filter(e=>e.global),c=Ou(),l=new Set(c.deletes),u=e=>Ju(c,e),d=Su(r.copy),f=Yu(t,o,new Set([...c.projects[n]?.remove??[],...l,...u(!0)]),d),p=Yu(Zl(),s,new Set([...l,...u(!1)]),d);return{project:f,user:p,skipped:[...f.skipped,...p.skipped],missing:a.filter(e=>!e.local).map(e=>e.name)}}function Ju(e,t){return Object.entries(e.globals).filter(([,e])=>e===t).map(([e])=>e)}function Yu(e,t,n,r){let i=new Set(t.map(e=>e.name));pu(e);let a=fu(e,ru(e).filter(e=>n.has(e)&&!i.has(e)));return{...lu(e,t.flatMap(e=>e.local?[e.local]:[]),{copy:r}),removed:a}}async function Xu(e){let t=await Wu(e),n=t.entries.filter(e=>e.global),r=n.filter(e=>!e.local).map(e=>e.name);if(t.live)return{...Du(n.map(e=>e.name)),missing:r};let i=Ou(),a=new Set([...i.deletes,...Ju(i,!1)]);return{...Yu(Zl(),n,a,!1),missing:r}}async function Zu(e,t,n,r=new Map){let i=bu();for(let a of t){Vu(a.name,r.get(a.name)??null),Gl(a.name,a.files,a.editedAt);let t=await e.try(e=>e.putSkill(a.name,a.files,a.editedAt)),o=n.get(a.name)?.remote;t?i.skills[a.name]={contentHash:a.contentHash,editedAt:a.editedAt,syncedAt:Date.now()}:o?i.skills[a.name]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:Date.now()}:delete i.skills[a.name]}return xu(i),await B(e),t.map(e=>e.name)}var Qu=v(((e,t)=>{let n=typeof process<`u`&&process.env.TERM_PROGRAM===`Hyper`,r=typeof process<`u`&&process.platform===`win32`,i=typeof process<`u`&&process.platform===`linux`,a={ballotDisabled:`☒`,ballotOff:`☐`,ballotOn:`☑`,bullet:`•`,bulletWhite:`◦`,fullBlock:`█`,heart:`❤`,identicalTo:`≡`,line:`─`,mark:`※`,middot:`·`,minus:`-`,multiplication:`×`,obelus:`÷`,pencilDownRight:`✎`,pencilRight:`✏`,pencilUpRight:`✐`,percent:`%`,pilcrow2:`❡`,pilcrow:`¶`,plusMinus:`±`,question:`?`,section:`§`,starsOff:`☆`,starsOn:`★`,upDownArrow:`↕`},o=Object.assign({},a,{check:`√`,cross:`×`,ellipsisLarge:`...`,ellipsis:`...`,info:`i`,questionSmall:`?`,pointer:`>`,pointerSmall:`»`,radioOff:`( )`,radioOn:`(*)`,warning:`‼`}),s=Object.assign({},a,{ballotCross:`✘`,check:`✔`,cross:`✖`,ellipsisLarge:`⋯`,ellipsis:`…`,info:`ℹ`,questionFull:`?`,questionSmall:`﹖`,pointer:i?`▸`:`❯`,pointerSmall:i?`‣`:`›`,radioOff:`◯`,radioOn:`◉`,warning:`⚠`});t.exports=r&&!n?o:s,Reflect.defineProperty(t.exports,`common`,{enumerable:!1,value:a}),Reflect.defineProperty(t.exports,`windows`,{enumerable:!1,value:o}),Reflect.defineProperty(t.exports,`other`,{enumerable:!1,value:s})})),$u=v(((e,t)=>{let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,i=()=>typeof process<`u`?process.env.FORCE_COLOR!==`0`:!1,a=()=>{let e={enabled:i(),visible:!0,styles:{},keys:{}},t=e=>{let t=e.open=`\u001b[${e.codes[0]}m`,n=e.close=`\u001b[${e.codes[1]}m`,r=e.regex=RegExp(`\\u001b\\[${e.codes[1]}m`,`g`);return e.wrap=(e,i)=>{e.includes(n)&&(e=e.replace(r,n+t));let a=t+e+n;return i?a.replace(/\r*\n/g,`${n}$&${t}`):a},e},a=(e,t,n)=>typeof e==`function`?e(t):e.wrap(t,n),o=(t,n)=>{if(t===``||t==null)return``;if(e.enabled===!1)return t;if(e.visible===!1)return``;let r=``+t,i=r.includes(`
|
|
83
|
+
`),o=n.length;for(o>0&&n.includes(`unstyle`)&&(n=[...new Set([`unstyle`,...n])].reverse());o-- >0;)r=a(e.styles[n[o]],r,i);return r},s=(n,r,i)=>{e.styles[n]=t({name:n,codes:r}),(e.keys[i]||(e.keys[i]=[])).push(n),Reflect.defineProperty(e,n,{configurable:!0,enumerable:!0,set(t){e.alias(n,t)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(n):[n],t}})};return s(`reset`,[0,0],`modifier`),s(`bold`,[1,22],`modifier`),s(`dim`,[2,22],`modifier`),s(`italic`,[3,23],`modifier`),s(`underline`,[4,24],`modifier`),s(`inverse`,[7,27],`modifier`),s(`hidden`,[8,28],`modifier`),s(`strikethrough`,[9,29],`modifier`),s(`black`,[30,39],`color`),s(`red`,[31,39],`color`),s(`green`,[32,39],`color`),s(`yellow`,[33,39],`color`),s(`blue`,[34,39],`color`),s(`magenta`,[35,39],`color`),s(`cyan`,[36,39],`color`),s(`white`,[37,39],`color`),s(`gray`,[90,39],`color`),s(`grey`,[90,39],`color`),s(`bgBlack`,[40,49],`bg`),s(`bgRed`,[41,49],`bg`),s(`bgGreen`,[42,49],`bg`),s(`bgYellow`,[43,49],`bg`),s(`bgBlue`,[44,49],`bg`),s(`bgMagenta`,[45,49],`bg`),s(`bgCyan`,[46,49],`bg`),s(`bgWhite`,[47,49],`bg`),s(`blackBright`,[90,39],`bright`),s(`redBright`,[91,39],`bright`),s(`greenBright`,[92,39],`bright`),s(`yellowBright`,[93,39],`bright`),s(`blueBright`,[94,39],`bright`),s(`magentaBright`,[95,39],`bright`),s(`cyanBright`,[96,39],`bright`),s(`whiteBright`,[97,39],`bright`),s(`bgBlackBright`,[100,49],`bgBright`),s(`bgRedBright`,[101,49],`bgBright`),s(`bgGreenBright`,[102,49],`bgBright`),s(`bgYellowBright`,[103,49],`bgBright`),s(`bgBlueBright`,[104,49],`bgBright`),s(`bgMagentaBright`,[105,49],`bgBright`),s(`bgCyanBright`,[106,49],`bgBright`),s(`bgWhiteBright`,[107,49],`bgBright`),e.ansiRegex=r,e.hasColor=e.hasAnsi=t=>(e.ansiRegex.lastIndex=0,typeof t==`string`&&t!==``&&e.ansiRegex.test(t)),e.alias=(t,n)=>{let r=typeof n==`string`?e[n]:n;if(typeof r!=`function`)throw TypeError(`Expected alias to be the name of an existing color (string) or a function`);r.stack||=(Reflect.defineProperty(r,`name`,{value:t}),e.styles[t]=r,[t]),Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,set(n){e.alias(t,n)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(r.stack):r.stack,t}})},e.theme=t=>{if(!n(t))throw TypeError(`Expected theme to be an object`);for(let n of Object.keys(t))e.alias(n,t[n]);return e},e.alias(`unstyle`,t=>typeof t==`string`&&t!==``?(e.ansiRegex.lastIndex=0,t.replace(e.ansiRegex,``)):``),e.alias(`noop`,e=>e),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Qu(),e.define=s,e};t.exports=a(),t.exports.create=a})),V=v((e=>{let t=Object.prototype.toString,n=$u(),r=!1,i=new Set,a={yellow:`blue`,cyan:`red`,green:`magenta`,black:`white`,blue:`yellow`,red:`cyan`,magenta:`green`,white:`black`};e.longest=(e,t)=>e.reduce((e,n)=>Math.max(e,t?n[t].length:n.length),0),e.hasColor=e=>!!e&&n.hasColor(e);let o=e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e);e.nativeType=e=>t.call(e).slice(8,-1).toLowerCase().replace(/\s/g,``),e.isAsyncFn=t=>e.nativeType(t)===`asyncfunction`,e.isPrimitive=e=>e!=null&&typeof e!=`object`&&typeof e!=`function`,e.resolve=(e,t,...n)=>typeof t==`function`?t.call(e,...n):t,e.scrollDown=(e=[])=>[...e.slice(1),e[0]],e.scrollUp=(e=[])=>[e.pop(),...e],e.reorder=(e=[])=>{let t=e.slice();return t.sort((e,t)=>e.index>t.index?1:e.index<t.index?-1:0),t},e.swap=(e,t,n)=>{let r=e.length,i=n===r?0:n<0?r-1:n,a=e[t];e[t]=e[i],e[i]=a},e.width=(e,t=80)=>{let n=e&&e.columns?e.columns:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[0]),process.platform===`win32`?n-1:n},e.height=(e,t=20)=>{let n=e&&e.rows?e.rows:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[1]),n},e.wordWrap=(e,t={})=>{if(!e)return e;typeof t==`number`&&(t={width:t});let{indent:n=``,newline:r=`
|
|
84
|
+
`+n,width:i=80}=t,a=(r+n).match(/[^\S\n]/g)||[];i-=a.length;let o=`.{1,${i}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,s=e.trim(),c=new RegExp(o,`g`),l=s.match(c)||[];return l=l.map(e=>e.replace(/\n$/,``)),t.padEnd&&(l=l.map(e=>e.padEnd(i,` `))),t.padStart&&(l=l.map(e=>e.padStart(i,` `))),n+l.join(r)},e.unmute=e=>{let t=e.stack.find(e=>n.keys.color.includes(e));return t?n[t]:e.stack.find(e=>e.slice(2)===`bg`)?n[t.slice(2)]:e=>e},e.pascal=e=>e?e[0].toUpperCase()+e.slice(1):``,e.inverse=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e));if(r){let i=n[`bg`+e.pascal(r)];return i?i.black:t}let i=t.stack.find(e=>e.slice(0,2)===`bg`);return i?n[i.slice(2).toLowerCase()]||t:n.none},e.complement=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e)),i=t.stack.find(e=>e.slice(0,2)===`bg`);if(r&&!i)return n[a[r]||r];if(i){let r=a[i.slice(2).toLowerCase()];return r&&n[`bg`+e.pascal(r)]||t}return n.none},e.meridiem=e=>{let t=e.getHours(),n=e.getMinutes(),r=t>=12?`pm`:`am`;t%=12;let i=t===0?12:t,a=n<10?`0`+n:n;return i+`:`+a+` `+r},e.set=(t={},n=``,r)=>n.split(`.`).reduce((t,n,i,a)=>{let o=a.length-1>i?t[n]||{}:r;return!e.isObject(o)&&i<a.length-1&&(o={}),t[n]=o},t),e.get=(e={},t=``,n)=>(e[t]==null?t.split(`.`).reduce((e,t)=>e&&e[t],e):e[t])??n,e.mixin=(t,n)=>{if(!o(t))return n;if(!o(n))return t;for(let r of Object.keys(n)){let i=Object.getOwnPropertyDescriptor(n,r);if(hasOwnProperty.call(i,`value`))if(hasOwnProperty.call(t,r)&&o(i.value)){let a=Object.getOwnPropertyDescriptor(t,r);o(a.value)&&a.value!==i.value?t[r]=e.merge({},t[r],n[r]):Reflect.defineProperty(t,r,i)}else Reflect.defineProperty(t,r,i);else Reflect.defineProperty(t,r,i)}return t},e.merge=(...t)=>{let n={};for(let r of t)e.mixin(n,r);return n},e.mixinEmitter=(t,n)=>{let r=n.constructor.prototype;for(let i of Object.keys(r)){let a=r[i];typeof a==`function`?e.define(t,i,a.bind(n)):e.define(t,i,a)}};let s=(e,t)=>{r||(r=!0,i.forEach(e=>e()),e===!0&&process.exit(128+t))},c=s.bind(null,!0,15),l=s.bind(null,!0,2);e.onExit=e=>(i.size===0&&(process.once(`SIGTERM`,c),process.once(`SIGINT`,l),process.once(`exit`,s)),i.add(e),()=>{i.delete(e),i.size===0&&(process.off(`SIGTERM`,c),process.off(`SIGINT`,l),process.off(`exit`,s))}),e.define=(e,t,n)=>{Reflect.defineProperty(e,t,{value:n})},e.defineExport=(e,t,n)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(e){r=e},get(){return r?r():n()}})}})),ed=v(((e,t)=>{t.exports=({onlyFirst:e=!1}={})=>{let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}})),td=v(((e,t)=>{let n=ed();t.exports=e=>typeof e==`string`?e.replace(n(),``):e})),nd=v((e=>{e.ctrl={a:`first`,b:`backward`,c:`cancel`,d:`deleteForward`,e:`last`,f:`forward`,g:`reset`,i:`tab`,k:`cutForward`,l:`reset`,n:`newItem`,m:`cancel`,j:`submit`,p:`search`,r:`remove`,s:`save`,u:`undo`,w:`cutLeft`,x:`toggleCursor`,v:`paste`},e.shift={up:`shiftUp`,down:`shiftDown`,left:`shiftLeft`,right:`shiftRight`,tab:`prev`},e.fn={up:`pageUp`,down:`pageDown`,left:`pageLeft`,right:`pageRight`,delete:`deleteForward`},e.option={b:`backward`,f:`forward`,d:`cutRight`,left:`cutLeft`,up:`altUp`,down:`altDown`},e.keys={pageup:`pageUp`,pagedown:`pageDown`,home:`home`,end:`end`,cancel:`cancel`,delete:`deleteForward`,backspace:`delete`,down:`down`,enter:`submit`,escape:`cancel`,left:`left`,space:`space`,number:`number`,return:`submit`,right:`right`,tab:`next`,up:`up`}})),rd=v(((e,t)=>{t.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}})),id=v(((e,t)=>{let n=y(`readline`),r=nd(),i=rd(),a=/^(?:\x1b)([a-zA-Z0-9])$/,o=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,s={OP:`f1`,OQ:`f2`,OR:`f3`,OS:`f4`,"[11~":`f1`,"[12~":`f2`,"[13~":`f3`,"[14~":`f4`,"[[A":`f1`,"[[B":`f2`,"[[C":`f3`,"[[D":`f4`,"[[E":`f5`,"[15~":`f5`,"[17~":`f6`,"[18~":`f7`,"[19~":`f8`,"[20~":`f9`,"[21~":`f10`,"[23~":`f11`,"[24~":`f12`,"[A":`up`,"[B":`down`,"[C":`right`,"[D":`left`,"[E":`clear`,"[F":`end`,"[H":`home`,OA:`up`,OB:`down`,OC:`right`,OD:`left`,OE:`clear`,OF:`end`,OH:`home`,"[1~":`home`,"[2~":`insert`,"[3~":`delete`,"[4~":`end`,"[5~":`pageup`,"[6~":`pagedown`,"[[5~":`pageup`,"[[6~":`pagedown`,"[7~":`home`,"[8~":`end`,"[a":`up`,"[b":`down`,"[c":`right`,"[d":`left`,"[e":`clear`,"[2$":`insert`,"[3$":`delete`,"[5$":`pageup`,"[6$":`pagedown`,"[7$":`home`,"[8$":`end`,Oa:`up`,Ob:`down`,Oc:`right`,Od:`left`,Oe:`clear`,"[2^":`insert`,"[3^":`delete`,"[5^":`pageup`,"[6^":`pagedown`,"[7^":`home`,"[8^":`end`,"[Z":`tab`};function c(e){return[`[a`,`[b`,`[c`,`[d`,`[e`,`[2$`,`[3$`,`[5$`,`[6$`,`[7$`,`[8$`,`[Z`].includes(e)}function l(e){return[`Oa`,`Ob`,`Oc`,`Od`,`Oe`,`[2^`,`[3^`,`[5^`,`[6^`,`[7^`,`[8^`].includes(e)}let u=(e=``,t={})=>{let n,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B`+String(e)):e=String(e):e!==void 0&&typeof e!=`string`?e=String(e):e||=r.sequence||``,r.sequence=r.sequence||e||r.name,e===`\r`)r.raw=void 0,r.name=`return`;else if(e===`
|
|
85
|
+
`)r.name=`enter`;else if(e===` `)r.name=`tab`;else if(e===`\b`||e===``||e===`\x1B`||e===`\x1B\b`)r.name=`backspace`,r.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)r.name=`escape`,r.meta=e.length===2;else if(e===` `||e===`\x1B `)r.name=`space`,r.meta=e.length===2;else if(e<=``)r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)r.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)r.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)r.name=e.toLowerCase(),r.shift=!0;else if(n=a.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=o.exec(e)){let t=[...e];t[0]===`\x1B`&&t[1]===`\x1B`&&(r.option=!0);let i=[n[1],n[2],n[4],n[6]].filter(Boolean).join(``),a=(n[3]||n[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=s[i],r.shift=c(i)||r.shift,r.ctrl=l(i)||r.ctrl}return r};u.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw Error(`Invalid stream passed`);let a=n.createInterface({terminal:!0,input:r});n.emitKeypressEvents(r,a);let o=new i((e,n)=>t(e,u(e,n),a)),s=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on(`keypress`,o.enqueue),a.resume(),()=>{r.isTTY&&r.setRawMode(s),r.removeListener(`keypress`,o.enqueue),o.destroy(),a.pause(),a.close()}},u.action=(e,t,n)=>{let i={...r,...n};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)},t.exports=u})),ad=v(((e,t)=>{t.exports=e=>{e.timers=e.timers||{};let t=e.options.timers;if(t)for(let r of Object.keys(t)){let i=t[r];typeof i==`number`&&(i={interval:i}),n(e,r,i)}};function n(e,t,n={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},i=n.interval||120;r.frames=n.frames||[],r.loading=!0;let a=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},i);return r.stop=()=>{r.loading=!1,clearInterval(a)},Reflect.defineProperty(r,`interval`,{value:a}),e.once(`close`,()=>r.stop()),r.stop}})),od=v(((e,t)=>{let{define:n,width:r}=V();t.exports=class{constructor(e){let t=e.options;n(this,`_prompt`,e),this.type=e.type,this.name=e.name,this.message=``,this.header=``,this.footer=``,this.error=``,this.hint=``,this.input=``,this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt=``,this.buffer=``,this.width=r(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==`function`?t:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading==`boolean`?this._loading:this.loadingChoices?`choices`:!1}get status(){return this.cancelled?`cancelled`:this.submitted?`submitted`:`pending`}}})),sd=v(((e,t)=>{let n=V(),r=$u(),i={default:r.noop,noop:r.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||n.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||n.complement(this.primary)},primary:r.cyan,success:r.green,danger:r.magenta,strong:r.bold,warning:r.yellow,muted:r.dim,disabled:r.gray,dark:r.dim.gray,underline:r.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};i.merge=(e={})=>{e.styles&&typeof e.styles.enabled==`boolean`&&(r.enabled=e.styles.enabled),e.styles&&typeof e.styles.visible==`boolean`&&(r.visible=e.styles.visible);let t=n.merge({},i,e.styles);delete t.merge;for(let e of Object.keys(r))hasOwnProperty.call(t,e)||Reflect.defineProperty(t,e,{get:()=>r[e]});for(let e of Object.keys(r.styles))hasOwnProperty.call(t,e)||Reflect.defineProperty(t,e,{get:()=>r[e]});return t},t.exports=i})),cd=v(((e,t)=>{let n=process.platform===`win32`,r=$u(),i=V(),a={...r.symbols,upDownDoubleArrow:`⇕`,upDownDoubleArrow2:`⬍`,upDownArrow:`↕`,asterisk:`*`,asterism:`⁂`,bulletWhite:`◦`,electricArrow:`⌁`,ellipsisLarge:`⋯`,ellipsisSmall:`…`,fullBlock:`█`,identicalTo:`≡`,indicator:r.symbols.check,leftAngle:`‹`,mark:`※`,minus:`−`,multiplication:`×`,obelus:`÷`,percent:`%`,pilcrow:`¶`,pilcrow2:`❡`,pencilUpRight:`✐`,pencilDownRight:`✎`,pencilRight:`✏`,plus:`+`,plusMinus:`±`,pointRight:`☞`,rightAngle:`›`,section:`§`,hexagon:{off:`⬡`,on:`⬢`,disabled:`⬢`},ballot:{on:`☑`,off:`☐`,disabled:`☒`},stars:{on:`★`,off:`☆`,disabled:`☆`},folder:{on:`▼`,off:`▶`,disabled:`▶`},prefix:{pending:r.symbols.question,submitted:r.symbols.check,cancelled:r.symbols.cross},separator:{pending:r.symbols.pointerSmall,submitted:r.symbols.middot,cancelled:r.symbols.middot},radio:{off:n?`( )`:`◯`,on:n?`(*)`:`◉`,disabled:n?`(|)`:`Ⓘ`},numbers:`⓪.①.②.③.④.⑤.⑥.⑦.⑧.⑨.⑩.⑪.⑫.⑬.⑭.⑮.⑯.⑰.⑱.⑲.⑳.㉑.㉒.㉓.㉔.㉕.㉖.㉗.㉘.㉙.㉚.㉛.㉜.㉝.㉞.㉟.㊱.㊲.㊳.㊴.㊵.㊶.㊷.㊸.㊹.㊺.㊻.㊼.㊽.㊾.㊿`.split(`.`)};a.merge=e=>{let t=i.merge({},r.symbols,a,e.symbols);return delete t.merge,t},t.exports=a})),ld=v(((e,t)=>{let n=sd(),r=cd(),i=V();t.exports=e=>{e.options=i.merge({},e.options.theme,e.options),e.symbols=r.merge(e.options),e.styles=n.merge(e.options)}})),ud=v(((e,t)=>{let n=process.env.TERM_PROGRAM===`Apple_Terminal`,r=td(),i=V(),a=t.exports=e,o=!1,s=a.code={bell:`\x07`,beep:`\x07`,beginning:`\x1B[G`,down:`\x1B[J`,esc:`\x1B[`,getPosition:`\x1B[6n`,hide:`\x1B[?25l`,line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,restorePosition:`\x1B[`+(n?`8`:`u`),savePosition:`\x1B[`+(n?`7`:`s`),screen:`\x1B[2J`,show:`\x1B[?25h`,up:`\x1B[1J`},c=a.cursor={get hidden(){return o},hide(){return o=!0,s.hide},show(){return o=!1,s.show},forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),up:(e=1)=>e?`[${e}A`:``,down:(e=1)=>e?`[${e}B`:``,right:(e=1)=>e?`[${e}C`:``,left:(e=1)=>e?`[${e}D`:``,to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e=0,t=0){let n=``;return n+=e<0?c.left(-e):e>0?c.right(e):``,n+=t<0?c.up(-t):t>0?c.down(t):``,n},strLen(e){for(var t=0,n=e.length,r=-1,i=0;i<n;i++)r=e.charCodeAt(i),r>=0&&r<=128?t+=1:t+=2;return t},restore(e={}){let{after:t,cursor:n,initial:r,input:o,prompt:s,size:c,value:l}=e;if(r=i.isPrimitive(r)?String(r):``,o=i.isPrimitive(o)?String(o):``,l=i.isPrimitive(l)?String(l):``,c){let e=a.cursor.up(c)+a.cursor.to(this.strLen(s)),t=o.length-n;return t>0&&(e+=a.cursor.left(t)),e}if(l||t){let e=!o&&r?-this.strLen(r):-this.strLen(o)+n;return t&&(e-=this.strLen(t)),o===``&&r&&!s.includes(r)&&(e+=this.strLen(r)),a.cursor.move(e)}}},l=a.erase={screen:s.screen,up:s.up,down:s.down,line:s.line,lineEnd:s.lineEnd,lineStart:s.lineStart,lines(e){let t=``;for(let n=0;n<e;n++)t+=a.erase.line+(n<e-1?a.cursor.up(1):``);return e&&(t+=a.code.beginning),t}};a.clear=(e=``,t=process.stdout.columns)=>{if(!t)return l.line+c.to(0);let n=e=>[...r(e)].length,i=e.split(/\r?\n/),a=0;for(let e of i)a+=1+Math.floor(Math.max(n(e)-1,0)/t);return(l.line+c.prevLine()).repeat(a-1)+l.line+c.to(0)}})),dd=v(((e,t)=>{let n=y(`events`),r=td(),i=id(),a=ad(),o=od(),s=ld(),c=V(),l=ud();var u=class e extends n{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,s(this),a(this),this.state=new o(this),this.initial=[e.initial,e.default].find(e=>e!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=f(this.options.margin),this.setMaxListeners(0),d(this)}async keypress(e,t={}){this.keypressed=!0;let n=i.action(e,i(e,t),this.options.actions);this.state.keypress=n,this.emit(`keypress`,e,n),this.emit(`state`,this.state.clone());let r=this.options[n.action]||this[n.action]||this.dispatch;if(typeof r==`function`)return await r.call(this,e,n);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit(`alert`):this.stdout.write(l.code.beep)}cursorHide(){this.stdout.write(l.cursor.hide());let e=c.onExit(()=>this.cursorShow());this.on(`close`,()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(l.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer=``,!(!t&&!e||this.options.show===!1)&&this.stdout.write(l.cursor.down(e)+l.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:n}=this.sections(),{cursor:r,initial:i=``,input:a=``,value:o=``}=this,s={after:t,cursor:r,initial:i,input:a,prompt:e,size:this.state.size=n.length,value:o},c=l.cursor.restore(s);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:n}=this.state;n=r(n);let i=r(e),a=i.indexOf(n),o=i.slice(0,a),s=i.slice(a).split(`
|
|
86
86
|
`),c=s[0],l=s[s.length-1],u=(n+(t?` `+t:``)).length;return{header:o,prompt:c,after:u<c.length?c.slice(u+1):``,rest:s.slice(1),last:l}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
|
|
87
87
|
`+this.symbols.pointer+` `;typeof e==`string`?t+=e.trim():t+=`Invalid input`,this.state.error=`
|
|
88
88
|
`+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit(`submit`,this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==`function`&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit(`cancel`,await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(l.cursor.down(e.rest.length)),this.write(`
|
|
89
89
|
`.repeat(t))}catch{}this.emit(`close`)}start(){!this.stop&&this.options.show!==!1&&(this.stop=i.listen(this,this.keypress.bind(this)),this.once(`close`,this.stop),this.emit(`start`,this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip==`function`&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:t,result:n}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>n.call(this,this.value),typeof t.initial==`function`&&(this.initial=await t.initial.call(this,this)),typeof t.onRun==`function`&&await t.onRun.call(this,this),typeof t.onSubmit==`function`){let e=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await e(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw Error(`expected prompt to have a custom render method`)}run(){return new Promise(async(e,t)=>{if(this.once(`submit`,e),this.once(`cancel`,t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit(`run`)})}async element(e,t,n){let{options:r,state:i,symbols:a,timers:o}=this;i.timer=o&&o[e];let s=r[e]||i[e]||a[e],c=t&&t[e]!=null?t[e]:await s;if(c===``)return c;let l=await this.resolve(c,i,t,n);return!l&&t&&t[e]?this.resolve(s,i,t,n):l}async prefix(){let e=await this.element(`prefix`)||this.symbols,t=this.timers&&this.timers.prefix,n=this.state;return n.timer=t,c.isObject(e)&&(e=e[n.status]||e.pending),c.hasColor(e)?e:(this.styles[n.status]||this.styles.pending)(e)}async message(){let e=await this.element(`message`);return c.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element(`separator`)||this.symbols,t=this.timers&&this.timers.separator,n=this.state;n.timer=t;let r=e[n.status]||e.pending||n.separator,i=await this.resolve(r,n);return c.isObject(i)&&(i=i[n.status]||i.pending),c.hasColor(i)?i:this.styles.muted(i)}async pointer(e,t){let n=await this.element(`pointer`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let e=this.styles,r=this.index===t,i=r?e.primary:e=>e,a=await this.resolve(n[r?`on`:`off`]||n,this.state),o=c.hasColor(a)?a:i(a);return r?o:` `.repeat(a.length)}}async indicator(e,t){let n=await this.element(`indicator`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let t=this.styles,r=e.enabled===!0,i=r?t.success:t.dark,a=n[r?`on`:`off`]||n;return c.hasColor(a)?a:i(a)}return``}body(){return null}footer(){if(this.state.status===`pending`)return this.element(`footer`)}header(){if(this.state.status===`pending`)return this.element(`header`)}async hint(){if(this.state.status===`pending`&&!this.isValue(this.state.input)){let e=await this.element(`hint`);return c.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?``:e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==``}resolve(e,...t){return c.resolve(this,e,...t)}get base(){return e.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||c.height(this.stdout,25)}get width(){return this.options.columns||c.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,n=[t,e].find(this.isValue.bind(this));return this.isValue(n)?n:this.initial}static get prompt(){return e=>new this(e).run()}};function d(e){let t=t=>e[t]===void 0||typeof e[t]==`function`,n=[`actions`,`choices`,`initial`,`margin`,`roles`,`styles`,`symbols`,`theme`,`timers`,`value`],r=[`body`,`footer`,`error`,`header`,`hint`,`indicator`,`message`,`prefix`,`separator`,`skip`];for(let i of Object.keys(e.options)){if(n.includes(i)||/^on[A-Z]/.test(i))continue;let a=e.options[i];typeof a==`function`&&t(i)?r.includes(i)||(e[i]=a.bind(e)):typeof e[i]!=`function`&&(e[i]=a)}}function f(e){typeof e==`number`&&(e=[e,e,e,e]);let t=[].concat(e||[]),n=e=>e%2==0?`
|
|
90
|
-
`:` `,r=[];for(let e=0;e<4;e++){let i=n(e);t[e]?r.push(i.repeat(t[e])):r.push(``)}return r}t.exports=u})),ld=v(((e,t)=>{let n=z(),r={default(e,t){return t},checkbox(e,t){throw Error(`checkbox role is not implemented yet`)},editable(e,t){throw Error(`editable role is not implemented yet`)},expandable(e,t){throw Error(`expandable role is not implemented yet`)},heading(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||``,t},input(e,t){throw Error(`input role is not implemented yet`)},option(e,t){return r.default(e,t)},radio(e,t){throw Error(`radio role is not implemented yet`)},separator(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};t.exports=(e,t={})=>{let i=n.merge({},r,t.roles);return i[e]||i.default}})),ud=v(((e,t)=>{let n=Qu(),r=cd(),i=ld(),a=z(),{reorder:o,scrollUp:s,scrollDown:c,isObject:l,swap:u}=a;var d=class extends r{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=``}async initialize(){typeof this.options.initial==`function`&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:n,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(e=>e.enabled=!1),typeof r!=`function`&&this.selectable.length===0)throw Error(`At least one choice must be selectable`);l(t)&&(t=Object.keys(t)),Array.isArray(t)?(n!=null&&(this.index=this.findIndex(n)),t.forEach(e=>this.enable(this.find(e))),await this.render()):(n!=null&&(t=n),typeof t==`string`&&(t=this.findIndex(t)),typeof t==`number`&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let n=[],r=0,i=async(e,t)=>{typeof e==`function`&&(e=await e.call(this)),e instanceof Promise&&(e=await e);for(let a=0;a<e.length;a++){let o=e[a]=await this.toChoice(e[a],r++,t);n.push(o),o.choices&&await i(o.choices,o)}return n};return i(e,t).then(e=>(this.state.loadingChoices=!1,e))}async toChoice(e,t,r){if(typeof e==`function`&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e==`string`&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value;if(e=i(e.role,this.options)(this,e),typeof e.disabled==`string`&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint=`(disabled)`),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||``,e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input=``,e.index=t,e.cursor=0,a.define(e,`parent`,r),e.level=r?r.level+1:1,e.indent??=r?r.indent+` `:e.indent||``,e.path=r?r.path+`.`+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,n(e.message).length));let s={...e};return e.reset=(t=s.input,n=s.value)=>{for(let t of Object.keys(s))e[t]=s[t];e.input=t,e.value=n},o==null&&typeof e.initial==`function`&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit(`choice`,e,t,this),typeof e.onChoice==`function`&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,n){let r=await this.toChoice(e,t,n);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,n){let r={name:`New choice name?`,editable:!0,newChoice:!0,...e},i=await this.addChoice(r,t,n);return i.updateChoice=()=>{delete i.newChoice,i.name=i.message=i.input,i.input=``,i.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?` `.repeat(e.level-1):``:e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!=`boolean`&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(e=>e.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(e=>!!e.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!=`boolean`&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(e=>this.toggle(e,t));let n=e.parent;for(;n;){let e=n.choices.filter(e=>this.isDisabled(e));n.enabled=e.every(e=>e.enabled===!0),n=n.parent}return f(this,this.choices),this.emit(`toggle`,e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=e=>{let t=Number(e);if(t>this.choices.length-1)return this.alert();let n=this.focused,r=this.choices.find(e=>t===e.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(r)===-1){let e=o(this.choices),t=e.indexOf(r);if(n.index>t){let n=e.slice(t,t+this.limit),r=e.filter(e=>!n.includes(e));this.choices=n.concat(r)}else{let n=t-this.limit+1;this.choices=e.slice(n).concat(e.slice(0,n))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(e=>{let n=this.choices.length,r=this.num,i=(n=!1,i)=>{clearTimeout(this.numberTimeout),n&&(i=t(r)),this.num=``,e(i)};if(r===`0`||r.length===1&&Number(r+`0`)>n)return i(!0);if(Number(r)>n)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=o(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=o(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===0?this.alert():e>t&&n===0?this.scrollUp():(this.index=(n-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===t-1?this.alert():e>t&&n===t-1?this.scrollDown():(this.index=(n+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=s(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=c(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){u(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(e=>this.isDisabled(e))}isDisabled(e=this.focused){return e&&[`disabled`,`collapsed`,`hidden`,`completing`,`readonly`].some(t=>e[t]===!0)?!0:e&&e.role===`heading`}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(e=>this.isEnabled(e));if(e.choices){let t=e.choices.filter(e=>!this.isDisabled(e));return e.enabled&&t.every(e=>this.isEnabled(e))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t=`value`){return[].concat(e||[]).reduce((e,n)=>(e[n]=this.find(n,t),e),{})}filter(e,t){let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=(this.options.multiple?this.state._choices:this.choices).filter(n);return t?r.map(e=>e[t]):r}find(e,t){if(l(e))return t?e[t]:e;let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=this.choices.find(n);if(r)return t?r[t]:r}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(e=>e.newChoice))return this.alert();let{reorder:t,sort:n}=this.options,r=this.multiple===!0,i=this.selected;return i===void 0?this.alert():(Array.isArray(i)&&t!==!1&&n!==!0&&(i=a.reorder(i)),this.value=r?i.map(e=>e.name):i.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(e=>e.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let e=this.initial;if(typeof e==`string`||typeof e==`number`){let t=this.find(e);t&&(this.initial=t.index,this.focus(t,!0))}}}get choices(){return f(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:n}=this,r=e.limit||this._limit||t.limit||n.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!=`string`&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function f(e,t){if(t instanceof Promise)return t;if(typeof t==`function`){if(a.isAsyncFn(t))return t;t=t.call(e,e)}for(let n of t)Array.isArray(n.choices)&&(n.enabled=n.choices.filter(t=>!e.isDisabled(t)).every(e=>e.enabled===!0)),e.isDisabled(n)===!0&&delete n.enabled;return t}t.exports=d})),dd=v(((e,t)=>{let n=ud(),r=z();t.exports=class extends n{constructor(e){super(e),this.emptyError=this.options.emptyError||`No items were selected`}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):``}indicator(e,t){return this.multiple?super.indicator(e,t):``}choiceMessage(e,t){let n=this.resolve(e.message,this.state,e,t);return e.role===`heading`&&!r.hasColor(n)&&(n=this.styles.strong(n)),this.resolve(n,this.state,e,t)}choiceSeparator(){return`:`}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,i=await this.pointer(e,t),a=await this.indicator(e,t)+(e.pad||``),o=await this.resolve(e.hint,this.state,e,t);o&&!r.hasColor(o)&&(o=this.styles.muted(o));let s=this.indent(e),c=await this.choiceMessage(e,t),l=()=>[this.margin[3],s+i+a,c,this.margin[1],o].filter(Boolean).join(` `);return e.role===`heading`?l():e.disabled?(r.hasColor(c)||(c=this.styles.disabled(c)),l()):(n&&(c=this.styles.em(c)),l())}async renderChoices(){if(this.state.loading===`choices`)return this.styles.warning(`Loading choices`);if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);t.length||t.push(this.styles.danger(`No matching choices`));let n=this.margin[0]+t.join(`
|
|
90
|
+
`:` `,r=[];for(let e=0;e<4;e++){let i=n(e);t[e]?r.push(i.repeat(t[e])):r.push(``)}return r}t.exports=u})),fd=v(((e,t)=>{let n=V(),r={default(e,t){return t},checkbox(e,t){throw Error(`checkbox role is not implemented yet`)},editable(e,t){throw Error(`editable role is not implemented yet`)},expandable(e,t){throw Error(`expandable role is not implemented yet`)},heading(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||``,t},input(e,t){throw Error(`input role is not implemented yet`)},option(e,t){return r.default(e,t)},radio(e,t){throw Error(`radio role is not implemented yet`)},separator(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};t.exports=(e,t={})=>{let i=n.merge({},r,t.roles);return i[e]||i.default}})),pd=v(((e,t)=>{let n=td(),r=dd(),i=fd(),a=V(),{reorder:o,scrollUp:s,scrollDown:c,isObject:l,swap:u}=a;var d=class extends r{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=``}async initialize(){typeof this.options.initial==`function`&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:n,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(e=>e.enabled=!1),typeof r!=`function`&&this.selectable.length===0)throw Error(`At least one choice must be selectable`);l(t)&&(t=Object.keys(t)),Array.isArray(t)?(n!=null&&(this.index=this.findIndex(n)),t.forEach(e=>this.enable(this.find(e))),await this.render()):(n!=null&&(t=n),typeof t==`string`&&(t=this.findIndex(t)),typeof t==`number`&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let n=[],r=0,i=async(e,t)=>{typeof e==`function`&&(e=await e.call(this)),e instanceof Promise&&(e=await e);for(let a=0;a<e.length;a++){let o=e[a]=await this.toChoice(e[a],r++,t);n.push(o),o.choices&&await i(o.choices,o)}return n};return i(e,t).then(e=>(this.state.loadingChoices=!1,e))}async toChoice(e,t,r){if(typeof e==`function`&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e==`string`&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value;if(e=i(e.role,this.options)(this,e),typeof e.disabled==`string`&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint=`(disabled)`),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||``,e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input=``,e.index=t,e.cursor=0,a.define(e,`parent`,r),e.level=r?r.level+1:1,e.indent??=r?r.indent+` `:e.indent||``,e.path=r?r.path+`.`+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,n(e.message).length));let s={...e};return e.reset=(t=s.input,n=s.value)=>{for(let t of Object.keys(s))e[t]=s[t];e.input=t,e.value=n},o==null&&typeof e.initial==`function`&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit(`choice`,e,t,this),typeof e.onChoice==`function`&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,n){let r=await this.toChoice(e,t,n);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,n){let r={name:`New choice name?`,editable:!0,newChoice:!0,...e},i=await this.addChoice(r,t,n);return i.updateChoice=()=>{delete i.newChoice,i.name=i.message=i.input,i.input=``,i.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?` `.repeat(e.level-1):``:e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!=`boolean`&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(e=>e.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(e=>!!e.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!=`boolean`&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(e=>this.toggle(e,t));let n=e.parent;for(;n;){let e=n.choices.filter(e=>this.isDisabled(e));n.enabled=e.every(e=>e.enabled===!0),n=n.parent}return f(this,this.choices),this.emit(`toggle`,e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=e=>{let t=Number(e);if(t>this.choices.length-1)return this.alert();let n=this.focused,r=this.choices.find(e=>t===e.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(r)===-1){let e=o(this.choices),t=e.indexOf(r);if(n.index>t){let n=e.slice(t,t+this.limit),r=e.filter(e=>!n.includes(e));this.choices=n.concat(r)}else{let n=t-this.limit+1;this.choices=e.slice(n).concat(e.slice(0,n))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(e=>{let n=this.choices.length,r=this.num,i=(n=!1,i)=>{clearTimeout(this.numberTimeout),n&&(i=t(r)),this.num=``,e(i)};if(r===`0`||r.length===1&&Number(r+`0`)>n)return i(!0);if(Number(r)>n)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=o(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=o(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===0?this.alert():e>t&&n===0?this.scrollUp():(this.index=(n-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===t-1?this.alert():e>t&&n===t-1?this.scrollDown():(this.index=(n+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=s(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=c(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){u(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(e=>this.isDisabled(e))}isDisabled(e=this.focused){return e&&[`disabled`,`collapsed`,`hidden`,`completing`,`readonly`].some(t=>e[t]===!0)?!0:e&&e.role===`heading`}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(e=>this.isEnabled(e));if(e.choices){let t=e.choices.filter(e=>!this.isDisabled(e));return e.enabled&&t.every(e=>this.isEnabled(e))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t=`value`){return[].concat(e||[]).reduce((e,n)=>(e[n]=this.find(n,t),e),{})}filter(e,t){let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=(this.options.multiple?this.state._choices:this.choices).filter(n);return t?r.map(e=>e[t]):r}find(e,t){if(l(e))return t?e[t]:e;let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=this.choices.find(n);if(r)return t?r[t]:r}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(e=>e.newChoice))return this.alert();let{reorder:t,sort:n}=this.options,r=this.multiple===!0,i=this.selected;return i===void 0?this.alert():(Array.isArray(i)&&t!==!1&&n!==!0&&(i=a.reorder(i)),this.value=r?i.map(e=>e.name):i.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(e=>e.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let e=this.initial;if(typeof e==`string`||typeof e==`number`){let t=this.find(e);t&&(this.initial=t.index,this.focus(t,!0))}}}get choices(){return f(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:n}=this,r=e.limit||this._limit||t.limit||n.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!=`string`&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function f(e,t){if(t instanceof Promise)return t;if(typeof t==`function`){if(a.isAsyncFn(t))return t;t=t.call(e,e)}for(let n of t)Array.isArray(n.choices)&&(n.enabled=n.choices.filter(t=>!e.isDisabled(t)).every(e=>e.enabled===!0)),e.isDisabled(n)===!0&&delete n.enabled;return t}t.exports=d})),md=v(((e,t)=>{let n=pd(),r=V();t.exports=class extends n{constructor(e){super(e),this.emptyError=this.options.emptyError||`No items were selected`}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):``}indicator(e,t){return this.multiple?super.indicator(e,t):``}choiceMessage(e,t){let n=this.resolve(e.message,this.state,e,t);return e.role===`heading`&&!r.hasColor(n)&&(n=this.styles.strong(n)),this.resolve(n,this.state,e,t)}choiceSeparator(){return`:`}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,i=await this.pointer(e,t),a=await this.indicator(e,t)+(e.pad||``),o=await this.resolve(e.hint,this.state,e,t);o&&!r.hasColor(o)&&(o=this.styles.muted(o));let s=this.indent(e),c=await this.choiceMessage(e,t),l=()=>[this.margin[3],s+i+a,c,this.margin[1],o].filter(Boolean).join(` `);return e.role===`heading`?l():e.disabled?(r.hasColor(c)||(c=this.styles.disabled(c)),l()):(n&&(c=this.styles.em(c)),l())}async renderChoices(){if(this.state.loading===`choices`)return this.styles.warning(`Loading choices`);if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);t.length||t.push(this.styles.danger(`No matching choices`));let n=this.margin[0]+t.join(`
|
|
91
91
|
`),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,n].filter(Boolean).join(`
|
|
92
92
|
`)}format(){return!this.state.submitted||this.state.cancelled?``:Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(`, `):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,n=``,r=await this.header(),i=await this.prefix(),a=await this.separator(),o=await this.message();this.options.promptLine!==!1&&(n=[i,o,a,``].join(` `),this.state.prompt=n);let s=await this.format(),c=await this.error()||await this.hint(),l=await this.renderChoices(),u=await this.footer();s&&(n+=s),c&&!n.includes(c)&&(n+=` `+c),e&&!s&&!l.trim()&&this.multiple&&this.emptyError!=null&&(n+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,n,l,u].filter(Boolean).join(`
|
|
93
|
-
`)),this.write(this.margin[2]),this.restore()}}})),
|
|
94
|
-
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),
|
|
93
|
+
`)),this.write(this.margin[2]),this.restore()}}})),hd=v(((e,t)=>{let n=md(),r=(e,t)=>{let n=e?new RegExp(e,`ig`):/$^/;return r=>e?r.replace(n,e=>t(e)):r};t.exports=class extends n{constructor(e){super(e),this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:n}=this.state;return this.input=n.slice(0,t)+e+n.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest==`function`)return this.options.suggest.call(this,e,t);let n=e.toLowerCase();return t.filter(e=>e.message.toLowerCase().includes(n))}pointer(){return``}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(`, `);if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!==`pending`)return super.render();let e=this.options.highlight||this.styles.complement,t=r(this.input,(t,n)=>t&&(e.stack?e(t):e.call(this,t))),n=this.choices;this.choices=n.map(e=>({...e,message:t(e.message)})),await super.render(),this.choices=n}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}}})),gd=v(((e,t)=>{let n=V();t.exports=(e,t={})=>{e.cursorHide();let{input:r=``,initial:i=``,pos:a,showCursor:o=!0,color:s}=t,c=s||e.styles.placeholder,l=n.inverse(e.styles.primary),u=t=>l(e.styles.black(t)),d=r,f=u(` `);if(e.blink&&e.blink.off===!0&&(u=e=>e,f=``),o&&a===0&&i===``&&r===``)return u(` `);if(o&&a===0&&(r===i||r===``))return u(i[0])+c(i.slice(1));i=n.isPrimitive(i)?`${i}`:``,r=n.isPrimitive(r)?`${r}`:``;let p=i&&i.startsWith(r)&&i!==r,m=p?u(i[r.length]):f;if(a!==r.length&&o===!0&&(d=r.slice(0,a)+u(r[a])+r.slice(a+1),m=``),o===!1&&(m=``),p){let t=e.styles.unstyle(d+m);return d+m+c(i.slice(t.length))}return d+m}})),_d=v(((e,t)=>{let n=td(),r=md(),i=gd();t.exports=class extends r{constructor(e){super({...e,multiple:!0}),this.type=`form`,this.initial=this.options.initial,this.align=[this.options.align,`right`].find(e=>e!=null),this.emptyError=``,this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(e=>e.reset&&e.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:n,input:r}=t;return t.value=t.input=r.slice(0,n)+e+r.slice(n),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:n}=e;return e.value=e.input=n.slice(0,t-1)+n.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:n}=e;return n[t]===void 0?this.alert():(e.value=e.input=`${n}`.slice(0,t)+`${n}`.slice(t+1),this.render())}right(){let e=this.focused;return!e||e.cursor>=e.input.length?this.alert():(e.cursor++,this.render())}left(){let e=this.focused;return!e||e.cursor<=0?this.alert():(e.cursor--,this.render())}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:n}=e;return t&&t.startsWith(n)&&n!==t?(e.value=e.input=t,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input=``,e.cursor=0,this.render()):this.alert()}separator(){return``}format(e){return this.state.submitted?``:super.format(e)}pointer(){return``}indicator(e){return e.input?`⦿`:`⊙`}async choiceSeparator(e,t){let n=await this.resolve(e.separator,this.state,e,t)||`:`;return n?` `+this.styles.disabled(n):``}async renderChoice(e,t){await this.onChoice(e,t);let{state:r,styles:a}=this,{cursor:o,initial:s=``,name:c,input:l=``}=e,{muted:u,submitted:d,primary:f,danger:p}=a,m=this.index===t,h=e.validate||(()=>!0),ee=await this.choiceSeparator(e,t),g=e.message;this.align===`right`&&(g=g.padStart(this.longest+1,` `)),this.align===`left`&&(g=g.padEnd(this.longest+1,` `));let _=this.values[c]=l||s,v=l?`success`:`dark`;await h.call(e,_,this.state)!==!0&&(v=`danger`);let te=a[v],ne=te(await this.indicator(e,t))+(e.pad||``),y=this.indent(e),re=()=>[y,ne,g+ee,l].filter(Boolean).join(` `);if(r.submitted)return g=n(g),l=d(l),re();if(e.format)l=await e.format.call(this,l,e,t);else{let e=this.styles.muted;l=i(this,{input:l,initial:s,pos:o,showCursor:m,color:e})}return this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[c]=await e.result.call(this,_,e,t)),m&&(g=f(g)),e.error?l+=(l?` `:``)+p(e.error.trim()):e.hint&&(l+=(l?` `:``)+u(e.hint.trim())),re()}async submit(){return this.value=this.values,super.base.submit.call(this)}}})),vd=v(((e,t)=>{let n=_d(),r=()=>{throw Error(`expected prompt to have a custom authenticate method`)},i=(e=r)=>{class t extends n{constructor(e){super(e)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(e){return i(e)}}return t};t.exports=i()})),yd=v(((e,t)=>{let n=vd();function r(e,t){return e.username===this.options.username&&e.password===this.options.password}let i=(e=r)=>{let t=[{name:`username`,message:`username`},{name:`password`,message:`password`,format(e){return this.options.showPassword?e:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length))}}];class a extends n.create(e){constructor(e){super({...e,choices:t})}static create(e){return i(e)}}return a};t.exports=i()})),bd=v(((e,t)=>{let n=dd(),{isPrimitive:r,hasColor:i}=V();t.exports=class extends n{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:n}=this;return n.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return r(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status===`pending`){let e=await this.element(`hint`);return i(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),this.styles.muted(this.default),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=this.value=this.cast(e),s=await this.format(o),c=await this.error()||await this.hint(),l=await this.footer();c&&!i.includes(c)&&(s+=` `+c),i+=` `+s,this.clear(t),this.write([a,i,l].filter(Boolean).join(`
|
|
94
|
+
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),xd=v(((e,t)=>{let n=bd();t.exports=class extends n{constructor(e){super(e),this.default=this.options.default||(this.initial?`(Y/n)`:`(y/N)`)}}})),Sd=v(((e,t)=>{let n=md(),r=_d().prototype;t.exports=class extends n{constructor(e){super({...e,multiple:!0}),this.align=[this.options.align,`left`].find(e=>e!=null),this.emptyError=``,this.values={}}dispatch(e,t){let n=this.focused,i=n.parent||{};return!n.editable&&!i.editable&&(e===`a`||e===`i`)?super[e]():r.dispatch.call(this,e,t)}append(e,t){return r.append.call(this,e,t)}delete(e,t){return r.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?r.next.call(this):super.next()}prev(){return this.focused.editable?r.prev.call(this):super.prev()}async indicator(e,t){let n=e.indicator||``,r=e.editable?n:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||``}indent(e){return e.role===`heading`?``:e.editable?` `:` `}async renderChoice(e,t){return e.indent=``,e.editable?r.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return``}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!=`function`||t.role===`heading`)continue;let n=t.parent?this.value[t.parent.name]:this.value;if(t.editable?n=t.value===t.name?t.initial||``:t.value:this.isDisabled(t)||(n=t.enabled===!0),e=await t.validate(n,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e==`string`?e:`Invalid Input`),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role===`heading`){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||``:e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}}})),Cd=v(((e,t)=>{let n=dd(),r=id(),i=gd(),{isPrimitive:a}=V();t.exports=class extends n{constructor(e){super(e),this.initial=a(this.initial)?String(this.initial):``,this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout===void 0?null:this.options.keypressTimeout}async keypress(e,t=e?r(e,{}):{}){let n=Date.now(),i=n-this.lastKeypress;this.lastKeypress=n;let a=t.name===`return`||t.name===`enter`,o=this.state.prevKeypress,s;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&a){if(i<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||``,this.state.multilineBuffer+=e,s=!0,o=null}return(s||this.options.multiline&&a)&&(!o||o.name!==`return`)?this.append(`
|
|
95
95
|
`,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value=``,this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:n}=this.state;this.input=`${n}`.slice(0,t)+e+`${n}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),n=this.input.slice(e),r=t.split(` `);this.state.clipboard.push(r.pop()),this.input=r.join(` `),this.cursor=this.input.length,this.input+=n,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial==null?``:String(this.initial);if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):i(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),n=await this.separator(),r=[t,await this.message(),n].filter(Boolean).join(` `);this.state.prompt=r;let i=await this.header(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer();o&&!a.includes(o)&&(a+=` `+o),r+=` `+a,this.clear(e),this.write([i,r,s].filter(Boolean).join(`
|
|
96
|
-
`)),this.restore()}}})),
|
|
96
|
+
`)),this.restore()}}})),wd=v(((e,t)=>{let n=e=>e.filter((t,n)=>e.lastIndexOf(t)===n),r=e=>n(e).filter(Boolean);t.exports=(e,t={},n=``)=>{let{past:i=[],present:a=``}=t,o,s;switch(e){case`prev`:case`undo`:return o=i.slice(0,i.length-1),s=i[i.length-1]||``,{past:r([n,...o]),present:s};case`next`:case`redo`:return o=i.slice(1),s=i[0]||``,{past:r([...o,n]),present:s};case`save`:return{past:r([...i,n]),present:``};case`remove`:return s=r(i.filter(e=>e!==n)),a=``,s.length&&(a=s.pop()),{past:s,present:a};default:throw Error(`Invalid action: "${e}"`)}}})),Td=v(((e,t)=>{let n=Cd(),r=wd();t.exports=class extends n{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let e=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get(`values`)||{past:[],present:e},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return!this.store||(this.data=r(e,this.data,this.input),!this.data.present)?this.alert():(this.input=this.data.present,this.cursor=this.input.length,this.render())}altUp(){return this.completion(`prev`)}altDown(){return this.completion(`next`)}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=r(`save`,this.data,this.input),this.store.set(`values`,this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}}})),Ed=v(((e,t)=>{let n=Cd();t.exports=class extends n{format(){return``}}})),Dd=v(((e,t)=>{let n=Cd();t.exports=class extends n{constructor(e={}){super(e),this.sep=this.options.separator||/, */,this.initial=e.initial||``}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:e=>e;return this.list.map(e).join(`, `)}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t===!0?(this.value=this.list,super.submit()):(this.state.error=t,super.submit())}get list(){return this.split()}}})),Od=v(((e,t)=>{let n=md();t.exports=class extends n{constructor(e){super({...e,multiple:!0})}}})),kd=v(((e,t)=>{let n=Cd();t.exports=class extends n{constructor(e={}){super({style:`number`,...e}),this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay==null?1e3:e.delay,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial==null?``:e.initial,this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e===`.`&&this.input.includes(`.`)?this.alert(`invalid number`):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial||!this.isValue(this.initial)?this.alert():(this.input=this.initial,this.cursor=String(this.initial).length,this.render())}up(e){let t=e||this.minor,n=this.toNumber(this.input);return n>this.max+t?this.alert():(this.input=`${n+t}`,this.render())}down(e){let t=e||this.minor,n=this.toNumber(this.input);return n<this.min-t?this.alert():(this.input=`${n-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format==`function`?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=``){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(e=>this.isValue(e));return this.value=this.toNumber(e||0),super.submit()}}})),Ad=v(((e,t)=>{t.exports=kd()})),jd=v(((e,t)=>{let n=Cd();t.exports=class extends n{constructor(e){super(e),this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):``}}})),Md=v(((e,t)=>{let n=td(),r=pd(),i=V();t.exports=class extends r{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||`left`),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
|
|
97
97
|
`;let t=e.startNumber||1;typeof this.scale==`number`&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((e,n)=>({name:n+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let e=0;e<this.scale.length;e++)t.scale.push({index:e})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,n){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return``}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.index)).join(`, `):``}pointer(){return``}renderScaleKey(){return this.scaleKey===!1||this.state.submitted?``:[``,...this.scale.map(e=>` ${e.name} - ${e.message}`)].map(e=>this.styles.muted(e)).join(`
|
|
98
98
|
`)}renderScaleHeading(e){let t=this.scale.map(e=>e.name);typeof this.options.renderScaleHeading==`function`&&(t=this.options.renderScaleHeading.call(this,e));let n=this.scaleLength-t.join(``).length,r=Math.round(n/(t.length-1)),i=t.map(e=>this.styles.strong(e)).join(` `.repeat(r)),a=` `.repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+i}scaleIndicator(e,t,n){if(typeof this.options.scaleIndicator==`function`)return this.options.scaleIndicator.call(this,e,t,n);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let n=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term===`Hyper`?``:` `;return n.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let r=this.index===t,a=await this.pointer(e,t),o=await e.hint;o&&!i.hasColor(o)&&(o=this.styles.muted(o));let s=e=>this.margin[3]+e.replace(/\s+$/,``).padEnd(this.widths[0],` `),c=this.newline,l=this.indent(e),u=await this.resolve(e.message,this.state,e,t),d=await this.renderScale(e,t),f=this.margin[1]+this.margin[3];this.scaleLength=n(d).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-f.length);let p=i.wordWrap(u,{width:this.widths[0],newline:c}).split(`
|
|
99
99
|
`).map(e=>s(e)+this.margin[1]);return r&&(d=this.styles.info(d),p=p.map(e=>this.styles.info(e))),p[0]+=d,this.linebreak&&p.push(``),[l+a,p.join(`
|
|
100
100
|
`)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return``;this.tableize();let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e),n=await this.renderScaleHeading();return this.margin[0]+[n,...t.map(e=>e.join(` `))].join(`
|
|
101
101
|
`)}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=await this.message(),a=``;this.options.promptLine!==!1&&(a=[n,i,r,``].join(` `),this.state.prompt=a);let o=await this.header(),s=await this.format(),c=await this.renderScaleKey(),l=await this.error()||await this.hint(),u=await this.renderChoices(),d=await this.footer(),f=this.emptyError;s&&(a+=s),l&&!a.includes(l)&&(a+=` `+l),e&&!s&&!u.trim()&&this.multiple&&f!=null&&(a+=this.styles.danger(f)),this.clear(t),this.write([o,a,c,u,d].filter(Boolean).join(`
|
|
102
|
-
`)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}})),
|
|
103
|
-
`){m({type:`newline`,value:e}),u++;continue}if(e===`\\`){e+=f(),m({type:`text`,value:e});continue}if((e===`$`||e===`#`||e===`{`)&&p()===`{`){let o=f();e+=o;let s={type:`template`,open:e,inner:``,close:``,value:e},u;for(;u=f();){if(u===`}`){p()===`}`&&(u+=f()),s.value+=u,s.close=u;break}u===`:`?(s.initial=``,s.key=s.inner):s.initial!==void 0&&(s.initial+=u),s.value+=u,s.inner+=u}s.template=s.open+(s.initial||s.inner)+s.close,s.key=s.key||s.inner,hasOwnProperty.call(t,s.key)&&(s.initial=t[s.key]),s=n(s),m(s),l.push(s.key),r.add(s.key);let d=c.find(e=>e.name===s.key);s.field=a.find(e=>e.name===s.key),d||(d=new i(s),c.push(d)),d.lines.push(s.line-1);continue}let o=s[s.length-1];o.type===`text`&&o.line===u?o.value+=e:m({type:`text`,value:e})}return m({type:`eos`,value:``}),{input:o,tabstops:s,unique:r,keys:l,items:c}};t.exports=async e=>{let t=e.options,r=new Set(t.required===!0?[]:t.required||[]),{tabstops:i,items:s,keys:c}=await a(t,{...t.values,...t.initial}),l=o(`result`,e,t),u=o(`format`,e,t),d=o(`validate`,e,t,!0),f=e.isValue.bind(e);return async(a={},o=!1)=>{let p=0;a.required=r,a.items=s,a.keys=c,a.output=``;let m=async(e,t,n,r)=>{let i=await d(e,t,n,r);return i===!1?`Invalid field `+n.name:i};for(let r of i){let i=r.value,c=r.key;if(r.type!==`template`){i&&(a.output+=i);continue}if(r.type===`template`){let d=s.find(e=>e.name===c);t.required===!0&&a.required.add(d.name);let h=[d.input,a.values[d.value],d.value,i].find(f),
|
|
104
|
-
`).map(e=>` `+e),
|
|
105
|
-
`),a.output}};function o(e,t,n,r){return(n,i,a,o)=>typeof a.field[e]==`function`?a.field[e].call(t,n,i,a,o):[r,n].find(e=>t.isValue(e))}})),
|
|
102
|
+
`)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}})),Nd=v(((e,t)=>{let n=td(),r=(e=``)=>typeof e==`string`?e.replace(/^['"]|['"]$/g,``):``;var i=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=r(e.initial||this.field.initial||``),this.message=e.message||this.name,this.cursor=0,this.input=``,this.lines=[]}};let a=async(e={},t={},n=e=>e)=>{let r=new Set,a=e.fields||[],o=e.template,s=[],c=[],l=[],u=1;typeof o==`function`&&(o=await o());let d=-1,f=()=>o[++d],p=()=>o[d+1],m=e=>{e.line=u,s.push(e)};for(m({type:`bos`,value:``});d<o.length-1;){let e=f();if(/^[^\S\n ]$/.test(e)){m({type:`text`,value:e});continue}if(e===`
|
|
103
|
+
`){m({type:`newline`,value:e}),u++;continue}if(e===`\\`){e+=f(),m({type:`text`,value:e});continue}if((e===`$`||e===`#`||e===`{`)&&p()===`{`){let o=f();e+=o;let s={type:`template`,open:e,inner:``,close:``,value:e},u;for(;u=f();){if(u===`}`){p()===`}`&&(u+=f()),s.value+=u,s.close=u;break}u===`:`?(s.initial=``,s.key=s.inner):s.initial!==void 0&&(s.initial+=u),s.value+=u,s.inner+=u}s.template=s.open+(s.initial||s.inner)+s.close,s.key=s.key||s.inner,hasOwnProperty.call(t,s.key)&&(s.initial=t[s.key]),s=n(s),m(s),l.push(s.key),r.add(s.key);let d=c.find(e=>e.name===s.key);s.field=a.find(e=>e.name===s.key),d||(d=new i(s),c.push(d)),d.lines.push(s.line-1);continue}let o=s[s.length-1];o.type===`text`&&o.line===u?o.value+=e:m({type:`text`,value:e})}return m({type:`eos`,value:``}),{input:o,tabstops:s,unique:r,keys:l,items:c}};t.exports=async e=>{let t=e.options,r=new Set(t.required===!0?[]:t.required||[]),{tabstops:i,items:s,keys:c}=await a(t,{...t.values,...t.initial}),l=o(`result`,e,t),u=o(`format`,e,t),d=o(`validate`,e,t,!0),f=e.isValue.bind(e);return async(a={},o=!1)=>{let p=0;a.required=r,a.items=s,a.keys=c,a.output=``;let m=async(e,t,n,r)=>{let i=await d(e,t,n,r);return i===!1?`Invalid field `+n.name:i};for(let r of i){let i=r.value,c=r.key;if(r.type!==`template`){i&&(a.output+=i);continue}if(r.type===`template`){let d=s.find(e=>e.name===c);t.required===!0&&a.required.add(d.name);let h=[d.input,a.values[d.value],d.value,i].find(f),ee=(d.field||{}).message||r.inner;if(o){let e=await m(a.values[c],a,d,p);if(e&&typeof e==`string`||e===!1){a.invalid.set(c,e);continue}a.invalid.delete(c);let t=await l(a.values[c],a,d,p);a.output+=n(t);continue}d.placeholder=!1;let g=i;i=await u(i,a,d,p),h===i?(a.values[c]=void 0,h=`<${ee}>`,i=e.styles.primary(h),d.placeholder=!0,a.required.has(c)&&a.missing.add(ee)):(a.values[c]=h,i=e.styles.typing(h),a.missing.delete(ee)),a.missing.has(ee)&&a.validating&&(i=e.styles.warning(h)),a.invalid.has(c)&&a.validating&&(i=e.styles.danger(h)),p===a.index&&(i=g===i?e.styles.heading(n(i)):e.styles.underline(i)),p++}i&&(a.output+=i)}let h=a.output.split(`
|
|
104
|
+
`).map(e=>` `+e),ee=s.length,g=0;for(let t of s)a.invalid.has(t.name)&&t.lines.forEach(e=>{h[e][0]===` `&&(h[e]=a.styles.danger(a.symbols.bullet)+h[e].slice(1))}),e.isValue(a.values[t.name])&&g++;return a.completed=(g/ee*100).toFixed(0),a.output=h.join(`
|
|
105
|
+
`),a.output}};function o(e,t,n,r){return(n,i,a,o)=>typeof a.field[e]==`function`?a.field[e].call(t,n,i,a,o):[r,n].find(e=>t.isValue(e))}})),Pd=v(((e,t)=>{let n=td(),r=Nd(),i=dd();t.exports=class extends i{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await r(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let n=this.getItem();this.input=n.input=`${n.input.slice(0,this.cursor)}${e}${n.input.slice(this.cursor)}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor);this.input=e.input=`${e.input.slice(0,this.cursor-1)}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:n,size:r}=this.state,i=[this.options.newline,`
|
|
106
106
|
`].find(e=>e!=null),a=await this.prefix(),o=await this.separator(),s=[a,await this.message(),o].filter(Boolean).join(` `);this.state.prompt=s;let c=await this.header(),l=await this.error()||``,u=await this.hint()||``,d=n?``:await this.interpolate(this.state),f=this.state.key=t[e]||``,p=await this.format(f),m=await this.footer();p&&(s+=` `+p),u&&!p&&this.state.completed===0&&(s+=` `+u),this.clear(r);let h=[c,s,d,m,l.trim()];this.write(h.filter(Boolean).join(i)),this.restore()}getItem(e){let{items:t,keys:n,index:r}=this.state,i=t.find(e=>e.name===n[r]);return i&&i.input!=null&&(this.input=i.input,this.cursor=i.cursor),i}async submit(){typeof this.interpolate!=`function`&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:r,values:i}=this.state;if(e.size){let t=``;for(let[n,r]of e)t+=`Invalid ${n}: ${r}\n`;return this.state.error=t,super.submit()}return t.size?(this.state.error=`Required: `+[...t.keys()].join(`, `),super.submit()):(this.value={values:i,result:n(r).split(`
|
|
107
107
|
`).map(e=>e.slice(1)).join(`
|
|
108
|
-
`)},super.submit())}}})),
|
|
108
|
+
`)},super.submit())}}})),Fd=v(((e,t)=>{let n=md();t.exports=class extends n{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,`(Use <shift>+<up/down> to sort)`].find(this.isValue.bind(this))}indicator(){return``}async renderChoice(e,t){let n=await super.renderChoice(e,t),r=this.symbols.identicalTo+` `,i=this.index===t&&this.sorting?this.styles.muted(r):` `;return this.options.drag===!1&&(i=``),this.options.numbered===!0?i+`${t+1} - `+n:i+n}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}}})),Id=v(((e,t)=>{let n=pd();var r=class extends n{constructor(e={}){if(super(e),this.emptyError=e.emptyError||`No items were selected`,this.term=process.env.TERM_PROGRAM,!this.options.header){let e=[``,`4 - Strongly Agree`,`3 - Agree`,`2 - Neutral`,`1 - Disagree`,`0 - Strongly Disagree`,``];e=e.map(e=>this.styles.muted(e)),this.state.header=e.join(`
|
|
109
109
|
`)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let e of t)e.scale=i(5,this.options),e.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],n=t.selected;return e.scale.forEach(e=>e.selected=!1),t.selected=!n,this.render()}indicator(){return``}pointer(){return``}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return` `}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,r=this.term===`Hyper`,i=r?9:8,a=r?``:` `,o=this.symbols.line.repeat(i),s=` `.repeat(i+(r?0:1)),c=e=>(e?this.styles.success(`◉`):`◯`)+a,l=t+1+`.`,u=n?this.styles.heading:this.styles.noop,d=await this.resolve(e.message,this.state,e,t),f=this.indent(e),p=f+e.scale.map((t,n)=>c(n===e.scaleIdx)).join(o),m=t=>t===e.scaleIdx?u(t):t,h=f+e.scale.map((e,t)=>m(t)).join(s);return n&&(p=this.styles.cyan(p),h=this.styles.cyan(h)),[[l,d].filter(Boolean).join(` `),p,h,` `].filter(Boolean).join(`
|
|
110
110
|
`)}async renderChoices(){if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);return t.length||t.push(this.styles.danger(`No matching choices`)),t.join(`
|
|
111
111
|
`)}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.scaleIdx)).join(`, `):``}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=await this.format(),s=await this.error()||await this.hint(),c=await this.renderChoices(),l=await this.footer();(o||!s)&&(i+=` `+o),s&&!i.includes(s)&&(i+=` `+s),e&&!o&&!c&&this.multiple&&this.type!==`form`&&(i+=this.styles.danger(this.emptyError)),this.clear(t),this.write([i,a,c,l].filter(Boolean).join(`
|
|
112
|
-
`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function i(e,t={}){if(Array.isArray(t.scale))return t.scale.map(e=>({...e}));let n=[];for(let t=1;t<e+1;t++)n.push({i:t,selected:!1});return n}t.exports=r})),
|
|
113
|
-
`)),this.write(this.margin[2]),this.restore()}}})),
|
|
112
|
+
`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function i(e,t={}){if(Array.isArray(t.scale))return t.scale.map(e=>({...e}));let n=[];for(let t=1;t<e+1;t++)n.push({i:t,selected:!1});return n}t.exports=r})),Ld=v(((e,t)=>{t.exports=Td()})),Rd=v(((e,t)=>{let n=bd();t.exports=class extends n{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||`no`,this.enabled=this.options.enabled||`yes`,await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e=``,t){switch(e.toLowerCase()){case` `:return this.toggle();case`1`:case`y`:case`t`:return this.enable();case`0`:case`n`:case`f`:return this.disable();default:return this.alert()}}format(){let e=e=>this.styles.primary.underline(e);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(` / `))}async render(){let{size:e}=this.state,t=await this.header(),n=await this.prefix(),r=await this.separator(),i=await this.message(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer(),c=[n,i,r,a].join(` `);this.state.prompt=c,o&&!c.includes(o)&&(c+=` `+o),this.clear(e),this.write([t,c,s].filter(Boolean).join(`
|
|
113
|
+
`)),this.write(this.margin[2]),this.restore()}}})),zd=v(((e,t)=>{let n=md();t.exports=class extends n{constructor(e){if(super(e),typeof this.options.correctChoice!=`number`||this.options.correctChoice<0)throw Error(`Please specify the index of the correct answer from the list of choices`)}async toChoices(e,t){let n=await super.toChoices(e,t);if(n.length<2)throw Error(`Please give at least two choices to the user`);if(this.options.correctChoice>n.length)throw Error(`Please specify the index of the correct answer from the list of choices`);return n}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}})),Bd=v((e=>{let t=V(),n=(n,r)=>{t.defineExport(e,n,r),t.defineExport(e,n.toLowerCase(),r)};n(`AutoComplete`,()=>hd()),n(`BasicAuth`,()=>yd()),n(`Confirm`,()=>xd()),n(`Editable`,()=>Sd()),n(`Form`,()=>_d()),n(`Input`,()=>Td()),n(`Invisible`,()=>Ed()),n(`List`,()=>Dd()),n(`MultiSelect`,()=>Od()),n(`Numeral`,()=>Ad()),n(`Password`,()=>jd()),n(`Scale`,()=>Md()),n(`Select`,()=>md()),n(`Snippet`,()=>Pd()),n(`Sort`,()=>Fd()),n(`Survey`,()=>Id()),n(`Text`,()=>Ld()),n(`Toggle`,()=>Rd()),n(`Quiz`,()=>zd())})),Vd=v(((e,t)=>{t.exports={ArrayPrompt:pd(),AuthPrompt:vd(),BooleanPrompt:bd(),NumberPrompt:kd(),StringPrompt:Cd()}})),Hd=ne(v(((e,t)=>{let n=y(`assert`),r=y(`events`),i=V();var a=class extends r{constructor(e,t){super(),this.options=i.merge({},e),this.answers={...t}}register(e,t){if(i.isObject(e)){for(let t of Object.keys(e))this.register(t,e[t]);return this}n.equal(typeof t,`function`,`expected a function`);let r=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[r]=t:this.prompts[r]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t==`function`&&(t=await t.call(this)),await this.ask(i.merge({},this.options,t))}catch(e){return Promise.reject(e)}return this.answers}async ask(e){typeof e==`function`&&(e=await e.call(this));let t=i.merge({},this.options,e),{type:r,name:a}=e,{set:o,get:s}=i;if(typeof r==`function`&&(r=await r.call(this,e,this.answers)),!r)return this.answers[a];r===`number`&&(r=`numeral`),n(this.prompts[r],`Prompt "${r}" is not registered`);let c=new this.prompts[r](t),l=s(this.answers,a);c.state.answers=this.answers,c.enquirer=this,a&&c.on(`submit`,e=>{this.emit(`answer`,a,e,c),o(this.answers,a,e)});let u=c.emit.bind(c);return c.emit=(...e)=>(this.emit.call(this,...e),u(...e)),this.emit(`prompt`,c,this),t.autofill&&l!=null?(c.value=c.input=l,t.autofill===`show`&&await c.submit()):l=c.value=await c.run(),l}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||dd()}static get prompts(){return Bd()}static get types(){return Vd()}static get prompt(){let e=(t,...n)=>{let r=new this(...n),i=r.emit.bind(r);return r.emit=(...t)=>(e.emit(...t),i(...t)),r.prompt(t)};return i.mixinEmitter(e,new r),e}};i.mixinEmitter(a,new r);let o=a.prompts;for(let e of Object.keys(o)){let t=e.toLowerCase(),n=t=>new o[e](t).run();a.prompt[t]=n,a[t]=n,a[e]||Reflect.defineProperty(a,e,{get:()=>o[e]})}let s=e=>{i.defineExport(a,e,()=>a.types[e])};s(`ArrayPrompt`),s(`AuthPrompt`),s(`BooleanPrompt`),s(`NumberPrompt`),s(`StringPrompt`),t.exports=a}))(),1);const Ud=(e=0)=>t=>`\u001B[${t+e}m`,Wd=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,Gd=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,H={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(H.modifier);const Kd=Object.keys(H.color),qd=Object.keys(H.bgColor);[...Kd,...qd];function Jd(){let e=new Map;for(let[t,n]of Object.entries(H)){for(let[t,r]of Object.entries(n))H[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=H[t],e.set(r[0],r[1]);Object.defineProperty(H,t,{value:n,enumerable:!1})}return Object.defineProperty(H,`codes`,{value:e,enumerable:!1}),H.color.close=`\x1B[39m`,H.bgColor.close=`\x1B[49m`,H.color.ansi=Ud(),H.color.ansi256=Wd(),H.color.ansi16m=Gd(),H.bgColor.ansi=Ud(10),H.bgColor.ansi256=Wd(10),H.bgColor.ansi16m=Gd(10),Object.defineProperties(H,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>H.rgbToAnsi256(...H.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>H.ansi256ToAnsi(H.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>H.ansi256ToAnsi(H.hexToAnsi256(e)),enumerable:!1}}),H}var Yd=Jd();function Xd(e,t=globalThis.Deno?globalThis.Deno.args:o.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:U}=o;let Zd;Xd(`no-color`)||Xd(`no-colors`)||Xd(`color=false`)||Xd(`color=never`)?Zd=0:(Xd(`color`)||Xd(`colors`)||Xd(`color=true`)||Xd(`color=always`))&&(Zd=1);function Qd(){if(`FORCE_COLOR`in U)return U.FORCE_COLOR===`true`?1:U.FORCE_COLOR===`false`?0:U.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(U.FORCE_COLOR,10),3)}function $d(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ef(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Qd();r!==void 0&&(Zd=r);let i=n?Zd:r;if(i===0)return 0;if(n){if(Xd(`color=16m`)||Xd(`color=full`)||Xd(`color=truecolor`))return 3;if(Xd(`color=256`))return 2}if(`TF_BUILD`in U&&`AGENT_NAME`in U)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(U.TERM===`dumb`)return a;if(o.platform===`win32`){let e=s.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in U)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in U)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in U)||U.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in U)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(U.TEAMCITY_VERSION)?1:0;if(U.COLORTERM===`truecolor`||U.TERM===`xterm-kitty`||U.TERM===`xterm-ghostty`||U.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in U){let e=Number.parseInt((U.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(U.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(U.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(U.TERM)||`COLORTERM`in U?1:a}function tf(e,t={}){return $d(ef(e,{streamIsTTY:e&&e.isTTY,...t}))}var nf={stdout:tf({isTTY:d.isatty(1)}),stderr:tf({isTTY:d.isatty(2)})};function rf(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function af(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
114
114
|
`:`
|
|
115
115
|
`)+n,i=r+1,r=e.indexOf(`
|
|
116
|
-
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:
|
|
117
|
-
`);return a!==-1&&(t=ef(t,i,r,a)),r+t+i};Object.defineProperties(df.prototype,cf);const _f=df();df({level:nf?nf.level:0});var vf=_f;const yf=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!bf(i,a)&&r||Object.defineProperty(e,n,a)},bf=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},xf=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Sf=(e,t)=>`/* Wrapped ${e}*/\n${t}`,Cf=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),wf=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),Tf=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=Sf.bind(null,r,t.toString());Object.defineProperty(i,`name`,wf);let{writable:a,enumerable:o,configurable:s}=Cf;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function Ef(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))yf(e,t,r,n);return xf(e,t),Tf(e,t,r),e}const Df=new WeakMap,Of=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected a function`);let n,r=0,i=e.displayName||e.name||`<anonymous>`,a=function(...o){if(Df.set(a,++r),r===1)n=e.apply(this,o),e=void 0;else if(t.throw===!0)throw Error(`Function \`${i}\` can only be called once`);return n};return Ef(a,e),Df.set(a,r),a};Of.callCount=e=>{if(!Df.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Df.get(e)};var kf=Of;const Af=[];Af.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Af.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Af.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const jf=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Mf=Symbol.for(`signal-exit emitter`),Nf=globalThis,Pf=Object.defineProperty.bind(Object);var Ff=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Nf[Mf])return Nf[Mf];Pf(Nf,Mf,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},If=class{};const Lf=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Rf=class extends If{onExit(){return()=>{}}load(){}unload(){}},zf=class extends If{#e=Bf.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Ff;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Af)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!jf(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Af)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Af.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return jf(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&jf(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}};const Bf=globalThis.process,{onExit:Vf,load:Hf,unload:Uf}=Lf(jf(Bf)?new zf(Bf):new Rf),Wf=o.stderr.isTTY?o.stderr:o.stdout.isTTY?o.stdout:void 0;var Gf=Wf?kf(()=>{Vf(()=>{Wf.write(`\x1B[?25h`)},{alwaysLast:!0})}):()=>{};let Kf=!1;const qf={};qf.show=(e=o.stderr)=>{e.isTTY&&(Kf=!1,e.write(`\x1B[?25h`))},qf.hide=(e=o.stderr)=>{e.isTTY&&(Gf(),Kf=!0,e.write(`\x1B[?25l`))},qf.toggle=(e,t)=>{e!==void 0&&(Kf=e),Kf?qf.show(t):qf.hide(t)};var Jf=qf,Yf={dots:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]},dots2:{interval:80,frames:[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`]},dots3:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠞`,`⠖`,`⠦`,`⠴`,`⠲`,`⠳`,`⠓`]},dots4:{interval:80,frames:[`⠄`,`⠆`,`⠇`,`⠋`,`⠙`,`⠸`,`⠰`,`⠠`,`⠰`,`⠸`,`⠙`,`⠋`,`⠇`,`⠆`]},dots5:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`]},dots6:{interval:80,frames:[`⠁`,`⠉`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠤`,`⠄`,`⠄`,`⠤`,`⠴`,`⠲`,`⠒`,`⠂`,`⠂`,`⠒`,`⠚`,`⠙`,`⠉`,`⠁`]},dots7:{interval:80,frames:[`⠈`,`⠉`,`⠋`,`⠓`,`⠒`,`⠐`,`⠐`,`⠒`,`⠖`,`⠦`,`⠤`,`⠠`,`⠠`,`⠤`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`,`⠉`,`⠈`]},dots8:{interval:80,frames:`⠁.⠁.⠉.⠙.⠚.⠒.⠂.⠂.⠒.⠲.⠴.⠤.⠄.⠄.⠤.⠠.⠠.⠤.⠦.⠖.⠒.⠐.⠐.⠒.⠓.⠋.⠉.⠈.⠈`.split(`.`)},dots9:{interval:80,frames:[`⢹`,`⢺`,`⢼`,`⣸`,`⣇`,`⡧`,`⡗`,`⡏`]},dots10:{interval:80,frames:[`⢄`,`⢂`,`⢁`,`⡁`,`⡈`,`⡐`,`⡠`]},dots11:{interval:100,frames:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},dots12:{interval:80,frames:`⢀⠀.⡀⠀.⠄⠀.⢂⠀.⡂⠀.⠅⠀.⢃⠀.⡃⠀.⠍⠀.⢋⠀.⡋⠀.⠍⠁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⢈⠩.⡀⢙.⠄⡙.⢂⠩.⡂⢘.⠅⡘.⢃⠨.⡃⢐.⠍⡐.⢋⠠.⡋⢀.⠍⡁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⠈⠩.⠀⢙.⠀⡙.⠀⠩.⠀⢘.⠀⡘.⠀⠨.⠀⢐.⠀⡐.⠀⠠.⠀⢀.⠀⡀`.split(`.`)},dots13:{interval:80,frames:[`⣼`,`⣹`,`⢻`,`⠿`,`⡟`,`⣏`,`⣧`,`⣶`]},dots14:{interval:80,frames:[`⠉⠉`,`⠈⠙`,`⠀⠹`,`⠀⢸`,`⠀⣰`,`⢀⣠`,`⣀⣀`,`⣄⡀`,`⣆⠀`,`⡇⠀`,`⠏⠀`,`⠋⠁`]},dots8Bit:{interval:80,frames:`⠀.⠁.⠂.⠃.⠄.⠅.⠆.⠇.⡀.⡁.⡂.⡃.⡄.⡅.⡆.⡇.⠈.⠉.⠊.⠋.⠌.⠍.⠎.⠏.⡈.⡉.⡊.⡋.⡌.⡍.⡎.⡏.⠐.⠑.⠒.⠓.⠔.⠕.⠖.⠗.⡐.⡑.⡒.⡓.⡔.⡕.⡖.⡗.⠘.⠙.⠚.⠛.⠜.⠝.⠞.⠟.⡘.⡙.⡚.⡛.⡜.⡝.⡞.⡟.⠠.⠡.⠢.⠣.⠤.⠥.⠦.⠧.⡠.⡡.⡢.⡣.⡤.⡥.⡦.⡧.⠨.⠩.⠪.⠫.⠬.⠭.⠮.⠯.⡨.⡩.⡪.⡫.⡬.⡭.⡮.⡯.⠰.⠱.⠲.⠳.⠴.⠵.⠶.⠷.⡰.⡱.⡲.⡳.⡴.⡵.⡶.⡷.⠸.⠹.⠺.⠻.⠼.⠽.⠾.⠿.⡸.⡹.⡺.⡻.⡼.⡽.⡾.⡿.⢀.⢁.⢂.⢃.⢄.⢅.⢆.⢇.⣀.⣁.⣂.⣃.⣄.⣅.⣆.⣇.⢈.⢉.⢊.⢋.⢌.⢍.⢎.⢏.⣈.⣉.⣊.⣋.⣌.⣍.⣎.⣏.⢐.⢑.⢒.⢓.⢔.⢕.⢖.⢗.⣐.⣑.⣒.⣓.⣔.⣕.⣖.⣗.⢘.⢙.⢚.⢛.⢜.⢝.⢞.⢟.⣘.⣙.⣚.⣛.⣜.⣝.⣞.⣟.⢠.⢡.⢢.⢣.⢤.⢥.⢦.⢧.⣠.⣡.⣢.⣣.⣤.⣥.⣦.⣧.⢨.⢩.⢪.⢫.⢬.⢭.⢮.⢯.⣨.⣩.⣪.⣫.⣬.⣭.⣮.⣯.⢰.⢱.⢲.⢳.⢴.⢵.⢶.⢷.⣰.⣱.⣲.⣳.⣴.⣵.⣶.⣷.⢸.⢹.⢺.⢻.⢼.⢽.⢾.⢿.⣸.⣹.⣺.⣻.⣼.⣽.⣾.⣿`.split(`.`)},dotsCircle:{interval:80,frames:[`⢎ `,`⠎⠁`,`⠊⠑`,`⠈⠱`,` ⡱`,`⢀⡰`,`⢄⡠`,`⢆⡀`]},sand:{interval:80,frames:`⠁.⠂.⠄.⡀.⡈.⡐.⡠.⣀.⣁.⣂.⣄.⣌.⣔.⣤.⣥.⣦.⣮.⣶.⣷.⣿.⡿.⠿.⢟.⠟.⡛.⠛.⠫.⢋.⠋.⠍.⡉.⠉.⠑.⠡.⢁`.split(`.`)},line:{interval:130,frames:[`-`,`\\`,`|`,`/`]},line2:{interval:100,frames:[`⠂`,`-`,`–`,`—`,`–`,`-`]},rollingLine:{interval:80,frames:[`/ `,` - `,` \\ `,` |`,` |`,` \\ `,` - `,`/ `]},pipe:{interval:100,frames:[`┤`,`┘`,`┴`,`└`,`├`,`┌`,`┬`,`┐`]},simpleDots:{interval:400,frames:[`. `,`.. `,`...`,` `]},simpleDotsScrolling:{interval:200,frames:[`. `,`.. `,`...`,` ..`,` .`,` `]},star:{interval:70,frames:[`✶`,`✸`,`✹`,`✺`,`✹`,`✷`]},star2:{interval:80,frames:[`+`,`x`,`*`]},flip:{interval:70,frames:[`_`,`_`,`_`,`-`,"`","`",`'`,`´`,`-`,`_`,`_`,`_`]},hamburger:{interval:100,frames:[`☱`,`☲`,`☴`]},growVertical:{interval:120,frames:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`▆`,`▅`,`▄`,`▃`]},growHorizontal:{interval:120,frames:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`▊`,`▋`,`▌`,`▍`,`▎`]},balloon:{interval:140,frames:[` `,`.`,`o`,`O`,`@`,`*`,` `]},balloon2:{interval:120,frames:[`.`,`o`,`O`,`°`,`O`,`o`,`.`]},noise:{interval:100,frames:[`▓`,`▒`,`░`]},bounce:{interval:120,frames:[`⠁`,`⠂`,`⠄`,`⠂`]},boxBounce:{interval:120,frames:[`▖`,`▘`,`▝`,`▗`]},boxBounce2:{interval:100,frames:[`▌`,`▀`,`▐`,`▄`]},triangle:{interval:50,frames:[`◢`,`◣`,`◤`,`◥`]},binary:{interval:80,frames:[`010010`,`001100`,`100101`,`111010`,`111101`,`010111`,`101011`,`111000`,`110011`,`110101`]},arc:{interval:100,frames:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`]},circle:{interval:120,frames:[`◡`,`⊙`,`◠`]},squareCorners:{interval:180,frames:[`◰`,`◳`,`◲`,`◱`]},circleQuarters:{interval:120,frames:[`◴`,`◷`,`◶`,`◵`]},circleHalves:{interval:50,frames:[`◐`,`◓`,`◑`,`◒`]},squish:{interval:100,frames:[`╫`,`╪`]},toggle:{interval:250,frames:[`⊶`,`⊷`]},toggle2:{interval:80,frames:[`▫`,`▪`]},toggle3:{interval:120,frames:[`□`,`■`]},toggle4:{interval:100,frames:[`■`,`□`,`▪`,`▫`]},toggle5:{interval:100,frames:[`▮`,`▯`]},toggle6:{interval:300,frames:[`ဝ`,`၀`]},toggle7:{interval:80,frames:[`⦾`,`⦿`]},toggle8:{interval:100,frames:[`◍`,`◌`]},toggle9:{interval:100,frames:[`◉`,`◎`]},toggle10:{interval:100,frames:[`㊂`,`㊀`,`㊁`]},toggle11:{interval:50,frames:[`⧇`,`⧆`]},toggle12:{interval:120,frames:[`☗`,`☖`]},toggle13:{interval:80,frames:[`=`,`*`,`-`]},arrow:{interval:100,frames:[`←`,`↖`,`↑`,`↗`,`→`,`↘`,`↓`,`↙`]},arrow2:{interval:80,frames:[`⬆️ `,`↗️ `,`➡️ `,`↘️ `,`⬇️ `,`↙️ `,`⬅️ `,`↖️ `]},arrow3:{interval:120,frames:[`▹▹▹▹▹`,`▸▹▹▹▹`,`▹▸▹▹▹`,`▹▹▸▹▹`,`▹▹▹▸▹`,`▹▹▹▹▸`]},bouncingBar:{interval:80,frames:[`[ ]`,`[= ]`,`[== ]`,`[=== ]`,`[====]`,`[ ===]`,`[ ==]`,`[ =]`,`[ ]`,`[ =]`,`[ ==]`,`[ ===]`,`[====]`,`[=== ]`,`[== ]`,`[= ]`]},bouncingBall:{interval:80,frames:[`( ● )`,`( ● )`,`( ● )`,`( ● )`,`( ●)`,`( ● )`,`( ● )`,`( ● )`,`( ● )`,`(● )`]},smiley:{interval:200,frames:[`😄 `,`😝 `]},monkey:{interval:300,frames:[`🙈 `,`🙈 `,`🙉 `,`🙊 `]},hearts:{interval:100,frames:[`💛 `,`💙 `,`💜 `,`💚 `,`💗 `]},clock:{interval:100,frames:[`🕛 `,`🕐 `,`🕑 `,`🕒 `,`🕓 `,`🕔 `,`🕕 `,`🕖 `,`🕗 `,`🕘 `,`🕙 `,`🕚 `]},earth:{interval:180,frames:[`🌍 `,`🌎 `,`🌏 `]},material:{interval:17,frames:`█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███████▁▁▁▁▁▁▁▁▁▁▁▁▁.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.██████████▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.█████████████▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁██████████████▁▁▁▁.▁▁▁██████████████▁▁▁.▁▁▁▁█████████████▁▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁▁▁████████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.██████▁▁▁▁▁▁▁▁▁▁▁▁▁█.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁▁█████████████▁▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁▁███████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁▁█████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁`.split(`.`)},moon:{interval:80,frames:[`🌑 `,`🌒 `,`🌓 `,`🌔 `,`🌕 `,`🌖 `,`🌗 `,`🌘 `]},runner:{interval:140,frames:[`🚶 `,`🏃 `]},pong:{interval:80,frames:`▐⠂ ▌.▐⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂▌.▐ ⠠▌.▐ ⡀▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐⠠ ▌`.split(`.`)},shark:{interval:120,frames:`▐|\\____________▌.▐_|\\___________▌.▐__|\\__________▌.▐___|\\_________▌.▐____|\\________▌.▐_____|\\_______▌.▐______|\\______▌.▐_______|\\_____▌.▐________|\\____▌.▐_________|\\___▌.▐__________|\\__▌.▐___________|\\_▌.▐____________|\\▌.▐____________/|▌.▐___________/|_▌.▐__________/|__▌.▐_________/|___▌.▐________/|____▌.▐_______/|_____▌.▐______/|______▌.▐_____/|_______▌.▐____/|________▌.▐___/|_________▌.▐__/|__________▌.▐_/|___________▌.▐/|____________▌`.split(`.`)},dqpb:{interval:100,frames:[`d`,`q`,`p`,`b`]},weather:{interval:100,frames:[`☀️ `,`☀️ `,`☀️ `,`🌤 `,`⛅️ `,`🌥 `,`☁️ `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`⛈ `,`🌨 `,`🌧 `,`🌨 `,`☁️ `,`🌥 `,`⛅️ `,`🌤 `,`☀️ `,`☀️ `]},christmas:{interval:400,frames:[`🌲`,`🎄`]},grenade:{interval:80,frames:[`، `,`′ `,` ´ `,` ‾ `,` ⸌`,` ⸊`,` |`,` ⁎`,` ⁕`,` ෴ `,` ⁓`,` `,` `,` `]},point:{interval:125,frames:[`∙∙∙`,`●∙∙`,`∙●∙`,`∙∙●`,`∙∙∙`]},layer:{interval:150,frames:[`-`,`=`,`≡`]},betaWave:{interval:80,frames:[`ρββββββ`,`βρβββββ`,`ββρββββ`,`βββρβββ`,`ββββρββ`,`βββββρβ`,`ββββββρ`]},fingerDance:{interval:160,frames:[`🤘 `,`🤟 `,`🖖 `,`✋ `,`🤚 `,`👆 `]},fistBump:{interval:80,frames:[`🤜 🤛 `,`🤜 🤛 `,`🤜 🤛 `,` 🤜 🤛 `,` 🤜🤛 `,` 🤜✨🤛 `,`🤜 ✨ 🤛 `]},soccerHeader:{interval:80,frames:[` 🧑⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `]},mindblown:{interval:160,frames:[`😐 `,`😐 `,`😮 `,`😮 `,`😦 `,`😦 `,`😧 `,`😧 `,`🤯 `,`💥 `,`✨ `,` `,` `,` `]},speaker:{interval:160,frames:[`🔈 `,`🔉 `,`🔊 `,`🔉 `]},orangePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `]},bluePulse:{interval:100,frames:[`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},orangeBluePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `,`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},timeTravel:{interval:100,frames:[`🕛 `,`🕚 `,`🕙 `,`🕘 `,`🕗 `,`🕖 `,`🕕 `,`🕔 `,`🕓 `,`🕒 `,`🕑 `,`🕐 `]},aesthetic:{interval:80,frames:[`▰▱▱▱▱▱▱`,`▰▰▱▱▱▱▱`,`▰▰▰▱▱▱▱`,`▰▰▰▰▱▱▱`,`▰▰▰▰▰▱▱`,`▰▰▰▰▰▰▱`,`▰▰▰▰▰▰▰`,`▰▱▱▱▱▱▱`]},dwarfFortress:{interval:80,frames:` ██████£££ .☺██████£££ .☺██████£££ .☺▓█████£££ .☺▓█████£££ .☺▒█████£££ .☺▒█████£££ .☺░█████£££ .☺░█████£££ .☺ █████£££ . ☺█████£££ . ☺█████£££ . ☺▓████£££ . ☺▓████£££ . ☺▒████£££ . ☺▒████£££ . ☺░████£££ . ☺░████£££ . ☺ ████£££ . ☺████£££ . ☺████£££ . ☺▓███£££ . ☺▓███£££ . ☺▒███£££ . ☺▒███£££ . ☺░███£££ . ☺░███£££ . ☺ ███£££ . ☺███£££ . ☺███£££ . ☺▓██£££ . ☺▓██£££ . ☺▒██£££ . ☺▒██£££ . ☺░██£££ . ☺░██£££ . ☺ ██£££ . ☺██£££ . ☺██£££ . ☺▓█£££ . ☺▓█£££ . ☺▒█£££ . ☺▒█£££ . ☺░█£££ . ☺░█£££ . ☺ █£££ . ☺█£££ . ☺█£££ . ☺▓£££ . ☺▓£££ . ☺▒£££ . ☺▒£££ . ☺░£££ . ☺░£££ . ☺ £££ . ☺£££ . ☺£££ . ☺▓££ . ☺▓££ . ☺▒££ . ☺▒££ . ☺░££ . ☺░££ . ☺ ££ . ☺££ . ☺££ . ☺▓£ . ☺▓£ . ☺▒£ . ☺▒£ . ☺░£ . ☺░£ . ☺ £ . ☺£ . ☺£ . ☺▓ . ☺▓ . ☺▒ . ☺▒ . ☺░ . ☺░ . ☺ . ☺ &. ☺ ☼&. ☺ ☼ &. ☺☼ &. ☺☼ & . ‼ & . ☺ & . ‼ & . ☺ & . ‼ & . ☺ & .‼ & . & . & . & ░ . & ▒ . & ▓ . & £ . & ░£ . & ▒£ . & ▓£ . & ££ . & ░££ . & ▒££ .& ▓££ .& £££ . ░£££ . ▒£££ . ▓£££ . █£££ . ░█£££ . ▒█£££ . ▓█£££ . ██£££ . ░██£££ . ▒██£££ . ▓██£££ . ███£££ . ░███£££ . ▒███£££ . ▓███£££ . ████£££ . ░████£££ . ▒████£££ . ▓████£££ . █████£££ . ░█████£££ . ▒█████£££ . ▓█████£££ . ██████£££ . ██████£££ `.split(`.`)},fish:{interval:80,frames:`~~~~~~~~~~~~~~~~~~~~.> ~~~~~~~~~~~~~~~~~~.º> ~~~~~~~~~~~~~~~~~.(º> ~~~~~~~~~~~~~~~~.((º> ~~~~~~~~~~~~~~~.<((º> ~~~~~~~~~~~~~~.><((º> ~~~~~~~~~~~~~. ><((º> ~~~~~~~~~~~~.~ ><((º> ~~~~~~~~~~~.~~ <>((º> ~~~~~~~~~~.~~~ ><((º> ~~~~~~~~~.~~~~ <>((º> ~~~~~~~~.~~~~~ ><((º> ~~~~~~~.~~~~~~ <>((º> ~~~~~~.~~~~~~~ ><((º> ~~~~~.~~~~~~~~ <>((º> ~~~~.~~~~~~~~~ ><((º> ~~~.~~~~~~~~~~ <>((º> ~~.~~~~~~~~~~~ ><((º> ~.~~~~~~~~~~~~ <>((º> .~~~~~~~~~~~~~ ><((º>.~~~~~~~~~~~~~~ <>((º.~~~~~~~~~~~~~~~ ><((.~~~~~~~~~~~~~~~~ <>(.~~~~~~~~~~~~~~~~~ ><.~~~~~~~~~~~~~~~~~~ <.~~~~~~~~~~~~~~~~~~~~`.split(`.`)}};const Xf=u?.WriteStream?.prototype?.hasColors?.()??!1,U=(e,t)=>{if(!Xf)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}};U(0,0),U(1,22),U(2,22),U(3,23),U(4,24),U(`4:2`,24),U(`4:3`,24),U(`4:4`,24),U(`4:5`,24),U(53,55),U(7,27),U(8,28),U(9,29),U(30,39);const Zf=U(31,39),Qf=U(32,39),$f=U(33,39),ep=U(34,39);U(35,39),U(36,39),U(37,39),U(90,39),U(40,49),U(41,49),U(42,49),U(43,49),U(44,49),U(45,49),U(46,49),U(47,49),U(100,49),U(91,39),U(92,39),U(93,39),U(94,39),U(95,39),U(96,39),U(97,39),U(101,49),U(102,49),U(103,49),U(104,49),U(105,49),U(106,49),U(107,49),U(`58;5;0`,59),U(`58;5;1`,59),U(`58;5;2`,59),U(`58;5;3`,59),U(`58;5;4`,59),U(`58;5;5`,59),U(`58;5;6`,59),U(`58;5;7`,59),U(`58;5;8`,59),U(`58;5;9`,59),U(`58;5;10`,59),U(`58;5;11`,59),U(`58;5;12`,59),U(`58;5;13`,59),U(`58;5;14`,59),U(`58;5;15`,59);function tp(){let{env:e}=o,{TERM:t,TERM_PROGRAM:n}=e;return o.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const np=tp(),rp=ep(np?`ℹ`:`i`),ip=Qf(np?`✔`:`√`),ap=$f(np?`⚠`:`‼`),op=Zf(np?`✖`:`×`);function sp({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const cp=sp();function lp(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(cp,``)}const up=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],dp=[12288,12288,65281,65376,65504,65510],fp=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141],pp=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},mp=19968,[hp,gp]=_p(fp);function _p(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(mp>=i&&mp<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}const vp=e=>e<161||e>1114109?!1:pp(up,e),yp=e=>e<12288||e>65510?!1:pp(dp,e),bp=e=>e>=hp&&e<=gp?!0:e<4352||e>262141?!1:pp(fp,e);function xp(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Sp(e,{ambiguousAsWide:t=!1}={}){return xp(e),yp(e)||bp(e)||t&&vp(e)?2:1}const Cp=new Intl.Segmenter,wp=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Tp=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Ep=/\p{Spacing_Mark}/v,Dp=/^\p{RGI_Emoji}$/v,Op=/^[\d#*]\u20E3$/,kp=/\p{Extended_Pictographic}/gu;function Ap(e){if(e.length>50)return!1;if(Op.test(e))return!0;if(e.includes(``)){let t=e.match(kp);return t!==null&&t.length>=2}return!1}function jp(e){return e.replace(Tp,``)}function Mp(e){return wp.test(e)}function Np(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Pp(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Fp(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Ip(e){return Np(e)||Pp(e)||Fp(e)}function Lp(e,t){let n=[];for(let t of e)wp.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!Ip(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=Sp(n[i],t);return r}if(Np(i)&&Pp(n[e+1])){r+=2,e+=Fp(n[e+2])?2:1;continue}r+=Sp(i,t)}return r}function Rp(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(Ep.test(i)||i>=``&&i<=``)&&(n+=Sp(i.codePointAt(0),t))}return n}function zp(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(``))&&(i=lp(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of Cp.segment(i)){if(Mp(e))continue;if(Dp.test(e)||Ap(e)){a+=2;continue}let t=jp(e),n=Lp(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=Sp(r,o),a+=Rp(t,o)}return a}function Bp({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!==`dumb`&&!(`CI`in process.env))}const Vp=new class{#e=0;#t;#n=!1;#r=!1;#i=e=>{e?.length&&(typeof e==`string`?e.codePointAt(0):e[0])===3&&o.kill(o.pid,`SIGINT`)};start(){this.#e++,this.#e===1&&this.#a()}stop(){this.#e!==0&&--this.#e===0&&this.#o()}#a(){let{stdin:e}=o;if(o.platform===`win32`||!e?.isTTY||typeof e.setRawMode!=`function`){this.#t=void 0;return}this.#t=e,this.#n=e.isPaused(),this.#r=!!e.isRaw,e.setRawMode(!0),e.prependListener(`data`,this.#i),this.#n&&e.resume()}#o(){if(!this.#t)return;let e=this.#t;e.off(`data`,this.#i),e.isTTY&&e.setRawMode?.(this.#r),this.#n&&e.pause(),this.#t=void 0,this.#n=!1,this.#r=!1}};var Hp=Object.freeze(Vp);const Up=new Map,Wp=new Set([`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`gray`]);var Gp=class{#e=0;#t=-1;#n=0;#r;#i;#a;#o;#s=new Map;#c=!1;#l;#u;#d=!1;#f;#p(e){this.#c=!0;try{return e()}finally{this.#c=!1}}#m(){this.isSpinning&&this.render()}#h(e,t){if(e==null)return``;if(typeof e==`string`)return e;if(Buffer.isBuffer(e)||ArrayBuffer.isView(e)){let n=typeof t==`string`&&t&&t!==`buffer`?t:`utf8`;return Buffer.from(e).toString(n)}return String(e)}#g(e){if(!e)return!1;let t=e.at(-1);return t===`
|
|
118
|
-
`||t===`\r`}#_(){this.#u||(this.#u=setTimeout(()=>{this.#u=void 0,this.isSpinning&&this.#m()},200),typeof this.#u?.unref==`function`&&this.#u.unref())}#v(){this.#u&&=(clearTimeout(this.#u),void 0)}#y(e,t,n,r){let i=this.#x(n,` `),a=typeof t==`string`?(e?` `:``)+t:``,o=this.#S(r,` `);return i+e+a+o}constructor(e){if(typeof e==`string`&&(e={text:e}),this.#r={color:`cyan`,stream:o.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#r.color,this.#a=this.#r.stream,typeof this.#r.isEnabled!=`boolean`&&(this.#r.isEnabled=
|
|
119
|
-
`))n+=Math.max(1,Math.ceil(
|
|
116
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:of,stderr:sf}=nf,cf=Symbol(`GENERATOR`),lf=Symbol(`STYLER`),uf=Symbol(`IS_EMPTY`),df=[`ansi`,`ansi`,`ansi256`,`ansi16m`],ff=Object.create(null),pf=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=of?of.level:0;e.level=t.level===void 0?n:t.level},mf=e=>{let t=(...e)=>e.join(` `);return pf(t,e),Object.setPrototypeOf(t,hf.prototype),t};function hf(e){return mf(e)}Object.setPrototypeOf(hf.prototype,Function.prototype);for(let[e,t]of Object.entries(Yd))ff[e]={get(){let n=yf(this,vf(t.open,t.close,this[lf]),this[uf]);return Object.defineProperty(this,e,{value:n}),n}};ff.visible={get(){let e=yf(this,this[lf],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const gf=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?Yd[n].ansi16m(...r):t===`ansi256`?Yd[n].ansi256(Yd.rgbToAnsi256(...r)):Yd[n].ansi(Yd.rgbToAnsi(...r)):e===`hex`?gf(`rgb`,t,n,...Yd.hexToRgb(...r)):Yd[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){ff[e]={get(){let{level:t}=this;return function(...n){let r=vf(gf(e,df[t],`color`,...n),Yd.color.close,this[lf]);return yf(this,r,this[uf])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);ff[t]={get(){let{level:t}=this;return function(...n){let r=vf(gf(e,df[t],`bgColor`,...n),Yd.bgColor.close,this[lf]);return yf(this,r,this[uf])}}}}const _f=Object.defineProperties(()=>{},{...ff,level:{enumerable:!0,get(){return this[cf].level},set(e){this[cf].level=e}}}),vf=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},yf=(e,t,n)=>{let r=(...e)=>bf(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,_f),r[cf]=e,r[lf]=t,r[uf]=n,r},bf=(e,t)=>{if(e.level<=0||!t)return e[uf]?``:t;let n=e[lf];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=rf(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
117
|
+
`);return a!==-1&&(t=af(t,i,r,a)),r+t+i};Object.defineProperties(hf.prototype,ff);const xf=hf();hf({level:sf?sf.level:0});var Sf=xf;const Cf=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!wf(i,a)&&r||Object.defineProperty(e,n,a)},wf=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Tf=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Ef=(e,t)=>`/* Wrapped ${e}*/\n${t}`,Df=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),Of=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),kf=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=Ef.bind(null,r,t.toString());Object.defineProperty(i,`name`,Of);let{writable:a,enumerable:o,configurable:s}=Df;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function Af(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))Cf(e,t,r,n);return Tf(e,t),kf(e,t,r),e}const jf=new WeakMap,Mf=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected a function`);let n,r=0,i=e.displayName||e.name||`<anonymous>`,a=function(...o){if(jf.set(a,++r),r===1)n=e.apply(this,o),e=void 0;else if(t.throw===!0)throw Error(`Function \`${i}\` can only be called once`);return n};return Af(a,e),jf.set(a,r),a};Mf.callCount=e=>{if(!jf.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return jf.get(e)};var Nf=Mf;const Pf=[];Pf.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Pf.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Pf.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Ff=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,If=Symbol.for(`signal-exit emitter`),Lf=globalThis,Rf=Object.defineProperty.bind(Object);var zf=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Lf[If])return Lf[If];Rf(Lf,If,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Bf=class{};const Vf=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Hf=class extends Bf{onExit(){return()=>{}}load(){}unload(){}},Uf=class extends Bf{#e=Wf.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new zf;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Pf)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!Ff(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Pf)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Pf.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return Ff(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&Ff(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}};const Wf=globalThis.process,{onExit:Gf,load:Kf,unload:qf}=Vf(Ff(Wf)?new Uf(Wf):new Hf),Jf=o.stderr.isTTY?o.stderr:o.stdout.isTTY?o.stdout:void 0;var Yf=Jf?Nf(()=>{Gf(()=>{Jf.write(`\x1B[?25h`)},{alwaysLast:!0})}):()=>{};let Xf=!1;const Zf={};Zf.show=(e=o.stderr)=>{e.isTTY&&(Xf=!1,e.write(`\x1B[?25h`))},Zf.hide=(e=o.stderr)=>{e.isTTY&&(Yf(),Xf=!0,e.write(`\x1B[?25l`))},Zf.toggle=(e,t)=>{e!==void 0&&(Xf=e),Xf?Zf.show(t):Zf.hide(t)};var Qf=Zf,$f={dots:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]},dots2:{interval:80,frames:[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`]},dots3:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠞`,`⠖`,`⠦`,`⠴`,`⠲`,`⠳`,`⠓`]},dots4:{interval:80,frames:[`⠄`,`⠆`,`⠇`,`⠋`,`⠙`,`⠸`,`⠰`,`⠠`,`⠰`,`⠸`,`⠙`,`⠋`,`⠇`,`⠆`]},dots5:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`]},dots6:{interval:80,frames:[`⠁`,`⠉`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠤`,`⠄`,`⠄`,`⠤`,`⠴`,`⠲`,`⠒`,`⠂`,`⠂`,`⠒`,`⠚`,`⠙`,`⠉`,`⠁`]},dots7:{interval:80,frames:[`⠈`,`⠉`,`⠋`,`⠓`,`⠒`,`⠐`,`⠐`,`⠒`,`⠖`,`⠦`,`⠤`,`⠠`,`⠠`,`⠤`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`,`⠉`,`⠈`]},dots8:{interval:80,frames:`⠁.⠁.⠉.⠙.⠚.⠒.⠂.⠂.⠒.⠲.⠴.⠤.⠄.⠄.⠤.⠠.⠠.⠤.⠦.⠖.⠒.⠐.⠐.⠒.⠓.⠋.⠉.⠈.⠈`.split(`.`)},dots9:{interval:80,frames:[`⢹`,`⢺`,`⢼`,`⣸`,`⣇`,`⡧`,`⡗`,`⡏`]},dots10:{interval:80,frames:[`⢄`,`⢂`,`⢁`,`⡁`,`⡈`,`⡐`,`⡠`]},dots11:{interval:100,frames:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},dots12:{interval:80,frames:`⢀⠀.⡀⠀.⠄⠀.⢂⠀.⡂⠀.⠅⠀.⢃⠀.⡃⠀.⠍⠀.⢋⠀.⡋⠀.⠍⠁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⢈⠩.⡀⢙.⠄⡙.⢂⠩.⡂⢘.⠅⡘.⢃⠨.⡃⢐.⠍⡐.⢋⠠.⡋⢀.⠍⡁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⠈⠩.⠀⢙.⠀⡙.⠀⠩.⠀⢘.⠀⡘.⠀⠨.⠀⢐.⠀⡐.⠀⠠.⠀⢀.⠀⡀`.split(`.`)},dots13:{interval:80,frames:[`⣼`,`⣹`,`⢻`,`⠿`,`⡟`,`⣏`,`⣧`,`⣶`]},dots14:{interval:80,frames:[`⠉⠉`,`⠈⠙`,`⠀⠹`,`⠀⢸`,`⠀⣰`,`⢀⣠`,`⣀⣀`,`⣄⡀`,`⣆⠀`,`⡇⠀`,`⠏⠀`,`⠋⠁`]},dots8Bit:{interval:80,frames:`⠀.⠁.⠂.⠃.⠄.⠅.⠆.⠇.⡀.⡁.⡂.⡃.⡄.⡅.⡆.⡇.⠈.⠉.⠊.⠋.⠌.⠍.⠎.⠏.⡈.⡉.⡊.⡋.⡌.⡍.⡎.⡏.⠐.⠑.⠒.⠓.⠔.⠕.⠖.⠗.⡐.⡑.⡒.⡓.⡔.⡕.⡖.⡗.⠘.⠙.⠚.⠛.⠜.⠝.⠞.⠟.⡘.⡙.⡚.⡛.⡜.⡝.⡞.⡟.⠠.⠡.⠢.⠣.⠤.⠥.⠦.⠧.⡠.⡡.⡢.⡣.⡤.⡥.⡦.⡧.⠨.⠩.⠪.⠫.⠬.⠭.⠮.⠯.⡨.⡩.⡪.⡫.⡬.⡭.⡮.⡯.⠰.⠱.⠲.⠳.⠴.⠵.⠶.⠷.⡰.⡱.⡲.⡳.⡴.⡵.⡶.⡷.⠸.⠹.⠺.⠻.⠼.⠽.⠾.⠿.⡸.⡹.⡺.⡻.⡼.⡽.⡾.⡿.⢀.⢁.⢂.⢃.⢄.⢅.⢆.⢇.⣀.⣁.⣂.⣃.⣄.⣅.⣆.⣇.⢈.⢉.⢊.⢋.⢌.⢍.⢎.⢏.⣈.⣉.⣊.⣋.⣌.⣍.⣎.⣏.⢐.⢑.⢒.⢓.⢔.⢕.⢖.⢗.⣐.⣑.⣒.⣓.⣔.⣕.⣖.⣗.⢘.⢙.⢚.⢛.⢜.⢝.⢞.⢟.⣘.⣙.⣚.⣛.⣜.⣝.⣞.⣟.⢠.⢡.⢢.⢣.⢤.⢥.⢦.⢧.⣠.⣡.⣢.⣣.⣤.⣥.⣦.⣧.⢨.⢩.⢪.⢫.⢬.⢭.⢮.⢯.⣨.⣩.⣪.⣫.⣬.⣭.⣮.⣯.⢰.⢱.⢲.⢳.⢴.⢵.⢶.⢷.⣰.⣱.⣲.⣳.⣴.⣵.⣶.⣷.⢸.⢹.⢺.⢻.⢼.⢽.⢾.⢿.⣸.⣹.⣺.⣻.⣼.⣽.⣾.⣿`.split(`.`)},dotsCircle:{interval:80,frames:[`⢎ `,`⠎⠁`,`⠊⠑`,`⠈⠱`,` ⡱`,`⢀⡰`,`⢄⡠`,`⢆⡀`]},sand:{interval:80,frames:`⠁.⠂.⠄.⡀.⡈.⡐.⡠.⣀.⣁.⣂.⣄.⣌.⣔.⣤.⣥.⣦.⣮.⣶.⣷.⣿.⡿.⠿.⢟.⠟.⡛.⠛.⠫.⢋.⠋.⠍.⡉.⠉.⠑.⠡.⢁`.split(`.`)},line:{interval:130,frames:[`-`,`\\`,`|`,`/`]},line2:{interval:100,frames:[`⠂`,`-`,`–`,`—`,`–`,`-`]},rollingLine:{interval:80,frames:[`/ `,` - `,` \\ `,` |`,` |`,` \\ `,` - `,`/ `]},pipe:{interval:100,frames:[`┤`,`┘`,`┴`,`└`,`├`,`┌`,`┬`,`┐`]},simpleDots:{interval:400,frames:[`. `,`.. `,`...`,` `]},simpleDotsScrolling:{interval:200,frames:[`. `,`.. `,`...`,` ..`,` .`,` `]},star:{interval:70,frames:[`✶`,`✸`,`✹`,`✺`,`✹`,`✷`]},star2:{interval:80,frames:[`+`,`x`,`*`]},flip:{interval:70,frames:[`_`,`_`,`_`,`-`,"`","`",`'`,`´`,`-`,`_`,`_`,`_`]},hamburger:{interval:100,frames:[`☱`,`☲`,`☴`]},growVertical:{interval:120,frames:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`▆`,`▅`,`▄`,`▃`]},growHorizontal:{interval:120,frames:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`▊`,`▋`,`▌`,`▍`,`▎`]},balloon:{interval:140,frames:[` `,`.`,`o`,`O`,`@`,`*`,` `]},balloon2:{interval:120,frames:[`.`,`o`,`O`,`°`,`O`,`o`,`.`]},noise:{interval:100,frames:[`▓`,`▒`,`░`]},bounce:{interval:120,frames:[`⠁`,`⠂`,`⠄`,`⠂`]},boxBounce:{interval:120,frames:[`▖`,`▘`,`▝`,`▗`]},boxBounce2:{interval:100,frames:[`▌`,`▀`,`▐`,`▄`]},triangle:{interval:50,frames:[`◢`,`◣`,`◤`,`◥`]},binary:{interval:80,frames:[`010010`,`001100`,`100101`,`111010`,`111101`,`010111`,`101011`,`111000`,`110011`,`110101`]},arc:{interval:100,frames:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`]},circle:{interval:120,frames:[`◡`,`⊙`,`◠`]},squareCorners:{interval:180,frames:[`◰`,`◳`,`◲`,`◱`]},circleQuarters:{interval:120,frames:[`◴`,`◷`,`◶`,`◵`]},circleHalves:{interval:50,frames:[`◐`,`◓`,`◑`,`◒`]},squish:{interval:100,frames:[`╫`,`╪`]},toggle:{interval:250,frames:[`⊶`,`⊷`]},toggle2:{interval:80,frames:[`▫`,`▪`]},toggle3:{interval:120,frames:[`□`,`■`]},toggle4:{interval:100,frames:[`■`,`□`,`▪`,`▫`]},toggle5:{interval:100,frames:[`▮`,`▯`]},toggle6:{interval:300,frames:[`ဝ`,`၀`]},toggle7:{interval:80,frames:[`⦾`,`⦿`]},toggle8:{interval:100,frames:[`◍`,`◌`]},toggle9:{interval:100,frames:[`◉`,`◎`]},toggle10:{interval:100,frames:[`㊂`,`㊀`,`㊁`]},toggle11:{interval:50,frames:[`⧇`,`⧆`]},toggle12:{interval:120,frames:[`☗`,`☖`]},toggle13:{interval:80,frames:[`=`,`*`,`-`]},arrow:{interval:100,frames:[`←`,`↖`,`↑`,`↗`,`→`,`↘`,`↓`,`↙`]},arrow2:{interval:80,frames:[`⬆️ `,`↗️ `,`➡️ `,`↘️ `,`⬇️ `,`↙️ `,`⬅️ `,`↖️ `]},arrow3:{interval:120,frames:[`▹▹▹▹▹`,`▸▹▹▹▹`,`▹▸▹▹▹`,`▹▹▸▹▹`,`▹▹▹▸▹`,`▹▹▹▹▸`]},bouncingBar:{interval:80,frames:[`[ ]`,`[= ]`,`[== ]`,`[=== ]`,`[====]`,`[ ===]`,`[ ==]`,`[ =]`,`[ ]`,`[ =]`,`[ ==]`,`[ ===]`,`[====]`,`[=== ]`,`[== ]`,`[= ]`]},bouncingBall:{interval:80,frames:[`( ● )`,`( ● )`,`( ● )`,`( ● )`,`( ●)`,`( ● )`,`( ● )`,`( ● )`,`( ● )`,`(● )`]},smiley:{interval:200,frames:[`😄 `,`😝 `]},monkey:{interval:300,frames:[`🙈 `,`🙈 `,`🙉 `,`🙊 `]},hearts:{interval:100,frames:[`💛 `,`💙 `,`💜 `,`💚 `,`💗 `]},clock:{interval:100,frames:[`🕛 `,`🕐 `,`🕑 `,`🕒 `,`🕓 `,`🕔 `,`🕕 `,`🕖 `,`🕗 `,`🕘 `,`🕙 `,`🕚 `]},earth:{interval:180,frames:[`🌍 `,`🌎 `,`🌏 `]},material:{interval:17,frames:`█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███████▁▁▁▁▁▁▁▁▁▁▁▁▁.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.██████████▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.█████████████▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁██████████████▁▁▁▁.▁▁▁██████████████▁▁▁.▁▁▁▁█████████████▁▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁▁▁████████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.██████▁▁▁▁▁▁▁▁▁▁▁▁▁█.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁▁█████████████▁▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁▁███████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁▁█████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁`.split(`.`)},moon:{interval:80,frames:[`🌑 `,`🌒 `,`🌓 `,`🌔 `,`🌕 `,`🌖 `,`🌗 `,`🌘 `]},runner:{interval:140,frames:[`🚶 `,`🏃 `]},pong:{interval:80,frames:`▐⠂ ▌.▐⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂▌.▐ ⠠▌.▐ ⡀▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐⠠ ▌`.split(`.`)},shark:{interval:120,frames:`▐|\\____________▌.▐_|\\___________▌.▐__|\\__________▌.▐___|\\_________▌.▐____|\\________▌.▐_____|\\_______▌.▐______|\\______▌.▐_______|\\_____▌.▐________|\\____▌.▐_________|\\___▌.▐__________|\\__▌.▐___________|\\_▌.▐____________|\\▌.▐____________/|▌.▐___________/|_▌.▐__________/|__▌.▐_________/|___▌.▐________/|____▌.▐_______/|_____▌.▐______/|______▌.▐_____/|_______▌.▐____/|________▌.▐___/|_________▌.▐__/|__________▌.▐_/|___________▌.▐/|____________▌`.split(`.`)},dqpb:{interval:100,frames:[`d`,`q`,`p`,`b`]},weather:{interval:100,frames:[`☀️ `,`☀️ `,`☀️ `,`🌤 `,`⛅️ `,`🌥 `,`☁️ `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`⛈ `,`🌨 `,`🌧 `,`🌨 `,`☁️ `,`🌥 `,`⛅️ `,`🌤 `,`☀️ `,`☀️ `]},christmas:{interval:400,frames:[`🌲`,`🎄`]},grenade:{interval:80,frames:[`، `,`′ `,` ´ `,` ‾ `,` ⸌`,` ⸊`,` |`,` ⁎`,` ⁕`,` ෴ `,` ⁓`,` `,` `,` `]},point:{interval:125,frames:[`∙∙∙`,`●∙∙`,`∙●∙`,`∙∙●`,`∙∙∙`]},layer:{interval:150,frames:[`-`,`=`,`≡`]},betaWave:{interval:80,frames:[`ρββββββ`,`βρβββββ`,`ββρββββ`,`βββρβββ`,`ββββρββ`,`βββββρβ`,`ββββββρ`]},fingerDance:{interval:160,frames:[`🤘 `,`🤟 `,`🖖 `,`✋ `,`🤚 `,`👆 `]},fistBump:{interval:80,frames:[`🤜 🤛 `,`🤜 🤛 `,`🤜 🤛 `,` 🤜 🤛 `,` 🤜🤛 `,` 🤜✨🤛 `,`🤜 ✨ 🤛 `]},soccerHeader:{interval:80,frames:[` 🧑⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `]},mindblown:{interval:160,frames:[`😐 `,`😐 `,`😮 `,`😮 `,`😦 `,`😦 `,`😧 `,`😧 `,`🤯 `,`💥 `,`✨ `,` `,` `,` `]},speaker:{interval:160,frames:[`🔈 `,`🔉 `,`🔊 `,`🔉 `]},orangePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `]},bluePulse:{interval:100,frames:[`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},orangeBluePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `,`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},timeTravel:{interval:100,frames:[`🕛 `,`🕚 `,`🕙 `,`🕘 `,`🕗 `,`🕖 `,`🕕 `,`🕔 `,`🕓 `,`🕒 `,`🕑 `,`🕐 `]},aesthetic:{interval:80,frames:[`▰▱▱▱▱▱▱`,`▰▰▱▱▱▱▱`,`▰▰▰▱▱▱▱`,`▰▰▰▰▱▱▱`,`▰▰▰▰▰▱▱`,`▰▰▰▰▰▰▱`,`▰▰▰▰▰▰▰`,`▰▱▱▱▱▱▱`]},dwarfFortress:{interval:80,frames:` ██████£££ .☺██████£££ .☺██████£££ .☺▓█████£££ .☺▓█████£££ .☺▒█████£££ .☺▒█████£££ .☺░█████£££ .☺░█████£££ .☺ █████£££ . ☺█████£££ . ☺█████£££ . ☺▓████£££ . ☺▓████£££ . ☺▒████£££ . ☺▒████£££ . ☺░████£££ . ☺░████£££ . ☺ ████£££ . ☺████£££ . ☺████£££ . ☺▓███£££ . ☺▓███£££ . ☺▒███£££ . ☺▒███£££ . ☺░███£££ . ☺░███£££ . ☺ ███£££ . ☺███£££ . ☺███£££ . ☺▓██£££ . ☺▓██£££ . ☺▒██£££ . ☺▒██£££ . ☺░██£££ . ☺░██£££ . ☺ ██£££ . ☺██£££ . ☺██£££ . ☺▓█£££ . ☺▓█£££ . ☺▒█£££ . ☺▒█£££ . ☺░█£££ . ☺░█£££ . ☺ █£££ . ☺█£££ . ☺█£££ . ☺▓£££ . ☺▓£££ . ☺▒£££ . ☺▒£££ . ☺░£££ . ☺░£££ . ☺ £££ . ☺£££ . ☺£££ . ☺▓££ . ☺▓££ . ☺▒££ . ☺▒££ . ☺░££ . ☺░££ . ☺ ££ . ☺££ . ☺££ . ☺▓£ . ☺▓£ . ☺▒£ . ☺▒£ . ☺░£ . ☺░£ . ☺ £ . ☺£ . ☺£ . ☺▓ . ☺▓ . ☺▒ . ☺▒ . ☺░ . ☺░ . ☺ . ☺ &. ☺ ☼&. ☺ ☼ &. ☺☼ &. ☺☼ & . ‼ & . ☺ & . ‼ & . ☺ & . ‼ & . ☺ & .‼ & . & . & . & ░ . & ▒ . & ▓ . & £ . & ░£ . & ▒£ . & ▓£ . & ££ . & ░££ . & ▒££ .& ▓££ .& £££ . ░£££ . ▒£££ . ▓£££ . █£££ . ░█£££ . ▒█£££ . ▓█£££ . ██£££ . ░██£££ . ▒██£££ . ▓██£££ . ███£££ . ░███£££ . ▒███£££ . ▓███£££ . ████£££ . ░████£££ . ▒████£££ . ▓████£££ . █████£££ . ░█████£££ . ▒█████£££ . ▓█████£££ . ██████£££ . ██████£££ `.split(`.`)},fish:{interval:80,frames:`~~~~~~~~~~~~~~~~~~~~.> ~~~~~~~~~~~~~~~~~~.º> ~~~~~~~~~~~~~~~~~.(º> ~~~~~~~~~~~~~~~~.((º> ~~~~~~~~~~~~~~~.<((º> ~~~~~~~~~~~~~~.><((º> ~~~~~~~~~~~~~. ><((º> ~~~~~~~~~~~~.~ ><((º> ~~~~~~~~~~~.~~ <>((º> ~~~~~~~~~~.~~~ ><((º> ~~~~~~~~~.~~~~ <>((º> ~~~~~~~~.~~~~~ ><((º> ~~~~~~~.~~~~~~ <>((º> ~~~~~~.~~~~~~~ ><((º> ~~~~~.~~~~~~~~ <>((º> ~~~~.~~~~~~~~~ ><((º> ~~~.~~~~~~~~~~ <>((º> ~~.~~~~~~~~~~~ ><((º> ~.~~~~~~~~~~~~ <>((º> .~~~~~~~~~~~~~ ><((º>.~~~~~~~~~~~~~~ <>((º.~~~~~~~~~~~~~~~ ><((.~~~~~~~~~~~~~~~~ <>(.~~~~~~~~~~~~~~~~~ ><.~~~~~~~~~~~~~~~~~~ <.~~~~~~~~~~~~~~~~~~~~`.split(`.`)}};const ep=d?.WriteStream?.prototype?.hasColors?.()??!1,W=(e,t)=>{if(!ep)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}};W(0,0),W(1,22),W(2,22),W(3,23),W(4,24),W(`4:2`,24),W(`4:3`,24),W(`4:4`,24),W(`4:5`,24),W(53,55),W(7,27),W(8,28),W(9,29),W(30,39);const tp=W(31,39),np=W(32,39),rp=W(33,39),ip=W(34,39);W(35,39),W(36,39),W(37,39),W(90,39),W(40,49),W(41,49),W(42,49),W(43,49),W(44,49),W(45,49),W(46,49),W(47,49),W(100,49),W(91,39),W(92,39),W(93,39),W(94,39),W(95,39),W(96,39),W(97,39),W(101,49),W(102,49),W(103,49),W(104,49),W(105,49),W(106,49),W(107,49),W(`58;5;0`,59),W(`58;5;1`,59),W(`58;5;2`,59),W(`58;5;3`,59),W(`58;5;4`,59),W(`58;5;5`,59),W(`58;5;6`,59),W(`58;5;7`,59),W(`58;5;8`,59),W(`58;5;9`,59),W(`58;5;10`,59),W(`58;5;11`,59),W(`58;5;12`,59),W(`58;5;13`,59),W(`58;5;14`,59),W(`58;5;15`,59);function ap(){let{env:e}=o,{TERM:t,TERM_PROGRAM:n}=e;return o.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const op=ap(),sp=ip(op?`ℹ`:`i`),cp=np(op?`✔`:`√`),lp=rp(op?`⚠`:`‼`),up=tp(op?`✖`:`×`);function dp({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const fp=dp();function pp(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(fp,``)}const mp=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],hp=[12288,12288,65281,65376,65504,65510],gp=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141],_p=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},vp=19968,[yp,bp]=xp(gp);function xp(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(vp>=i&&vp<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}const Sp=e=>e<161||e>1114109?!1:_p(mp,e),Cp=e=>e<12288||e>65510?!1:_p(hp,e),wp=e=>e>=yp&&e<=bp?!0:e<4352||e>262141?!1:_p(gp,e);function Tp(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ep(e,{ambiguousAsWide:t=!1}={}){return Tp(e),Cp(e)||wp(e)||t&&Sp(e)?2:1}const Dp=new Intl.Segmenter,Op=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,kp=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Ap=/\p{Spacing_Mark}/v,jp=/^\p{RGI_Emoji}$/v,Mp=/^[\d#*]\u20E3$/,Np=/\p{Extended_Pictographic}/gu;function Pp(e){if(e.length>50)return!1;if(Mp.test(e))return!0;if(e.includes(``)){let t=e.match(Np);return t!==null&&t.length>=2}return!1}function Fp(e){return e.replace(kp,``)}function Ip(e){return Op.test(e)}function Lp(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Rp(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function zp(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Bp(e){return Lp(e)||Rp(e)||zp(e)}function Vp(e,t){let n=[];for(let t of e)Op.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!Bp(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=Ep(n[i],t);return r}if(Lp(i)&&Rp(n[e+1])){r+=2,e+=zp(n[e+2])?2:1;continue}r+=Ep(i,t)}return r}function Hp(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(Ap.test(i)||i>=``&&i<=``)&&(n+=Ep(i.codePointAt(0),t))}return n}function Up(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(``))&&(i=pp(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of Dp.segment(i)){if(Ip(e))continue;if(jp.test(e)||Pp(e)){a+=2;continue}let t=Fp(e),n=Vp(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=Ep(r,o),a+=Hp(t,o)}return a}function Wp({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!==`dumb`&&!(`CI`in process.env))}const Gp=new class{#e=0;#t;#n=!1;#r=!1;#i=e=>{e?.length&&(typeof e==`string`?e.codePointAt(0):e[0])===3&&o.kill(o.pid,`SIGINT`)};start(){this.#e++,this.#e===1&&this.#a()}stop(){this.#e!==0&&--this.#e===0&&this.#o()}#a(){let{stdin:e}=o;if(o.platform===`win32`||!e?.isTTY||typeof e.setRawMode!=`function`){this.#t=void 0;return}this.#t=e,this.#n=e.isPaused(),this.#r=!!e.isRaw,e.setRawMode(!0),e.prependListener(`data`,this.#i),this.#n&&e.resume()}#o(){if(!this.#t)return;let e=this.#t;e.off(`data`,this.#i),e.isTTY&&e.setRawMode?.(this.#r),this.#n&&e.pause(),this.#t=void 0,this.#n=!1,this.#r=!1}};var Kp=Object.freeze(Gp);const qp=new Map,Jp=new Set([`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`gray`]);var Yp=class{#e=0;#t=-1;#n=0;#r;#i;#a;#o;#s=new Map;#c=!1;#l;#u;#d=!1;#f;#p(e){this.#c=!0;try{return e()}finally{this.#c=!1}}#m(){this.isSpinning&&this.render()}#h(e,t){if(e==null)return``;if(typeof e==`string`)return e;if(Buffer.isBuffer(e)||ArrayBuffer.isView(e)){let n=typeof t==`string`&&t&&t!==`buffer`?t:`utf8`;return Buffer.from(e).toString(n)}return String(e)}#g(e){if(!e)return!1;let t=e.at(-1);return t===`
|
|
118
|
+
`||t===`\r`}#_(){this.#u||(this.#u=setTimeout(()=>{this.#u=void 0,this.isSpinning&&this.#m()},200),typeof this.#u?.unref==`function`&&this.#u.unref())}#v(){this.#u&&=(clearTimeout(this.#u),void 0)}#y(e,t,n,r){let i=this.#x(n,` `),a=typeof t==`string`?(e?` `:``)+t:``,o=this.#S(r,` `);return i+e+a+o}constructor(e){if(typeof e==`string`&&(e={text:e}),this.#r={color:`cyan`,stream:o.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#r.color,this.#a=this.#r.stream,typeof this.#r.isEnabled!=`boolean`&&(this.#r.isEnabled=Wp({stream:this.#a})),typeof this.#r.isSilent!=`boolean`&&(this.#r.isSilent=!1),this.#r.interval!==void 0&&!(Number.isInteger(this.#r.interval)&&this.#r.interval>0))throw Error("The `interval` option must be a positive integer");let t=this.#r.interval;this.spinner=this.#r.spinner,this.#r.interval=t,this.text=this.#r.text,this.prefixText=this.#r.prefixText,this.suffixText=this.#r.suffixText,this.indent=this.#r.indent,o.env.NODE_ENV===`test`&&(this._stream=this.#a,this._isEnabled=this.#r.isEnabled,Object.defineProperty(this,`_linesToClear`,{get(){return this.#e},set(e){this.#e=e}}),Object.defineProperty(this,`_frameIndex`,{get(){return this.#t}}),Object.defineProperty(this,`_lineCount`,{get(){let e=this.#a.columns??80,t=typeof this.#r.prefixText==`function`?``:this.#r.prefixText,n=typeof this.#r.suffixText==`function`?``:this.#r.suffixText,r=typeof t==`string`&&t!==``?t+` `:``,i=typeof n==`string`&&n!==``?` `+n:``,a=` `.repeat(this.#r.indent)+r+`-`+(typeof this.#r.text==`string`?` `+this.#r.text:``)+i;return this.#C(a,e)}}))}get indent(){return this.#r.indent}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw Error("The `indent` option must be an integer from 0 and up");this.#r.indent=e}get interval(){return this.#r.interval??this.#i.interval??100}get spinner(){return this.#i}set spinner(e){if(this.#t=-1,this.#r.interval=void 0,typeof e==`object`){if(!Array.isArray(e.frames)||e.frames.length===0||e.frames.some(e=>typeof e!=`string`))throw Error("The given spinner must have a non-empty `frames` array of strings");if(e.interval!==void 0&&!(Number.isInteger(e.interval)&&e.interval>0))throw Error("`spinner.interval` must be a positive integer if provided");this.#i=e}else if(!ap())this.#i=$f.line;else if(e===void 0)this.#i=$f.dots;else if(e!==`default`&&$f[e])this.#i=$f[e];else throw Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#r.text}set text(e=``){this.#r.text=e}get prefixText(){return this.#r.prefixText}set prefixText(e=``){this.#r.prefixText=e}get suffixText(){return this.#r.suffixText}set suffixText(e=``){this.#r.suffixText=e}get isSpinning(){return this.#o!==void 0}#b(e,t,n=!1){let r=typeof e==`function`?e():e;return typeof r==`string`&&r!==``?n?t+r:r+t:``}#x(e=this.#r.prefixText,t=` `){return this.#b(e,t,!1)}#S(e=this.#r.suffixText,t=` `){return this.#b(e,t,!0)}#C(e,t){let n=0;for(let r of u(e).split(`
|
|
119
|
+
`))n+=Math.max(1,Math.ceil(Up(r)/t));return n}get color(){return this.#f}set color(e){if(e!==void 0&&e!==!1&&!Jp.has(e))throw Error("The `color` option must be a valid color or `false` to disable");this.#f=e}get isEnabled(){return this.#r.isEnabled&&!this.#r.isSilent}set isEnabled(e){if(typeof e!=`boolean`)throw TypeError("The `isEnabled` option must be a boolean");this.#r.isEnabled=e}get isSilent(){return this.#r.isSilent}set isSilent(e){if(typeof e!=`boolean`)throw TypeError("The `isSilent` option must be a boolean");this.#r.isSilent=e}frame(){let e=Date.now();(this.#t===-1||e-this.#n>=this.interval)&&(this.#t=(this.#t+1)%this.#i.frames.length,this.#n=e);let{frames:t}=this.#i,n=t[this.#t];this.#f&&(n=Sf[this.#f](n));let r=this.#x(this.#r.prefixText,` `),i=typeof this.text==`string`?` `+this.text:``,a=this.#S(this.#r.suffixText,` `);return r+n+i+a}clear(){return!this.isEnabled||!this.#a.isTTY?this:(this.#p(()=>{this.#a.cursorTo(0);for(let e=0;e<this.#e;e++)e>0&&this.#a.moveCursor(0,-1),this.#a.clearLine(1);this.#r.indent&&this.#a.cursorTo(this.#r.indent)}),this.#e=0,this)}#w(e){if(!e||this.#s.has(e)||!e.isTTY||typeof e.write!=`function`)return;qp.has(e)&&console.warn(`[ora] Multiple concurrent spinners detected. This may cause visual corruption. Use one spinner at a time.`);let t=e.write;this.#s.set(e,t),qp.set(e,this),e.write=(n,r,i)=>this.#D(e,t,n,r,i)}#T(){if(!this.isEnabled||this.#s.size>0)return;let e=new Set([this.#a,o.stdout,o.stderr]);for(let t of e)this.#w(t)}#E(){for(let[e,t]of this.#s)e.write=t,qp.get(e)===this&&qp.delete(e);this.#s.clear()}#D(e,t,n,r,i){if(typeof r==`function`&&(i=r,r=void 0),this.#c)return t.call(e,n,r,i);this.clear();let a=this.#h(n,r),o=this.#g(a),s=t.call(e,n,r,i);return o?this.#v():a.length>0&&this.#_(),this.isSpinning&&!this.#u&&this.render(),s}render(){if(!this.isEnabled||this.#l||this.#u)return this;let e=this.#a.isTTY,t=!1;try{e&&(this.#p(()=>this.#a.write(`\x1B[?2026h`)),t=!0),this.clear();let n=this.frame(),r=this.#a.columns??80,i=this.#C(n,r),a=this.#a.rows;if(a&&a>1&&i>a){let e=n.split(`
|
|
120
120
|
`),t=a-1;n=[...e.slice(0,t),`... (content truncated to fit terminal)`].join(`
|
|
121
121
|
`)}this.#p(()=>this.#a.write(n))===!1&&this.#a.isTTY&&(this.#l=()=>{this.#l=void 0,this.#m()},this.#a.once(`drain`,this.#l)),this.#e=this.#C(n,r)}finally{t&&this.#p(()=>this.#a.write(`\x1B[?2026l`))}return this}start(e){if(e!==void 0&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let e=this.text?`-`:``,t=` `.repeat(this.#r.indent)+this.#y(e,this.text,this.#r.prefixText,this.#r.suffixText);return t.trim()!==``&&this.#p(()=>this.#a.write(t+`
|
|
122
|
-
`)),this}return this.isSpinning?this:(this.#r.hideCursor&&
|
|
123
|
-
`;return this.stop(),this.#p(()=>this.#a.write(a)),this}};function
|
|
124
|
-
`)}},
|
|
125
|
-
`)}))}function Um(e){process.env[Hm]===`1`?console.trace(e):q.error(W.default.red(e.toString())),process.exit(1)}async function Q(e){try{return await e()}catch(e){return e instanceof P?Um(e):Um(new P(e instanceof Error?e.message:String(e),{suggestion:`Run with ${Hm}=1 for a stack trace.`,cause:e}))}}function Wm(){let e=_m();if(!e)throw new tl;return new gm(e,bm())}function Gm(e,t){if(t)return t;let n=hl(e);if(!n)throw new nl;return n}const Km=`~/.agents/skills`;function qm(e){let t=b.normalize(s.homedir());return e===t||e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}async function Jm(e,t={}){for(let n of e.skipped){if(n.reason===`tracked`){q.warn(`\`${n.name}\` is tracked by git here, so it was left alone.`);continue}let e=(n.occupied?.paths??[]).map(qm).join(` and `);if(!(t.yes||$p&&await Qp(`Overwrite ${e}?`,!1))){$p?q.dim(`Kept ${e}, so ${n.name} is not linked there.`):(q.warn(`Skipped ${n.name}: ${e} was not made by skilless.`),q.dim(` Run this in a terminal to overwrite it, or pass --yes.`));continue}pu(n,{copy:bu(t.copy)}),q.step(`Overwrote ${e}.`)}for(let t of e.missing??[])q.warn(`${t} is not on this machine yet, so it will be linked on the next sync.`)}const Ym=Y.extend({project:j().optional(),copy:N().optional(),global:N().optional(),notGlobal:N().optional(),overwrite:N(),yes:N()}),Xm=new y(`add`).description(`Add skills to this project, from your library or from a git repository.`).argument(`[skills...]`,"Skills to add, or a repo (`owner/repo` or any git URL) then the skills to take from it. Omit the skills to pick from a list.").option(`-g, --global`,`Make these skills global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has them, including cloud agents.`).option(`--not-global`,`Stop treating these skills as global, and unlink them from your user-level skills.`).option(`--copy`,`Write real files instead of symlinking into the store.`).option(`--overwrite`,`From a repo: replace library skills of the same name.`,!1).addOption(X.yes).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Ym,t);q.intro(J),await Q(async()=>{let t=new xm,[r,...i]=e;if(r&&Sm(r)){await $m(t,Cm(r),i,n);return}let a=e.find(Sm);if(a)throw new P(`${a} is a repository, not a skill.`,{suggestion:`Name the repository first: \`skilless add ${a} <skills...>\`.`});let{entries:o,live:s}=await K(`Loading your library`,async()=>(await L(t),R(t))),c=e=>s||e.local!==null,l=e=>{let t=o.filter(t=>e.includes(t.name)&&!c(t)).map(e=>e.name);if(t.length!==0)throw new P(`${t.join(`, `)} ${t.length===1?`is`:`are`} not on this machine, and the server can't be reached to fetch ${t.length===1?`it`:`them`}.`,{suggestion:"Run `skilless sync` once you are back online, then try again."})},u=new Set(o.map(e=>e.name)),d=e.filter(e=>!u.has(e));if(d.length>0)throw new P(`Not in your library: ${d.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(n.global||n.notGlobal){let r=n.global===!0,i=e;if(i.length===0){let e=o.filter(e=>e.global!==r&&(!r||c(e)));if(e.length===0){q.info(r?`Every skill in your library is already global.`:`No skills in your library are global.`);return}if(i=await tm(r?`Make global`:`Stop being global`,e.map(e=>({name:e.name}))),i.length===0){q.info(`Nothing selected.`);return}}r&&l(i),await Zm(t,i,r,n),t.report();return}let f=Gm(n.cwd,n.project),p=new Set(await K(`Loading ${f}`,()=>Hu(t,f))),m=e;if(m.length===0){let e=o.filter(e=>!p.has(e.name)&&c(e));if(e.length===0){q.info(s?`Every skill in your library is already in this project.`:`Every skill on this machine is already in this project.`),t.report();return}if(m=await tm(`Add to ${f}`,e.map(e=>({name:e.name}))),m.length===0){q.info(`Nothing selected.`);return}}let h=o.filter(e=>e.global).map(e=>e.name);l(m.filter(e=>!h.includes(e))),await Qm(t,f,m,h,n),t.report()})});async function Zm(e,t,n,r){Mu(t,n),await K(`Saving to skilless.dev`,()=>L(e));for(let e of t)q.step(n?`${e} is now global, so every project has it.`:`${e} is no longer global.`);let i=r.project??hl(r.cwd),a=gu(r.cwd),[o,s]=await K(`Updating your skills`,async()=>{if(!i){let t=await qu(e);return[t,t]}let t=await Wu(e,a,i,{copy:r.copy});return[t,t.user]});for(let e of s.written.filter(e=>t.includes(e)))q.dim(`Linked ${e} into ${Km}.`);for(let e of s.removed)q.dim(`Unlinked ${e} from ${Km}.`);if(`project`in o){for(let e of o.project.removed)q.dim(`Moved ${e} out of this project.`);for(let e of o.project.written.filter(e=>t.includes(e)))q.dim(`${e} is still added to this project, so it is linked here again.`)}await Jm(o,r)}async function Qm(e,t,n,r,i){for(let e of n)r.includes(e)&&q.dim(`${e} is global, so it is already in this project.`);let a=n.filter(e=>!r.includes(e));Au(t,a);let o=gu(i.cwd),s=await K(`Updating this project`,async()=>(await L(e),Wu(e,o,t,{copy:i.copy})));for(let e of a)q.step(`Added ${e} to this project.`);await Jm(s,i)}async function $m(e,t,n,r){if(r.notGlobal)throw new P(`--not-global only applies to skills already in your library.`);let i=r.global?null:r.project??hl(r.cwd),a=await K(`Loading your library`,async()=>(await L(e),R(e))),o=new Map(a.entries.map(e=>[e.name,e])),s=[...n,...t.skill?[t.skill]:[]],c=await Dm(t,async e=>{let n=Mm(e,t.subpath);if(n.length===0)throw new P(`No skills found in ${t.label}.`,{suggestion:`A skill is a directory containing a SKILL.md.`});let i=n;if(s.length>0){let e=e=>n.find(t=>t.name===e.toLowerCase()||t.dir.split(`/`).at(-1)?.toLowerCase()===e.toLowerCase()),r=s.filter(t=>!e(t));if(r.length>0)throw new P(`Not in ${t.label}: ${r.join(`, `)}`,{suggestion:`It has: ${n.map(e=>e.name).join(`, `)}`});i=[...new Set(s.map(t=>e(t)))]}else if(n.length>1&&!r.yes){if(!$p)throw new P(`${t.label} has ${n.length} skills.`,{suggestion:`Name the ones you want after the repository, or pass --yes for all of them: ${n.map(e=>e.name).join(`, `)}`});let e=await tm(`Add from ${t.label}`,n.map(e=>({name:e.name,hint:eh(e.description)})));i=n.filter(t=>e.includes(t.name))}let a=[];for(let t of i)try{Wl(t.name),a.push({skill:Kl(t.dir,t.name),path:b.relative(e,t.dir)})}catch(e){q.warn(`Skipped ${t.name}: ${e instanceof P?e.message:e}`)}return a},{interactive:$p});if(c.length===0){q.info(`Nothing selected.`),e.report();return}let l=[],u=[],d=new Map;for(let{skill:e,path:n}of c){d.set(e.name,{url:t.url,...t.ref?{ref:t.ref}:{},path:n,hash:e.contentHash});let i=o.get(e.name),a=i?.local?.contentHash??i?.remote?.contentHash;if(!i||a===e.contentHash){i?zu(e.name,d.get(e.name)):l.push(e),u.push(e.name);continue}if(!(r.overwrite||$p&&!r.yes&&await Qp(`${e.name} is already in your library. Replace it with the one from ${t.label}?`))){q.warn(`Kept your own ${e.name}. Pass --overwrite to replace it.`);continue}l.push(e),u.push(e.name)}let f=await K(`Saving ${l.length} skill(s) to your library`,()=>Ju(e,l,o,d));for(let e of f)q.step(`Copied ${e} into your library from ${t.label}.`);if(u.length===0){e.report();return}r.global?await Zm(e,u,!0,r):i?await Qm(e,i,u,(await K(`Loading your library`,()=>R(e))).entries.filter(e=>e.global).map(e=>e.name),r):(q.blank(),q.dim(`This directory has no git remote, so ${u.length===1?`it is`:`they are`} only in your library. Run \`skilless add ${u[0]}\` inside a project to add ${u.length===1?`it`:`them`} there.`)),e.report()}function eh(e){if(e)return e.length>60?`${e.slice(0,57)}...`:e}function th(e){switch(process.platform){case`darwin`:return[`open`,[e]];case`win32`:return[`rundll32`,[`url.dll,FileProtocolHandler`,e]];default:return[`xdg-open`,[e]]}}function nh(e){let[t,n]=th(e);try{let e=r(t,n,{stdio:`ignore`,detached:!0,windowsHide:!0});e.on(`error`,()=>{}),e.unref()}catch{}}async function rh(){let e=c.randomBytes(16).toString(`hex`),t=bm(),n=new URL(t).origin,r={"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`,"Access-Control-Allow-Private-Network":`true`},i,a=new Promise((e,t)=>{i={resolve:e,reject:t}}),o=d.createServer((t,n)=>{if(t.method===`OPTIONS`){n.writeHead(204,r),n.end();return}if(t.method!==`POST`){n.writeHead(405,r),n.end();return}let a=``;t.on(`data`,e=>{a+=e}),t.on(`end`,()=>{let t;try{t=JSON.parse(a)}catch{n.writeHead(400,r),n.end();return}if(t.state!==e||!t.token){n.writeHead(400,r),n.end();return}n.writeHead(200,{...r,"Content-Type":`application/json`}),n.end(JSON.stringify({ok:!0})),i.resolve(t.token)})}),s=setTimeout(()=>{i.reject(new P(`Timed out waiting for sign in.`,{suggestion:"Run `skilless auth` again, or paste a token with `skilless auth --token <token>`."}))},3e5);try{await new Promise((e,t)=>{o.once(`error`,t),o.listen(0,`127.0.0.1`,e)});let{port:n}=o.address(),r=`${t}/cli/auth?port=${n}&state=${e}`;q.info(`Opening your browser to sign in…`),q.dim(r),q.blank(),nh(r),vm(await K(`Waiting for you to sign in`,()=>a))}finally{clearTimeout(s),o.close()}}const ih=Y.extend({logout:N(),token:j().optional()}),ah=new y(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new _e(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new _e(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(X.cwd).action(async e=>{let t=Z(ih,e);q.intro(J),await Q(async()=>{if(t.logout){if(!_m()){q.info(`You were not signed in.`);return}ym(),q.step(`Signed out on this machine.`);return}if(t.token){vm(t.token),q.step(`Token saved. You are signed in to skilless.dev.`);return}await rh(),q.step(`Signed in to skilless.dev.`)})}),oh=s.homedir(),sh=process.env.LOCALAPPDATA??b.join(oh,`AppData`,`Local`),ch=process.env.ProgramFiles??`C:/Program Files`,$={cursor:{label:`Cursor`,cli:`cursor`,fallbacks:{darwin:[`/Applications/Cursor.app/Contents/Resources/app/bin/cursor`,`${oh}/Applications/Cursor.app/Contents/Resources/app/bin/cursor`],win32:[b.join(sh,`Programs/cursor/resources/app/bin/cursor.cmd`)],linux:[`/usr/share/cursor/bin/cursor`,`/opt/Cursor/resources/app/bin/cursor`]}},vscode:{label:`VS Code`,cli:`code`,fallbacks:{darwin:[`/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`,`${oh}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`],win32:[b.join(sh,`Programs/Microsoft VS Code/bin/code.cmd`),b.join(ch,`Microsoft VS Code/bin/code.cmd`)],linux:[`/usr/share/code/bin/code`,`/snap/bin/code`]}},windsurf:{label:`Windsurf`,cli:`windsurf`,fallbacks:{darwin:[`/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`,`${oh}/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`],win32:[b.join(sh,`Programs/Windsurf/bin/windsurf.cmd`)],linux:[`/usr/share/windsurf/bin/windsurf`]}},zed:{label:`Zed`,cli:`zed`,fallbacks:{darwin:[`/Applications/Zed.app/Contents/MacOS/cli`,`${oh}/Applications/Zed.app/Contents/MacOS/cli`],win32:[b.join(sh,`Programs/Zed/bin/zed.exe`)],linux:[`${oh}/.local/bin/zed`]}},sublime:{label:`Sublime Text`,cli:`subl`,fallbacks:{darwin:[`/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl`],win32:[b.join(ch,`Sublime Text/subl.exe`)],linux:[`/opt/sublime_text/sublime_text`]}},neovim:{label:`Neovim`,cli:`nvim`,terminal:!0},vim:{label:`Vim`,cli:`vim`,terminal:!0}},lh=Object.keys($);function uh(e){return Object.hasOwn($,e)}function dh(e){let t=i(process.platform===`win32`?`where`:`which`,[e],{encoding:`utf8`,windowsHide:!0});if(t.status!==0||!t.stdout)return null;let n=t.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return process.platform===`win32`?n.find(e=>/\.(exe|cmd|bat)$/i.test(e))??n[0]??null:n[0]??null}function fh(e){let t=$[e],n=dh(t.cli);if(n)return n;let r=process.platform;return t.fallbacks?.[r]?.find(e=>F(e))??null}function ph(){return lh.filter(e=>fh(e)!==null)}function mh(e){return $[e].terminal===!0}function hh(e,t){let n=fh(e);if(!n)return Promise.reject(Error(`${$[e].label} was not found. Is \`${$[e].cli}\` on your PATH?`));let i=mh(e);return new Promise((e,a)=>{let o=r(n,[t],{cwd:b.dirname(t),stdio:i?`inherit`:`ignore`,detached:!i,windowsHide:!0,shell:process.platform===`win32`&&/\.(cmd|bat)$/i.test(n)});o.on(`error`,a),i?o.on(`exit`,()=>e()):(o.unref(),setImmediate(e))})}function gh(){let e=cl(Ol,{});return e.editor!==void 0&&!uh(e.editor)&&delete e.editor,e}function _h(e){ll(Ol,e)}function vh(e){let t={...gh(),...e};for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return _h(t),t}const yh=`none`,bh=Tc({unset:N()}),xh=new y(`editor`).description("Choose the editor `skilless create` opens a new skill in.").argument(`[editor]`,`Set it directly: ${lh.join(`, `)}.`).addOption(new _e(`--unset`,`Stop opening new skills in an editor.`).default(!1)).action(async(e,t)=>{let n=Z(bh,t);q.intro(J),await Q(async()=>{let t=gh().editor;if(n.unset){vh({editor:void 0}),q.step(`New skills will no longer open in an editor.`);return}if(e){if(!uh(e))throw new P(`${e} is not an editor skilless knows.`,{suggestion:`Pick one of: ${lh.join(`, `)}.`});vh({editor:e}),q.step(`New skills will open in ${$[e].label}.`);return}if(!$p){q.info(t?`Editor: ${$[t].label}`:`No editor set.`);return}let r=ph();if(r.length===0)throw new P(`None of the editors skilless knows are installed.`,{suggestion:`skilless looks for: ${lh.map(e=>$[e].cli).join(`, `)}.`});let i=await nm(`Open new skills in`,[...r.map(e=>({name:e,message:$[e].label,hint:e===t?W.default.gray(`current`):void 0})),{name:yh,message:`None`,hint:t?void 0:W.default.gray(`current`)}],t??yh);if(i===yh){vh({editor:void 0}),q.step(`New skills will not open in an editor.`);return}uh(i)&&(vh({editor:i}),q.step(`New skills will open in ${$[i].label}.`))})}),Sh=new y(`config`).description(`View or change your skilless settings.`).addCommand(xh).action(async()=>{q.intro(J),await Q(async()=>{let e=gh();q.info(`editor ${e.editor?$[e.editor].label:W.default.gray(`not set`)}`),q.blank(),q.dim(`Stored in ${Ol}`)})}),Ch=Y.extend({description:j().optional(),project:j().optional(),global:N().optional(),open:N()}),wh=new y(`create`).description(`Create a skill, add it to this project, and print the path to edit it.`).argument(`[name]`,`The name of the skill. You will be asked if you leave it out.`).option(`-d, --description <description>`,`What the skill does, for the frontmatter.`).option(`-g, --global`,`Make it global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has it, including cloud agents.`).option(`--no-open`,"Do not open SKILL.md in your editor (see `skilless config editor`).").addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Ch,t);q.intro(J),await Q(async()=>{let t=new xm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Set(r.entries.map(e=>e.name)),a=e;if(!a){if(!$p)throw new P(`No name given.`,{suggestion:"Run `skilless create <name>`."});a=await em(`Name`,{validate:e=>e?Ul(e)?i.has(e)?`${e} already exists in your library.`:!0:`Use lowercase letters, digits, dots, dashes and underscores.`:`A name is required.`})}if(Wl(a),Xl(a))throw new P(`${a} already exists in your library.`,{suggestion:`Edit it at ${b.join(Al(a),`SKILL.md`)}`});if(i.has(a))throw new P(`${a} already exists in your library.`,{suggestion:`Run \`skilless sync\` to bring ${a} down to this machine.`});let o=n.description??await em(`What does this skill do?`);ql(a,Zl(a,o));let s=Kl(Al(a),a);if(await K(`Creating ${a}`,()=>t.try(e=>e.putSkill(a,s.files,s.editedAt)))){let e=vu();e.skills[a]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:Date.now()},yu(e)}q.step(`Created ${a} in your library.`),n.global&&Mu([a],!0);let c=n.project??hl(n.cwd);if(c){n.global||Au(c,[a]);let e=gu(n.cwd);await Jm(await K(`Updating this project`,async()=>(await L(t),Wu(t,e,c))))}else n.global?await Jm(await K(`Linking your global skills`,async()=>(await L(t),qu(t)))):await K(`Saving to skilless.dev`,()=>L(t));n.global?q.step(`${a} is now global, so every project has it.`):c?q.step(`Added ${a} to ${c}.`):q.warn(`No git remote here, so ${a} was not added to a project.`);let l=b.join(Al(a),`SKILL.md`),u=n.open?gh().editor:void 0,d=u&&(!mh(u)||$p);if(q.blank(),u&&d)try{q.dim(`Opening ${a} in ${$[u].label}...`),await hh(u,l)}catch(e){q.warn(e instanceof Error?e.message:String(e)),q.dim(`Edit ${a} at ${l}`)}else q.dim(`Edit ${a} at ${l}`);t.api&&q.dim("Run `skilless sync` to save your changes."),t.report()})}),Th=Y.extend({yes:N()}),Eh=new y(`delete`).description(`Delete skills from your library, everywhere.`).argument(`<skills...>`,`Skills to delete.`).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Th,t);q.intro(J),await Q(async()=>{let t=new xm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Set(r.entries.map(e=>e.name)),a=e.filter(e=>!i.has(e));if(a.length>0)throw new P(`Not in your library: ${a.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(q.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),q.dim(`Run \`skilless remove ${e.join(` `)}\` to take ${e.length===1?`it`:`them`} out of just this project.`),!(n.yes||await Qp(`Delete ${e.join(`, `)}?`,!1))){q.info(`Nothing was deleted.`);return}Pu(e),Bu(e);let o=vu(),s=gu(n.cwd);for(let t of e)I(Al(t)),delete o.skills[t],q.step(`Deleted ${t} from your library.`);yu(o),mu(s,e),mu($l(),e),await K(`Deleting from skilless.dev`,()=>L(t)),q.blank(),q.dim("Other checkouts will clean up on their next `skilless install`."),q.dim(`Restore at skilless.dev/skills within 30 days.`),t.report()})}),Dh=Y.extend({yes:N(),overwrite:N()});function Oh(e){return a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:b.join(e,t.name)})).filter(e=>F(b.join(e.dir,zl))).sort((e,t)=>e.name.localeCompare(t.name))}const kh=new y(`import`).description(`Import a directory of existing skills into your library.`).argument(`<dir>`,`A directory whose subdirectories each contain a SKILL.md.`).option(`--overwrite`,`Replace skills that already exist.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Dh,t);q.intro(J),await Q(async()=>{let t=new xm,r=b.resolve(n.cwd,e);if(!F(r))throw new P(`${r} does not exist.`);let i=Oh(r);if(i.length===0)throw new P(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${zl}.`});let a=await K(`Loading your library`,async()=>(await L(t),R(t))),o=new Map(a.entries.map(e=>[e.name,e])),s=[],c=[];for(let e of i){if(!Ul(e.name)){c.push({name:e.name,reason:`invalid name`});continue}if(o.has(e.name)&&!n.overwrite){c.push({name:e.name,reason:`already in your library`});continue}try{s.push(Kl(e.dir,e.name))}catch(t){c.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of c)q.warn(`Skipped ${e.name}: ${e.reason}.`);if(s.length===0){q.info(`Nothing to import.`),t.report();return}if(q.blank(),q.info(`Importing: ${s.map(e=>e.name).join(`, `)}`),!(n.yes||await Qp(`Import ${s.length} skill(s)?`,!0)))return;let l=await K(`Importing ${s.length} skill(s)`,()=>Ju(t,s,o));for(let e of l)q.step(`Imported ${e} into your library.`);q.blank(),q.dim(`Run \`skilless add ${s[0]?.name??`<skill>`}\` to add one to this project.`),t.report()})}),Ah=new y(`init`).description(`Create the local skilless directory.`).addOption(X.cwd).action(async e=>{Z(Y,e),q.intro(J),await Q(async()=>{let e=!F(Sl);al(Sl),q.step(`${e?`Created`:`Found`} your library at ${xl}.`),q.blank(),q.dim("Run `skilless create <name>` to make a skill."),q.dim("Run `skilless import <dir>` to bring in skills you already have."),_m()||q.dim("Run `skilless auth` to sync your skills with the cloud.")})}),jh=Y.extend({project:j().optional(),copy:N().optional()}),Mh=new y(`install`).description(`Install every skill added to this project, and your global skills at the user level.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async e=>{let t=Z(jh,e);q.intro(J),await Q(async()=>{let e=Wm(),n=Gm(t.cwd,t.project),r=gu(t.cwd),i=await K(`Installing ${n}'s skills`,async()=>(await Fu(e),Cu(e,r,n,{copy:t.copy}))),{project:a,user:o}=i;for(let e of[...a.pruned,...o.pruned])q.dim(`Pruned ${e}, which is no longer in your library.`);for(let e of[...a.fetched,...o.fetched])q.dim(`Fetched ${e} from your library.`);for(let e of a.removed)q.dim(`Removed ${e}, which is no longer in this project.`);for(let e of o.removed)q.dim(`Removed ${e} from ${Km}, since it is no longer global.`);for(let e of a.written)q.step(`Installed ${e}.`);for(let e of o.written)q.step(`Installed ${e} globally.`);if(i.count===0){q.info(`No skills added to ${n} yet.`),q.dim("Run `skilless add <skill>` to add one.");return}await Jm(i,{copy:t.copy}),q.blank(),q.dim(bu(t.copy)?`Wrote real files into .agents/skills, and global skills into ~/.agents/skills.`:`Linked .agents/skills, and global skills in ~/.agents/skills, to your library.`)})}),Nh=Y.extend({project:Dc([N(),j()]).optional()});function Ph(e,t){let n=[];return e.global&&n.push(`global`),e.source&&n.push(`from ${ml(e.source.url)??e.source.url}`),e.local?t&&e.unsynced&&n.push(`not synced`):n.push(`not on this machine`),n.map(e=>` · ${e}`).join(``)}const Fh=new y(`list`).description(`List your skills, or the ones added to this project.`).option(`-p, --project [key]`,`List this project’s skills instead of your library.`).addOption(X.cwd).action(async e=>{let t=Z(Nh,e);q.intro(J),await Q(async()=>{let e=new xm,n=await K(`Loading your library`,async()=>(await L(e),R(e)));if(t.project!==void 0){let r=Gm(t.cwd,typeof t.project==`string`?t.project:void 0),i=Uu(n,await K(`Loading ${r}`,()=>Hu(e,r)));q.info(`${W.default.bold(r)}`),q.blank(),i.length===0&&q.dim("No skills in this project. Run `skilless add <skill>` to add one.");for(let t of i)q.dim(` ${t.name}${W.default.gray(Ph(t,e.api!==null))}`);e.report();return}n.entries.length===0&&q.dim("Your library is empty. Run `skilless create <name>` to make one.");for(let t of n.entries){let n=t.local?.editedAt??t.remote?.updatedAt??0,r=new Date(n).toISOString().slice(0,10);q.dim(` ${t.name.padEnd(28)} ${W.default.gray(r+Ph(t,e.api!==null))}`)}e.report()})}),Ih=Y.extend({yes:N(),user:N().optional()});function Lh(e,t){return F(e)?a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.isSymbolicLink()).map(n=>({name:n.name,dir:b.join(e,n.name),scope:t})).filter(e=>F(b.join(e.dir,zl))):[]}const Rh=new y(`migrate`).description(`Move this project's skills into your library and link them back. Offers your user-level skills too, as globals linked back at the user level.`).option(`--user`,`Migrate your user-level skills too, without asking.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(Ih,e);q.intro(J),await Q(async()=>{let e=new xm,n=gu(t.cwd),r=hl(t.cwd),i=r?[jl,Ml].flatMap(e=>Lh(b.join(n,e),`project`).filter(e=>{let t=vl(n,b.relative(n,e.dir));return t&&q.warn(`${e.name} is committed to this repo, so it was left alone. Remove it from git first to migrate it.`),!t})):[],a=[...Lh(Fl(),`user`),...Lh(Pl(),`user`)];if(r||q.dim(`No git remote here, so there are no project skills to migrate.`),i.length===0&&a.length===0){q.info(`Nothing to migrate.`);return}let o=await K(`Loading your library`,async()=>(await L(e),R(e))),s=new Map(o.entries.map(e=>[e.name,e])),c=async e=>{let t=new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);let n=[];for(let[e,r]of[...t].sort(([e],[t])=>e.localeCompare(t))){if(!Ul(e)){q.warn(`Skipped ${e}: not a valid skill name.`);continue}let t;try{t=r.map(t=>Kl(t.dir,e))}catch(t){q.warn(`Skipped ${e}: ${t instanceof Error?t.message:`unreadable`}.`);continue}let i=t[0];if(!i)continue;if(t.some(e=>e.contentHash!==i.contentHash)){q.warn(`Skipped ${e}: found more than one version (${r.map(e=>e.dir).join(`, `)}).`);continue}let a=s.get(e),o=a?.local?.contentHash??a?.remote?.contentHash;if(o&&o!==i.contentHash){q.warn(`Skipped ${e}: a different ${e} is already in your library. Rename one to migrate it.`);continue}n.push({skill:i,dirs:r.map(e=>e.dir),scope:r.some(e=>e.scope===`user`)?`user`:`project`,adopted:o!==void 0})}return n},l=await c(i);if(l.length>0&&(q.info(`Project skills in ${r}: ${l.map(e=>e.skill.name).join(`, `)}`),t.yes||await Qp(`Move ${l.length} skill(s) into skilless and link them here?`,!0)||(l=[])),a.length>0){let e=[...new Set(a.map(e=>e.name))].sort();if(q.info(`User-level skills: ${e.join(`, `)}`),t.user||!t.yes&&$p&&await Qp(`Would you also like to migrate your user-level skills? They become global and are linked back into ~/.agents/skills, so every project still gets them.`,!1)){let e=new Set(l.map(e=>e.skill.name)),t=await c([...a,...i.filter(e=>a.some(t=>t.name===e.name))]);l=[...l.filter(e=>!t.some(t=>t.skill.name===e.skill.name)),...t];for(let t of e)l.some(e=>e.skill.name===t)||q.warn(`Skipped ${t}: its project and user-level copies differ.`)}}if(l.length===0){q.info(`Nothing was migrated.`);return}let u=vu();for(let{skill:t,adopted:n}of l)ql(t.name,t.files,t.editedAt),!n&&(await K(`Saving ${t.name} to your library`,()=>e.try(e=>e.putSkill(t.name,t.files,t.editedAt)))?u.skills[t.name]={contentHash:t.contentHash,editedAt:t.editedAt,syncedAt:Date.now()}:delete u.skills[t.name]);yu(u);for(let{dirs:e}of l)for(let t of e)I(t);let d=l.filter(e=>e.scope===`user`).map(e=>e.skill.name),f=l.filter(e=>e.scope===`project`).map(e=>e.skill.name);d.length>0&&Mu(d,!0),r&&f.length>0&&Au(r,f),await K(`Saving to skilless.dev`,()=>L(e));for(let e of f)q.step(`Migrated ${e} into your library and this project.`);for(let e of d)q.step(`Migrated ${e} into your library as a global skill.`);r?await Jm(await K(`Updating this project`,()=>Wu(e,n,r)),{yes:t.yes}):d.length>0&&await Jm(await K(`Linking your global skills`,()=>qu(e)),{yes:t.yes}),e.report()})}),zh=Y.extend({project:j().optional(),copy:N().optional()}),Bh=new y(`remove`).description(`Remove skills from this project. They stay in your library.`).argument(`<skills...>`,`Skills to remove.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(zh,t);q.intro(J),await Q(async()=>{let t=new xm,r=Gm(n.cwd,n.project),[i,a]=await K(`Loading your library`,async()=>(await L(t),[await R(t),new Set(await Hu(t,r))])),o=new Set(i.entries.filter(e=>e.global).map(e=>e.name)),s=[];for(let t of e){if(o.has(t)){q.warn(`${t} is global, so it is in every project.`),q.dim(` Run \`skilless add --not-global ${t}\` to take it out of every project.`);continue}if(!a.has(t)){q.warn(`${t} is not in this project.`);continue}s.push(t)}if(s.length===0){t.report();return}ju(r,s);let c=gu(n.cwd),l=await K(`Updating this project`,async()=>(await L(t),Wu(t,c,r,{copy:n.copy})));for(let e of s)q.step(`Removed ${e} from this project.`);await Jm(l,{copy:n.copy}),q.blank(),q.dim(`Run \`skilless delete ${s.join(` `)}\` to delete ${s.length===1?`it`:`them`}.`),t.report()})});function Vh(e,t,n,r){let i=[...new Set([...e.keys(),...t.keys()])].sort(),a=[];for(let o of i){let i=e.get(o),s=t.get(o),c=n.skills[o];if(i&&s){if(i.contentHash===s.contentHash){a.push({type:`noop`,name:o});continue}let e=!c||c.contentHash!==i.contentHash,t=!c||c.contentHash!==s.contentHash;if(e&&!t)a.push({type:`push`,name:o});else if(!e&&t)a.push({type:`pull`,name:o});else{let e=r??(i.editedAt>=s.editedAt?`push`:`pull`);a.push({type:e===`push`?`conflict-push`:`conflict-pull`,name:o})}continue}if(i&&!s){a.push({type:c?`delete-local`:`push`,name:o});continue}!i&&s&&a.push({type:c?`delete-remote`:`pull`,name:o})}return a}function Hh(e,t,n){return Uh(e,t===`push`?`remote`:`local`,n)}function Uh(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=b.join(kl,e,`${r}-${t}`);for(let e of n)sl(b.join(i,e.path),e.contents);return i}async function Wh(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now();for(let a of t){let{name:t}=a,o=n.local.get(t);switch(a.type){case`noop`:o&&(n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i});break;case`push`:case`conflict-push`:if(!o)break;if(a.type===`conflict-push`){let n=await e.getSkill(t);n&&r.conflicts.push({name:t,kept:`push`,stashedAt:Hh(t,`push`,n.files)})}await e.putSkill(t,o.files,o.editedAt),n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i};break;case`pull`:case`conflict-pull`:{let s=await e.getSkill(t);if(!s)break;a.type===`conflict-pull`&&o&&r.conflicts.push({name:t,kept:`pull`,stashedAt:Hh(t,`pull`,o.files)}),ql(t,s.files,s.editedAt),n.state.skills[t]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i};break}case`delete-local`:if(!(n.yes||await Qp(`Delete ${t} from this machine? It was deleted elsewhere.`,!0))){r.skipped.push(t);continue}I(Al(t)),delete n.state.skills[t];break;case`delete-remote`:if(!(n.yes||await Qp(`Delete ${t} everywhere? It was deleted on this machine.`,!0))){r.skipped.push(t);continue}await e.deleteSkill(t),delete n.state.skills[t];break}r.actions.push(a)}return r}function Gh(e){switch(e.type){case`push`:return`Pushed ${e.name} to skilless.dev.`;case`pull`:return`Pulled ${e.name} from skilless.dev.`;case`conflict-push`:return`${e.name} changed in both places. Kept the copy on this machine.`;case`conflict-pull`:return`${e.name} changed in both places. Kept the copy from skilless.dev.`;case`delete-local`:return`Deleted ${e.name} from this machine.`;case`delete-remote`:return`Deleted ${e.name} everywhere.`;default:return null}}const Kh=Y.extend({yes:N(),push:N().optional(),pull:N().optional()}),qh=new y(`sync`).description(`Sync your library with skilless.dev, in both directions, and update this project's skills and your global ones.`).option(`--push`,`On a conflict, keep the local copy.`).option(`--pull`,`On a conflict, keep the remote copy.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(Kh,e);q.intro(J),await Q(async()=>{let e=Wm(),[n,r]=await K(`Checking skilless.dev`,async()=>[await Fu(e),await e.listSkills()]),i=new Map(Yl().map(e=>[e.name,e])),a=new Map(r.map(e=>[e.name,e])),o=vu(),s=Vh(i,a,o,t.push?`push`:t.pull?`pull`:void 0),c=await K(`Syncing your library`,()=>Wh(e,s,{local:i,state:o,yes:t.yes}));yu(o);let l=c.actions.map(Gh).filter(e=>e!==null);for(let e of l)q.step(e);let[u,d]=await K(`Syncing your library`,async()=>{let t=n+await Fu(e);return[t,l.length>0||t>0?await e.listSkills():r]});u>0&&q.step(`Sent ${u} change(s) made while offline.`),Ll(d),Vu(d);let f=hl(t.cwd),p=await K(f?`Updating this project`:`Updating your global skills`,async()=>{if(!f)return{user:Tu(d.filter(e=>e.global).map(e=>e.name))};let n=await Cu(e,gu(t.cwd),f);return{...n,project:n.project}}),m=`project`in p?p.project:void 0,{user:h}=p;if(m){for(let e of m.added)q.step(`Linked ${e} into this project.`);for(let e of m.removed)q.step(`Unlinked ${e}, which is no longer in this project.`);for(let e of m.pruned)q.step(`Unlinked ${e}, which is no longer in your library.`)}for(let e of h.added)q.step(`Linked ${e} into ${Km}.`);for(let e of h.removed)q.step(`Unlinked ${e} from ${Km}, since it is no longer global.`);for(let e of h.pruned)q.step(`Unlinked ${e} from ${Km}, since it is no longer in your library.`);let g=[m,h].reduce((e,t)=>e+(t?t.added.length+t.removed.length+t.pruned.length:0),0);if(l.length===0&&g===0&&u===0&&q.info(`Everything is already in sync.`),c.conflicts.length>0){q.blank(),q.warn(`${c.conflicts.length} skill(s) changed in two places. The copy that lost is kept here:`);for(let e of c.conflicts)q.dim(` ${e.stashedAt}`)}await Jm({skipped:[...m?.skipped??[],...h.skipped]},{yes:t.yes}),c.skipped.length>0&&(q.blank(),q.dim(`Skipped ${c.skipped.join(`, `)}.`))})}),Jh=Y.extend({yes:N(),force:N()});function Yh(e){let t=ml(e.url)??e.url;return e.ref?`${t}#${e.ref}`:t}const Xh=new y(`update`).description(`Update skills added from a git repository to what the repository has now.`).argument(`[skills...]`,`Skills to update. Omit to update every skill added from a repository.`).option(`-f, --force`,`Replace skills you have edited too. Your copy is kept first.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Jh,t);q.intro(J),await Q(async()=>{let t=new xm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Map(r.entries.map(e=>[e.name,e])),a=r.entries.filter(e=>e.source!==null);if(e.length>0){let t=e.filter(e=>!i.has(e));if(t.length>0)throw new P(`Not in your library: ${t.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let n=e.filter(e=>!i.get(e)?.source);if(n.length>0)throw new P(`${n.join(`, `)} ${n.length===1?`was`:`were`} not added from a repository, so there is nothing to update from.`)}let o=e.length>0?a.filter(t=>e.includes(t.name)):a;if(o.length===0){q.info(`None of your skills were added from a repository.`),q.dim("Run `skilless add owner/repo` to add some."),t.report();return}let s=new Map;for(let e of o){let t=`${e.source.url}#${e.source.ref??``}`;s.set(t,[...s.get(t)??[],e])}let c=[],l=new Map,u=[],d=[],f=[],p=[];for(let e of s.values()){let r=e[0].source,i=Yh(r);await Dm({url:r.url,ref:r.ref,label:i},async r=>{for(let a of e){let e=Nm(r,a.source.path,a.name);if(!e){q.warn(`${a.name} is no longer in ${i}.`);continue}let o;try{o=Kl(e.dir,a.name)}catch(e){q.warn(`Skipped ${a.name}: ${e instanceof Error?e.message:e}`);continue}let s={...a.source,path:e.path,hash:o.contentHash},p=a.local?.contentHash??a.remote?.contentHash;if(o.contentHash===a.source.hash||p===o.contentHash){zu(a.name,s),u.push(a.name);continue}if(p!==a.source.hash){if(!(n.force||$p&&!n.yes&&await Qp(`You have edited ${a.name} since it came from ${i}. Replace your edits with what it has now?`))){d.push(a.name);continue}let e=a.local?.files??(await K(`Fetching your copy of ${a.name}`,()=>t.try(e=>e.getSkill(a.name))))?.files;if(!e){q.warn(`Couldn't fetch your copy of ${a.name} to keep it, so it was left alone.`);continue}f.push({name:a.name,dir:Uh(a.name,`update`,e)})}c.push(o),l.set(a.name,s)}},{interactive:$p}).then(()=>!0,e=>{if(!(e instanceof P))throw e;return q.warn(e.toString()),!1})||p.push(...e.map(e=>e.name))}q.blank();let m=await K(`Saving ${c.length} skill(s) to your library`,()=>Ju(t,c,i,l));for(let e of m)q.step(`Updated ${e}.`);if(u.length>0&&q.info(u.length===1?`${u[0]} is already up to date.`:`${u.length} skills are already up to date.`),d.length>0&&q.warn(`Kept your edits to ${d.join(`, `)}. Run \`skilless update ${d.join(` `)} --force\` to replace them.`),p.length>0&&q.warn(`Couldn't check ${p.join(`, `)}.`),f.length>0){q.blank(),q.dim(`Your edited copies are kept here:`);for(let e of f)q.dim(` ${e.dir}`)}t.report()})});le.name(Bm).description(Vm).version(J).addCommand(Ah).addCommand(ah).addCommand(wh).addCommand(Xm).addCommand(Xh).addCommand(Bh).addCommand(Eh).addCommand(Mh).addCommand(qh).addCommand(kh).addCommand(Rh).addCommand(Fh).addCommand(Sh).parse();export{};
|
|
122
|
+
`)),this}return this.isSpinning?this:(this.#r.hideCursor&&Qf.hide(this.#a),this.#r.discardStdin&&o.stdin.isTTY&&(Kp.start(),this.#d=!0),this.#T(),this.render(),this.#o=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#o),this.#o=void 0,this.#t=-1,this.#n=0,this.#v(),this.#E(),this.#l&&=(this.#a.removeListener(`drain`,this.#l),void 0),this.isEnabled&&(this.clear(),this.#r.hideCursor&&Qf.show(this.#a)),this.#d&&(this.#d=!1,Kp.stop()),this}succeed(e){return this.stopAndPersist({symbol:cp,text:e})}fail(e){return this.stopAndPersist({symbol:up,text:e})}warn(e){return this.stopAndPersist({symbol:lp,text:e})}info(e){return this.stopAndPersist({symbol:sp,text:e})}stopAndPersist(e={}){if(this.isSilent)return this;let t=e.symbol??` `,n=e.text??this.text,r=e.prefixText??this.#r.prefixText,i=e.suffixText??this.#r.suffixText,a=this.#y(t,n,r,i)+`
|
|
123
|
+
`;return this.stop(),this.#p(()=>this.#a.write(a)),this}};function Xp(e){return new Yp(e)}var G=ne(v(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}))(),1);const Zp=Hd.default.prompt;function Qp(){process.stdout.write(`\r\x1B[0J`),process.stdin.isTTY&&process.stdin.setRawMode(!1),tm()}const $p={limit:10,up(){if(this.index>0)return this.index--,this.render();if(this.choices[0]?.index!==0)return this.scrollUp()},down(){if(this.index<this.visible.length-1)return this.index++,this.render();if(this.visible.at(-1)?.index!==this.choices.length-1)return this.scrollDown()}};async function em(e,t){cm();try{return await Zp({...e,cancel:Qp})}catch{return tm(),t}finally{lm()}}function tm(){cm(),process.stdout.write(`${G.default.yellow(`!`)} Cancelled\n`),process.exit(1)}async function nm(e,t=!1){return(await em({type:`confirm`,name:`value`,message:e,initial:t},{value:!1})).value}const rm=!!(process.stdin.isTTY&&process.stdout.isTTY);async function im(e,t={}){return(await em({type:`input`,name:`value`,message:e,initial:t.initial,validate:t.validate?e=>t.validate((e??``).trim()):void 0},{value:``})).value.trim()}async function am(e,t){return t.length===0?[]:(await em({type:`multiselect`,name:`value`,message:e,choices:t,...$p},{value:[]})).value}async function om(e,t,n){let r=n?t.findIndex(e=>e.name===n):-1;return(await em({type:`select`,name:`value`,message:e,choices:t,initial:r===-1?0:r,...$p},{value:``})).value}let K=null;function sm(e){let t=e.step%3+1;return`${e.message}${`.`.repeat(t)}${` `.repeat(3-t)}`}function cm(){K?.ora.isSpinning&&K.ora.stop()}function lm(){K&&!K.ora.isSpinning&&K.ora.start(sm(K))}async function q(e,t){if(!process.stdout.isTTY||!process.stdout.columns)return t();if(K){let n=K.message;K.message=e;try{return await t()}finally{K&&(K.message=n)}}let n={ora:Xp({stream:process.stdout,color:`cyan`,discardStdin:!1}),message:e,step:0,dots:setInterval(()=>{n.step++,n.ora.text=sm(n)},300)};K=n,lm();try{return await t()}finally{clearInterval(n.dots),cm(),K=null}}function um(e,t){let n=K?.ora.isSpinning===!0;n&&K.ora.clear(),e.write(t),n&&K.ora.render()}const dm=e=>G.default.isColorSupported?`\x1b[48;2;95;95;95m\x1b[38;2;250;250;250m${e}\x1b[39m\x1b[49m`:e,J={intro(e){um(process.stdout,`${dm(` skilless `)}${G.default.gray(` v${e}`)}\n\n`)},info(e){um(process.stdout,`${G.default.blue(`·`)} ${e}\n`)},step(e){um(process.stdout,`${G.default.green(`✓`)} ${e}\n`)},warn(e){um(process.stdout,`${G.default.yellow(`!`)} ${e}\n`)},error(e){um(process.stderr,`${G.default.red(`✖`)} ${e}\n`)},dim(e){um(process.stdout,`${G.default.gray(e)}\n`)},blank(){um(process.stdout,`
|
|
124
|
+
`)}},fm=Cc({path:P(),contents:P()}),pm=Cc({url:P(),ref:P().optional(),path:P(),hash:P()}),mm=Cc({name:P(),contentHash:P(),editedAt:fc(),updatedAt:fc(),global:I(),source:pm.nullable().default(null)}),hm=mm.extend({files:xc(fm)}),gm=Cc({bound:xc(P()),unknown:xc(P())}),_m=Cc({error:P(),message:P().optional()}),vm=new Set([502,503,504]);function ym(e){try{return JSON.parse(e)}catch{return null}}var bm=class{#e;#t;#n=!1;constructor(e,t){this.#e=e,this.#t=t}get baseUrl(){return this.#t}async#r(e,t,n){if(this.#n)throw new tl(this.#t);let r;for(let i=0;i<2;i++){i>0&&await new Promise(e=>setTimeout(e,500));try{let i=await fetch(`${this.#t}/api/v1${t}`,{method:e,headers:{Authorization:`Bearer ${this.#e}`,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n),signal:AbortSignal.timeout(1e4)}),a=await i.text();if(vm.has(i.status)){r=Error(`${e} ${t} returned ${i.status}.`);continue}return{status:i.status,text:a}}catch(e){r=e}}throw this.#n=!0,new tl(this.#t,r)}async#i(e,t,n,r){let i=await this.#r(e,t,r);if(i.status===401)throw new $c;if(i.status<200||i.status>=300){let n=_m.safeParse(ym(i.text));throw new L(n.success?n.data.message??n.data.error:`${e} ${t} failed with ${i.status}.`)}if(i.status===204)return n.parse(void 0);let a=n.safeParse(ym(i.text));if(!a.success)throw new L(`Unexpected response from ${e} ${t}.`,{suggestion:`This is likely a version mismatch. Try updating skilless.`});return a.data}async listSkills(){return await this.#i(`GET`,`/skills`,xc(mm))}async getSkill(e){return await this.#i(`GET`,`/skills/${encodeURIComponent(e)}`,hm.nullable())}async putSkill(e,t,n){return await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}`,mm,{files:t,editedAt:n})}async setGlobal(e,t){await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}/global`,_c(),{global:t})}async setSource(e,t){await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}/source`,_c(),{source:t})}async deleteSkill(e){await this.#i(`DELETE`,`/skills/${encodeURIComponent(e)}`,_c())}async getBindings(e){return await this.#i(`GET`,`/projects/skills?key=${encodeURIComponent(e)}`,xc(hm))}async setBindings(e,t){return await this.#i(`PUT`,`/projects/skills`,gm,{key:e,names:t})}},xm=class{api;#e=null;constructor(){let e=hu();this.api=e?new bm(e,vu()):null}get online(){return this.api!==null&&this.#e===null}async try(e){if(!(!this.api||this.#e))try{return await e(this.api)}catch(e){if(e instanceof tl||e instanceof $c){this.#e=e;return}throw e}}report(){if(this.#e){if(J.blank(),this.#e instanceof tl){J.warn(`Couldn't reach ${this.#e.url}. Run \`skilless sync\` to sync your skills with the cloud.`);return}J.warn(`Your sign-in was rejected, so this only changed this machine.`),J.dim("Run `skilless auth` to sign in again, then `skilless sync` to sync your skills.")}}};function Sm(e){return e.includes(`/`)||e.includes(`:`)}function Cm(e){let t=e.trim(),n,r=t.indexOf(`#`);if(r>=0&&(n=t.slice(r+1)||void 0,t=t.slice(0,r)),/^ext::/i.test(t))throw new L(`The ext:: git transport is not supported.`);let i=/^(github|gitlab):(.+)$/.exec(t);i&&(t=i[1]===`gitlab`?`https://gitlab.com/${i[2]}`:i[2]??``);let a;return a=/^https?:\/\//i.test(t)?wm(t,n):/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||/^[^@/\s]+@[^:/\s]+:/.test(t)?{url:t,ref:n}:Tm(t,n),a.subpath&&=Em(a.subpath),{...a,label:fl(a.url)??a.url}}function wm(e,t){let n;try{n=new URL(e)}catch{throw new L(`${e} is not a valid URL.`)}let r=n.pathname.split(`/`).filter(Boolean).map(decodeURIComponent),i=`${n.protocol}//${n.host}`;if(n.hostname===`github.com`&&r.length>=2){let[e,n,a,o,...s]=r,c=`${i}/${e}/${n?.replace(/\.git$/,``)}.git`;return(a===`tree`||a===`blob`)&&o?{url:c,ref:o,subpath:s.join(`/`)||void 0}:{url:c,ref:t}}let a=r.indexOf(`-`);return a>0&&r[a+1]===`tree`&&r[a+2]?{url:`${i}/${r.slice(0,a).join(`/`).replace(/\.git$/,``)}.git`,ref:r[a+2],subpath:r.slice(a+3).join(`/`)||void 0}:{url:e,ref:t}}function Tm(e,t){let n=/^([^/@\s]+)\/([^/@\s]+)@([^/\s]+)$/.exec(e);if(n)return{url:`https://github.com/${n[1]}/${n[2]}.git`,ref:t,skill:n[3]};let r=/^([^/\s.][^/\s]*)\/([^/\s]+?)(?:\/(.+?))?\/?$/.exec(e);if(!r)throw new L(`Can't tell where ${e} points.`,{suggestion:"Pass `owner/repo` for GitHub, or a full git URL for anywhere else."});return{url:`https://github.com/${r[1]}/${r[2]?.replace(/\.git$/,``)}.git`,ref:t,subpath:r[3]}}function Em(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);if(t.includes(`..`))throw new L(`${e} reaches outside the repository.`);return t.join(`/`)}async function Dm(e,t,r){let i=a.mkdtempSync(S.join(s.tmpdir(),`skilless-`));try{let o=[`clone`,`--depth`,`1`,`--quiet`];e.ref&&o.push(`--branch`,e.ref),o.push(`--`,e.url,i);try{await q(`Cloning ${e.label}${e.ref?`#${e.ref}`:``}`,()=>Om(o,{...process.env,GIT_TERMINAL_PROMPT:`0`,GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??`ssh -o BatchMode=yes`}))}catch(t){if(!r.interactive)throw km(e,t);z(i),a.mkdirSync(i);try{n(`git`,o,{stdio:[`inherit`,`ignore`,`pipe`],encoding:`utf8`})}catch(t){throw km(e,t)}}return await t(i)}finally{z(i)}}function Om(e,n){return new Promise((r,i)=>{t(`git`,e,{env:n,encoding:`utf8`},(e,t,n)=>{e?i(Object.assign(e,{stderr:n})):r()})})}function km(e,t){let n=t.stderr?.trim();return new L(`Couldn't clone ${e.label}.`,{suggestion:n||`Check the address, and that you have access to the repository.`,cause:t})}const Am=new Set([`node_modules`,`.git`,`dist`,`build`,`__pycache__`]),jm=[`skills`,`skills/.curated`,`skills/.experimental`,`skills/.system`,`.agents/skills`,`.claude/skills`];function Mm(e,t){let n=t?S.join(e,t):e;if(!R(n))throw new L(`${t} does not exist in the repository.`);let r=new Map,i=e=>{let t=Im(e);r.has(t.name)||r.set(t.name,t)};if(Pm(n))return i(n),[...r.values()];Fm(n,1,i);for(let e of jm)Fm(S.join(n,e),3,i);return r.size===0&&Fm(n,5,i),[...r.values()].sort((e,t)=>e.name.localeCompare(t.name))}function Nm(e,t,n){try{let n=Em(t);if(Pm(S.join(e,n)))return{dir:S.join(e,n),path:n}}catch{}let r=Mm(e).find(e=>e.name===n);return r?{dir:r.dir,path:S.relative(e,r.dir)}:null}function Pm(e){return a.existsSync(S.join(e,Ll))}function Fm(e,t,n){let r;try{r=a.readdirSync(e,{withFileTypes:!0})}catch{return}for(let i of r.sort((e,t)=>e.name.localeCompare(t.name))){if(!i.isDirectory()||Am.has(i.name))continue;let r=S.join(e,i.name);Pm(r)?n(r):t>1&&Fm(r,t-1,n)}}function Im(e){let t=Lm(a.readFileSync(S.join(e,Ll),`utf8`)),n=t.name?.toLowerCase().replace(/[\s_]+/g,`-`);return{name:n&&Vl(n)?n:S.basename(e).toLowerCase(),dir:e,description:t.description}}function Lm(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e)?.[1];if(!t)return{};let n=e=>{let n=RegExp(`^${e}:[ \\t]*(.+)$`,`m`).exec(t)?.[1]?.trim();if(!(!n||n===`|`||n===`>`))return n.replace(/^(['"])(.*)\1$/,`$2`)};return{name:n(`name`),description:n(`description`)}}var Rm=`skilless`,zm=`Author skills once, sync them everywhere, install them per project.`;const Y=`0.0.4`,Bm=Rm,Vm=zm,Hm=`SKILLESS_TRACE`,Um=Cc({cwd:P()}),X={cwd:new x(`--cwd <path>`,`The current working directory.`).default(process.cwd()),yes:new x(`-y, --yes`,`Skip confirmation prompts.`).default(!1),project:new x(`--project <key>`,`Override the project key. Defaults to the normalized git remote.`)};function Z(e,t){let n=e.safeParse(t);return n.success?n.data:Wm(new L(`Invalid options.`,{suggestion:n.error.issues.map(e=>` ${e.message}`).join(`
|
|
125
|
+
`)}))}function Wm(e){process.env[Hm]===`1`?console.trace(e):J.error(G.default.red(e.toString())),process.exit(1)}async function Q(e){try{return await e()}catch(e){return e instanceof L?Wm(e):Wm(new L(e instanceof Error?e.message:String(e),{suggestion:`Run with ${Hm}=1 for a stack trace.`,cause:e}))}}function Gm(){let e=hu();if(!e)throw new $c;return new bm(e,vu())}function Km(e,t){if(t)return t;let n=pl(e);if(!n)throw new el;return n}const qm=`~/.agents/skills`;function Jm(e){let t=S.normalize(s.homedir());return e===t||e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}async function Ym(e,t={}){for(let n of e.skipped){if(n.reason===`tracked`){J.warn(`\`${n.name}\` is tracked by git here, so it was left alone.`);continue}let e=(n.occupied?.paths??[]).map(Jm).join(` and `);if(!(t.yes||rm&&await nm(`Overwrite ${e}?`,!1))){rm?J.dim(`Kept ${e}, so ${n.name} is not linked there.`):(J.warn(`Skipped ${n.name}: ${e} was not made by skilless.`),J.dim(` Run this in a terminal to overwrite it, or pass --yes.`));continue}du(n,{copy:Su(t.copy)}),J.step(`Overwrote ${e}.`)}for(let t of e.missing??[])J.warn(`${t} is not on this machine yet, so it will be linked on the next sync.`)}const Xm=Um.extend({project:P().optional(),copy:I().optional(),global:I().optional(),notGlobal:I().optional(),overwrite:I(),yes:I()}),Zm=new b(`add`).description(`Add skills to this project, from your library or from a git repository.`).argument(`[skills...]`,"Skills to add, or a repo (`owner/repo` or any git URL) then the skills to take from it. Omit the skills to pick from a list.").option(`-g, --global`,`Make these skills global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has them, including cloud agents.`).option(`--not-global`,`Stop treating these skills as global, and unlink them from your user-level skills.`).option(`--copy`,`Write real files instead of symlinking into the store.`).option(`--overwrite`,`From a repo: replace library skills of the same name.`,!1).addOption(X.yes).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Xm,t);J.intro(Y),await Q(async()=>{let t=new xm,[r,...i]=e;if(r&&Sm(r)){await eh(t,Cm(r),i,n);return}let a=e.find(Sm);if(a)throw new L(`${a} is a repository, not a skill.`,{suggestion:`Name the repository first: \`skilless add ${a} <skills...>\`.`});let{entries:o,live:s}=await q(`Loading your library`,async()=>(await B(t),Wu(t))),c=e=>s||e.local!==null,l=e=>{let t=o.filter(t=>e.includes(t.name)&&!c(t)).map(e=>e.name);if(t.length!==0)throw new L(`${t.join(`, `)} ${t.length===1?`is`:`are`} not on this machine, and the server can't be reached to fetch ${t.length===1?`it`:`them`}.`,{suggestion:"Run `skilless sync` once you are back online, then try again."})},u=new Set(o.map(e=>e.name)),d=e.filter(e=>!u.has(e));if(d.length>0)throw new L(`Not in your library: ${d.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(n.global||n.notGlobal){let r=n.global===!0,i=e;if(i.length===0){let e=o.filter(e=>e.global!==r&&(!r||c(e)));if(e.length===0){J.info(r?`Every skill in your library is already global.`:`No skills in your library are global.`);return}if(i=await am(r?`Make global`:`Stop being global`,e.map(e=>({name:e.name}))),i.length===0){J.info(`Nothing selected.`);return}}r&&l(i),await Qm(t,i,r,n),t.report();return}let f=Km(n.cwd,n.project),p=new Set(await q(`Loading ${f}`,()=>Gu(t,f))),m=e;if(m.length===0){let e=o.filter(e=>!p.has(e.name)&&c(e));if(e.length===0){J.info(s?`Every skill in your library is already in this project.`:`Every skill on this machine is already in this project.`),t.report();return}if(m=await am(`Add to ${f}`,e.map(e=>({name:e.name}))),m.length===0){J.info(`Nothing selected.`);return}}let h=o.filter(e=>e.global).map(e=>e.name);l(m.filter(e=>!h.includes(e))),await $m(t,f,m,h,n),t.report()})});async function Qm(e,t,n,r){Pu(t,n),await q(`Saving to skilless.dev`,()=>B(e));for(let e of t)J.step(n?`${e} is now global, so every project has it.`:`${e} is no longer global.`);let i=r.project??pl(r.cwd),a=mu(r.cwd),[o,s]=await q(`Updating your skills`,async()=>{if(!i){let t=await Xu(e);return[t,t]}let t=await qu(e,a,i,{copy:r.copy});return[t,t.user]});for(let e of s.written.filter(e=>t.includes(e)))J.dim(`Linked ${e} into ${qm}.`);for(let e of s.removed)J.dim(`Unlinked ${e} from ${qm}.`);if(`project`in o){for(let e of o.project.removed)J.dim(`Moved ${e} out of this project.`);for(let e of o.project.written.filter(e=>t.includes(e)))J.dim(`${e} is still added to this project, so it is linked here again.`)}await Ym(o,r)}async function $m(e,t,n,r,i){for(let e of n)r.includes(e)&&J.dim(`${e} is global, so it is already in this project.`);let a=n.filter(e=>!r.includes(e));Mu(t,a);let o=mu(i.cwd),s=await q(`Updating this project`,async()=>(await B(e),qu(e,o,t,{copy:i.copy})));for(let e of a)J.step(`Added ${e} to this project.`);await Ym(s,i)}async function eh(e,t,n,r){if(r.notGlobal)throw new L(`--not-global only applies to skills already in your library.`);let i=r.global?null:r.project??pl(r.cwd),a=await q(`Loading your library`,async()=>(await B(e),Wu(e))),o=new Map(a.entries.map(e=>[e.name,e])),s=[...n,...t.skill?[t.skill]:[]],c=await Dm(t,async e=>{let n=Mm(e,t.subpath);if(n.length===0)throw new L(`No skills found in ${t.label}.`,{suggestion:`A skill is a directory containing a SKILL.md.`});let i=n;if(s.length>0){let e=e=>n.find(t=>t.name===e.toLowerCase()||t.dir.split(`/`).at(-1)?.toLowerCase()===e.toLowerCase()),r=s.filter(t=>!e(t));if(r.length>0)throw new L(`Not in ${t.label}: ${r.join(`, `)}`,{suggestion:`It has: ${n.map(e=>e.name).join(`, `)}`});i=[...new Set(s.map(t=>e(t)))]}else if(n.length>1&&!r.yes){if(!rm)throw new L(`${t.label} has ${n.length} skills.`,{suggestion:`Name the ones you want after the repository, or pass --yes for all of them: ${n.map(e=>e.name).join(`, `)}`});let e=await am(`Add from ${t.label}`,n.map(e=>({name:e.name,hint:th(e.description)})));i=n.filter(t=>e.includes(t.name))}let a=[];for(let t of i)try{Hl(t.name),a.push({skill:Wl(t.dir,t.name),path:S.relative(e,t.dir)})}catch(e){J.warn(`Skipped ${t.name}: ${e instanceof L?e.message:e}`)}return a},{interactive:rm});if(c.length===0){J.info(`Nothing selected.`),e.report();return}let l=[],u=[],d=new Map;for(let{skill:e,path:n}of c){d.set(e.name,{url:t.url,...t.ref?{ref:t.ref}:{},path:n,hash:e.contentHash});let i=o.get(e.name),a=i?.local?.contentHash??i?.remote?.contentHash;if(!i||a===e.contentHash){i?Vu(e.name,d.get(e.name)):l.push(e),u.push(e.name);continue}if(!(r.overwrite||rm&&!r.yes&&await nm(`${e.name} is already in your library. Replace it with the one from ${t.label}?`))){J.warn(`Kept your own ${e.name}. Pass --overwrite to replace it.`);continue}l.push(e),u.push(e.name)}let f=await q(`Saving ${l.length} skill(s) to your library`,()=>Zu(e,l,o,d));for(let e of f)J.step(`Copied ${e} into your library from ${t.label}.`);if(u.length===0){e.report();return}r.global?await Qm(e,u,!0,r):i?await $m(e,i,u,(await q(`Loading your library`,()=>Wu(e))).entries.filter(e=>e.global).map(e=>e.name),r):(J.blank(),J.dim(`This directory has no git remote, so ${u.length===1?`it is`:`they are`} only in your library. Run \`skilless add ${u[0]}\` inside a project to add ${u.length===1?`it`:`them`} there.`)),e.report()}function th(e){if(e)return e.length>60?`${e.slice(0,57)}...`:e}function nh(e){switch(process.platform){case`darwin`:return[`open`,[e]];case`win32`:return[`rundll32`,[`url.dll,FileProtocolHandler`,e]];default:return[`xdg-open`,[e]]}}function rh(e){let[t,n]=nh(e);try{let e=r(t,n,{stdio:`ignore`,detached:!0,windowsHide:!0});e.on(`error`,()=>{}),e.unref()}catch{}}async function ih(){let e=c.randomBytes(16).toString(`hex`),t=vu(),n=new URL(t).origin,r={"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`,"Access-Control-Allow-Private-Network":`true`},i,a=new Promise((e,t)=>{i={resolve:e,reject:t}}),o=f.createServer((t,n)=>{if(t.method===`OPTIONS`){n.writeHead(204,r),n.end();return}if(t.method!==`POST`){n.writeHead(405,r),n.end();return}let a=``;t.on(`data`,e=>{a+=e}),t.on(`end`,()=>{let t;try{t=JSON.parse(a)}catch{n.writeHead(400,r),n.end();return}if(t.state!==e||!t.token){n.writeHead(400,r),n.end();return}n.writeHead(200,{...r,"Content-Type":`application/json`}),n.end(JSON.stringify({ok:!0})),i.resolve(t.token)})}),s=setTimeout(()=>{i.reject(new L(`Timed out waiting for sign in.`,{suggestion:"Run `skilless auth` again, or paste a token with `skilless auth --token <token>`."}))},3e5);try{await new Promise((e,t)=>{o.once(`error`,t),o.listen(0,`127.0.0.1`,e)});let{port:n}=o.address(),r=`${t}/cli/auth?port=${n}&state=${e}`;J.info(`Opening your browser to sign in…`),J.dim(r),J.blank(),rh(r),gu(await q(`Waiting for you to sign in`,()=>a))}finally{clearTimeout(s),o.close()}}const ah=Um.extend({logout:I(),token:P().optional()}),oh=new b(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new x(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new x(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(X.cwd).action(async e=>{let t=Z(ah,e);J.intro(Y),await Q(async()=>{if(t.logout){if(!hu()){J.info(`You were not signed in.`);return}_u(),J.step(`Signed out on this machine.`);return}if(t.token){gu(t.token),J.step(`Token saved. You are signed in to skilless.dev.`);return}await ih(),J.step(`Signed in to skilless.dev.`)})}),sh=s.homedir(),ch=process.env.LOCALAPPDATA??S.join(sh,`AppData`,`Local`),lh=process.env.ProgramFiles??`C:/Program Files`,$={cursor:{label:`Cursor`,cli:`cursor`,fallbacks:{darwin:[`/Applications/Cursor.app/Contents/Resources/app/bin/cursor`,`${sh}/Applications/Cursor.app/Contents/Resources/app/bin/cursor`],win32:[S.join(ch,`Programs/cursor/resources/app/bin/cursor.cmd`)],linux:[`/usr/share/cursor/bin/cursor`,`/opt/Cursor/resources/app/bin/cursor`]}},vscode:{label:`VS Code`,cli:`code`,fallbacks:{darwin:[`/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`,`${sh}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`],win32:[S.join(ch,`Programs/Microsoft VS Code/bin/code.cmd`),S.join(lh,`Microsoft VS Code/bin/code.cmd`)],linux:[`/usr/share/code/bin/code`,`/snap/bin/code`]}},windsurf:{label:`Windsurf`,cli:`windsurf`,fallbacks:{darwin:[`/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`,`${sh}/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`],win32:[S.join(ch,`Programs/Windsurf/bin/windsurf.cmd`)],linux:[`/usr/share/windsurf/bin/windsurf`]}},zed:{label:`Zed`,cli:`zed`,fallbacks:{darwin:[`/Applications/Zed.app/Contents/MacOS/cli`,`${sh}/Applications/Zed.app/Contents/MacOS/cli`],win32:[S.join(ch,`Programs/Zed/bin/zed.exe`)],linux:[`${sh}/.local/bin/zed`]}},sublime:{label:`Sublime Text`,cli:`subl`,fallbacks:{darwin:[`/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl`],win32:[S.join(lh,`Sublime Text/subl.exe`)],linux:[`/opt/sublime_text/sublime_text`]}},neovim:{label:`Neovim`,cli:`nvim`,terminal:!0},vim:{label:`Vim`,cli:`vim`,terminal:!0}},uh=Object.keys($);function dh(e){return Object.hasOwn($,e)}function fh(e){let t=i(process.platform===`win32`?`where`:`which`,[e],{encoding:`utf8`,windowsHide:!0});if(t.status!==0||!t.stdout)return null;let n=t.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return process.platform===`win32`?n.find(e=>/\.(exe|cmd|bat)$/i.test(e))??n[0]??null:n[0]??null}function ph(e){let t=$[e],n=fh(t.cli);if(n)return n;let r=process.platform;return t.fallbacks?.[r]?.find(e=>R(e))??null}function mh(){return uh.filter(e=>ph(e)!==null)}function hh(e){return $[e].terminal===!0}function gh(e,t){let n=ph(e);if(!n)return Promise.reject(Error(`${$[e].label} was not found. Is \`${$[e].cli}\` on your PATH?`));let i=hh(e);return new Promise((e,a)=>{let o=r(n,[t],{cwd:S.dirname(t),stdio:i?`inherit`:`ignore`,detached:!i,windowsHide:!0,shell:process.platform===`win32`&&/\.(cmd|bat)$/i.test(n)});o.on(`error`,a),i?o.on(`exit`,()=>e()):(o.unref(),setImmediate(e))})}function _h(){let e=ol(El,{});return e.editor!==void 0&&!dh(e.editor)&&delete e.editor,e}function vh(e){sl(El,e)}function yh(e){let t={..._h(),...e};for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return vh(t),t}const bh=`none`,xh=Cc({unset:I()}),Sh=new b(`editor`).description("Choose the editor `skilless create` opens a new skill in.").argument(`[editor]`,`Set it directly: ${uh.join(`, `)}.`).addOption(new x(`--unset`,`Stop opening new skills in an editor.`).default(!1)).action(async(e,t)=>{let n=Z(xh,t);J.intro(Y),await Q(async()=>{let t=_h().editor;if(n.unset){yh({editor:void 0}),J.step(`New skills will no longer open in an editor.`);return}if(e){if(!dh(e))throw new L(`${e} is not an editor skilless knows.`,{suggestion:`Pick one of: ${uh.join(`, `)}.`});yh({editor:e}),J.step(`New skills will open in ${$[e].label}.`);return}if(!rm){J.info(t?`Editor: ${$[t].label}`:`No editor set.`);return}let r=mh();if(r.length===0)throw new L(`None of the editors skilless knows are installed.`,{suggestion:`skilless looks for: ${uh.map(e=>$[e].cli).join(`, `)}.`});let i=await om(`Open new skills in`,[...r.map(e=>({name:e,message:$[e].label,hint:e===t?G.default.gray(`current`):void 0})),{name:bh,message:`None`,hint:t?void 0:G.default.gray(`current`)}],t??bh);if(i===bh){yh({editor:void 0}),J.step(`New skills will not open in an editor.`);return}dh(i)&&(yh({editor:i}),J.step(`New skills will open in ${$[i].label}.`))})}),Ch=new b(`config`).description(`View or change your skilless settings.`).addCommand(Sh).action(async()=>{J.intro(Y),await Q(async()=>{let e=_h();J.info(`editor ${e.editor?$[e.editor].label:G.default.gray(`not set`)}`),J.blank(),J.dim(`Stored in ${El}`)})}),wh=Um.extend({description:P().optional(),project:P().optional(),global:I().optional(),open:I()}),Th=new b(`create`).description(`Create a skill, add it to this project, and print the path to edit it.`).argument(`[name]`,`The name of the skill. You will be asked if you leave it out.`).option(`-d, --description <description>`,`What the skill does, for the frontmatter.`).option(`-g, --global`,`Make it global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has it, including cloud agents.`).option(`--no-open`,"Do not open SKILL.md in your editor (see `skilless config editor`).").addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(wh,t);J.intro(Y),await Q(async()=>{let t=new xm,r=await q(`Loading your library`,async()=>(await B(t),Wu(t))),i=new Set(r.entries.map(e=>e.name)),a=e;if(!a){if(!rm)throw new L(`No name given.`,{suggestion:"Run `skilless create <name>`."});a=await im(`Name`,{validate:e=>e?Vl(e)?i.has(e)?`${e} already exists in your library.`:!0:`Use lowercase letters, digits, dots, dashes and underscores.`:`A name is required.`})}if(Hl(a),Jl(a))throw new L(`${a} already exists in your library.`,{suggestion:`Edit it at ${S.join(Ol(a),`SKILL.md`)}`});if(i.has(a))throw new L(`${a} already exists in your library.`,{suggestion:`Run \`skilless sync\` to bring ${a} down to this machine.`});let o=n.description??await im(`What does this skill do?`);Gl(a,Yl(a,o));let s=Wl(Ol(a),a);if(await q(`Creating ${a}`,()=>t.try(e=>e.putSkill(a,s.files,s.editedAt)))){let e=bu();e.skills[a]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:Date.now()},xu(e)}J.step(`Created ${a} in your library.`),n.global&&Pu([a],!0);let c=n.project??pl(n.cwd);if(c){n.global||Mu(c,[a]);let e=mu(n.cwd);await Ym(await q(`Updating this project`,async()=>(await B(t),qu(t,e,c))))}else n.global?await Ym(await q(`Linking your global skills`,async()=>(await B(t),Xu(t)))):await q(`Saving to skilless.dev`,()=>B(t));n.global?J.step(`${a} is now global, so every project has it.`):c?J.step(`Added ${a} to ${c}.`):J.warn(`No git remote here, so ${a} was not added to a project.`);let l=S.join(Ol(a),`SKILL.md`),u=n.open?_h().editor:void 0,d=u&&(!hh(u)||rm);if(J.blank(),u&&d)try{J.dim(`Opening ${a} in ${$[u].label}...`),await gh(u,l)}catch(e){J.warn(e instanceof Error?e.message:String(e)),J.dim(`Edit ${a} at ${l}`)}else J.dim(`Edit ${a} at ${l}`);t.api&&J.dim("Run `skilless sync` to save your changes."),t.report()})}),Eh=Um.extend({yes:I()}),Dh=new b(`delete`).description(`Delete skills from your library, everywhere.`).argument(`<skills...>`,`Skills to delete.`).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Eh,t);J.intro(Y),await Q(async()=>{let t=new xm,r=await q(`Loading your library`,async()=>(await B(t),Wu(t))),i=new Set(r.entries.map(e=>e.name)),a=e.filter(e=>!i.has(e));if(a.length>0)throw new L(`Not in your library: ${a.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(J.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),J.dim(`Run \`skilless remove ${e.join(` `)}\` to take ${e.length===1?`it`:`them`} out of just this project.`),!(n.yes||await nm(`Delete ${e.join(`, `)}?`,!1))){J.info(`Nothing was deleted.`);return}Iu(e),Hu(e);let o=bu(),s=mu(n.cwd);for(let t of e)z(Ol(t)),delete o.skills[t],J.step(`Deleted ${t} from your library.`);xu(o),fu(s,e),fu(Zl(),e),await q(`Deleting from skilless.dev`,()=>B(t)),J.blank(),J.dim("Other checkouts will clean up on their next `skilless install`."),J.dim(`Restore at skilless.dev/skills within 30 days.`),t.report()})}),Oh=Um.extend({yes:I(),overwrite:I()});function kh(e){return a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:S.join(e,t.name)})).filter(e=>R(S.join(e.dir,Ll))).sort((e,t)=>e.name.localeCompare(t.name))}const Ah=new b(`import`).description(`Import a directory of existing skills into your library.`).argument(`<dir>`,`A directory whose subdirectories each contain a SKILL.md.`).option(`--overwrite`,`Replace skills that already exist.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Oh,t);J.intro(Y),await Q(async()=>{let t=new xm,r=S.resolve(n.cwd,e);if(!R(r))throw new L(`${r} does not exist.`);let i=kh(r);if(i.length===0)throw new L(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${Ll}.`});let a=await q(`Loading your library`,async()=>(await B(t),Wu(t))),o=new Map(a.entries.map(e=>[e.name,e])),s=[],c=[];for(let e of i){if(!Vl(e.name)){c.push({name:e.name,reason:`invalid name`});continue}if(o.has(e.name)&&!n.overwrite){c.push({name:e.name,reason:`already in your library`});continue}try{s.push(Wl(e.dir,e.name))}catch(t){c.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of c)J.warn(`Skipped ${e.name}: ${e.reason}.`);if(s.length===0){J.info(`Nothing to import.`),t.report();return}if(J.blank(),J.info(`Importing: ${s.map(e=>e.name).join(`, `)}`),!(n.yes||await nm(`Import ${s.length} skill(s)?`,!0)))return;let l=await q(`Importing ${s.length} skill(s)`,()=>Zu(t,s,o));for(let e of l)J.step(`Imported ${e} into your library.`);J.blank(),J.dim(`Run \`skilless add ${s[0]?.name??`<skill>`}\` to add one to this project.`),t.report()})}),jh=new b(`init`).description(`Create the local skilless directory.`).addOption(X.cwd).action(async e=>{Z(Um,e),J.intro(Y),await Q(async()=>{let e=!R(bl);rl(bl),J.step(`${e?`Created`:`Found`} your library at ${yl}.`),J.blank(),J.dim("Run `skilless create <name>` to make a skill."),J.dim("Run `skilless import <dir>` to bring in skills you already have."),hu()||J.dim("Run `skilless auth` to sync your skills with the cloud.")})}),Mh=Um.extend({project:P().optional(),copy:I().optional()}),Nh=new b(`install`).description(`Install every skill added to this project, and your global skills at the user level.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async e=>{let t=Z(Mh,e);J.intro(Y),await Q(async()=>{let e=Gm(),n=Km(t.cwd,t.project),r=mu(t.cwd),i=await q(`Installing ${n}'s skills`,async()=>(await Lu(e),Tu(e,r,n,{copy:t.copy}))),{project:a,user:o}=i;for(let e of[...a.pruned,...o.pruned])J.dim(`Pruned ${e}, which is no longer in your library.`);for(let e of[...a.fetched,...o.fetched])J.dim(`Fetched ${e} from your library.`);for(let e of a.removed)J.dim(`Removed ${e}, which is no longer in this project.`);for(let e of o.removed)J.dim(`Removed ${e} from ${qm}, since it is no longer global.`);for(let e of a.written)J.step(`Installed ${e}.`);for(let e of o.written)J.step(`Installed ${e} globally.`);if(i.count===0){J.info(`No skills added to ${n} yet.`),J.dim("Run `skilless add <skill>` to add one.");return}await Ym(i,{copy:t.copy}),J.blank(),J.dim(Su(t.copy)?`Wrote real files into .agents/skills, and global skills into ~/.agents/skills.`:`Linked .agents/skills, and global skills in ~/.agents/skills, to your library.`)})}),Ph=Um.extend({project:Tc([I(),P()]).optional()});function Fh(e,t){let n=[];return e.global&&n.push(`global`),e.source&&n.push(`from ${fl(e.source.url)??e.source.url}`),e.local?t&&e.unsynced&&n.push(`not synced`):n.push(`not on this machine`),n.map(e=>` · ${e}`).join(``)}const Ih=new b(`list`).description(`List your skills, or the ones added to this project.`).option(`-p, --project [key]`,`List this project’s skills instead of your library.`).addOption(X.cwd).action(async e=>{let t=Z(Ph,e);J.intro(Y),await Q(async()=>{let e=new xm,n=await q(`Loading your library`,async()=>(await B(e),Wu(e)));if(t.project!==void 0){let r=Km(t.cwd,typeof t.project==`string`?t.project:void 0),i=Ku(n,await q(`Loading ${r}`,()=>Gu(e,r)));J.info(`${G.default.bold(r)}`),J.blank(),i.length===0&&J.dim("No skills in this project. Run `skilless add <skill>` to add one.");for(let t of i)J.dim(` ${t.name}${G.default.gray(Fh(t,e.api!==null))}`);e.report();return}n.entries.length===0&&J.dim("Your library is empty. Run `skilless create <name>` to make one.");for(let t of n.entries){let n=t.local?.editedAt??t.remote?.updatedAt??0,r=new Date(n).toISOString().slice(0,10);J.dim(` ${t.name.padEnd(28)} ${G.default.gray(r+Fh(t,e.api!==null))}`)}e.report()})}),Lh=Um.extend({yes:I(),user:I().optional()});function Rh(e,t){return R(e)?a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.isSymbolicLink()).map(n=>({name:n.name,dir:S.join(e,n.name),scope:t})).filter(e=>R(S.join(e.dir,Ll))):[]}const zh=new b(`migrate`).description(`Move this project's skills into your library and link them back. Offers your user-level skills too, as globals linked back at the user level.`).option(`--user`,`Migrate your user-level skills too, without asking.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(Lh,e);J.intro(Y),await Q(async()=>{let e=new xm,n=mu(t.cwd),r=pl(t.cwd),i=r?[kl,Al].flatMap(e=>Rh(S.join(n,e),`project`).filter(e=>{let t=gl(n,S.relative(n,e.dir));return t&&J.warn(`${e.name} is committed to this repo, so it was left alone. Remove it from git first to migrate it.`),!t})):[],a=[...Rh(Nl(),`user`),...Rh(Ml(),`user`)];if(r||J.dim(`No git remote here, so there are no project skills to migrate.`),i.length===0&&a.length===0){J.info(`Nothing to migrate.`);return}let o=await q(`Loading your library`,async()=>(await B(e),Wu(e))),s=new Map(o.entries.map(e=>[e.name,e])),c=async e=>{let t=new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);let n=[];for(let[e,r]of[...t].sort(([e],[t])=>e.localeCompare(t))){if(!Vl(e)){J.warn(`Skipped ${e}: not a valid skill name.`);continue}let t;try{t=r.map(t=>Wl(t.dir,e))}catch(t){J.warn(`Skipped ${e}: ${t instanceof Error?t.message:`unreadable`}.`);continue}let i=t[0];if(!i)continue;if(t.some(e=>e.contentHash!==i.contentHash)){J.warn(`Skipped ${e}: found more than one version (${r.map(e=>e.dir).join(`, `)}).`);continue}let a=s.get(e),o=a?.local?.contentHash??a?.remote?.contentHash;if(o&&o!==i.contentHash){J.warn(`Skipped ${e}: a different ${e} is already in your library. Rename one to migrate it.`);continue}n.push({skill:i,dirs:r.map(e=>e.dir),scope:r.some(e=>e.scope===`user`)?`user`:`project`,adopted:o!==void 0})}return n},l=await c(i);if(l.length>0&&(J.info(`Project skills in ${r}: ${l.map(e=>e.skill.name).join(`, `)}`),t.yes||await nm(`Move ${l.length} skill(s) into skilless and link them here?`,!0)||(l=[])),a.length>0){let e=[...new Set(a.map(e=>e.name))].sort();if(J.info(`User-level skills: ${e.join(`, `)}`),t.user||!t.yes&&rm&&await nm(`Would you also like to migrate your user-level skills? They become global and are linked back into ~/.agents/skills, so every project still gets them.`,!1)){let e=new Set(l.map(e=>e.skill.name)),t=await c([...a,...i.filter(e=>a.some(t=>t.name===e.name))]);l=[...l.filter(e=>!t.some(t=>t.skill.name===e.skill.name)),...t];for(let t of e)l.some(e=>e.skill.name===t)||J.warn(`Skipped ${t}: its project and user-level copies differ.`)}}if(l.length===0){J.info(`Nothing was migrated.`);return}let u=bu();for(let{skill:t,adopted:n}of l)Gl(t.name,t.files,t.editedAt),!n&&(await q(`Saving ${t.name} to your library`,()=>e.try(e=>e.putSkill(t.name,t.files,t.editedAt)))?u.skills[t.name]={contentHash:t.contentHash,editedAt:t.editedAt,syncedAt:Date.now()}:delete u.skills[t.name]);xu(u);for(let{dirs:e}of l)for(let t of e)z(t);let d=l.filter(e=>e.scope===`user`).map(e=>e.skill.name),f=l.filter(e=>e.scope===`project`).map(e=>e.skill.name);d.length>0&&Pu(d,!0),r&&f.length>0&&Mu(r,f),await q(`Saving to skilless.dev`,()=>B(e));for(let e of f)J.step(`Migrated ${e} into your library and this project.`);for(let e of d)J.step(`Migrated ${e} into your library as a global skill.`);r?await Ym(await q(`Updating this project`,()=>qu(e,n,r)),{yes:t.yes}):d.length>0&&await Ym(await q(`Linking your global skills`,()=>Xu(e)),{yes:t.yes}),e.report()})}),Bh=Um.extend({project:P().optional(),copy:I().optional()}),Vh=new b(`remove`).description(`Remove skills from this project. They stay in your library.`).argument(`<skills...>`,`Skills to remove.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Bh,t);J.intro(Y),await Q(async()=>{let t=new xm,r=Km(n.cwd,n.project),[i,a]=await q(`Loading your library`,async()=>(await B(t),[await Wu(t),new Set(await Gu(t,r))])),o=new Set(i.entries.filter(e=>e.global).map(e=>e.name)),s=[];for(let t of e){if(o.has(t)){J.warn(`${t} is global, so it is in every project.`),J.dim(` Run \`skilless add --not-global ${t}\` to take it out of every project.`);continue}if(!a.has(t)){J.warn(`${t} is not in this project.`);continue}s.push(t)}if(s.length===0){t.report();return}Nu(r,s);let c=mu(n.cwd),l=await q(`Updating this project`,async()=>(await B(t),qu(t,c,r,{copy:n.copy})));for(let e of s)J.step(`Removed ${e} from this project.`);await Ym(l,{copy:n.copy}),J.blank(),J.dim(`Run \`skilless delete ${s.join(` `)}\` to delete ${s.length===1?`it`:`them`}.`),t.report()})});function Hh(e,t,n,r){let i=[...new Set([...e.keys(),...t.keys()])].sort(),a=[];for(let o of i){let i=e.get(o),s=t.get(o),c=n.skills[o];if(i&&s){if(i.contentHash===s.contentHash){a.push({type:`noop`,name:o});continue}let e=!c||c.contentHash!==i.contentHash,t=!c||c.contentHash!==s.contentHash;if(e&&!t)a.push({type:`push`,name:o});else if(!e&&t)a.push({type:`pull`,name:o});else{let e=r??(i.editedAt>=s.editedAt?`push`:`pull`);a.push({type:e===`push`?`conflict-push`:`conflict-pull`,name:o})}continue}if(i&&!s){a.push({type:c?`delete-local`:`push`,name:o});continue}!i&&s&&a.push({type:c?`delete-remote`:`pull`,name:o})}return a}function Uh(e,t,n){return Wh(e,t===`push`?`remote`:`local`,n)}function Wh(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=S.join(Dl,e,`${r}-${t}`);for(let e of n)al(S.join(i,e.path),e.contents);return i}async function Gh(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now();for(let a of t){let{name:t}=a,o=n.local.get(t);switch(a.type){case`noop`:o&&(n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i});break;case`push`:case`conflict-push`:if(!o)break;if(a.type===`conflict-push`){let n=await e.getSkill(t);n&&r.conflicts.push({name:t,kept:`push`,stashedAt:Uh(t,`push`,n.files)})}await e.putSkill(t,o.files,o.editedAt),n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i};break;case`pull`:case`conflict-pull`:{let s=await e.getSkill(t);if(!s)break;a.type===`conflict-pull`&&o&&r.conflicts.push({name:t,kept:`pull`,stashedAt:Uh(t,`pull`,o.files)}),Gl(t,s.files,s.editedAt),n.state.skills[t]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i};break}case`delete-local`:if(!(n.yes||await nm(`Delete ${t} from this machine? It was deleted elsewhere.`,!0))){r.skipped.push(t);continue}z(Ol(t)),delete n.state.skills[t];break;case`delete-remote`:if(!(n.yes||await nm(`Delete ${t} everywhere? It was deleted on this machine.`,!0))){r.skipped.push(t);continue}await e.deleteSkill(t),delete n.state.skills[t];break}r.actions.push(a)}return r}function Kh(e){switch(e.type){case`push`:return`Pushed ${e.name} to skilless.dev.`;case`pull`:return`Pulled ${e.name} from skilless.dev.`;case`conflict-push`:return`${e.name} changed in both places. Kept the copy on this machine.`;case`conflict-pull`:return`${e.name} changed in both places. Kept the copy from skilless.dev.`;case`delete-local`:return`Deleted ${e.name} from this machine.`;case`delete-remote`:return`Deleted ${e.name} everywhere.`;default:return null}}const qh=Um.extend({yes:I(),push:I().optional(),pull:I().optional()}),Jh=new b(`sync`).description(`Sync your library with skilless.dev, in both directions, and update this project's skills and your global ones.`).option(`--push`,`On a conflict, keep the local copy.`).option(`--pull`,`On a conflict, keep the remote copy.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(qh,e);J.intro(Y),await Q(async()=>{let e=Gm(),[n,r]=await q(`Checking skilless.dev`,async()=>[await Lu(e),await e.listSkills()]),i=new Map(ql().map(e=>[e.name,e])),a=new Map(r.map(e=>[e.name,e])),o=bu(),s=Hh(i,a,o,t.push?`push`:t.pull?`pull`:void 0),c=await q(`Syncing your library`,()=>Gh(e,s,{local:i,state:o,yes:t.yes}));xu(o);let l=c.actions.map(Kh).filter(e=>e!==null);for(let e of l)J.step(e);let[u,d]=await q(`Syncing your library`,async()=>{let t=n+await Lu(e);return[t,l.length>0||t>0?await e.listSkills():r]});u>0&&J.step(`Sent ${u} change(s) made while offline.`),Fl(d),Uu(d);let f=pl(t.cwd),p=await q(f?`Updating this project`:`Updating your global skills`,async()=>{if(!f)return{user:Du(d.filter(e=>e.global).map(e=>e.name))};let n=await Tu(e,mu(t.cwd),f);return{...n,project:n.project}}),m=`project`in p?p.project:void 0,{user:h}=p;if(m){for(let e of m.added)J.step(`Linked ${e} into this project.`);for(let e of m.removed)J.step(`Unlinked ${e}, which is no longer in this project.`);for(let e of m.pruned)J.step(`Unlinked ${e}, which is no longer in your library.`)}for(let e of h.added)J.step(`Linked ${e} into ${qm}.`);for(let e of h.removed)J.step(`Unlinked ${e} from ${qm}, since it is no longer global.`);for(let e of h.pruned)J.step(`Unlinked ${e} from ${qm}, since it is no longer in your library.`);let ee=[m,h].reduce((e,t)=>e+(t?t.added.length+t.removed.length+t.pruned.length:0),0);if(l.length===0&&ee===0&&u===0&&J.info(`Everything is already in sync.`),c.conflicts.length>0){J.blank(),J.warn(`${c.conflicts.length} skill(s) changed in two places. The copy that lost is kept here:`);for(let e of c.conflicts)J.dim(` ${e.stashedAt}`)}await Ym({skipped:[...m?.skipped??[],...h.skipped]},{yes:t.yes}),c.skipped.length>0&&(J.blank(),J.dim(`Skipped ${c.skipped.join(`, `)}.`))})}),Yh=Um.extend({yes:I(),force:I()});function Xh(e){let t=fl(e.url)??e.url;return e.ref?`${t}#${e.ref}`:t}const Zh=new b(`update`).description(`Update skills added from a git repository to what the repository has now.`).argument(`[skills...]`,`Skills to update. Omit to update every skill added from a repository.`).option(`-f, --force`,`Replace skills you have edited too. Your copy is kept first.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Yh,t);J.intro(Y),await Q(async()=>{let t=new xm,r=await q(`Loading your library`,async()=>(await B(t),Wu(t))),i=new Map(r.entries.map(e=>[e.name,e])),a=r.entries.filter(e=>e.source!==null);if(e.length>0){let t=e.filter(e=>!i.has(e));if(t.length>0)throw new L(`Not in your library: ${t.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let n=e.filter(e=>!i.get(e)?.source);if(n.length>0)throw new L(`${n.join(`, `)} ${n.length===1?`was`:`were`} not added from a repository, so there is nothing to update from.`)}let o=e.length>0?a.filter(t=>e.includes(t.name)):a;if(o.length===0){J.info(`None of your skills were added from a repository.`),J.dim("Run `skilless add owner/repo` to add some."),t.report();return}let s=new Map;for(let e of o){let t=`${e.source.url}#${e.source.ref??``}`;s.set(t,[...s.get(t)??[],e])}let c=[],l=new Map,u=[],d=[],f=[],p=[];for(let e of s.values()){let r=e[0].source,i=Xh(r);await Dm({url:r.url,ref:r.ref,label:i},async r=>{for(let a of e){let e=Nm(r,a.source.path,a.name);if(!e){J.warn(`${a.name} is no longer in ${i}.`);continue}let o;try{o=Wl(e.dir,a.name)}catch(e){J.warn(`Skipped ${a.name}: ${e instanceof Error?e.message:e}`);continue}let s={...a.source,path:e.path,hash:o.contentHash},p=a.local?.contentHash??a.remote?.contentHash;if(o.contentHash===a.source.hash||p===o.contentHash){Vu(a.name,s),u.push(a.name);continue}if(p!==a.source.hash){if(!(n.force||rm&&!n.yes&&await nm(`You have edited ${a.name} since it came from ${i}. Replace your edits with what it has now?`))){d.push(a.name);continue}let e=a.local?.files??(await q(`Fetching your copy of ${a.name}`,()=>t.try(e=>e.getSkill(a.name))))?.files;if(!e){J.warn(`Couldn't fetch your copy of ${a.name} to keep it, so it was left alone.`);continue}f.push({name:a.name,dir:Wh(a.name,`update`,e)})}c.push(o),l.set(a.name,s)}},{interactive:rm}).then(()=>!0,e=>{if(!(e instanceof L))throw e;return J.warn(e.toString()),!1})||p.push(...e.map(e=>e.name))}J.blank();let m=await q(`Saving ${c.length} skill(s) to your library`,()=>Zu(t,c,i,l));for(let e of m)J.step(`Updated ${e}.`);if(u.length>0&&J.info(u.length===1?`${u[0]} is already up to date.`:`${u.length} skills are already up to date.`),d.length>0&&J.warn(`Kept your edits to ${d.join(`, `)}. Run \`skilless update ${d.join(` `)} --force\` to replace them.`),p.length>0&&J.warn(`Couldn't check ${p.join(`, `)}.`),f.length>0){J.blank(),J.dim(`Your edited copies are kept here:`);for(let e of f)J.dim(` ${e.dir}`)}t.report()})});le.name(Bm).description(Vm).version(Y).addCommand(jh).addCommand(oh).addCommand(Th).addCommand(Zm).addCommand(Zh).addCommand(Vh).addCommand(Dh).addCommand(Nh).addCommand(Jh).addCommand(Ah).addCommand(zh).addCommand(Ih).addCommand(Ch).parse();export{};
|