skilless 0.0.5 → 0.0.8
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 +34 -33
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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,{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,
|
|
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,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:p(_(e)),ee(t||!e||!e.__esModule?m(n,`default`,{value:e,enumerable:!0}):n,e)),b=e(import.meta.url),ne=y((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})),re=y((e=>{let{InvalidArgumentError:t}=ne();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})),ie=y((e=>{let{humanReadableArgName:t}=re();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
|
-
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),
|
|
5
|
+
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),ae=y((e=>{let{InvalidArgumentError:t}=ne();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}
|
|
6
6
|
- a short flag is a single dash and a single character
|
|
7
7
|
- either use a single dash and a single character (for a short flag)
|
|
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})),
|
|
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})),oe=y((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})),se=y((e=>{let t=b(`node:events`).EventEmitter,n=b(`node:child_process`),r=b(`node:path`),i=b(`node:fs`),a=b(`node:process`),{Argument:o,humanReadableArgName:s}=re(),{CommanderError:c}=ne(),{Help:l,stripColor:u}=ie(),{Option:d,DualOptions:f}=ae(),{suggestSimilar:p}=oe();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:()=>g()??(a.stdout.isTTY&&a.stdout.hasColors?.()),getErrHasColors:()=>g()??(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 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(`
|
|
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:ce,createCommand:le,createArgument:ue,createOption:de,CommanderError:fe,InvalidArgumentError:pe,InvalidOptionArgumentError:me,Command:x,Argument:he,Option:S,Help:ge}=te(y((e=>{let{Argument:t}=re(),{Command:n}=se(),{CommanderError:r,InvalidArgumentError:i}=ne(),{Help:a}=ie(),{Option:o}=ae();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 _e=()=>{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:()=>qe});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(ue(t)(r)&&r.index===e.length)return r.output;throw Error(`Failed to parse at index ${r.indexMax}`)},v=(e,t)=>c(e)?y(e,t):m(e)?te(e,t):ee(e,t),y=(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}},ee=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return ce(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})},te=(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},b=(e,t,n,r)=>{let i=ue(e);return ce(se(oe(e=>{let r=0;for(;r<n;){let t=e.index;if(!i(e)||(r+=1,e.index===t))break}return r>=t})))},ne=(e,t)=>b(e,0,1),re=(e,t)=>b(e,0,1/0),ie=(e,t)=>{let n=e.map(ue);return ce(se(oe(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},ae=(e,t)=>{let n=e.map(ue);return ce(se(e=>{for(let t=0,r=n.length;t<r;t++)if(n[t](e))return!0;return!1}))},oe=(e,t=!1)=>{let n=ue(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}},se=(e,t)=>ue(e),ce=(()=>{let e=0;return t=>{let n=ue(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}}}})(),le=e=>{let t;return n=>(t||=ue(e()),t(n))},ue=g(e=>{if(l(e))return u(e)?le(e):e;if(m(e)||p(e))return v(e);if(c(e))return ie(e);if(f(e))return ae(Object.values(e));throw Error(`Invalid rule`)}),de=`abcdefghijklmnopqrstuvwxyz`,fe=e=>{let t=``;for(;e>0;)t=de[(e-1)%26]+t,e=Math.floor((e-1)/26);return t},pe=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t=t*26+de.indexOf(e[n])+1;return t},me=(e,t)=>{if(t<e)return me(t,e);let n=[];for(;e<=t;)n.push(e++);return n},x=(e,t,n)=>me(e,t).map(e=>String(e).padStart(n,`0`)),he=(e,t)=>me(pe(e),pe(t)).map(fe),S=e=>e,ge=e=>_e(t=>_(t,e,{memoization:!1}).join(``)),_e=e=>{let t={};return n=>t[n]??(t[n]=e(n))},ve=v(/^\*\*\/\*$/,`.*`),ye=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),be=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),xe=v(/\\./,S),Se=v(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ce=v(/./,S),we=ae([v(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${Ue(t)}$).*?`),v(/^(!!)+/,``)]),Te=ae([v(/\/(\*\*\/)+/,`(?:/.+/|/)`),v(/^(\*\*\/)+/,`(?:^|.*/)`),v(/\/(\*\*)$/,`(?:/.*|$)`),v(/\*\*/,`.*`)]),Ee=ae([v(/\*\/(?!\*\*\/)/,`[^/]*/`),v(/\*/,`[^/]*`)]),De=v(`?`,`[^/]`),Oe=v(`[`,S),ke=v(`]`,S),Ae=v(/[!^]/,`^/`),je=v(/[a-z]-[a-z]|[0-9]-[0-9]/i,S),Me=ae([xe,v(/[$.*+?^(){}[\|]/,e=>`\\${e}`),je,v(/[^\]]/,S)]),Ne=ie([Oe,ne(Ae),re(Me),ke]),Pe=v(`{`,`(?:`),Fe=v(`}`,`)`),Ie=ie([Pe,ae([v(/(\d+)\.\.(\d+)/,(e,t,n)=>x(+t,+n,Math.min(t.length,n.length)).join(`|`)),v(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>he(t,n).join(`|`)),v(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>he(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Fe]),Le=v(`{`,`(?:`),Re=v(`}`,`)`),ze=v(`,`,`|`),Be=v(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),Ve=v(/[^}]/,S),He=ie([Le,re(ae([Te,Ee,De,Ne,Ie,le(()=>He),xe,Be,ze,Ve])),Re]),Ue=ge(re(ae([ve,ye,be,we,Te,Ee,De,Ne,Ie,He,xe,Se,Ce]))),C=v(/\\./,S),We=v(/./,S),Ge=ge(re(ae([C,v(/\*\*\*+/,`*`),v(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),v(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),We]))),Ke=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(Ke.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};Ke.compile=e=>RegExp(`^${Ue(Ge(e))}$`,`s`);var qe=Ke;return o(s)})();return e.default||e},ve;const ye=(e,t)=>(ve||(ve=_e(),_e=null),ve(e,t)),be=/^[A-Za-z]:\//;function xe(e=``){return e&&e.replace(/\\/g,`/`).replace(be,e=>e.toUpperCase())}const Se=/^[/\\]{2}/,Ce=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,we=/^[A-Za-z]:$/,Te=/^\/([A-Za-z]:)?$/,Ee=/.(\.[^./]+|\.)$/,De=/^[/\\]|^[a-zA-Z]:[/\\]/,Oe=function(e){if(e.length===0)return`.`;e=xe(e);let t=e.match(Se),n=Ne(e),r=e[e.length-1]===`/`;return e=Me(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),we.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Ne(e)?`/${e}`:e)},ke=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 Oe(t)};function Ae(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const je=function(...e){e=e.map(e=>xe(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Ae();!i||i.length===0||(t=`${i}/${t}`,n=Ne(i))}return t=Me(t,!n),n&&!Ne(t)?`/${t}`:t.length>0?t:`.`};function Me(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 Ne=function(e){return Ce.test(e)},Pe=function(e){return xe(e)},Fe=function(e){if(e===`..`)return``;let t=Ee.exec(xe(e));return t&&t[1]||``},Ie=function(e,t){let n=je(e).replace(Te,`$1`).split(`/`),r=je(t).replace(Te,`$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(`/`)},Le=function(e){let t=xe(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&we.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Ne(e)?`/`:`.`)},Re=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 xe(e.root?je(...n):n.join(`/`))},ze=function(e,t){let n=xe(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},Be={__proto__:null,basename:ze,dirname:Le,extname:Fe,format:Re,isAbsolute:Ne,join:ke,matchesGlob:(e,t)=>ye(t,Oe(e)),normalize:Oe,normalizeString:Me,parse:function(e){let t=De.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=ze(e),r=Fe(n);return{root:t,dir:Le(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Ie,resolve:je,sep:`/`,toNamespacedPath:Pe},Ve=globalThis.process?.platform===`win32`?`;`:`:`,He={posix:void 0,win32:void 0},Ue=(e=Ve)=>new Proxy(Be,{get(t,n){return n===`delimiter`?e:n===`posix`?C:n===`win32`?We:He[n]||Be[n]}}),C=Ue(`:`),We=Ue(`;`);function Ge(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 Ke(e,t=`|`){return e.map(e=>gt(e)).join(t)}function qe(e,t){return typeof t==`bigint`?t.toString():t}var Je=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 Ye(e){return new Je(e)}function Xe(e){return e==null}function Ze(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Qe(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 $e(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function et(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function tt(e){return et(e._zod.def)??e._zod.def.shape}function nt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return $e(this,t,e),e},enumerable:!0,configurable:!0})}function rt(e,t,n){t in e?$e(e,t,n):e[t]=n}function it(e,t,n,r){let i=tt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?nt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):rt(e,a,r?r(n.value,a):n.value))}}function at(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?nt(e,n,()=>t[n]):rt(e,n,r.value))}}function w(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ot(e){return JSON.stringify(e)}function st(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const ct=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ut=Ye(()=>{if(rn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function dt(e){if(lt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(lt(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ft(e){return dt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const pt=new Set([`string`,`number`,`symbol`]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ht(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function T(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 gt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function _t(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const vt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},yt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function bt(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 it(i,e,xt(e,t)),ht(e,w(n,{shape:i,checks:[]}))}function xt(e,t){let n=tt(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 St(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(xt(e,t)),a={};return it(a,e,Reflect.ownKeys(tt(e)).filter(e=>!i.has(e))),ht(e,w(n,{shape:a,checks:[]}))}function Ct(e,t){if(!dt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=tt(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 ht(e,w(e._zod.def,{shape:wt(e,t)}))}function wt(e,t){let n={};return it(n,e,Reflect.ownKeys(tt(e))),at(n,t),n}function Tt(e,t){if(!dt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ht(e,w(e._zod.def,{shape:wt(e,t)}))}function Et(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 it(n,e,Reflect.ownKeys(tt(e))),it(n,t,Reflect.ownKeys(tt(t))),ht(e,w(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Dt(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(xt(t,n)):void 0,o={};return it(o,t,Reflect.ownKeys(tt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),ht(t,w(t._zod.def,{shape:o,checks:[]}))}function Ot(e,t,n){let r=n?new Set(xt(t,n)):void 0,i={};return it(i,t,Reflect.ownKeys(tt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),ht(t,w(t._zod.def,{shape:i}))}function kt(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 At(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 jt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Mt(e){return typeof e==`string`?e:e?.message}function Nt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Pt(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:Mt(e.inst?._zod.def?.error?.(e))??Mt(a?.(e))??Mt(t?.error?.(e))??Mt(n.customError?.(e))??Mt(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 Ft=/[\uD800-\uDBFF]/;function It(e){let t=e.length;if(!Ft.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 Lt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Rt(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 zt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Bt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Wt(e,n,r.value)}}function Vt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ht(e,t,n){return Vt(e,t,n,!1)}function Ut(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Vt(this,n,r(this))},set(e){Vt(this,n,e)}})}return t}function Wt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Vt(this,t,n.bind(this))},set(e){Vt(this,t,e)}})}function Gt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Kt,qt=!1;const Jt={configurable:!0,get(){qt=!0}};function E(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Kt!==e._zod){Kt=void 0;return}Kt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Jt);let e=qt;qt=!1;try{let r=n(this);return qt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),qt||=e,r}catch(n){throw delete this[t],qt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Yt(e,t,n,r){let i=Gt(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 Xt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Zt;const Qt={value:void 0,enumerable:!1};let $t=`captureStackTrace`in Error?Error:null;function en(e){let t=$t;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return $t=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function D(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{Qt.value=new a(r);try{Object.defineProperty(n,`_zod`,Qt)}finally{Qt.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),Bt(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?en(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 tn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},nn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Zt=globalThis).__zod_globalConfig??(Zt.__zod_globalConfig={});const rn=globalThis.__zod_globalConfig;function an(e){return e&&Object.assign(rn,e),rn}function on(){let e=this._zod;return e.message??=JSON.stringify(e.def,qe,2),e.message}function sn(e){this._zod.message=e}const cn={get:on,set:sn,enumerable:!0,configurable:!0},ln={value:void 0,enumerable:!1},un=new WeakSet([Object.prototype,Error.prototype]),dn=(e,t)=>{e.name=`$ZodError`,ln.value=t,Object.defineProperty(e,`issues`,ln),ln.value=void 0,Object.defineProperty(e,`message`,cn);let n=Object.getPrototypeOf(e);un.has(n)||(un.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})}}))},fn=D(`$ZodError`,dn);D(`$ZodError`,dn,void 0,{Parent:Error});function pn(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 mn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?pn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function hn(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 gn(e,t){return{callee:t?.callee??e,Err:t?.Err}}const _n=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 tn;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Pt(e,o,an())));throw ct(n,a?.callee??t),n}return s.value};return t},vn=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=>Pt(e,o,an())));throw ct(n,a?.callee??t),n}return s.value};return t},yn=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 tn;return a.issues.length?bn(e,a.issues,i):{success:!0,data:a.value}};function bn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Pt(e,n,an()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const xn=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?bn(e,a.issues,i):{success:!0,data:a.value}},Sn=Symbol.for(`zod.compile.invalid`),Cn=Symbol.for(`zod.compile.fallback`),wn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Sn)return!0;if(r.definite===!0&&n===void 0)return!1}return Tn(e,t,n)});function Tn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Cn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new tn;return a.issues.length===0}const En=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},Dn=e=>{let t=_n(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},gn(n,a));return n},On=e=>{let t=_n(e),n=(e,r,i,a)=>t(e,r,i,gn(n,a));return n},kn=e=>{let t=vn(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},gn(n,a));return n},An=e=>{let t=vn(e),n=async(e,r,i,a)=>await t(e,r,i,gn(n,a));return n},jn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yn(e)(t,n,i)},Mn=e=>(t,n,r)=>yn(e)(t,n,r),Nn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xn(e)(t,n,i)},Pn=e=>async(t,n,r)=>xn(e)(t,n,r),Fn=/^[cC][0-9a-z]{6,}$/,In=/^[0-9a-z]+$/,Ln=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Rn=/^[0-9a-vA-V]{20}$/,zn=/^[A-Za-z0-9]{27}$/,Bn=/^[a-zA-Z0-9_-]{21}$/;function Vn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Hn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Un=/^([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})$/,Wn=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)$/,Gn=/^(?:[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 Kn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const qn=/^(?:(?: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])$/,Jn=/^(([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}|:))$/,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])\/([0-9]|[1-2][0-9]|3[0-2])$/,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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Zn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,$n=/^https?$/,er=/^\+[1-9]\d{6,14}$/,tr=`(?:(?:\\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 nr(e){return RegExp(`^${e}$`)}const rr=nr(tr);function ir(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 ar(e){return RegExp(`^${ir(e)}$`)}function or(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ir({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ir({precision:e.precision})}`:n;return RegExp(`^${tr}T(?:${r})$`)}const sr=/^[\s\S]{0,}$/,cr=/^-?\d+(?:\.\d+)?$/,lr=/^(?:true|false)$/i,ur=/^[^A-Z]*$/,dr=/^[^a-z]*$/,O=D(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fr=e=>{let t=e.value;return!Xe(t)&&t.length!==void 0},pr={number:`number`,bigint:`bigint`,object:`date`},mr=D(`$ZodCheckLessThan`,(e,t)=>{O.init(e,t);let n=pr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:pr[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})}}),hr=D(`$ZodCheckGreaterThan`,(e,t)=>{O.init(e,t);let n=pr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:pr[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})}}),gr=D(`$ZodCheckMultipleOf`,(e,t)=>{O.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):Qe(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})}}),_r=D(`$ZodCheckNumberFormat`,(e,t)=>{O.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=vt[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})}}),vr=D(`$ZodCheckMaxLength`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=fr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?It(r):i)<=t.maximum)return;let a=Lt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yr=D(`$ZodCheckMinLength`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=fr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?It(r):i)>=t.minimum)return;let a=Lt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),br=D(`$ZodCheckLengthEquals`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=fr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?It(r):i;if(a===t.length)return;let o=Lt(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})}}),xr=D(`$ZodCheckStringFormat`,(e,t)=>{var n,r;O.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=()=>{})}),Sr=D(`$ZodCheckRegex`,(e,t)=>{xr.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})}}),Cr=D(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ur,xr.init(e,t)}),wr=D(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=dr,xr.init(e,t)}),Tr=D(`$ZodCheckIncludes`,(e,t)=>{O.init(e,t);let n=mt(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})}}),Er=D(`$ZodCheckStartsWith`,(e,t)=>{O.init(e,t);let n=RegExp(`^${mt(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})}}),Dr=D(`$ZodCheckEndsWith`,(e,t)=>{O.init(e,t);let n=RegExp(`.*${mt(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})}}),Or=D(`$ZodCheckOverwrite`,(e,t)=>{O.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var kr=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 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)=>`
|
|
22
|
+
`)}\n};`)(...Object.values(this.closed))}};const Ar={major:4,minor:6,patch:5},k=D(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;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=kt(t),a;for(let o of n){if(o._zod.def.when){if(At(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 tn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Nt(t.issues,n,e),i||=kt(t,n))});else{if(t.issues.length===n)continue;Nt(t.issues,n,e),i||=kt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(kt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new tn;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 tn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Ht(this,`~standard`,Nr(this))},set"~standard"(e){Vt(this,`~standard`,e)}}),jr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Pt(e,t,an()))}:{value:e.value};async function Mr(e,t){let n={async:!0};return jr(await e._zod.run({value:t,issues:[]},n),n)}function Nr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return jr(r,n)}catch{}return Mr(e,t)},vendor:`zod`,version:1}}const Pr=D(`$ZodString`,(e,t)=>{k.init(e,t),e._zod.pattern=t.pattern??sr,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}}),A=D(`$ZodStringFormat`,(e,t)=>{xr.init(e,t),Pr.init(e,t)}),Fr=D(`$ZodGUID`,(e,t)=>{t.pattern??=Un,A.init(e,t)}),Ir=D(`$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??=Wn(e)}else t.pattern??=Wn();A.init(e,t)}),Lr=D(`$ZodEmail`,(e,t)=>{t.pattern??=Gn,A.init(e,t)});function Rr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function zr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Rr(e)||2:Br(e,t)}function Br(e,t){if(!t.normalize&&t.protocol?.source===$n.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 Vr=/[\t\n\r]/g;function Hr(e){return e.replace(Vr,``)}function Ur(e,t){return t.lastIndex=0,t.test(e.hostname)}function Wr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const Gr=D(`$ZodURL`,(e,t)=>{A.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=zr(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=Hr(r);return}t.hostname&&!Ur(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&&!Wr(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:Hr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Kr=D(`$ZodEmoji`,(e,t)=>{t.pattern??=Kn(),A.init(e,t)}),qr=D(`$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?Bn:Vn(t.length),A.init(e,t)}),Jr=D(`$ZodCUID`,(e,t)=>{t.pattern??=Fn,A.init(e,t)}),Yr=D(`$ZodCUID2`,(e,t)=>{t.pattern??=In,A.init(e,t)}),Xr=D(`$ZodULID`,(e,t)=>{t.pattern??=Ln,A.init(e,t)}),Zr=D(`$ZodXID`,(e,t)=>{t.pattern??=Rn,A.init(e,t)}),Qr=D(`$ZodKSUID`,(e,t)=>{t.pattern??=zn,A.init(e,t)}),$r=D(`$ZodISODateTime`,(e,t)=>{t.pattern??=or(t),A.init(e,t)}),ei=D(`$ZodISODate`,(e,t)=>{t.pattern??=rr,A.init(e,t)}),ti=D(`$ZodISOTime`,(e,t)=>{t.pattern??=ar(t),A.init(e,t)}),ni=D(`$ZodISODuration`,(e,t)=>{t.pattern??=Hn,A.init(e,t)}),ri=D(`$ZodIPv4`,(e,t)=>{t.pattern??=qn,A.init(e,t)}),ii=/^[0-9a-fA-F:.]+$/;function ai(e){return ii.test(e)?Rr(`http://[${e}]`):!1}const oi=D(`$ZodIPv6`,(e,t)=>{t.pattern??=Jn,A.init(e,t),e._zod.check=n=>{ai(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),si=D(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Yn,A.init(e,t)});function ci(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:ai(n)}const li=D(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Xn,A.init(e,t),e._zod.check=n=>{ci(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ui(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const di=/^[0-9a-zA-Z+/]*={0,2}$/,fi=D(`$ZodBase64`,(e,t)=>{t.pattern??=di,A.init(e,t),e._zod.check=n=>{ui(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),pi=/^[A-Za-z0-9_-]*$/;function mi(e){if(!pi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ui(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const hi=D(`$ZodBase64URL`,(e,t)=>{t.pattern??=pi,A.init(e,t),e._zod.check=n=>{mi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),gi=D(`$ZodE164`,(e,t)=>{t.pattern??=er,A.init(e,t)});function _i(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 vi=D(`$ZodJWT`,(e,t)=>{A.init(e,t),e._zod.check=n=>{_i(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),yi=D(`$ZodNumber`,(e,t)=>{k.init(e,t),e._zod.pattern=cr,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}}),bi=D(`$ZodNumberFormat`,(e,t)=>{_r.init(e,t),yi.init(e,t)}),xi=D(`$ZodBoolean`,(e,t)=>{k.init(e,t),e._zod.pattern=lr,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}}),Si=D(`$ZodUnknown`,(e,t)=>{k.init(e,t),e._zod.parse=e=>e}),Ci=D(`$ZodNever`,(e,t)=>{k.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function wi(e,t,n){e.issues.length&&t.issues.push(...jt(n,e.issues)),t.value[n]=e.value}const Ti=D(`$ZodArray`,(e,t)=>{k.init(e,t);let n=rn.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=>wi(t,r,e)));else if(wi(c,r,e),s&&c.issues.length!==0&&kt(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Ei(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(...jt(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 Di=[];function Oi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Di,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=_t(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ki(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(kt(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=>Ei(e,n,i,t,d,f))):Ei(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 Ai=D(`$ZodObject`,(e,t)=>{k.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=Ye(()=>Oi(t));E(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)||$e(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=lt,o=t.catchall,s,c=rn.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(kt(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=>Ei(n,t,e,r,a,o))):Ei(s,t,e,r,a,o)}return o?ki(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),ji=D(`$ZodObjectJIT`,(e,t)=>{Ai.init(e,t);let n=e._zod.parse,r=Ye(()=>Oi(t)),i=rn.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new kr([`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)}]`:ot(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,58 @@ 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=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>
|
|
72
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=lt,c=!rn.jitless,l=c&&ut.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?ki([],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 Mi(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=>!kt(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=>Pt(e,r,an())))}),t)}const Ni=D(`$ZodUnion`,(e,t)=>{k.init(e,t),E(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),E(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),E(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)))}),E(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=>Ze(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=>Mi(t,r,e,i)):Mi(o,r,e,i)}}),Pi=D(`$ZodIntersection`,(e,t)=>{k.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])=>Ii(e,t,n)):Ii(e,i,a)}});function Fi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(dt(e)&&dt(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=Fi(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=Fi(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 Ii(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=Fi(t.value,n.value);if(!c.valid){if(kt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Li=D(`$ZodEnum`,(e,t)=>{k.init(e,t);let n=Ge(t.entries),r=new Set(n);e._zod.values=r,E(e,`pattern`,e=>{let t=Ge(e.def.entries).filter(e=>pt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>mt(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}}),Ri=D(`$ZodTransform`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,rn.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(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 tn;return n.value=i,n}});function zi(e,t){return e.value=t.issues.length?void 0:t.value,e}const Bi=D(`$ZodOptional`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,E(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ze(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=>zi(e,t)):zi(e,r)}return t.innerType._zod.run(e,n)}}),Vi=D(`$ZodExactOptional`,(e,t)=>{Bi.init(e,t),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Hi=D(`$ZodNullable`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin),E(e,`optout`,e=>e.def.innerType._zod.optout),E(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Ze(t.source)}|null)$`):void 0}),E(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)}),Ui=D(`$ZodDefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,E(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=>Wi(e,t)):Wi(r,t)}});function Wi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gi=D(`$ZodPrefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,E(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))}),Ki=D(`$ZodNonOptional`,(e,t)=>{k.init(e,t),E(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=>qi(t,e)):qi(i,e)}});function qi(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 Ji(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Pt(e,r,an()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Yi=D(`$ZodCatch`,(e,t)=>{k.init(e,t),E(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),E(e,`optout`,e=>e.def.innerType._zod.optout),E(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=>Ji(e,r,t,n)):Ji(e,r,t,n)}}),Xi=D(`$ZodPipe`,(e,t)=>{k.init(e,t),E(e,`values`,e=>e.def.in._zod.values),E(e,`optin`,e=>e.def.in._zod.optin),E(e,`optout`,e=>e.def.out._zod.optout),E(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=>Zi(e,t.in,n)):Zi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Zi(e,t.out,n)):Zi(r,t.out,n)}});function Zi(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 Qi=D(`$ZodReadonly`,(e,t)=>{k.init(e,t),E(e,`propValues`,e=>e.def.innerType._zod.propValues),E(e,`values`,e=>e.def.innerType._zod.values),E(e,`optin`,e=>e.def.innerType?._zod?.optin),E(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($i):$i(r)}});function $i(e){return e.memo||(e.value=Object.freeze(e.value)),e}const ea=D(`$ZodCustom`,(e,t)=>{O.init(e,t),k.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=>ta(t,n,r,e));ta(i,n,r,e)}});function ta(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(zt(e))}}var na=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const ra=`~memo`,ia=[];function aa(e){return typeof e==`object`&&!!e}function oa(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const sa=new WeakMap;function ca(e,t,n){let r=sa.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=ca(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?ca(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=et(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?ca(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),la(e,i)}function la(e,t){return t!==1&&sa.set(e,t===2),t}function ua(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let da;const fa=[],pa={alloc(e,t,n){let r=da;if(!r)return n;da=void 0;let i={value:n,issues:null};return r.set(t.value,i),fa.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`&&ha(n,e.value))throw new na;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=ca(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(!aa(l))return t(s,c);let u=c[ra];u||(u={buckets:new WeakMap,backEdges:void 0},c[ra]=u);let d;i===c?d=a:(d=ua(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(...oa(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;da=d;let p=fa.length,m=t(s,c);da=void 0;let h=fa.length>p?fa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?oa(e.issues):ia),e)):(h&&(h.issues=m.issues.length?oa(m.issues):ia),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ma(){return pa}function ha(e,t){let n=e[ra]?.backEdges;return n!==void 0&&aa(t)&&n.has(t)}const ga=()=>{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(Rt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${gt(e.values[0])}`:`Invalid option: expected one of ${Ke(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`:``}: ${Ke(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 _a(){return{localeError:ga()}}var va,ya=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 ba(){return new ya}(va=globalThis).__zod_globalRegistry??(va.__zod_globalRegistry=ba());const xa=globalThis.__zod_globalRegistry;function Sa(e){return e.checks&&=[...e.checks],e}function Ca(e,t){return new e(Sa({type:`string`,...T(t)}))}function wa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}function Ta(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}function Ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}function Da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}function Aa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}function ja(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}function Ma(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}function Na(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}function Pa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}function Fa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}function Ia(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}function La(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}function Ra(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}function za(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}function Ba(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}function Va(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}function Ha(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}function Ua(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}function Wa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}function Ga(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}function Ka(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}function qa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}function Ja(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}function Ya(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}function Xa(e,t){return new e(Sa({type:`number`,checks:[],...T(t)}))}function Za(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}function Qa(e,t){return new e({type:`boolean`,...T(t)})}function $a(e){return new e({type:`unknown`})}function eo(e,t){return new e({type:`never`,...T(t)})}function to(e,t){return new mr({check:`less_than`,...T(t),value:e,inclusive:!1})}function no(e,t){return new mr({check:`less_than`,...T(t),value:e,inclusive:!0})}function ro(e,t){return new hr({check:`greater_than`,...T(t),value:e,inclusive:!1})}function io(e,t){return new hr({check:`greater_than`,...T(t),value:e,inclusive:!0})}function ao(e,t){return new gr({check:`multiple_of`,...T(t),value:e})}function oo(e,t){return new vr({check:`max_length`,...T(t),maximum:e})}function so(e,t){return new yr({check:`min_length`,...T(t),minimum:e})}function co(e,t){return new br({check:`length_equals`,...T(t),length:e})}function lo(e,t){return new Sr({check:`string_format`,format:`regex`,...T(t),pattern:e})}function uo(e){return new Cr({check:`string_format`,format:`lowercase`,...T(e)})}function fo(e){return new wr({check:`string_format`,format:`uppercase`,...T(e)})}function po(e,t){return new Tr({check:`string_format`,format:`includes`,...T(t),includes:e})}function mo(e,t){return new Er({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}function ho(e,t){return new Dr({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}function go(e){return new Or({check:`overwrite`,tx:e})}function _o(e){return go(t=>t.normalize(e))}function vo(){return go(e=>e.trim())}function yo(){return go(e=>e.toLowerCase())}function bo(){return go(e=>e.toUpperCase())}function xo(){return go(e=>st(e))}function So(e,t,n){return new e({type:`array`,element:t,...T(n)})}function Co(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}function wo(e,t){let n=To(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(zt(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(zt(r))}},e(t.value,t)),t);return n}function To(e,t){let n=new O({check:`custom`,...T(t)});return n._zod.check=e,n}function Eo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&$e(e,t,n[t]);return e}function Do(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??xa,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 Oo(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 j(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,j(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Eo(o.schema,c),t.io===`input`&&M(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 ko(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ao(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}/${ko(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+ko(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 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(`
|
|
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 jo(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;jo(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 Mo=new Set([`type`,`properties`,`required`,`additionalProperties`]),No=[`oneOf`,`anyOf`];function Po(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Fo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Mo.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]??Po(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}$e(n,r,e.length===1?e[0]:Fo(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=Po(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 Io(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Mo)if(t in e)return;let n=t.filter(e=>No.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Fo(t);else{let e=n[0],i=No.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=>Fo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Eo(e,r))}function Lo(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)):Eo(i,s),Eo(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())jo(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)??[])Io(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)}Eo(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,$e(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:zo(t,`input`,e.processors),output:zo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function M(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 M(r.element,n);if(r.type===`set`)return M(r.valueType,n);if(r.type===`lazy`)return M(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 M(r.innerType,n);if(r.type===`intersection`)return M(r.left,n)||M(r.right,n);if(r.type===`record`||r.type===`map`)return M(r.keyType,n)||M(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:M(r.in,n)||M(r.out,n);if(r.type===`object`){for(let e in r.shape)if(M(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(M(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(M(e,n))return!0;return!!(r.rest&&M(r.rest,n))}return!1}const Ro=(e,t={})=>n=>{let r=Do({...n,processors:t});return j(e,r),Ao(r,e),Lo(r,e)},zo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Do({...i??{},target:a,io:t,processors:n});return j(e,o),Ao(o,e),Lo(o,e)},Bo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Vo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ho=(e,t)=>{Bo(e,`minimum`,t),Vo(e,`maximum`,t)},Uo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Wo=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Go=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ko=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},qo=(e,t)=>Bo(e,`minimum`,t.minimum),Jo=(e,t)=>Vo(e,`maximum`,t.maximum),Yo=e=>(t,n)=>{Ko(t,n.format);let[r,i]=e[n.format];Bo(t,`minimum`,r),Vo(t,`maximum`,i)},Xo={greater_than:(e,t)=>Bo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Vo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Uo(e,t.value),number_format:Yo(vt),bigint_format:Yo(yt),min_length:qo,max_length:Jo,length_equals:(e,t)=>Ho(e,t.length),min_size:qo,max_size:Jo,size_equals:(e,t)=>Ho(e,t.size),string_format:(e,t)=>{Ko(e,t.format),t.pattern&&Wo(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)=>Go(e,t.mime)};function Zo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Xo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Bo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Bo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Vo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Vo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Uo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Go(t,i.mime);for(let e of i.patterns??[])Wo(t,e);return t}const Qo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$o=new Map([[di,Zn],[pi,Qn]]),es=e=>$o.get(e)??e,ts=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qo[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(es);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}))])}},ns=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zo(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)):Oo(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}))])}},rs=(e,t,n,r)=>{n.type=`boolean`},is=(e,t,n,r)=>{n.not={}},as=(e,t,n,r)=>{let i=e._zod.def,a=Ge(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},os=(e,t,n,r)=>{Oo(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ss=(e,t,n,r)=>{Oo(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},cs=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Zo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})};function ls(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ls(t.out):t.type===`catch`?ls(t.innerType):e._zod.optin}const us=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Oo(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)$e(i.properties,e,j(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`?ls(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=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ds=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},fs=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(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)},ps=(e,t,n,r)=>{let i=e._zod.def,a=j(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`}]},ms=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},hs=Symbol();function gs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Oo(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),hs):JSON.parse(o)}const _s=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=gs(i.defaultValue,e,t,n,r);o!==hs&&(n.default=o)},vs=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=gs(i.defaultValue,e,t,n,r);o!==hs&&(n._prefault=o)},ys=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Oo(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},bs=(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;j(o,t,r);let s=t.seen.get(e);s.ref=o},xs=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ss=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Cs=new WeakSet([Object.prototype,Error.prototype]);function ws(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 Ts=D(`ZodError`,(e,t)=>{fn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Cs.has(n)||(Cs.add(n),ws(n,`format`,e=>t=>hn(e,t)),ws(n,`flatten`,e=>t=>mn(e,t)),ws(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,qe,2)}),ws(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,qe,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Es=_n(Ts),Ds=vn(Ts),Os=yn(Ts),ks=xn(Ts),As=Dn(Ts),js=On(Ts),Ms=kn(Ts),Ns=An(Ts),Ps=jn(Ts),Fs=Mn(Ts),Is=Nn(Ts),Ls=Pn(Ts);function Rs(){rn.localeError||an(_a())}function zs(){rn.memoizer||an({memoizer:ma()})}const N=D(`ZodType`,(e,t)=>(Rs(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(w(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 ht(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(go(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 xa.add(t,{description:e}),t},meta(...e){if(e.length===0)return xa.get(this);let t=this.clone();return xa.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 Ht(this,`~standard`,{...Nr(this),jsonSchema:{input:zo(this,`input`),output:zo(this,`output`)}})},set"~standard"(e){Vt(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){Vt(this,`spa`,e)},validate(e,t){return wn(this,e,t)},validateAsync(e,t){return En(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 Ro(this,{})(e)},get description(){return xa.get(this)?.description},get _def(){return this._zod.def}}),Bs=D(`_ZodString`,(e,t)=>{Pr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)},Ut({format:e=>Zo(e).format??null,minLength:e=>Zo(e).minimum??null,maxLength:e=>Zo(e).maximum??null},{regex(...e){return this.check(lo(...e))},includes(...e){return this.check(po(...e))},startsWith(...e){return this.check(mo(...e))},endsWith(...e){return this.check(ho(...e))},min(...e){return this.check(so(...e))},max(...e){return this.check(oo(...e))},length(...e){return this.check(co(...e))},nonempty(...e){return this.check(so(1,...e))},lowercase(e){return this.check(uo(e))},uppercase(e){return this.check(fo(e))},trim(){return this.check(vo())},normalize(...e){return this.check(_o(...e))},toLowerCase(){return this.check(yo())},toUpperCase(){return this.check(bo())},slugify(){return this.check(xo())}})),Vs=D(`ZodString`,(e,t)=>{Pr.init(e,t),Bs.init(e,t)},{email(e){return this.check(wa(Ks,e))},url(e){return this.check(Aa(Ys,e))},jwt(e){return this.check(Ga(uc,e))},emoji(e){return this.check(ja(Xs,e))},guid(e){return this.check(Ta(qs,e))},uuid(e){return this.check(Ea(Js,e))},uuidv4(e){return this.check(Da(Js,e))},uuidv6(e){return this.check(Oa(Js,e))},uuidv7(e){return this.check(ka(Js,e))},nanoid(e){return this.check(Ma(Zs,e))},cuid(e){return this.check(Na(Qs,e))},cuid2(e){return this.check(Pa($s,e))},ulid(e){return this.check(Fa(ec,e))},base64(e){return this.check(Ha(sc,e))},base64url(e){return this.check(Ua(cc,e))},xid(e){return this.check(Ia(tc,e))},ksuid(e){return this.check(La(nc,e))},ipv4(e){return this.check(Ra(rc,e))},ipv6(e){return this.check(za(ic,e))},cidrv4(e){return this.check(Ba(ac,e))},cidrv6(e){return this.check(Va(oc,e))},e164(e){return this.check(Wa(lc,e))},datetime(e){return this.check(Ka(Hs,e))},date(e){return this.check(qa(Us,e))},time(e){return this.check(Ja(Ws,e))},duration(e){return this.check(Ya(Gs,e))}});function P(e){return Ca(Vs,e)}const F=D(`ZodStringFormat`,(e,t)=>{A.init(e,t),Bs.init(e,t)}),Hs=D(`ZodISODateTime`,(e,t)=>{$r.init(e,t),F.init(e,t)}),Us=D(`ZodISODate`,(e,t)=>{ei.init(e,t),F.init(e,t)}),Ws=D(`ZodISOTime`,(e,t)=>{ti.init(e,t),F.init(e,t)}),Gs=D(`ZodISODuration`,(e,t)=>{ni.init(e,t),F.init(e,t)}),Ks=D(`ZodEmail`,(e,t)=>{Lr.init(e,t),F.init(e,t)}),qs=D(`ZodGUID`,(e,t)=>{Fr.init(e,t),F.init(e,t)}),Js=D(`ZodUUID`,(e,t)=>{Ir.init(e,t),F.init(e,t)}),Ys=D(`ZodURL`,(e,t)=>{Gr.init(e,t),F.init(e,t)}),Xs=D(`ZodEmoji`,(e,t)=>{Kr.init(e,t),F.init(e,t)}),Zs=D(`ZodNanoID`,(e,t)=>{qr.init(e,t),F.init(e,t)}),Qs=D(`ZodCUID`,(e,t)=>{Jr.init(e,t),F.init(e,t)}),$s=D(`ZodCUID2`,(e,t)=>{Yr.init(e,t),F.init(e,t)}),ec=D(`ZodULID`,(e,t)=>{Xr.init(e,t),F.init(e,t)}),tc=D(`ZodXID`,(e,t)=>{Zr.init(e,t),F.init(e,t)}),nc=D(`ZodKSUID`,(e,t)=>{Qr.init(e,t),F.init(e,t)}),rc=D(`ZodIPv4`,(e,t)=>{ri.init(e,t),F.init(e,t)}),ic=D(`ZodIPv6`,(e,t)=>{oi.init(e,t),F.init(e,t)}),ac=D(`ZodCIDRv4`,(e,t)=>{si.init(e,t),F.init(e,t)}),oc=D(`ZodCIDRv6`,(e,t)=>{li.init(e,t),F.init(e,t)}),sc=D(`ZodBase64`,(e,t)=>{fi.init(e,t),F.init(e,t)}),cc=D(`ZodBase64URL`,(e,t)=>{hi.init(e,t),F.init(e,t)}),lc=D(`ZodE164`,(e,t)=>{gi.init(e,t),F.init(e,t)}),uc=D(`ZodJWT`,(e,t)=>{vi.init(e,t),F.init(e,t)}),dc=D(`ZodNumber`,(e,t)=>{yi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.isFinite=!0},Ut({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Zo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zo(e).format??null},{gt(e,t){return this.check(ro(e,t))},gte(e,t){return this.check(io(e,t))},min(e,t){return this.check(io(e,t))},lt(e,t){return this.check(to(e,t))},lte(e,t){return this.check(no(e,t))},max(e,t){return this.check(no(e,t))},int(e){return this.check(mc(e))},safe(e){return this.check(mc(e))},positive(e){return this.check(ro(0,e))},nonnegative(e){return this.check(io(0,e))},negative(e){return this.check(to(0,e))},nonpositive(e){return this.check(no(0,e))},multipleOf(e,t){return this.check(ao(e,t))},step(e,t){return this.check(ao(e,t))},finite(){return this}}));function fc(e){return Xa(dc,e)}const pc=D(`ZodNumberFormat`,(e,t)=>{bi.init(e,t),dc.init(e,t)});function mc(e){return Za(pc,e)}const hc=D(`ZodBoolean`,(e,t)=>{xi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)});function I(e){return Qa(hc,e)}const gc=D(`ZodUnknown`,(e,t)=>{Si.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _c(){return $a(gc)}const vc=D(`ZodNever`,(e,t)=>{Ci.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function yc(e){return eo(vc,e)}const bc=D(`ZodArray`,(e,t)=>{zs(),Ti.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.element=t.element},{min(e,t){return this.check(so(e,t))},nonempty(e){return this.check(so(1,e))},max(e,t){return this.check(oo(e,t))},length(e,t){return this.check(co(e,t))},unwrap(){return this.element}});function xc(e,t){return So(bc,e,t)}const Sc=D(`ZodObject`,(e,t)=>{zs(),ji.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),Yt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return kc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(w(this._zod.def,{catchall:e}))},passthrough(){return this.clone(w(this._zod.def,{catchall:_c()}))},loose(){return this.clone(w(this._zod.def,{catchall:_c()}))},strict(){return this.clone(w(this._zod.def,{catchall:yc()}))},strip(){return this.clone(w(this._zod.def,{catchall:void 0}))},extend(e){return Ct(this,e)},safeExtend(e){return Tt(this,e)},merge(e){return Et(this,e)},pick(e){return bt(this,e)},omit(e){return St(this,e)},partial(...e){return Dt(Mc,this,e[0])},exactPartial(...e){return Dt(Pc,this,e[0],`exactPartial`)},required(...e){return Ot(Hc,this,e[0])}});function Cc(e,t){return new Sc({type:`object`,shape:e??{},...T(t)})}const wc=D(`ZodUnion`,(e,t)=>{Ni.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.options=t.options});function Tc(e,t){return new wc({type:`union`,options:e,...T(t)})}const Ec=D(`ZodIntersection`,(e,t)=>{Pi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function Dc(e,t){return new Ec({type:`intersection`,left:e,right:t})}const Oc=D(`ZodEnum`,(e,t)=>{Li.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(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:[],...T(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:[],...T(r),entries:i})}});function kc(e,t){return new Oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}const Ac=D(`ZodTransform`,(e,t)=>{zs(),Ri.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new nn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(zt(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(zt(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=D(`ZodOptional`,(e,t)=>{Bi.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 Nc(e){return new Mc({type:`optional`,innerType:e})}const Pc=D(`ZodExactOptional`,(e,t)=>{Vi.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 Fc(e){return new Pc({type:`optional`,innerType:e})}const Ic=D(`ZodNullable`,(e,t)=>{Hi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`nullable`,innerType:e})}const Rc=D(`ZodDefault`,(e,t)=>{Ui.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(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():ft(t)}})}const Bc=D(`ZodPrefault`,(e,t)=>{Gi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(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():ft(t)}})}const Hc=D(`ZodNonOptional`,(e,t)=>{Ki.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 Uc(e,t){return new Hc({type:`nonoptional`,innerType:e,...T(t)})}const Wc=D(`ZodCatch`,(e,t)=>{Yi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(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:Xt(t)})}const Kc=D(`ZodPipe`,(e,t)=>{Xi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(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=D(`ZodReadonly`,(e,t)=>{Qi.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`readonly`,innerType:e})}const Xc=D(`ZodCustom`,(e,t)=>{ea.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Zc(e,t={}){return Co(Xc,e,t)}function Qc(e,t){return wo(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})}}const il=new Set;function al(){for(let e of il)z(e);il.clear()}function ol(e){process.exit(128+s.constants.signals[e])}const sl=[`SIGINT`,`SIGTERM`];function cl(e){let t=a.mkdtempSync(C.join(s.tmpdir(),e));if(il.size===0){process.on(`exit`,al);for(let e of sl)process.on(e,ol)}return il.add(t),{dir:t,dispose(){if(z(t),il.delete(t),!(il.size>0)){process.off(`exit`,al);for(let e of sl)process.off(e,ol)}}}}function ll(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?C.join(i,a.name):a.name,s=C.join(e,a.name);a.isDirectory()?r(s,o):a.isFile()&&n.push(o)}};return r(e,``),n.sort()}function ul(e,t){rl(C.dirname(e)),a.writeFileSync(e,t,`utf8`)}function dl(e,t){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return t}}function fl(e,t,n){rl(C.dirname(e)),a.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function pl(e,t){rl(t),a.cpSync(e,t,{recursive:!0,dereference:!0})}function ml(e,t){try{return n(`git`,e,{cwd:t,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function hl(e){let t=ml([`rev-parse`,`--show-toplevel`],e);return t?C.normalize(t):null}function gl(e){return ml([`remote`,`get-url`,`origin`],e)}function _l(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 vl(e){let t=gl(e);return t?_l(t):null}function yl(e){let t=ml([`rev-parse`,`--git-common-dir`],e);return t?C.isAbsolute(t)?C.normalize(t):C.resolve(e,t):null}function bl(e){let t=yl(e);return t?C.join(t,`info`,`exclude`):null}function xl(e,t){return ml([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function Sl(e,t){return ml([`rm`,`-r`,`--cached`,`--quiet`,`--`,t],e)!==null}function Cl(e,t){let n=bl(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 rl(
|
|
80
|
-
`)}\n`,`utf8`),!0}function
|
|
79
|
+
`:``;return rl(C.dirname(n)),a.appendFileSync(n,`${c}${s}${o.join(`
|
|
80
|
+
`)}\n`,`utf8`),!0}function wl(e){let t=bl(e);return t?R(t)?new Set(a.readFileSync(t,`utf8`).split(`
|
|
81
|
+
`).map(e=>e.trim()).filter(Boolean)):new Set:null}function Tl(e,t){let n=bl(e);if(!n||!R(n))return;let r=new Set(t),i=a.readFileSync(n,`utf8`).split(`
|
|
81
82
|
`).filter(e=>!r.has(e.trim()));a.writeFileSync(n,i.join(`
|
|
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,t){let n=Ou();if(Au(n))return 0;let r=new Set((t??await e.listSkills()).map(e=>e.name)),i=e=>Kl().includes(e),a=0;for(let t of[...n.deletes])r.has(t)&&(await e.deleteSkill(t),r.delete(t),a++),n.deletes=n.deletes.filter(e=>e!==t),ku(n);for(let[t,o]of Object.entries(n.globals)){if(r.has(t))await e.setGlobal(t,o),a++;else if(i(t))continue;delete n.globals[t],ku(n)}for(let[t,o]of Object.entries(n.sources)){if(r.has(t))await e.setSource(t,o),a++;else if(i(t))continue;delete n.sources[t],ku(n)}for(let[t,r]of Object.entries(n.projects)){let o=(await e.getBindings(t)).filter(e=>!e.global).map(e=>e.name),s=[...new Set([...o,...r.add])].filter(e=>!r.remove.includes(e)),c=await e.setBindings(t,s),l=new Set(c.unknown);a+=r.add.filter(e=>!l.has(e)).length+r.remove.length,r.add=r.add.filter(e=>l.has(e)&&i(e)),r.remove=[],r.add.length===0&&delete n.projects[t],ku(n)}return a}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=
|
|
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})),
|
|
83
|
+
`),`utf8`)}const El=process.env.SKILLESS_HOME?C.resolve(process.env.SKILLESS_HOME):C.join(s.homedir(),`.skilless`),Dl=C.join(El,`skills`),Ol=C.join(El,`auth.json`),kl=C.join(El,`state.json`),Al=C.join(El,`cache.json`),jl=C.join(El,`sources.json`),Ml=C.join(El,`pending.json`),Nl=C.join(El,`config.json`),Pl=C.join(El,`conflicts`);function Fl(e){return C.join(Dl,e)}const Il=`.agents/skills`,Ll=`.claude/skills`;function Rl(){return process.env.CLAUDE_CONFIG_DIR?C.resolve(process.env.CLAUDE_CONFIG_DIR):C.join(s.homedir(),`.claude`)}function zl(){return C.join(s.homedir(),Il)}function Bl(){return C.join(Rl(),`skills`)}function Vl(){let e=dl(Al,{});return{version:1,library:e.library?.map(e=>({...e,source:e.source??null}))??null,projects:e.projects??{}}}function Hl(e){let t=Vl();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})),fl(Al,t)}function Ul(e,t){let n=Vl();n.projects[e]=t.filter(e=>!e.global).map(e=>e.name),fl(Al,n)}const Wl=`SKILL.md`,Gl=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),Kl=/^[a-z0-9][a-z0-9._-]*$/;function ql(e){return Gl.has(e)}function Jl(e){return e.length<=64&&Kl.test(e)}function Yl(e){if(!Jl(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 Xl(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 Zl(e,t){if(!R(C.join(e,Wl)))throw new L(`${t} has no ${Wl}.`,{suggestion:`Every skill needs a ${Wl} at its root.`});let n=ll(e,ql),r=[],i=0,o=0;for(let s of n){let n=C.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:Xl(r),editedAt:i}}function Ql(e,t,n){let r=Fl(e);z(r),rl(r);for(let e of t)ul(C.join(r,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)a.utimesSync(C.join(r,n.path),e,e)}}function $l(){return R(Dl)?a.readdirSync(Dl,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!ql(e.name)).map(e=>e.name).sort():[]}function eu(){return $l().map(e=>Zl(Fl(e),e))}function tu(e){let t=Fl(e);return R(t)?Zl(t,e):null}function nu(e,t){return[{path:Wl,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 ru(e){return{agents:C.join(e,Il),claude:C.join(e,Ll),repo:e}}function iu(){return{agents:zl(),claude:Bl(),repo:null}}function au(e){return typeof e==`string`?ru(e):e}const ou=`.agents/skills/.skilless.json`;function su(e){let t;try{t=C.normalize(a.realpathSync(e))}catch{t=C.normalize(e)}return process.platform===`win32`?t.toLowerCase():t}function cu(e,t){try{return su(C.resolve(C.dirname(e),a.readlinkSync(e)))===su(t)}catch{return!1}}function lu(e,t){let n=C.join(e.agents,t);if(cu(n,Fl(t)))return!0;if(!cu(C.join(e.claude,t),n))return!1;if(!e.repo)return!0;let r=wl(e.repo);return r===null||r.has(`/${Il}/${t}`)}function uu(e){let t=au(e);return R(t.agents)?a.readdirSync(t.agents).filter(e=>!e.startsWith(`.`)).filter(e=>lu(t,e)).sort():[]}function du(e){return R(e.claude)&&su(e.claude)===su(e.agents)}function fu(e,t){let n=C.join(e.agents,t),r=C.join(e.claude,t),i=[];return R(n)&&!lu(e,t)&&i.push(n),!du(e)&&R(r)&&!cu(r,n)&&i.push(r),i}function pu(e){return e.flatMap(e=>[`/${Il}/${e}`,`/${Ll}/${e}`])}function mu(e,t){process.platform===`win32`?a.symlinkSync(C.resolve(C.dirname(t),e),t,`junction`):a.symlinkSync(e,t,`dir`)}function hu(e,t,n){rl(C.dirname(t));try{mu(e,t)}catch{n()}}function gu(e,t,n){let r=au(e),{repo:i}=r;i&&z(C.join(i,ou));let a=[],o=[];for(let e of t){if(i&&(xl(i,`${Il}/${e.name}`)||xl(i,`${Ll}/${e.name}`))){o.push({name:e.name,reason:`tracked`});continue}let t=fu(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}_u(r,e,n),a.push(e.name)}return i&&(Tl(i,[`/${ou}`]),Cl(i,pu([...new Set([...a,...uu(r)])]))),{written:a,skipped:o}}function _u(e,t,n){let r=C.join(e.agents,t.name),i=C.join(e.claude,t.name),a=!du(e);if(z(r),a&&z(i),n.copy){rl(r);for(let e of t.files??[])ul(C.join(r,e.path),e.contents)}else{let e=Fl(t.name);hu(e,r,()=>pl(e,r))}a&&hu(C.relative(C.dirname(i),r),i,()=>pl(r,i))}function vu(e,t){if(!e.occupied)return;let{scope:n,skill:r,paths:i}=e.occupied;for(let e of i)z(e);_u(n,r,t),n.repo&&Cl(n.repo,pu([r.name]))}function yu(e,t){_u(ru(e),t,{copy:!0}),Tl(e,pu([t.name]))}function bu(e,t){let n=ru(e),r=C.join(n.agents,t);return cu(C.join(n.claude,t),r)?[]:fu(n,t).filter(t=>!xl(e,C.relative(e,t)))}function xu(e,t){let n=au(e),r=[];for(let e of t){if(!lu(n,e))continue;let t=C.join(n.agents,e),i=C.join(n.claude,e);!du(n)&&cu(i,t)&&z(i),z(t),r.push(e)}return n.repo&&Tl(n.repo,pu(r)),r}function Su(e){let t=au(e),n=uu(t).filter(e=>!a.existsSync(C.join(t.agents,e)));return n.length===0?[]:xu(t,n)}function Cu(e){return hl(e)??e}function wu(){return process.env.SKILLESS_TOKEN||dl(Ol,{}).token}function Tu(e){fl(Ol,{token:e},384)}function Eu(){z(Ol)}function Du(){return(process.env.SKILLESS_API_URL??`https://skilless.dev`).replace(/\/$/,``)}function Ou(){let e=wu()??``,t=l(`sha256`).update(e).digest(`hex`).slice(0,16);return`${Du()}#${t}`}function ku(){let e=dl(kl,{}),t=Ou();return e.remote===t?{version:1,remote:t,skills:e.skills??{}}:{version:1,remote:t,skills:{}}}function Au(e){fl(kl,{...e,remote:Ou()})}function ju(e){return e??!R(Dl)}async function Mu(e,t,n={}){let r=ju(n.copy),i=[];if(!r){let e=ku();for(let n of t)tu(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));Au(e)}let a=gu(e,t,{copy:r}),o=n.reconcile?xu(e,uu(e).filter(e=>!t.some(t=>t.name===e))):[];return{...a,fetched:i,removed:o}}async function Nu(e,t,n){let r=Su(e),i=new Set(uu(e)),a=await Mu(e,t,{copy:n.copy,reconcile:!0});return{...a,pruned:r,added:a.written.filter(e=>!i.has(e))}}async function Pu(e,t,n,r={}){let i=await e.getBindings(n);return Ul(n,i),Fu(t,i,r)}async function Fu(e,t,n={}){let r=await Nu(e,t.filter(e=>!e.global),n),i=await Nu(iu(),t.filter(e=>e.global),n);return{project:r,user:i,skipped:[...r.skipped,...i.skipped],count:t.length}}function Iu(e){let t=iu(),n=Su(t),r=new Set(uu(t)),i=gu(t,e.filter(e=>R(Fl(e))).map(e=>({name:e})),{copy:!1}),a=xu(t,uu(t).filter(t=>!e.includes(t)));return{...i,fetched:[],removed:a,pruned:n,added:i.written.filter(e=>!r.has(e))}}function Lu(){let e=dl(Ml,{});return{version:1,projects:e.projects??{},globals:e.globals??{},sources:e.sources??{},deletes:e.deletes??[]}}function Ru(e){if(zu(e)){z(Ml);return}fl(Ml,e)}function zu(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 Bu(e,t){return e.projects[t]??={add:[],remove:[]},e.projects[t]}function Vu(e,t){let n=Lu(),r=Bu(n,e);r.add=[...new Set([...r.add,...t])],r.remove=r.remove.filter(e=>!t.includes(e)),Ru(n)}function Hu(e,t){let n=Lu(),r=Bu(n,e);r.remove=[...new Set([...r.remove,...t])],r.add=r.add.filter(e=>!t.includes(e)),Ru(n)}function Uu(e,t){let n=Lu();for(let r of e)n.globals[r]=t;Ru(n)}function Wu(e,t){let n=Lu();n.sources[e]=t,Ru(n)}function Gu(e){let t=Lu();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));Ru(t)}async function Ku(e,t){let n=Lu();if(zu(n))return 0;let r=new Set((t??await e.listSkills()).map(e=>e.name)),i=e=>$l().includes(e),a=0;for(let t of[...n.deletes])r.has(t)&&(await e.deleteSkill(t),r.delete(t),a++),n.deletes=n.deletes.filter(e=>e!==t),Ru(n);for(let[t,o]of Object.entries(n.globals)){if(r.has(t))await e.setGlobal(t,o),a++;else if(i(t))continue;delete n.globals[t],Ru(n)}for(let[t,o]of Object.entries(n.sources)){if(r.has(t))await e.setSource(t,o),a++;else if(i(t))continue;delete n.sources[t],Ru(n)}for(let[t,r]of Object.entries(n.projects)){let o=(await e.getBindings(t)).filter(e=>!e.global).map(e=>e.name),s=[...new Set([...o,...r.add])].filter(e=>!r.remove.includes(e)),c=await e.setBindings(t,s),l=new Set(c.unknown);a+=r.add.filter(e=>!l.has(e)).length+r.remove.length,r.add=r.add.filter(e=>l.has(e)&&i(e)),r.remove=[],r.add.length===0&&delete n.projects[t],Ru(n)}return a}function qu(){return dl(jl,{}).skills??{}}function Ju(e){if(Object.keys(e).length===0){z(jl);return}fl(jl,{version:1,skills:e})}function Yu(e,t){return e?.url===t?.url&&e?.ref===t?.ref&&e?.path===t?.path&&e?.hash===t?.hash}function Xu(e,t){let n=qu();Yu(n[e],t)||(t?n[e]=t:delete n[e],Ju(n),Wu(e,t))}function Zu(e){let t=qu();for(let n of e)delete t[n];Ju(t)}function Qu(e){let t=qu(),n=Lu().sources,r=new Set(e.map(e=>e.name)),i=new Set($l());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];Ju(t)}async function B(e){await e.try(e=>Ku(e))}async function $u(e){let t=await e.try(e=>e.listSkills());t&&(Hl(t),Qu(t));let n=t??Vl().library??[],r=Lu(),i=ku(),a=qu(),o=new Map(eu().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 ed(e,t){let n=await e.try(e=>e.getBindings(t));n&&Ul(t,n);let r=n?n.filter(e=>!e.global).map(e=>e.name):Vl().projects[t]??[],i=Lu(),a=i.projects[t]??{add:[],remove:[]};return[...new Set([...r,...a.add])].filter(e=>!a.remove.includes(e)&&!i.deletes.includes(e)).sort()}function td(e,t){let n=new Set(t);return e.entries.filter(e=>e.global||n.has(e.name))}async function nd(e,t,n,r={}){let i=await e.try(e=>e.getBindings(n));if(i)return Ul(n,i),{...await Fu(t,i,{copy:r.copy}),missing:[]};let a=td(await $u(e),await ed(e,n)),o=a.filter(e=>!e.global),s=a.filter(e=>e.global),c=Lu(),l=new Set(c.deletes),u=e=>rd(c,e),d=ju(r.copy),f=id(t,o,new Set([...c.projects[n]?.remove??[],...l,...u(!0)]),d),p=id(iu(),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 rd(e,t){return Object.entries(e.globals).filter(([,e])=>e===t).map(([e])=>e)}function id(e,t,n,r){let i=new Set(t.map(e=>e.name));Su(e);let a=xu(e,uu(e).filter(e=>n.has(e)&&!i.has(e)));return{...gu(e,t.flatMap(e=>e.local?[e.local]:[]),{copy:r}),removed:a}}async function ad(e){let t=await $u(e),n=t.entries.filter(e=>e.global),r=n.filter(e=>!e.local).map(e=>e.name);if(t.live)return{...Iu(n.map(e=>e.name)),missing:r};let i=Lu(),a=new Set([...i.deletes,...rd(i,!1)]);return{...id(iu(),n,a,!1),missing:r}}async function od(e,t,n,r=new Map){let i=ku();for(let a of t){Xu(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 Au(i),await B(e),t.map(e=>e.name)}var sd=y(((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})})),cd=y(((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(`
|
|
84
|
+
`),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=sd(),e.define=s,e};t.exports=a(),t.exports.create=a})),V=y((e=>{let t=Object.prototype.toString,n=cd(),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=`
|
|
85
|
+
`+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()}})}})),ld=y(((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`)}})),ud=y(((e,t)=>{let n=ld();t.exports=e=>typeof e==`string`?e.replace(n(),``):e})),dd=y((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`}})),fd=y(((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()}))}}})),pd=y(((e,t)=>{let n=b(`readline`),r=dd(),i=fd(),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===`
|
|
86
|
+
`)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})),md=y(((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}})),hd=y(((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`}}})),gd=y(((e,t)=>{let n=V(),r=cd(),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})),_d=y(((e,t)=>{let n=process.platform===`win32`,r=cd(),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})),vd=y(((e,t)=>{let n=gd(),r=_d(),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)}})),yd=y(((e,t)=>{let n=process.env.TERM_PROGRAM===`Apple_Terminal`,r=ud(),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)}})),bd=y(((e,t)=>{let n=b(`events`),r=ud(),i=pd(),a=md(),o=hd(),s=vd(),c=V(),l=yd();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
87
|
`),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
88
|
`+this.symbols.pointer+` `;typeof e==`string`?t+=e.trim():t+=`Invalid input`,this.state.error=`
|
|
88
89
|
`+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
90
|
`.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})),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
|
+
`:` `,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})),xd=y(((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}})),Sd=y(((e,t)=>{let n=ud(),r=bd(),i=xd(),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})),Cd=y(((e,t)=>{let n=Sd(),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
92
|
`),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,n].filter(Boolean).join(`
|
|
92
93
|
`)}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)}}})),
|
|
94
|
+
`)),this.write(this.margin[2]),this.restore()}}})),wd=y(((e,t)=>{let n=Cd(),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()}}})),Td=y(((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}})),Ed=y(((e,t)=>{let n=ud(),r=Cd(),i=Td();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),g=await this.choiceSeparator(e,t),_=e.message;this.align===`right`&&(_=_.padStart(this.longest+1,` `)),this.align===`left`&&(_=_.padEnd(this.longest+1,` `));let v=this.values[c]=l||s,y=l?`success`:`dark`;await h.call(e,v,this.state)!==!0&&(y=`danger`);let ee=a[y],te=ee(await this.indicator(e,t))+(e.pad||``),b=this.indent(e),ne=()=>[b,te,_+g,l].filter(Boolean).join(` `);if(r.submitted)return _=n(_),l=d(l),ne();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,v,e,t)),m&&(_=f(_)),e.error?l+=(l?` `:``)+p(e.error.trim()):e.hint&&(l+=(l?` `:``)+u(e.hint.trim())),ne()}async submit(){return this.value=this.values,super.base.submit.call(this)}}})),Dd=y(((e,t)=>{let n=Ed(),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()})),Od=y(((e,t)=>{let n=Dd();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()})),kd=y(((e,t)=>{let n=bd(),{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(`
|
|
95
|
+
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),Ad=y(((e,t)=>{let n=kd();t.exports=class extends n{constructor(e){super(e),this.default=this.options.default||(this.initial?`(Y/n)`:`(y/N)`)}}})),jd=y(((e,t)=>{let n=Cd(),r=Ed().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)}}})),Md=y(((e,t)=>{let n=bd(),r=pd(),i=Td(),{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
96
|
`,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()}}})),
|
|
97
|
+
`)),this.restore()}}})),Nd=y(((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}"`)}}})),Pd=y(((e,t)=>{let n=Md(),r=Nd();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()}}})),Fd=y(((e,t)=>{let n=Md();t.exports=class extends n{format(){return``}}})),Id=y(((e,t)=>{let n=Md();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()}}})),Ld=y(((e,t)=>{let n=Cd();t.exports=class extends n{constructor(e){super({...e,multiple:!0})}}})),Rd=y(((e,t)=>{let n=Md();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()}}})),zd=y(((e,t)=>{t.exports=Rd()})),Bd=y(((e,t)=>{let n=Md();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)):``}}})),Vd=y(((e,t)=>{let n=ud(),r=Sd(),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
98
|
`;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
99
|
`)}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
100
|
`).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
101
|
`)].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
102
|
`)}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))}})),
|
|
103
|
+
`)),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)}}})),Hd=y(((e,t)=>{let n=ud(),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===`
|
|
104
|
+
`){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),g=(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 _=i;i=await u(i,a,d,p),h===i?(a.values[c]=void 0,h=`<${g}>`,i=e.styles.primary(h),d.placeholder=!0,a.required.has(c)&&a.missing.add(g)):(a.values[c]=h,i=e.styles.typing(h),a.missing.delete(g)),a.missing.has(g)&&a.validating&&(i=e.styles.warning(h)),a.invalid.has(c)&&a.validating&&(i=e.styles.danger(h)),p===a.index&&(i=_===i?e.styles.heading(n(i)):e.styles.underline(i)),p++}i&&(a.output+=i)}let h=a.output.split(`
|
|
105
|
+
`).map(e=>` `+e),g=s.length,_=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])&&_++;return a.completed=(_/g*100).toFixed(0),a.output=h.join(`
|
|
106
|
+
`),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))}})),Ud=y(((e,t)=>{let n=ud(),r=Hd(),i=bd();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
107
|
`].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
108
|
`).map(e=>e.slice(1)).join(`
|
|
108
|
-
`)},super.submit())}}})),
|
|
109
|
+
`)},super.submit())}}})),Wd=y(((e,t)=>{let n=Cd();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()}}})),Gd=y(((e,t)=>{let n=Sd();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
110
|
`)}}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
111
|
`)}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
112
|
`)}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()}}})),
|
|
113
|
+
`)),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})),Kd=y(((e,t)=>{t.exports=Pd()})),qd=y(((e,t)=>{let n=kd();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(`
|
|
114
|
+
`)),this.write(this.margin[2]),this.restore()}}})),Jd=y(((e,t)=>{let n=Cd();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)}}}})),Yd=y((e=>{let t=V(),n=(n,r)=>{t.defineExport(e,n,r),t.defineExport(e,n.toLowerCase(),r)};n(`AutoComplete`,()=>wd()),n(`BasicAuth`,()=>Od()),n(`Confirm`,()=>Ad()),n(`Editable`,()=>jd()),n(`Form`,()=>Ed()),n(`Input`,()=>Pd()),n(`Invisible`,()=>Fd()),n(`List`,()=>Id()),n(`MultiSelect`,()=>Ld()),n(`Numeral`,()=>zd()),n(`Password`,()=>Bd()),n(`Scale`,()=>Vd()),n(`Select`,()=>Cd()),n(`Snippet`,()=>Ud()),n(`Sort`,()=>Wd()),n(`Survey`,()=>Gd()),n(`Text`,()=>Kd()),n(`Toggle`,()=>qd()),n(`Quiz`,()=>Jd())})),Xd=y(((e,t)=>{t.exports={ArrayPrompt:Sd(),AuthPrompt:Dd(),BooleanPrompt:kd(),NumberPrompt:Rd(),StringPrompt:Md()}})),Zd=te(y(((e,t)=>{let n=b(`assert`),r=b(`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||bd()}static get prompts(){return Yd()}static get types(){return Xd()}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 Qd=(e=0)=>t=>`\u001B[${t+e}m`,$d=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,ef=(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 tf=Object.keys(H.color),nf=Object.keys(H.bgColor);[...tf,...nf];function rf(){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=Qd(),H.color.ansi256=$d(),H.color.ansi16m=ef(),H.bgColor.ansi=Qd(10),H.bgColor.ansi256=$d(10),H.bgColor.ansi16m=ef(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 af=rf();function of(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 sf;of(`no-color`)||of(`no-colors`)||of(`color=false`)||of(`color=never`)?sf=0:(of(`color`)||of(`colors`)||of(`color=true`)||of(`color=always`))&&(sf=1);function cf(){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 lf(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function uf(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=cf();r!==void 0&&(sf=r);let i=n?sf:r;if(i===0)return 0;if(n){if(of(`color=16m`)||of(`color=full`)||of(`color=truecolor`))return 3;if(of(`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 df(e,t={}){return lf(uf(e,{streamIsTTY:e&&e.isTTY,...t}))}var ff={stdout:df({isTTY:d.isatty(1)}),stderr:df({isTTY:d.isatty(2)})};function pf(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 mf(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
115
|
`:`
|
|
115
116
|
`)+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=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
|
|
119
|
-
`))n+=Math.max(1,Math.ceil(
|
|
117
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:hf,stderr:gf}=ff,_f=Symbol(`GENERATOR`),vf=Symbol(`STYLER`),yf=Symbol(`IS_EMPTY`),bf=[`ansi`,`ansi`,`ansi256`,`ansi16m`],xf=Object.create(null),Sf=(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=hf?hf.level:0;e.level=t.level===void 0?n:t.level},Cf=e=>{let t=(...e)=>e.join(` `);return Sf(t,e),Object.setPrototypeOf(t,wf.prototype),t};function wf(e){return Cf(e)}Object.setPrototypeOf(wf.prototype,Function.prototype);for(let[e,t]of Object.entries(af))xf[e]={get(){let n=Of(this,Df(t.open,t.close,this[vf]),this[yf]);return Object.defineProperty(this,e,{value:n}),n}};xf.visible={get(){let e=Of(this,this[vf],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const Tf=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?af[n].ansi16m(...r):t===`ansi256`?af[n].ansi256(af.rgbToAnsi256(...r)):af[n].ansi(af.rgbToAnsi(...r)):e===`hex`?Tf(`rgb`,t,n,...af.hexToRgb(...r)):af[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){xf[e]={get(){let{level:t}=this;return function(...n){let r=Df(Tf(e,bf[t],`color`,...n),af.color.close,this[vf]);return Of(this,r,this[yf])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);xf[t]={get(){let{level:t}=this;return function(...n){let r=Df(Tf(e,bf[t],`bgColor`,...n),af.bgColor.close,this[vf]);return Of(this,r,this[yf])}}}}const Ef=Object.defineProperties(()=>{},{...xf,level:{enumerable:!0,get(){return this[_f].level},set(e){this[_f].level=e}}}),Df=(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}},Of=(e,t,n)=>{let r=(...e)=>kf(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,Ef),r[_f]=e,r[vf]=t,r[yf]=n,r},kf=(e,t)=>{if(e.level<=0||!t)return e[yf]?``:t;let n=e[vf];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=pf(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
118
|
+
`);return a!==-1&&(t=mf(t,i,r,a)),r+t+i};Object.defineProperties(wf.prototype,xf);const Af=wf();wf({level:gf?gf.level:0});var jf=Af;const Mf=(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);!Nf(i,a)&&r||Object.defineProperty(e,n,a)},Nf=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)},Pf=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Ff=(e,t)=>`/* Wrapped ${e}*/\n${t}`,If=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),Lf=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),Rf=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=Ff.bind(null,r,t.toString());Object.defineProperty(i,`name`,Lf);let{writable:a,enumerable:o,configurable:s}=If;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function zf(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))Mf(e,t,r,n);return Pf(e,t),Rf(e,t,r),e}const Bf=new WeakMap,Vf=(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(Bf.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 zf(a,e),Bf.set(a,r),a};Vf.callCount=e=>{if(!Bf.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Bf.get(e)};var Hf=Vf;const Uf=[];Uf.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Uf.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Uf.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const Wf=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`,Gf=Symbol.for(`signal-exit emitter`),Kf=globalThis,qf=Object.defineProperty.bind(Object);var Jf=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Kf[Gf])return Kf[Gf];qf(Kf,Gf,{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}},Yf=class{};const Xf=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Zf=class extends Yf{onExit(){return()=>{}}load(){}unload(){}},Qf=class extends Yf{#e=$f.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Jf;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Uf)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(!Wf(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 Uf)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,Uf.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 Wf(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`&&Wf(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 $f=globalThis.process,{onExit:ep,load:tp,unload:np}=Xf(Wf($f)?new Qf($f):new Zf),rp=o.stderr.isTTY?o.stderr:o.stdout.isTTY?o.stdout:void 0;var ip=rp?Hf(()=>{ep(()=>{rp.write(`\x1B[?25h`)},{alwaysLast:!0})}):()=>{};let ap=!1;const op={};op.show=(e=o.stderr)=>{e.isTTY&&(ap=!1,e.write(`\x1B[?25h`))},op.hide=(e=o.stderr)=>{e.isTTY&&(ip(),ap=!0,e.write(`\x1B[?25l`))},op.toggle=(e,t)=>{e!==void 0&&(ap=e),ap?op.show(t):op.hide(t)};var sp=op,cp={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 lp=d?.WriteStream?.prototype?.hasColors?.()??!1,W=(e,t)=>{if(!lp)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 up=W(31,39),dp=W(32,39),fp=W(33,39),pp=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 mp(){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 hp=mp(),gp=pp(hp?`ℹ`:`i`),_p=dp(hp?`✔`:`√`),vp=fp(hp?`⚠`:`‼`),yp=up(hp?`✖`:`×`);function bp({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 xp=bp();function Sp(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(xp,``)}const Cp=[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],wp=[12288,12288,65281,65376,65504,65510],Tp=[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],Ep=(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},Dp=19968,[Op,kp]=Ap(Tp);function Ap(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(Dp>=i&&Dp<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}const jp=e=>e<161||e>1114109?!1:Ep(Cp,e),Mp=e=>e<12288||e>65510?!1:Ep(wp,e),Np=e=>e>=Op&&e<=kp?!0:e<4352||e>262141?!1:Ep(Tp,e);function Pp(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Fp(e,{ambiguousAsWide:t=!1}={}){return Pp(e),Mp(e)||Np(e)||t&&jp(e)?2:1}const Ip=new Intl.Segmenter,Lp=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Rp=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,zp=/\p{Spacing_Mark}/v,Bp=/^\p{RGI_Emoji}$/v,Vp=/^[\d#*]\u20E3$/,Hp=/\p{Extended_Pictographic}/gu;function Up(e){if(e.length>50)return!1;if(Vp.test(e))return!0;if(e.includes(``)){let t=e.match(Hp);return t!==null&&t.length>=2}return!1}function Wp(e){return e.replace(Rp,``)}function Gp(e){return Lp.test(e)}function Kp(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function qp(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Jp(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Yp(e){return Kp(e)||qp(e)||Jp(e)}function Xp(e,t){let n=[];for(let t of e)Lp.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(!Yp(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=Fp(n[i],t);return r}if(Kp(i)&&qp(n[e+1])){r+=2,e+=Jp(n[e+2])?2:1;continue}r+=Fp(i,t)}return r}function Zp(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(zp.test(i)||i>=``&&i<=``)&&(n+=Fp(i.codePointAt(0),t))}return n}function Qp(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=Sp(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 Ip.segment(i)){if(Gp(e))continue;if(Bp.test(e)||Up(e)){a+=2;continue}let t=Wp(e),n=Xp(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=Fp(r,o),a+=Zp(t,o)}return a}function $p({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!==`dumb`&&!(`CI`in process.env))}const em=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 tm=Object.freeze(em);const nm=new Map,rm=new Set([`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`gray`]);var im=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===`
|
|
119
|
+
`||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=$p({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(!mp())this.#i=cp.line;else if(e===void 0)this.#i=cp.dots;else if(e!==`default`&&cp[e])this.#i=cp[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(`
|
|
120
|
+
`))n+=Math.max(1,Math.ceil(Qp(r)/t));return n}get color(){return this.#f}set color(e){if(e!==void 0&&e!==!1&&!rm.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=jf[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;nm.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),nm.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,nm.get(e)===this&&nm.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
121
|
`),t=a-1;n=[...e.slice(0,t),`... (content truncated to fit terminal)`].join(`
|
|
121
122
|
`)}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 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){if(o.filter(e=>!p.has(e.name)&&c(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}`,o.filter(e=>p.has(e.name)||c(e)).map(e=>p.has(e.name)?{name:e.name,disabled:`already added`}:{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=Array(e.length),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}})),r}async function Kh(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now(),a=new Set;for(let e of t)e.type!==`delete-local`&&e.type!==`delete-remote`||(n.yes||await nm(e.type===`delete-local`?`Delete ${e.name} from this machine? It was deleted elsewhere.`:`Delete ${e.name} everywhere? It was deleted on this machine.`,!0)?a.add(e):r.skipped.push(e.name));let o=await Gh(t,8,async t=>{let{name:o}=t,s=n.local.get(o);switch(t.type){case`noop`:return s&&(n.state.skills[o]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i}),!0;case`push`:case`conflict-push`:if(!s)return!0;if(t.type===`conflict-push`){let t=await e.getSkill(o);t&&r.conflicts.push({name:o,kept:`push`,stashedAt:Uh(o,`push`,t.files)})}return n.remote.set(o,await e.putSkill(o,s.files,s.editedAt)),n.state.skills[o]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i},!0;case`pull`:case`conflict-pull`:{let a=await e.getSkill(o);return a?(t.type===`conflict-pull`&&s&&r.conflicts.push({name:o,kept:`pull`,stashedAt:Uh(o,`pull`,s.files)}),Gl(o,a.files,a.editedAt),n.state.skills[o]={contentHash:a.contentHash,editedAt:a.editedAt,syncedAt:i},!0):!0}case`delete-local`:return a.has(t)?(z(Ol(o)),delete n.state.skills[o],!0):!1;case`delete-remote`:return a.has(t)?(await e.deleteSkill(o),n.remote.delete(o),delete n.state.skills[o],!0):!1}});return r.actions=t.filter((e,t)=>o[t]),r.conflicts.sort((e,t)=>e.name.localeCompare(t.name)),r}function qh(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 Jh=Um.extend({yes:I(),push:I().optional(),pull:I().optional()}),Yh=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(Jh,e);J.intro(Y),await Q(async()=>{let e=Gm(),[n,r]=await q(`Checking skilless.dev`,async()=>{let t=await e.listSkills(),n=await Lu(e,t);return[n,n>0?await e.listSkills():t]}),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`,()=>Kh(e,s,{local:i,remote:a,state:o,yes:t.yes}));xu(o);let l=c.actions.map(qh).filter(e=>e!==null);for(let e of l)J.step(e);let[u,d]=await q(`Syncing your library`,async()=>{let t=[...a.values()],r=await Lu(e,t);return[n+r,r>0?await e.listSkills():t]});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(`, `)}.`))})}),Xh=Um.extend({yes:I(),force:I()});function Zh(e){let t=fl(e.url)??e.url;return e.ref?`${t}#${e.ref}`:t}const Qh=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(Xh,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=Zh(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(Qh).addCommand(Vh).addCommand(Dh).addCommand(Nh).addCommand(Yh).addCommand(Ah).addCommand(zh).addCommand(Ih).addCommand(Ch).parse();export{};
|
|
123
|
+
`)),this}return this.isSpinning?this:(this.#r.hideCursor&&sp.hide(this.#a),this.#r.discardStdin&&o.stdin.isTTY&&(tm.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&&sp.show(this.#a)),this.#d&&(this.#d=!1,tm.stop()),this}succeed(e){return this.stopAndPersist({symbol:_p,text:e})}fail(e){return this.stopAndPersist({symbol:yp,text:e})}warn(e){return this.stopAndPersist({symbol:vp,text:e})}info(e){return this.stopAndPersist({symbol:gp,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)+`
|
|
124
|
+
`;return this.stop(),this.#p(()=>this.#a.write(a)),this}};function am(e){return new im(e)}var G=te(y(((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 om=Zd.default.prompt;function sm(){process.stdout.write(`\r\x1B[0J`),process.stdin.isTTY&&process.stdin.setRawMode(!1),um()}const cm={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 lm(e,t){gm();try{return await om({...e,cancel:sm})}catch{return um(),t}finally{_m()}}function um(){gm(),process.stdout.write(`${G.default.yellow(`!`)} Cancelled\n`),process.exit(1)}async function dm(e,t=!1){return(await lm({type:`confirm`,name:`value`,message:e,initial:t},{value:!1})).value}const K=!!(process.stdin.isTTY&&process.stdout.isTTY);async function fm(e,t={}){return(await lm({type:`input`,name:`value`,message:e,initial:t.initial,validate:t.validate?e=>t.validate((e??``).trim()):void 0},{value:``})).value.trim()}async function pm(e,t){return t.every(e=>e.disabled)?[]:(await lm({type:`multiselect`,name:`value`,message:e,choices:t,...cm},{value:[]})).value}async function mm(e,t,n){let r=n?t.findIndex(e=>e.name===n):-1;return(await lm({type:`select`,name:`value`,message:e,choices:t,initial:r===-1?0:r,...cm},{value:``})).value}let q=null;function hm(e){let t=e.step%3+1;return`${e.message}${`.`.repeat(t)}${` `.repeat(3-t)}`}function gm(){q?.ora.isSpinning&&q.ora.stop()}function _m(){q&&!q.ora.isSpinning&&q.ora.start(hm(q))}async function J(e,t){if(!process.stdout.isTTY||!process.stdout.columns)return t();if(q){let n=q.message;q.message=e;try{return await t()}finally{q&&(q.message=n)}}let n={ora:am({stream:process.stdout,color:`cyan`,discardStdin:!1}),message:e,step:0,dots:setInterval(()=>{n.step++,n.ora.text=hm(n)},300)};q=n,_m();try{return await t()}finally{clearInterval(n.dots),gm(),q=null}}function vm(e,t){let n=q?.ora.isSpinning===!0;n&&q.ora.clear(),e.write(t),n&&q.ora.render()}const ym=e=>G.default.isColorSupported?`\x1b[48;2;95;95;95m\x1b[38;2;250;250;250m${e}\x1b[39m\x1b[49m`:e;function bm(e,t){let n=Math.min(process.stdout.columns||80,80)-2,r=[],i=``;for(let[a,o]of e.entries()){let s=a<e.length-1?`${o}${t.trimEnd()}`:o;i&&i.length+1+s.length>n?(r.push(i),i=s):i=i?`${i} ${s}`:s}return i&&r.push(i),r.map(e=>` ${e}\n`).join(``)}const Y={intro(e){vm(process.stdout,`${ym(` skilless `)}${G.default.gray(` v${e}`)}\n\n`)},info(e){vm(process.stdout,`${G.default.blue(`·`)} ${e}\n`)},step(e){vm(process.stdout,`${G.default.green(`✓`)} ${e}\n`)},warn(e){vm(process.stdout,`${G.default.yellow(`!`)} ${e}\n`)},error(e){vm(process.stderr,`${G.default.red(`✖`)} ${e}\n`)},dim(e){vm(process.stdout,`${G.default.gray(e)}\n`)},list(e,t,n=!1){let r=n?G.default.green(`✓`):G.default.blue(`·`);vm(process.stdout,`${r} ${e}\n${G.default.cyan(bm(t,`, `))}`)},note(e){vm(process.stdout,G.default.gray(bm(e.split(/\s+/),` `)))},blank(){vm(process.stdout,`
|
|
125
|
+
`)}},xm=Cc({path:P(),contents:P()}),Sm=Cc({url:P(),ref:P().optional(),path:P(),hash:P()}),Cm=Cc({name:P(),contentHash:P(),editedAt:fc(),updatedAt:fc(),global:I(),source:Sm.nullable().default(null)}),wm=Cm.extend({files:xc(xm)}),Tm=Cc({bound:xc(P()),unknown:xc(P())}),Em=Cc({error:P(),message:P().optional()}),Dm=new Set([502,503,504]);function Om(e){try{return JSON.parse(e)}catch{return null}}var km=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(Dm.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=Em.safeParse(Om(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(Om(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(Cm))}async getSkill(e){return await this.#i(`GET`,`/skills/${encodeURIComponent(e)}`,wm.nullable())}async putSkill(e,t,n){return await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}`,Cm,{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(wm))}async setBindings(e,t){return await this.#i(`PUT`,`/projects/skills`,Tm,{key:e,names:t})}},Am=class{api;#e=null;constructor(){let e=wu();this.api=e?new km(e,Du()):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(Y.blank(),this.#e instanceof tl){Y.warn(`Couldn't reach ${this.#e.url}. Run \`skilless sync\` to sync your skills with the cloud.`);return}Y.warn(`Your sign-in was rejected, so this only changed this machine.`),Y.dim("Run `skilless auth` to sign in again, then `skilless sync` to sync your skills.")}}};function jm(e){return e.includes(`/`)||e.includes(`:`)}function Mm(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)?Nm(t,n):/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||/^[^@/\s]+@[^:/\s]+:/.test(t)?{url:t,ref:n}:Pm(t,n),a.subpath&&=Fm(a.subpath),{...a,label:_l(a.url)??a.url}}function Nm(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 Pm(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 Fm(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 Im(e,t,r){let{dir:i,dispose:o}=cl(`skilless-`);try{let o=[`clone`,`--depth`,`1`,`--quiet`];e.ref&&o.push(`--branch`,e.ref),o.push(`--`,e.url,i);try{await J(`Cloning ${e.label}${e.ref?`#${e.ref}`:``}`,()=>Lm(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 Rm(e,t);z(i),a.mkdirSync(i);try{n(`git`,o,{stdio:[`inherit`,`ignore`,`pipe`],encoding:`utf8`})}catch(t){throw Rm(e,t)}}return await t(i)}finally{o()}}function Lm(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 Rm(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 zm=new Set([`node_modules`,`.git`,`dist`,`build`,`__pycache__`]),Bm=[`skills`,`skills/.curated`,`skills/.experimental`,`skills/.system`,`.agents/skills`,`.claude/skills`];function Vm(e,t){let n=t?C.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=Gm(e);r.has(t.name)||r.set(t.name,t)};if(Um(n))return i(n),[...r.values()];Wm(n,1,i);for(let e of Bm)Wm(C.join(n,e),3,i);return r.size===0&&Wm(n,5,i),[...r.values()].sort((e,t)=>e.name.localeCompare(t.name))}function Hm(e,t,n){try{let n=Fm(t);if(Um(C.join(e,n)))return{dir:C.join(e,n),path:n}}catch{}let r=Vm(e).find(e=>e.name===n);return r?{dir:r.dir,path:C.relative(e,r.dir)}:null}function Um(e){return a.existsSync(C.join(e,Wl))}function Wm(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()||zm.has(i.name))continue;let r=C.join(e,i.name);Um(r)?n(r):t>1&&Wm(r,t-1,n)}}function Gm(e){let t=Km(a.readFileSync(C.join(e,Wl),`utf8`)),n=t.name?.toLowerCase().replace(/[\s_]+/g,`-`);return{name:n&&Jl(n)?n:C.basename(e).toLowerCase(),dir:e,description:t.description}}function Km(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 qm=`skilless`,Jm=`Author skills once, sync them everywhere, install them per project.`;const X=`0.0.8`,Ym=qm,Xm=Jm,Zm=`SKILLESS_TRACE`,Qm=Cc({cwd:P()}),Z={cwd:new S(`--cwd <path>`,`The current working directory.`).default(process.cwd()),yes:new S(`-y, --yes`,`Skip confirmation prompts.`).default(!1),project:new S(`--project <key>`,`Override the project key. Defaults to the normalized git remote.`)};function Q(e,t){let n=e.safeParse(t);return n.success?n.data:$m(new L(`Invalid options.`,{suggestion:n.error.issues.map(e=>` ${e.message}`).join(`
|
|
126
|
+
`)}))}function $m(e){process.env[Zm]===`1`?console.trace(e):Y.error(G.default.red(e.toString())),process.exit(1)}async function $(e){try{return await e()}catch(e){return e instanceof L?$m(e):$m(new L(e instanceof Error?e.message:String(e),{suggestion:`Run with ${Zm}=1 for a stack trace.`,cause:e}))}}function eh(){let e=wu();if(!e)throw new $c;return new km(e,Du())}function th(e,t){if(t)return t;let n=vl(e);if(!n)throw new el;return n}const nh=`~/.agents/skills`;function rh(e){let t=C.normalize(s.homedir());return e===t||e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}async function ih(e,t={}){for(let n of e.skipped){if(n.reason===`tracked`){Y.warn(`\`${n.name}\` is tracked by git here, so it was left alone.`);continue}let e=(n.occupied?.paths??[]).map(rh).join(` and `);if(!(t.yes||K&&await dm(`Overwrite ${e}?`,!1))){K?Y.dim(`Kept ${e}, so ${n.name} is not linked there.`):(Y.warn(`Skipped ${n.name}: ${e} was not made by skilless.`),Y.dim(` Run this in a terminal to overwrite it, or pass --yes.`));continue}vu(n,{copy:ju(t.copy)}),Y.step(`Overwrote ${e}.`)}for(let t of e.missing??[])Y.warn(`${t} is not on this machine yet, so it will be linked on the next sync.`)}const ah=Qm.extend({project:P().optional(),copy:I().optional(),global:I().optional(),notGlobal:I().optional(),overwrite:I(),yes:I()}),oh=new x(`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(Z.yes).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(ah,t);Y.intro(X),await $(async()=>{let t=new Am,[r,...i]=e;if(r&&jm(r)){await lh(t,Mm(r),i,n);return}let a=e.find(jm);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 J(`Loading your library`,async()=>(await B(t),$u(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){Y.info(r?`Every skill in your library is already global.`:`No skills in your library are global.`);return}if(i=await pm(r?`Make global`:`Stop being global`,e.map(e=>({name:e.name}))),i.length===0){Y.info(`Nothing selected.`);return}}r&&l(i),await sh(t,i,r,n),t.report();return}let f=th(n.cwd,n.project),p=new Set(await J(`Loading ${f}`,()=>ed(t,f))),m=e;if(m.length===0){if(o.filter(e=>!p.has(e.name)&&!e.global&&c(e)).length===0){Y.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 pm(`Add to ${f}`,o.filter(e=>e.global||p.has(e.name)||c(e)).map(e=>e.global?{name:e.name,disabled:`installed globally`}:p.has(e.name)?{name:e.name,disabled:`already added`}:{name:e.name})),m.length===0){Y.info(`Nothing selected.`);return}}let h=o.filter(e=>e.global).map(e=>e.name);l(m.filter(e=>!h.includes(e))),await ch(t,f,m,h,n),t.report()})});async function sh(e,t,n,r){Uu(t,n),await J(`Saving to skilless.dev`,()=>B(e));for(let e of t)Y.step(n?`${e} is now global, so every project has it.`:`${e} is no longer global.`);let i=r.project??vl(r.cwd),a=Cu(r.cwd),[o,s]=await J(`Updating your skills`,async()=>{if(!i){let t=await ad(e);return[t,t]}let t=await nd(e,a,i,{copy:r.copy});return[t,t.user]});for(let e of s.written.filter(e=>t.includes(e)))Y.dim(`Linked ${e} into ${nh}.`);for(let e of s.removed)Y.dim(`Unlinked ${e} from ${nh}.`);if(`project`in o){for(let e of o.project.removed)Y.dim(`Moved ${e} out of this project.`);for(let e of o.project.written.filter(e=>t.includes(e)))Y.dim(`${e} is still added to this project, so it is linked here again.`)}await ih(o,r)}async function ch(e,t,n,r,i){for(let e of n)r.includes(e)&&Y.dim(`${e} is global, so it is already in this project.`);let a=n.filter(e=>!r.includes(e));Vu(t,a);let o=Cu(i.cwd),s=await J(`Updating this project`,async()=>(await B(e),nd(e,o,t,{copy:i.copy})));for(let e of a)Y.step(`Added ${e} to this project.`);await ih(s,i)}async function lh(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??vl(r.cwd),a=await J(`Loading your library`,async()=>(await B(e),$u(e))),o=new Map(a.entries.map(e=>[e.name,e])),s=[...n,...t.skill?[t.skill]:[]],c=await Im(t,async e=>{let n=Vm(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(!K)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 pm(`Add from ${t.label}`,n.map(e=>({name:e.name,hint:uh(e.description)})));i=n.filter(t=>e.includes(t.name))}let a=[];for(let t of i)try{Yl(t.name),a.push({skill:Zl(t.dir,t.name),path:C.relative(e,t.dir)})}catch(e){Y.warn(`Skipped ${t.name}: ${e instanceof L?e.message:e}`)}return a},{interactive:K});if(c.length===0){Y.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?Xu(e.name,d.get(e.name)):l.push(e),u.push(e.name);continue}if(!(r.overwrite||K&&!r.yes&&await dm(`${e.name} is already in your library. Replace it with the one from ${t.label}?`))){Y.warn(`Kept your own ${e.name}. Pass --overwrite to replace it.`);continue}l.push(e),u.push(e.name)}let f=await J(`Saving ${l.length} skill(s) to your library`,()=>od(e,l,o,d));for(let e of f)Y.step(`Copied ${e} into your library from ${t.label}.`);if(u.length===0){e.report();return}r.global?await sh(e,u,!0,r):i?await ch(e,i,u,(await J(`Loading your library`,()=>$u(e))).entries.filter(e=>e.global).map(e=>e.name),r):(Y.blank(),Y.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 uh(e){if(e)return e.length>60?`${e.slice(0,57)}...`:e}function dh(e){switch(process.platform){case`darwin`:return[`open`,[e]];case`win32`:return[`rundll32`,[`url.dll,FileProtocolHandler`,e]];default:return[`xdg-open`,[e]]}}function fh(e){let[t,n]=dh(e);try{let e=r(t,n,{stdio:`ignore`,detached:!0,windowsHide:!0});e.on(`error`,()=>{}),e.unref()}catch{}}async function ph(){let e=c.randomBytes(16).toString(`hex`),t=Du(),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}`;Y.info(`Opening your browser to sign in…`),Y.dim(r),Y.blank(),fh(r),Tu(await J(`Waiting for you to sign in`,()=>a))}finally{clearTimeout(s),o.close()}}const mh=Qm.extend({logout:I(),token:P().optional()}),hh=new x(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new S(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new S(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(Z.cwd).action(async e=>{let t=Q(mh,e);Y.intro(X),await $(async()=>{if(t.logout){if(!wu()){Y.info(`You were not signed in.`);return}Eu(),Y.step(`Signed out on this machine.`);return}if(t.token){Tu(t.token),Y.step(`Token saved. You are signed in to skilless.dev.`);return}await ph(),Y.step(`Signed in to skilless.dev.`)})}),gh=s.homedir(),_h=process.env.LOCALAPPDATA??C.join(gh,`AppData`,`Local`),vh=process.env.ProgramFiles??`C:/Program Files`,yh={cursor:{label:`Cursor`,cli:`cursor`,fallbacks:{darwin:[`/Applications/Cursor.app/Contents/Resources/app/bin/cursor`,`${gh}/Applications/Cursor.app/Contents/Resources/app/bin/cursor`],win32:[C.join(_h,`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`,`${gh}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`],win32:[C.join(_h,`Programs/Microsoft VS Code/bin/code.cmd`),C.join(vh,`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`,`${gh}/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`],win32:[C.join(_h,`Programs/Windsurf/bin/windsurf.cmd`)],linux:[`/usr/share/windsurf/bin/windsurf`]}},zed:{label:`Zed`,cli:`zed`,fallbacks:{darwin:[`/Applications/Zed.app/Contents/MacOS/cli`,`${gh}/Applications/Zed.app/Contents/MacOS/cli`],win32:[C.join(_h,`Programs/Zed/bin/zed.exe`)],linux:[`${gh}/.local/bin/zed`]}},sublime:{label:`Sublime Text`,cli:`subl`,fallbacks:{darwin:[`/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl`],win32:[C.join(vh,`Sublime Text/subl.exe`)],linux:[`/opt/sublime_text/sublime_text`]}},neovim:{label:`Neovim`,cli:`nvim`,terminal:!0},vim:{label:`Vim`,cli:`vim`,terminal:!0}},bh=Object.keys(yh);function xh(e){return Object.hasOwn(yh,e)}function Sh(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 Ch(e){let t=yh[e],n=Sh(t.cli);if(n)return n;let r=process.platform;return t.fallbacks?.[r]?.find(e=>R(e))??null}function wh(){return bh.filter(e=>Ch(e)!==null)}function Th(e){return yh[e].terminal===!0}function Eh(e,t){let n=Ch(e);if(!n)return Promise.reject(Error(`${yh[e].label} was not found. Is \`${yh[e].cli}\` on your PATH?`));let i=Th(e);return new Promise((e,a)=>{let o=r(n,[t],{cwd:C.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 Dh(){let e=dl(Nl,{});return e.editor!==void 0&&!xh(e.editor)&&delete e.editor,e}function Oh(e){fl(Nl,e)}function kh(e){let t={...Dh(),...e};for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return Oh(t),t}const Ah=`none`,jh=Cc({unset:I()}),Mh=new x(`editor`).description("Choose the editor `skilless create` opens a new skill in.").argument(`[editor]`,`Set it directly: ${bh.join(`, `)}.`).addOption(new S(`--unset`,`Stop opening new skills in an editor.`).default(!1)).action(async(e,t)=>{let n=Q(jh,t);Y.intro(X),await $(async()=>{let t=Dh().editor;if(n.unset){kh({editor:void 0}),Y.step(`New skills will no longer open in an editor.`);return}if(e){if(!xh(e))throw new L(`${e} is not an editor skilless knows.`,{suggestion:`Pick one of: ${bh.join(`, `)}.`});kh({editor:e}),Y.step(`New skills will open in ${yh[e].label}.`);return}if(!K){Y.info(t?`Editor: ${yh[t].label}`:`No editor set.`);return}let r=wh();if(r.length===0)throw new L(`None of the editors skilless knows are installed.`,{suggestion:`skilless looks for: ${bh.map(e=>yh[e].cli).join(`, `)}.`});let i=await mm(`Open new skills in`,[...r.map(e=>({name:e,message:yh[e].label,hint:e===t?G.default.gray(`current`):void 0})),{name:Ah,message:`None`,hint:t?void 0:G.default.gray(`current`)}],t??Ah);if(i===Ah){kh({editor:void 0}),Y.step(`New skills will not open in an editor.`);return}xh(i)&&(kh({editor:i}),Y.step(`New skills will open in ${yh[i].label}.`))})}),Nh=new x(`config`).description(`View or change your skilless settings.`).addCommand(Mh).action(async()=>{Y.intro(X),await $(async()=>{let e=Dh();Y.info(`editor ${e.editor?yh[e.editor].label:G.default.gray(`not set`)}`),Y.blank(),Y.dim(`Stored in ${Nl}`)})}),Ph=Qm.extend({description:P().optional(),project:P().optional(),global:I().optional(),open:I()}),Fh=new x(`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(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(Ph,t);Y.intro(X),await $(async()=>{let t=new Am,r=await J(`Loading your library`,async()=>(await B(t),$u(t))),i=new Set(r.entries.map(e=>e.name)),a=e;if(!a){if(!K)throw new L(`No name given.`,{suggestion:"Run `skilless create <name>`."});a=await fm(`Name`,{validate:e=>e?Jl(e)?i.has(e)?`${e} already exists in your library.`:!0:`Use lowercase letters, digits, dots, dashes and underscores.`:`A name is required.`})}if(Yl(a),tu(a))throw new L(`${a} already exists in your library.`,{suggestion:`Edit it at ${C.join(Fl(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 fm(`What does this skill do?`);Ql(a,nu(a,o));let s=Zl(Fl(a),a);if(await J(`Creating ${a}`,()=>t.try(e=>e.putSkill(a,s.files,s.editedAt)))){let e=ku();e.skills[a]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:Date.now()},Au(e)}Y.step(`Created ${a} in your library.`),n.global&&Uu([a],!0);let c=n.project??vl(n.cwd);if(c){n.global||Vu(c,[a]);let e=Cu(n.cwd);await ih(await J(`Updating this project`,async()=>(await B(t),nd(t,e,c))))}else n.global?await ih(await J(`Linking your global skills`,async()=>(await B(t),ad(t)))):await J(`Saving to skilless.dev`,()=>B(t));n.global?Y.step(`${a} is now global, so every project has it.`):c?Y.step(`Added ${a} to ${c}.`):Y.warn(`No git remote here, so ${a} was not added to a project.`);let l=C.join(Fl(a),`SKILL.md`),u=n.open?Dh().editor:void 0,d=u&&(!Th(u)||K);if(Y.blank(),u&&d)try{Y.dim(`Opening ${a} in ${yh[u].label}...`),await Eh(u,l)}catch(e){Y.warn(e instanceof Error?e.message:String(e)),Y.dim(`Edit ${a} at ${l}`)}else Y.dim(`Edit ${a} at ${l}`);t.api&&Y.dim("Run `skilless sync` to save your changes."),t.report()})}),Ih=Qm.extend({yes:I()}),Lh=new x(`delete`).description(`Delete skills from your library, everywhere.`).argument(`<skills...>`,`Skills to delete.`).addOption(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(Ih,t);Y.intro(X),await $(async()=>{let t=new Am,r=await J(`Loading your library`,async()=>(await B(t),$u(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(Y.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),Y.dim(`Run \`skilless remove ${e.join(` `)}\` to take ${e.length===1?`it`:`them`} out of just this project.`),!(n.yes||await dm(`Delete ${e.join(`, `)}?`,!1))){Y.info(`Nothing was deleted.`);return}Gu(e),Zu(e);let o=ku(),s=Cu(n.cwd);for(let t of e)z(Fl(t)),delete o.skills[t],Y.step(`Deleted ${t} from your library.`);Au(o),xu(s,e),xu(iu(),e),await J(`Deleting from skilless.dev`,()=>B(t)),Y.blank(),Y.dim("Other checkouts will clean up on their next `skilless install`."),Y.dim(`Restore at skilless.dev/skills within 30 days.`),t.report()})}),Rh=Qm.extend({yes:I(),overwrite:I()});function zh(e){return a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:C.join(e,t.name)})).filter(e=>R(C.join(e.dir,Wl))).sort((e,t)=>e.name.localeCompare(t.name))}const Bh=new x(`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(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(Rh,t);Y.intro(X),await $(async()=>{let t=new Am,r=C.resolve(n.cwd,e);if(!R(r))throw new L(`${r} does not exist.`);let i=zh(r);if(i.length===0)throw new L(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${Wl}.`});let a=await J(`Loading your library`,async()=>(await B(t),$u(t))),o=new Map(a.entries.map(e=>[e.name,e])),s=[],c=[];for(let e of i){if(!Jl(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(Zl(e.dir,e.name))}catch(t){c.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of c)Y.warn(`Skipped ${e.name}: ${e.reason}.`);if(s.length===0){Y.info(`Nothing to import.`),t.report();return}if(Y.blank(),Y.info(`Importing: ${s.map(e=>e.name).join(`, `)}`),!(n.yes||await dm(`Import ${s.length} skill(s)?`,!0)))return;let l=await J(`Importing ${s.length} skill(s)`,()=>od(t,s,o));for(let e of l)Y.step(`Imported ${e} into your library.`);Y.blank(),Y.dim(`Run \`skilless add ${s[0]?.name??`<skill>`}\` to add one to this project.`),t.report()})}),Vh=new x(`init`).description(`Create the local skilless directory.`).addOption(Z.cwd).action(async e=>{Q(Qm,e),Y.intro(X),await $(async()=>{let e=!R(Dl);rl(Dl),Y.step(`${e?`Created`:`Found`} your library at ${El}.`),Y.blank(),Y.dim("Run `skilless create <name>` to make a skill."),Y.dim("Run `skilless import <dir>` to bring in skills you already have."),wu()||Y.dim("Run `skilless auth` to sync your skills with the cloud.")})}),Hh=Qm.extend({project:P().optional(),copy:I().optional()}),Uh=new x(`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(Z.project).addOption(Z.cwd).action(async e=>{let t=Q(Hh,e);Y.intro(X),await $(async()=>{let e=eh(),n=th(t.cwd,t.project),r=Cu(t.cwd),i=await J(`Installing ${n}'s skills`,async()=>(await Ku(e),Pu(e,r,n,{copy:t.copy}))),{project:a,user:o}=i;for(let e of[...a.pruned,...o.pruned])Y.dim(`Pruned ${e}, which is no longer in your library.`);for(let e of[...a.fetched,...o.fetched])Y.dim(`Fetched ${e} from your library.`);for(let e of a.removed)Y.dim(`Removed ${e}, which is no longer in this project.`);for(let e of o.removed)Y.dim(`Removed ${e} from ${nh}, since it is no longer global.`);for(let e of a.written)Y.step(`Installed ${e}.`);for(let e of o.written)Y.step(`Installed ${e} globally.`);if(i.count===0){Y.info(`No skills added to ${n} yet.`),Y.dim("Run `skilless add <skill>` to add one.");return}await ih(i,{copy:t.copy}),Y.blank(),Y.dim(ju(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.`)})}),Wh=Qm.extend({project:Tc([I(),P()]).optional()});function Gh(e,t){let n=[];return e.global&&n.push(`global`),e.source&&n.push(`from ${_l(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 Kh=new x(`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(Z.cwd).action(async e=>{let t=Q(Wh,e);Y.intro(X),await $(async()=>{let e=new Am,n=await J(`Loading your library`,async()=>(await B(e),$u(e)));if(t.project!==void 0){let r=th(t.cwd,typeof t.project==`string`?t.project:void 0),i=td(n,await J(`Loading ${r}`,()=>ed(e,r)));Y.info(`${G.default.bold(r)}`),Y.blank(),i.length===0&&Y.dim("No skills in this project. Run `skilless add <skill>` to add one.");for(let t of i)Y.dim(` ${t.name}${G.default.gray(Gh(t,e.api!==null))}`);e.report();return}n.entries.length===0&&Y.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);Y.dim(` ${t.name.padEnd(28)} ${G.default.gray(r+Gh(t,e.api!==null))}`)}e.report()})});function qh(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 Jh(e,t,n){return Yh(e,t===`push`?`remote`:`local`,n)}function Yh(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=C.join(Pl,e,`${r}-${t}`);for(let e of n)ul(C.join(i,e.path),e.contents);return i}async function Xh(e,t,n){let r=Array(e.length),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}})),r}async function Zh(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now(),a=new Set;for(let e of t)e.type!==`delete-local`&&e.type!==`delete-remote`||(n.yes||await dm(e.type===`delete-local`?`Delete ${e.name} from this machine? It was deleted elsewhere.`:`Delete ${e.name} everywhere? It was deleted on this machine.`,!0)?a.add(e):r.skipped.push(e.name));let o=await Xh(t,8,async t=>{let{name:o}=t,s=n.local.get(o);switch(t.type){case`noop`:return s&&(n.state.skills[o]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i}),!0;case`push`:case`conflict-push`:if(!s)return!0;if(t.type===`conflict-push`){let t=await e.getSkill(o);t&&r.conflicts.push({name:o,kept:`push`,stashedAt:Jh(o,`push`,t.files)})}return n.remote.set(o,await e.putSkill(o,s.files,s.editedAt)),n.state.skills[o]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i},!0;case`pull`:case`conflict-pull`:{let a=await e.getSkill(o);return a?(t.type===`conflict-pull`&&s&&r.conflicts.push({name:o,kept:`pull`,stashedAt:Jh(o,`pull`,s.files)}),Ql(o,a.files,a.editedAt),n.state.skills[o]={contentHash:a.contentHash,editedAt:a.editedAt,syncedAt:i},!0):!0}case`delete-local`:return a.has(t)?(z(Fl(o)),delete n.state.skills[o],!0):!1;case`delete-remote`:return a.has(t)?(await e.deleteSkill(o),n.remote.delete(o),delete n.state.skills[o],!0):!1}});return r.actions=t.filter((e,t)=>o[t]),r.conflicts.sort((e,t)=>e.name.localeCompare(t.name)),r}function Qh(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 $h=Qm.extend({yes:I(),user:I().optional(),includeCommitted:I().optional()});function eg(e){let t=Math.max(0,Math.round((Date.now()-e)/6e4));if(t<1)return`just now`;if(t<60)return`${t} min ago`;let n=Math.round(t/60);if(n<24)return`${n} hour${n===1?``:`s`} ago`;let r=Math.round(n/24);return`${r} day${r===1?``:`s`} ago`}function tg(e,t){return R(e)?a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.isSymbolicLink()).map(n=>({name:n.name,dir:C.join(e,n.name),scope:t})).filter(e=>R(C.join(e.dir,Wl))):[]}async function ng(e,t){if(t.includeCommitted)return`move`;if(t.yes||!K)return Y.warn(`Skipped ${e}: it is committed to this repo. Pass --include-committed to move it out of git.`),`leave`;Y.warn(`${e} is committed to this repo.`),Y.note(`Moving it untracks it from git, so teammates lose it on their next pull unless they use skilless.`);let n=await mm(`What should happen to ${e}?`,[{name:`leave`,message:`Leave it`},{name:`copy`,message:`Copy it to my library`,hint:`keep it committed`},{name:`move`,message:`Move it`,hint:`untrack it from git`}]);return n===`copy`||n===`move`?n:`leave`}const rg=new x(`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.`).argument(`[skills...]`,`Skills to migrate, by name. Omit to migrate everything found.`).option(`--user`,`Migrate your user-level skills too, without asking.`).option(`--include-committed`,`Move skills committed to this repo too, without asking. Their removal from git is staged, not committed.`).addOption(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q($h,t);Y.intro(X),await $(async()=>{let t=new Am,r=Cu(n.cwd),i=vl(n.cwd),a=t=>e.length===0||e.includes(t.name),o=(i?[Il,Ll].flatMap(e=>tg(C.join(r,e),`project`)):[]).filter(a),s=[...tg(Bl(),`user`),...tg(zl(),`user`)].filter(a),c=e.filter(e=>![...o,...s].some(t=>t.name===e));if(c.length>0)throw new L(`Nothing to migrate named ${c.join(`, `)}.`,{suggestion:i?`Migrate looks for real skill directories in ${Il}, ${Ll} and at the user level. Linked ones are already in skilless.`:`This directory has no git remote, so only user-level skills can be migrated from it.`});let l=e=>xl(r,C.relative(r,e.dir)),u=[...new Set(o.filter(l).map(e=>e.name))].sort(),d=new Map;for(let e of u)d.set(e,await ng(e,n));let f=[],p=[];for(let e of o){let t=d.get(e.name);t?t===`copy`?p.push({...e,committed:`copy`}):t===`move`&&p.push(l(e)?{...e,committed:`move`}:e):f.push(e)}if(i||Y.dim(`No git remote here, so there are no project skills to migrate.`),f.length===0&&p.length===0&&s.length===0){Y.info(`Nothing to migrate.`);return}let m=await J(`Loading your library`,async()=>(await B(t),$u(t))),h=new Map(m.entries.map(e=>[e.name,e])),g=new Map,_=async(e,r)=>{let{name:i}=e,a=h.get(i),o=g.get(i);if(!o){if(n.yes||!K)Y.warn(`Skipped ${i}: a different ${i} is already in your library. Run migrate in a terminal to pick one.`),o=`skip`;else{let t=a.local?.editedAt??a.remote?.editedAt;Y.warn(`A different ${i} is already in your library.`),Y.note(`On disk: edited ${eg(e.editedAt)}, in ${r.map(e=>rh(e.dir)).join(` and `)}`),Y.note(`In your library: edited ${t?eg(t):`at an unknown time`}`);let n=await mm(`Which ${i} do you want to keep?`,[{name:`library`,message:`The one in my library`,hint:`replaces the copy on disk`},{name:`local`,message:`The one on disk`,hint:`replaces it in your library, everywhere`},{name:`skip`,message:`Skip it for now`}]);o=n===`library`||n===`local`?n:`skip`}g.set(i,o)}if(o===`skip`)return null;let s=a.local?.files??(await J(`Fetching ${i} from your library`,()=>t.try(e=>e.getSkill(i))))?.files;if(!s)return Y.warn(`Skipped ${i}: could not fetch the one in your library.`),null;if(o===`library`){let t=a.local?.editedAt??a.remote.editedAt;return{skill:{...e,files:s,editedAt:t,contentHash:a.local?.contentHash??a.remote.contentHash},adopted:!0,stash:{label:`local`,files:e.files}}}return{skill:{...e,editedAt:Date.now()},adopted:!1,stash:{label:`library`,files:s}}},v=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(!Jl(e)){Y.warn(`Skipped ${e}: not a valid skill name.`);continue}let t;try{t=r.map(t=>Zl(t.dir,e))}catch(t){Y.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)){Y.warn(`Skipped ${e}: found more than one version (${r.map(e=>e.dir).join(`, `)}).`);continue}let a=h.get(e),o=a?.local?.contentHash??a?.remote?.contentHash,s=o&&o!==i.contentHash?await _(i,r):{skill:i,adopted:o!==void 0};s&&n.push({...s,dirs:r.filter(e=>e.committed!==`copy`).map(e=>e.dir),untrack:r.filter(e=>e.committed===`move`).map(e=>e.dir),copyOnly:r.every(e=>e.committed===`copy`),scope:r.some(e=>e.scope===`user`)?`user`:`project`})}return n},y=await v(f);if(y.length>0&&(Y.list(`Project skills in ${i}`,y.map(e=>e.skill.name)),n.yes||e.length>0||await dm(y.length===1?`Move it into skilless and link it here?`:`Move these ${y.length} into skilless and link them here?`,!0)||(y=[])),y.push(...await v(p)),s.length>0){let t=[...new Set(s.map(e=>e.name))].sort();Y.list(`User-level skills`,t);let r=n.user===!0||e.length>0;if(!r&&!n.yes&&K&&(Y.note(`They would become global skills, linked back into ~/.agents/skills so every project still gets them.`),r=await dm(t.length===1?`Migrate it too?`:`Migrate these ${t.length} too?`,!1)),r){let e=new Set(y.map(e=>e.skill.name)),t=await v([...s,...[...f,...p].filter(e=>s.some(t=>t.name===e.name))]);y=[...y.filter(e=>!t.some(t=>t.skill.name===e.skill.name)),...t];for(let t of e)y.some(e=>e.skill.name===t)||Y.warn(`Skipped ${t}: its project and user-level copies differ.`)}}if(y.length===0){Y.info(`Nothing was migrated.`);return}let ee=ku(),te=[];for(let{skill:e,adopted:n,stash:r}of y)r&&te.push(Yh(e.name,r.label,r.files)),Ql(e.name,e.files,e.editedAt),!n&&(await J(`Saving ${e.name} to your library`,()=>t.try(t=>t.putSkill(e.name,e.files,e.editedAt)))?ee.skills[e.name]={contentHash:e.contentHash,editedAt:e.editedAt,syncedAt:Date.now()}:delete ee.skills[e.name]);Au(ee);let b=[];for(let{dirs:e,untrack:t}of y)for(let n of e){let e=C.relative(r,n);if(t.includes(n)){if(!Sl(r,e)){Y.warn(`Could not untrack ${e} from git, so it was left in place.`);continue}b.push(e)}z(n)}let ne=y.filter(e=>e.scope===`user`).map(e=>e.skill.name),re=y.filter(e=>e.scope===`project`&&!e.copyOnly).map(e=>e.skill.name);ne.length>0&&Uu(ne,!0),i&&re.length>0&&Vu(i,re),await J(`Saving to skilless.dev`,()=>B(t));let ie=e=>y.filter(e).map(e=>e.skill.name),ae=[[`Moved into your library and this project`,ie(e=>re.includes(e.skill.name)&&!e.adopted)],[`Already in your library, now linked to this project`,ie(e=>re.includes(e.skill.name)&&e.adopted)],[`Moved into your library as global skills`,ie(e=>e.scope===`user`&&!e.adopted)],[`Already in your library, now linked as global skills`,ie(e=>e.scope===`user`&&e.adopted)],[`Copied into your library, still committed here`,ie(e=>e.copyOnly&&!e.adopted)],[`Already in your library, still committed here`,ie(e=>e.copyOnly&&e.adopted)]];for(let[e,t]of ae)t.length>0&&Y.list(e,t,!0);if(te.length>0){Y.note(`The copies you did not keep are saved here:`);for(let e of te)Y.dim(` ${rh(e)}`)}b.length>0&&Y.note(`Staged the removal of ${b.join(`, `)} from git. Commit it when you are ready.`),i?await ih(await J(`Updating this project`,()=>nd(t,r,i)),{yes:n.yes}):ne.length>0&&await ih(await J(`Linking your global skills`,()=>ad(t)),{yes:n.yes}),t.report()})}),ig=Qm.extend({project:P().optional(),copy:I().optional()}),ag=new x(`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(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(ig,t);Y.intro(X),await $(async()=>{let t=new Am,r=th(n.cwd,n.project),[i,a]=await J(`Loading your library`,async()=>(await B(t),[await $u(t),new Set(await ed(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)){Y.warn(`${t} is global, so it is in every project.`),Y.dim(` Run \`skilless add --not-global ${t}\` to take it out of every project.`);continue}if(!a.has(t)){Y.warn(`${t} is not in this project.`);continue}s.push(t)}if(s.length===0){t.report();return}Hu(r,s);let c=Cu(n.cwd),l=await J(`Updating this project`,async()=>(await B(t),nd(t,c,r,{copy:n.copy})));for(let e of s)Y.step(`Removed ${e} from this project.`);await ih(l,{copy:n.copy}),Y.blank(),Y.dim(`Run \`skilless delete ${s.join(` `)}\` to delete ${s.length===1?`it`:`them`}.`),t.report()})}),og=Qm.extend({yes:I(),push:I().optional(),pull:I().optional()}),sg=new x(`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(Z.yes).addOption(Z.cwd).action(async e=>{let t=Q(og,e);Y.intro(X),await $(async()=>{let e=eh(),[n,r]=await J(`Checking skilless.dev`,async()=>{let t=await e.listSkills(),n=await Ku(e,t);return[n,n>0?await e.listSkills():t]}),i=new Map(eu().map(e=>[e.name,e])),a=new Map(r.map(e=>[e.name,e])),o=ku(),s=qh(i,a,o,t.push?`push`:t.pull?`pull`:void 0),c=await J(`Syncing your library`,()=>Zh(e,s,{local:i,remote:a,state:o,yes:t.yes}));Au(o);let l=c.actions.map(Qh).filter(e=>e!==null);for(let e of l)Y.step(e);let[u,d]=await J(`Syncing your library`,async()=>{let t=[...a.values()],r=await Ku(e,t);return[n+r,r>0?await e.listSkills():t]});u>0&&Y.step(`Sent ${u} change(s) made while offline.`),Hl(d),Qu(d);let f=vl(t.cwd),p=await J(f?`Updating this project`:`Updating your global skills`,async()=>{if(!f)return{user:Iu(d.filter(e=>e.global).map(e=>e.name))};let n=await Pu(e,Cu(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)Y.step(`Linked ${e} into this project.`);for(let e of m.removed)Y.step(`Unlinked ${e}, which is no longer in this project.`);for(let e of m.pruned)Y.step(`Unlinked ${e}, which is no longer in your library.`)}for(let e of h.added)Y.step(`Linked ${e} into ${nh}.`);for(let e of h.removed)Y.step(`Unlinked ${e} from ${nh}, since it is no longer global.`);for(let e of h.pruned)Y.step(`Unlinked ${e} from ${nh}, 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&&Y.info(`Everything is already in sync.`),c.conflicts.length>0){Y.blank(),Y.warn(`${c.conflicts.length} skill(s) changed in two places. The copy that lost is kept here:`);for(let e of c.conflicts)Y.dim(` ${e.stashedAt}`)}await ih({skipped:[...m?.skipped??[],...h.skipped]},{yes:t.yes}),c.skipped.length>0&&(Y.blank(),Y.dim(`Skipped ${c.skipped.join(`, `)}.`))})}),cg=Qm.extend({yes:I(),force:I()});function lg(e){let t=_l(e.url)??e.url;return e.ref?`${t}#${e.ref}`:t}const ug=new x(`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(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(cg,t);Y.intro(X),await $(async()=>{let t=new Am,r=await J(`Loading your library`,async()=>(await B(t),$u(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){Y.info(`None of your skills were added from a repository.`),Y.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=lg(r);await Im({url:r.url,ref:r.ref,label:i},async r=>{for(let a of e){let e=Hm(r,a.source.path,a.name);if(!e){Y.warn(`${a.name} is no longer in ${i}.`);continue}let o;try{o=Zl(e.dir,a.name)}catch(e){Y.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){Xu(a.name,s),u.push(a.name);continue}if(p!==a.source.hash){let e=n.force===!0;if(!e&&K&&!n.yes&&(Y.note(`You have edited ${a.name} since it came from ${i}.`),e=await dm(`Replace your edits to ${a.name}?`)),!e){d.push(a.name);continue}let r=a.local?.files??(await J(`Fetching your copy of ${a.name}`,()=>t.try(e=>e.getSkill(a.name))))?.files;if(!r){Y.warn(`Couldn't fetch your copy of ${a.name} to keep it, so it was left alone.`);continue}f.push({name:a.name,dir:Yh(a.name,`update`,r)})}c.push(o),l.set(a.name,s)}},{interactive:K}).then(()=>!0,e=>{if(!(e instanceof L))throw e;return Y.warn(e.toString()),!1})||p.push(...e.map(e=>e.name))}Y.blank();let m=await J(`Saving ${c.length} skill(s) to your library`,()=>od(t,c,i,l));for(let e of m)Y.step(`Updated ${e}.`);if(u.length>0&&Y.info(u.length===1?`${u[0]} is already up to date.`:`${u.length} skills are already up to date.`),d.length>0&&Y.warn(`Kept your edits to ${d.join(`, `)}. Run \`skilless update ${d.join(` `)} --force\` to replace them.`),p.length>0&&Y.warn(`Couldn't check ${p.join(`, `)}.`),f.length>0){Y.blank(),Y.dim(`Your edited copies are kept here:`);for(let e of f)Y.dim(` ${e.dir}`)}t.report()})}),dg=Qm.extend({project:P().optional(),yes:I()}),fg=new x(`vendor`).description(`Copy skills into this repo as real files to commit, instead of linking them.`).argument(`[skills...]`,`Skills to vendor. Omit to pick from a list.`).addOption(Z.yes).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(dg,t);Y.intro(X),await $(async()=>{let t=hl(n.cwd);if(!t)throw new L(`This directory is not in a git repo.`,{suggestion:`Vendored skills are meant to be committed, so run this inside one.`});let r=new Am,i=n.project??vl(n.cwd),[a,o]=await J(`Loading your library`,async()=>(await B(r),[await $u(r),new Set(i?await ed(r,i):[])])),s=new Map(a.entries.map(e=>[e.name,e])),c=e.filter(e=>!s.has(e));if(c.length>0)throw new L(`Not in your library: ${c.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let l=e;if(l.length===0){if(a.entries.length===0){Y.info(`Your library is empty.`),r.report();return}if(l=await pm(`Vendor into this repo`,a.entries.map(e=>({name:e.name,...o.has(e.name)?{hint:`in this project`}:{}}))),l.length===0){Y.info(`Nothing selected.`);return}}let u=[];for(let e of l){let i=await J(`Reading ${e}`,()=>pg(r,s.get(e)));if(!i){Y.warn(`${e} is not on this machine, and the server can't be reached to fetch it.`);continue}let a=bu(t,e);if(a.length>0){let t=a.join(` and `);if(!(n.yes||K&&await dm(`Overwrite ${t}?`,!1))){Y.warn(`Skipped ${e}: ${t} was not made by skilless.`),K||Y.dim(` Run this in a terminal to overwrite it, or pass --yes.`);continue}}yu(t,{name:e,files:i}),u.push(e),Y.step(`Vendored ${e} into ${Il}/${e}.`)}if(u.length===0){r.report();return}let d=i?u.filter(e=>o.has(e)):[];if(i&&d.length>0){Hu(i,d),await J(`Updating this project`,()=>B(r));for(let e of d)Y.dim(`Took ${e} out of this project in skilless.`)}for(let e of u.filter(e=>s.get(e).global))Y.dim(`${e} is global, so it is also still linked at the user level.`);Y.blank(),Y.dim(`Commit ${u.flatMap(e=>[`${Il}/${e}`,`${Ll}/${e}`]).join(`, `)} to share ${u.length===1?`it`:`them`}.`),r.report()})});async function pg(e,t){return t.local?t.local.files:(await e.try(e=>e.getSkill(t.name)))?.files??null}ce.name(Ym).description(Xm).version(X).addCommand(Vh).addCommand(hh).addCommand(Fh).addCommand(oh).addCommand(ug).addCommand(ag).addCommand(Lh).addCommand(Uh).addCommand(fg).addCommand(sg).addCommand(Bh).addCommand(rg).addCommand(Kh).addCommand(Nh).parse();export{};
|