skilless 0.0.1 → 0.0.2
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/README.md +3 -1
- package/dist/bin.mjs +38 -28
- package/package.json +2 -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{
|
|
2
|
+
import{createRequire as e}from"node:module";import{execFile as t,execFileSync as n,spawn as r,spawnSync as i}from"node:child_process";import a from"node:fs";import o from"node:process";import s from"node:os";import c from"node:crypto";import{stripVTControlCharacters as l}from"node:util";import u from"node:tty";import d from"node:http";var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(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=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:f(g(e)),ee(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)),ne=e(import.meta.url),re=v((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),ie=v((e=>{let{InvalidArgumentError:t}=re();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ae=v((e=>{let{humanReadableArgName:t}=ie();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
3
3
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
4
4
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
5
|
-
`)}};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})),oe=v((e=>{let{InvalidArgumentError:t}=re();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
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})),se=v((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),ce=v((e=>{let t=ne(`node:events`).EventEmitter,n=ne(`node:child_process`),r=ne(`node:path`),i=ne(`node:fs`),a=ne(`node:process`),{Argument:o,humanReadableArgName:s}=ie(),{CommanderError:c}=re(),{Help:l,stripColor:u}=ae(),{Option:d,DualOptions:f}=oe(),{suggestSimilar:p}=se();var m=class e extends t{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>a.stdout.write(e),writeErr:e=>a.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>a.stdout.isTTY?a.stdout.columns:void 0,getErrHelpWidth:()=>a.stderr.isTTY?a.stderr.columns:void 0,getOutHasColors:()=>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 re(){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=re}));const{program:ie,createCommand:ae,createArgument:oe,createOption:y,CommanderError:se,InvalidArgumentError:ce,InvalidOptionArgumentError:le,Command:b,Argument:ue,Option:de,Help:fe}=h(p((e=>{let{Argument:t}=v(),{Command:n}=re(),{CommanderError:r,InvalidArgumentError:i}=_(),{Help:a}=ee(),{Option:o}=te();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;function pe(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 me(e,t=`|`){return e.map(e=>Fe(e)).join(t)}function he(e,t){return typeof t==`bigint`?t.toString():t}var ge=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 x(e){return new ge(e)}function _e(e){return e==null}function ve(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ye(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 be(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xe(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function S(e){return xe(e._zod.def)??e._zod.def.shape}function Se(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return be(this,t,e),e},enumerable:!0,configurable:!0})}function Ce(e,t,n){t in e?be(e,t,n):e[t]=n}function we(e,t,n,r){let i=S(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Se(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ce(e,a,r?r(n.value,a):n.value))}}function Te(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Se(e,n,()=>t[n]):Ce(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 Ee(e){return JSON.stringify(e)}function De(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Oe=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ae=x(()=>{if(k.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function je(e){if(ke(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ke(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Me(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Ne=new Set([`string`,`number`,`symbol`]);function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function w(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 Fe(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const Le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Re={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ze(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 we(i,e,Be(e,t)),w(e,C(n,{shape:i,checks:[]}))}function Be(e,t){let n=S(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 Ve(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(Be(e,t)),a={};return we(a,e,Reflect.ownKeys(S(e)).filter(e=>!i.has(e))),w(e,C(n,{shape:a,checks:[]}))}function He(e,t){if(!je(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=S(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 w(e,C(e._zod.def,{shape:Ue(e,t)}))}function Ue(e,t){let n={};return we(n,e,Reflect.ownKeys(S(e))),Te(n,t),n}function We(e,t){if(!je(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return w(e,C(e._zod.def,{shape:Ue(e,t)}))}function Ge(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 we(n,e,Reflect.ownKeys(S(e))),we(n,t,Reflect.ownKeys(S(t))),w(e,C(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ke(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(Be(t,n)):void 0,o={};return we(o,t,Reflect.ownKeys(S(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),w(t,C(t._zod.def,{shape:o,checks:[]}))}function qe(e,t,n){let r=n?new Set(Be(t,n)):void 0,i={};return we(i,t,Reflect.ownKeys(S(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),w(t,C(t._zod.def,{shape:i}))}function E(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 Je(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 Ye(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Xe(e){return typeof e==`string`?e:e?.message}function Ze(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Qe(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:Xe(e.inst?._zod.def?.error?.(e))??Xe(a?.(e))??Xe(t?.error?.(e))??Xe(n.customError?.(e))??Xe(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 $e=/[\uD800-\uDBFF]/;function et(e){let t=e.length;if(!$e.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 tt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nt(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 rt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function it(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ct(e,n,r.value)}}function at(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ot(e,t,n){return at(e,t,n,!1)}function st(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return at(this,n,r(this))},set(e){at(this,n,e)}})}return t}function ct(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:at(this,t,n.bind(this))},set(e){at(this,t,e)}})}function lt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let ut,dt=!1;const ft={configurable:!0,get(){dt=!0}};function D(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&ut!==e._zod){ut=void 0;return}ut=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ft);let e=dt;dt=!1;try{let r=n(this);return dt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),dt||=e,r}catch(n){throw delete this[t],dt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function pt(e,t,n,r){let i=lt(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 mt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var ht;const gt={value:void 0,enumerable:!1};let _t=`captureStackTrace`in Error?Error:null;function vt(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 O(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{gt.value=new a(r);try{Object.defineProperty(n,`_zod`,gt)}finally{gt.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),it(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?vt(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 yt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},bt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ht=globalThis).__zod_globalConfig??(ht.__zod_globalConfig={});const k=globalThis.__zod_globalConfig;function xt(e){return e&&Object.assign(k,e),k}function St(){let e=this._zod;return e.message??=JSON.stringify(e.def,he,2),e.message}function Ct(e){this._zod.message=e}const wt={get:St,set:Ct,enumerable:!0,configurable:!0},Tt={value:void 0,enumerable:!1},Et=new WeakSet([Object.prototype,Error.prototype]),Dt=(e,t)=>{e.name=`$ZodError`,Tt.value=t,Object.defineProperty(e,`issues`,Tt),Tt.value=void 0,Object.defineProperty(e,`message`,wt);let n=Object.getPrototypeOf(e);Et.has(n)||(Et.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})}}))},Ot=O(`$ZodError`,Dt);O(`$ZodError`,Dt,void 0,{Parent:Error});function kt(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 At(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?kt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function jt(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 Mt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Nt=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 yt;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>Qe(e,o,xt())));throw Oe(n,a?.callee??t),n}return s.value};return t},Pt=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=>Qe(e,o,xt())));throw Oe(n,a?.callee??t),n}return s.value};return t},Ft=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 yt;return a.issues.length?It(e,a.issues,i):{success:!0,data:a.value}};function It(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Qe(e,n,xt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Lt=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?It(e,a.issues,i):{success:!0,data:a.value}},Rt=Symbol.for(`zod.compile.invalid`),zt=Symbol.for(`zod.compile.fallback`),Bt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Rt)return!0;if(r.definite===!0&&n===void 0)return!1}return Vt(e,t,n)});function Vt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[zt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new yt;return a.issues.length===0}const Ht=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},Ut=e=>{let t=Nt(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Mt(n,a));return n},Wt=e=>{let t=Nt(e),n=(e,r,i,a)=>t(e,r,i,Mt(n,a));return n},Gt=e=>{let t=Pt(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Mt(n,a));return n},Kt=e=>{let t=Pt(e),n=async(e,r,i,a)=>await t(e,r,i,Mt(n,a));return n},qt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ft(e)(t,n,i)},Jt=e=>(t,n,r)=>Ft(e)(t,n,r),Yt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Lt(e)(t,n,i)},Xt=e=>async(t,n,r)=>Lt(e)(t,n,r),Zt=/^[cC][0-9a-z]{6,}$/,Qt=/^[0-9a-z]+$/,$t=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,en=/^[0-9a-vA-V]{20}$/,tn=/^[A-Za-z0-9]{27}$/,nn=/^[a-zA-Z0-9_-]{21}$/;function rn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const an=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,on=/^([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})$/,sn=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)$/,cn=/^(?:[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 ln(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const un=/^(?:(?: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])$/,dn=/^(([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}|:))$/,fn=/^((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])$/,pn=/^(([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])$/,mn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,gn=/^https?$/,_n=/^\+[1-9]\d{6,14}$/,vn=`(?:(?:\\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 yn(e){return RegExp(`^${e}$`)}const bn=yn(vn);function xn(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 Sn(e){return RegExp(`^${xn(e)}$`)}function Cn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${xn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${xn({precision:e.precision})}`:n;return RegExp(`^${vn}T(?:${r})$`)}const wn=/^[\s\S]{0,}$/,Tn=/^-?\d+(?:\.\d+)?$/,En=/^(?:true|false)$/i,Dn=/^[^A-Z]*$/,On=/^[^a-z]*$/,A=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),kn=e=>{let t=e.value;return!_e(t)&&t.length!==void 0},An={number:`number`,bigint:`bigint`,object:`date`},jn=O(`$ZodCheckLessThan`,(e,t)=>{A.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:An[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})}}),Mn=O(`$ZodCheckGreaterThan`,(e,t)=>{A.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:An[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})}}),Nn=O(`$ZodCheckMultipleOf`,(e,t)=>{A.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):ye(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})}}),Pn=O(`$ZodCheckNumberFormat`,(e,t)=>{A.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Le[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})}}),Fn=O(`$ZodCheckMaxLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?et(r):i)<=t.maximum)return;let a=tt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),In=O(`$ZodCheckMinLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?et(r):i)>=t.minimum)return;let a=tt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ln=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=kn),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?et(r):i;if(a===t.length)return;let o=tt(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})}}),Rn=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;A.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=()=>{})}),zn=O(`$ZodCheckRegex`,(e,t)=>{Rn.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})}}),Bn=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Dn,Rn.init(e,t)}),Vn=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=On,Rn.init(e,t)}),Hn=O(`$ZodCheckIncludes`,(e,t)=>{A.init(e,t);let n=Pe(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})}}),Un=O(`$ZodCheckStartsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`^${Pe(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})}}),Wn=O(`$ZodCheckEndsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`.*${Pe(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})}}),Gn=O(`$ZodCheckOverwrite`,(e,t)=>{A.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Kn=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:le,createCommand:ue,createArgument:de,createOption:fe,CommanderError:pe,InvalidArgumentError:me,InvalidOptionArgumentError:he,Command:y,Argument:ge,Option:_e,Help:ve}=te(v((e=>{let{Argument:t}=ie(),{Command:n}=ce(),{CommanderError:r,InvalidArgumentError:i}=re(),{Help:a}=ae(),{Option:o}=oe();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;let ye=()=>{var e=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of n(a))!r.call(i,c)&&c!==o&&e(i,c,{get:()=>a[c],enumerable:!(s=t(a,c))||s.enumerable});return i},o=t=>a(e({},`__esModule`,{value:!0}),t),s={};i(s,{default:()=>Xe});var c=e=>Array.isArray(e),l=e=>typeof e==`function`,u=e=>e.length===0,d=e=>typeof e==`number`,f=e=>typeof e==`object`&&!!e,p=e=>e instanceof RegExp,m=e=>typeof e==`string`,h=e=>e===void 0,g=e=>{let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=e(n);return t.set(n,i),i}},_=(e,t,n={})=>{let r={cache:{},input:e,index:0,indexMax:0,options:n,output:[]};if(fe(t)(r)&&r.index===e.length)return r.output;throw Error(`Failed to parse at index ${r.indexMax}`)},v=(e,t)=>c(e)?ee(e,t):m(e)?ne(e,t):te(e,t),ee=(e,t)=>{let n={};for(let t of e){if(t.length!==1)throw Error(`Invalid character: "${t}"`);let e=t.charCodeAt(0);n[e]=!0}return e=>{let r=e.index,i=e.input;for(;e.index<i.length&&i.charCodeAt(e.index)in n;)e.index+=1;let a=e.index;if(a>r){if(!h(t)&&!e.options.silent){let n=e.input.slice(r,a),o=l(t)?t(n,i,String(r)):t;h(o)||e.output.push(o)}e.indexMax=Math.max(e.indexMax,e.index)}return!0}},te=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return ue(e=>{i.lastIndex=e.index;let n=i.exec(e.input);if(n){if(!h(t)&&!e.options.silent){let r=l(t)?t(...n,e.input,String(e.index)):t;h(r)||e.output.push(r)}return e.index+=n[0].length,e.indexMax=Math.max(e.indexMax,e.index),!0}else return!1})},ne=(e,t)=>n=>{if(n.input.startsWith(e,n.index)){if(!h(t)&&!n.options.silent){let r=l(t)?t(e,n.input,String(n.index)):t;h(r)||n.output.push(r)}return n.index+=e.length,n.indexMax=Math.max(n.indexMax,n.index),!0}else return!1},re=(e,t,n,r)=>{let i=fe(e);return ue(le(ce(e=>{let r=0;for(;r<n;){let t=e.index;if(!i(e)||(r+=1,e.index===t))break}return r>=t})))},ie=(e,t)=>re(e,0,1),ae=(e,t)=>re(e,0,1/0),oe=(e,t)=>{let n=e.map(fe);return ue(le(ce(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},se=(e,t)=>{let n=e.map(fe);return ue(le(e=>{for(let t=0,r=n.length;t<r;t++)if(n[t](e))return!0;return!1}))},ce=(e,t=!1)=>{let n=fe(e);return e=>{let r=e.index,i=e.output.length,a=n(e);return(!a||t)&&(e.index=r,e.output.length!==i&&(e.output.length=i)),a}},le=(e,t)=>fe(e),ue=(()=>{let e=0;return t=>{let n=fe(t),r=e+=1;return e=>{var t;if(e.options.memoization===!1)return n(e);let i=e.index,a=(t=e.cache)[r]||(t[r]=new Map),o=a.get(i);if(o===!1)return!1;if(d(o))return e.index=o,!0;if(o)return e.index=o.index,o.output?.length&&e.output.push(...o.output),!0;{let t=e.output.length;if(n(e)){let n=e.index,r=e.output.length;if(r>t){let o=e.output.slice(t,r);a.set(i,{index:n,output:o})}else a.set(i,n);return!0}else return a.set(i,!1),!1}}}})(),de=e=>{let t;return n=>(t||=fe(e()),t(n))},fe=g(e=>{if(l(e))return u(e)?de(e):e;if(m(e)||p(e))return v(e);if(c(e))return oe(e);if(f(e))return se(Object.values(e));throw Error(`Invalid rule`)}),pe=`abcdefghijklmnopqrstuvwxyz`,me=e=>{let t=``;for(;e>0;)t=pe[(e-1)%26]+t,e=Math.floor((e-1)/26);return t},he=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t=t*26+pe.indexOf(e[n])+1;return t},y=(e,t)=>{if(t<e)return y(t,e);let n=[];for(;e<=t;)n.push(e++);return n},ge=(e,t,n)=>y(e,t).map(e=>String(e).padStart(n,`0`)),_e=(e,t)=>y(he(e),he(t)).map(me),ve=e=>e,ye=e=>be(t=>_(t,e,{memoization:!1}).join(``)),be=e=>{let t={};return n=>t[n]??(t[n]=e(n))},xe=v(/^\*\*\/\*$/,`.*`),Se=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),Ce=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),we=v(/\\./,ve),Te=v(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=v(/./,ve),De=se([v(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${b(t)}$).*?`),v(/^(!!)+/,``)]),Oe=se([v(/\/(\*\*\/)+/,`(?:/.+/|/)`),v(/^(\*\*\/)+/,`(?:^|.*/)`),v(/\/(\*\*)$/,`(?:/.*|$)`),v(/\*\*/,`.*`)]),ke=se([v(/\*\/(?!\*\*\/)/,`[^/]*/`),v(/\*/,`[^/]*`)]),Ae=v(`?`,`[^/]`),je=v(`[`,ve),Me=v(`]`,ve),Ne=v(/[!^]/,`^/`),Pe=v(/[a-z]-[a-z]|[0-9]-[0-9]/i,ve),Fe=se([we,v(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Pe,v(/[^\]]/,ve)]),Ie=oe([je,ie(Ne),ae(Fe),Me]),Le=v(`{`,`(?:`),Re=v(`}`,`)`),ze=oe([Le,se([v(/(\d+)\.\.(\d+)/,(e,t,n)=>ge(+t,+n,Math.min(t.length,n.length)).join(`|`)),v(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>_e(t,n).join(`|`)),v(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>_e(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Re]),Be=v(`{`,`(?:`),Ve=v(`}`,`)`),He=v(`,`,`|`),Ue=v(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),We=v(/[^}]/,ve),Ge=oe([Be,ae(se([Oe,ke,Ae,Ie,ze,de(()=>Ge),we,Ue,He,We])),Ve]),b=ye(ae(se([xe,Se,Ce,De,Oe,ke,Ae,Ie,ze,Ge,we,Te,Ee]))),Ke=v(/\\./,ve),qe=v(/./,ve),Je=ye(ae(se([Ke,v(/\*\*\*+/,`*`),v(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),v(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),qe]))),Ye=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(Ye.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};Ye.compile=e=>RegExp(`^${b(Je(e))}$`,`s`);var Xe=Ye;return o(s)})();return e.default||e},be;const xe=(e,t)=>(be||(be=ye(),ye=null),be(e,t)),Se=/^[A-Za-z]:\//;function Ce(e=``){return e&&e.replace(/\\/g,`/`).replace(Se,e=>e.toUpperCase())}const we=/^[/\\]{2}/,Te=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Ee=/^[A-Za-z]:$/,De=/^\/([A-Za-z]:)?$/,Oe=/.(\.[^./]+|\.)$/,ke=/^[/\\]|^[a-zA-Z]:[/\\]/,Ae=function(e){if(e.length===0)return`.`;e=Ce(e);let t=e.match(we),n=Fe(e),r=e[e.length-1]===`/`;return e=Pe(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Ee.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Fe(e)?`/${e}`:e)},je=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return Ae(t)};function Me(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Ne=function(...e){e=e.map(e=>Ce(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:Me();!i||i.length===0||(t=`${i}/${t}`,n=Fe(i))}return t=Pe(t,!n),n&&!Fe(t)?`/${t}`:t.length>0?t:`.`};function Pe(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const Fe=function(e){return Te.test(e)},Ie=function(e){return Ce(e)},Le=function(e){if(e===`..`)return``;let t=Oe.exec(Ce(e));return t&&t[1]||``},Re=function(e,t){let n=Ne(e).replace(De,`$1`).split(`/`),r=Ne(t).replace(De,`$1`).split(`/`);if(r[0][1]===`:`&&n[0][1]===`:`&&n[0]!==r[0])return r.join(`/`);let i=[...n];for(let e of i){if(r[0]!==e)break;n.shift(),r.shift()}return[...n.map(()=>`..`),...r].join(`/`)},ze=function(e){let t=Ce(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Ee.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Fe(e)?`/`:`.`)},Be=function(e){let t=e.ext?e.ext.startsWith(`.`)?e.ext:`.${e.ext}`:``,n=[e.root,e.dir,e.base??(e.name??``)+t].filter(Boolean);return Ce(e.root?Ne(...n):n.join(`/`))},Ve=function(e,t){let n=Ce(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r},He={__proto__:null,basename:Ve,dirname:ze,extname:Le,format:Be,isAbsolute:Fe,join:je,matchesGlob:(e,t)=>xe(t,Ae(e)),normalize:Ae,normalizeString:Pe,parse:function(e){let t=ke.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=Ve(e),r=Le(n);return{root:t,dir:ze(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Re,resolve:Ne,sep:`/`,toNamespacedPath:Ie},Ue=globalThis.process?.platform===`win32`?`;`:`:`,We={posix:void 0,win32:void 0},Ge=(e=Ue)=>new Proxy(He,{get(t,n){return n===`delimiter`?e:n===`posix`?b:n===`win32`?Ke:We[n]||He[n]}}),b=Ge(`:`),Ke=Ge(`;`);function qe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Je(e,t=`|`){return e.map(e=>vt(e)).join(t)}function Ye(e,t){return typeof t==`bigint`?t.toString():t}var Xe=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Ze(e){return new Xe(e)}function Qe(e){return e==null}function $e(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function et(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function tt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function nt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function rt(e){return nt(e._zod.def)??e._zod.def.shape}function it(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return tt(this,t,e),e},enumerable:!0,configurable:!0})}function at(e,t,n){t in e?tt(e,t,n):e[t]=n}function ot(e,t,n,r){let i=rt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?it(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):at(e,a,r?r(n.value,a):n.value))}}function st(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?it(e,n,()=>t[n]):at(e,n,r.value))}}function x(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ct(e){return JSON.stringify(e)}function lt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const ut=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ft=Ze(()=>{if(on.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pt(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(dt(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function mt(e){return pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const ht=new Set([`string`,`number`,`symbol`]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _t(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function S(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function vt(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function yt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const bt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},xt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function St(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return ot(i,e,Ct(e,t)),_t(e,x(n,{shape:i,checks:[]}))}function Ct(e,t){let n=rt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function wt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Ct(e,t)),a={};return ot(a,e,Reflect.ownKeys(rt(e)).filter(e=>!i.has(e))),_t(e,x(n,{shape:a,checks:[]}))}function Tt(e,t){if(!pt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=rt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _t(e,x(e._zod.def,{shape:Et(e,t)}))}function Et(e,t){let n={};return ot(n,e,Reflect.ownKeys(rt(e))),st(n,t),n}function Dt(e,t){if(!pt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _t(e,x(e._zod.def,{shape:Et(e,t)}))}function Ot(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return ot(n,e,Reflect.ownKeys(rt(e))),ot(n,t,Reflect.ownKeys(rt(t))),_t(e,x(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function kt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ct(t,n)):void 0,o={};return ot(o,t,Reflect.ownKeys(rt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),_t(t,x(t._zod.def,{shape:o,checks:[]}))}function At(e,t,n){let r=n?new Set(Ct(t,n)):void 0,i={};return ot(i,t,Reflect.ownKeys(rt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),_t(t,x(t._zod.def,{shape:i}))}function jt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Mt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Nt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Pt(e){return typeof e==`string`?e:e?.message}function Ft(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function It(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Pt(e.inst?._zod.def?.error?.(e))??Pt(a?.(e))??Pt(t?.error?.(e))??Pt(n.customError?.(e))??Pt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t===`inst`||t===`schema`||t===`continue`||t===`input`||t===`__proto__`||(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const Lt=/[\uD800-\uDBFF]/;function Rt(e){let t=e.length;if(!Lt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function zt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Bt(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Vt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Ht(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Kt(e,n,r.value)}}function Ut(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Wt(e,t,n){return Ut(e,t,n,!1)}function Gt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ut(this,n,r(this))},set(e){Ut(this,n,e)}})}return t}function Kt(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ut(this,t,n.bind(this))},set(e){Ut(this,t,e)}})}function qt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Jt,Yt=!1;const Xt={configurable:!0,get(){Yt=!0}};function C(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Jt!==e._zod){Jt=void 0;return}Jt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Xt);let e=Yt;Yt=!1;try{let r=n(this);return Yt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Yt||=e,r}catch(n){throw delete this[t],Yt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Zt(e,t,n,r){let i=qt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Qt(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var $t;const en={value:void 0,enumerable:!1};let tn=`captureStackTrace`in Error?Error:null;function nn(e){let t=tn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return tn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function w(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{en.value=new a(r);try{Object.defineProperty(n,`_zod`,en)}finally{en.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Ht(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,`name`,{value:e});function d(e){let t=r?.Parent?nn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,`init`,{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,`name`,{value:e}),d}var rn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},an=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};($t=globalThis).__zod_globalConfig??($t.__zod_globalConfig={});const on=globalThis.__zod_globalConfig;function sn(e){return e&&Object.assign(on,e),on}function cn(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ye,2),e.message}function ln(e){this._zod.message=e}const un={get:cn,set:ln,enumerable:!0,configurable:!0},dn={value:void 0,enumerable:!1},fn=new WeakSet([Object.prototype,Error.prototype]),pn=(e,t)=>{e.name=`$ZodError`,dn.value=t,Object.defineProperty(e,`issues`,dn),dn.value=void 0,Object.defineProperty(e,`message`,un);let n=Object.getPrototypeOf(e);fn.has(n)||(fn.add(n),Object.defineProperty(n,`toString`,{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0})}}))},mn=w(`$ZodError`,pn);w(`$ZodError`,pn,void 0,{Parent:Error});function hn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function gn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?hn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _n(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function vn(e,t){return{callee:t?.callee??e,Err:t?.Err}}const yn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rn;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>It(e,o,sn())));throw ut(n,a?.callee??t),n}return s.value};return t},bn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>It(e,o,sn())));throw ut(n,a?.callee??t),n}return s.value};return t},xn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new rn;return a.issues.length?Sn(e,a.issues,i):{success:!0,data:a.value}};function Sn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>It(e,n,sn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const Cn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Sn(e,a.issues,i):{success:!0,data:a.value}},wn=Symbol.for(`zod.compile.invalid`),Tn=Symbol.for(`zod.compile.fallback`),En=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==wn)return!0;if(r.definite===!0&&n===void 0)return!1}return Dn(e,t,n)});function Dn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Tn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new rn;return a.issues.length===0}const On=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},kn=e=>{let t=yn(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},vn(n,a));return n},An=e=>{let t=yn(e),n=(e,r,i,a)=>t(e,r,i,vn(n,a));return n},jn=e=>{let t=bn(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},vn(n,a));return n},Mn=e=>{let t=bn(e),n=async(e,r,i,a)=>await t(e,r,i,vn(n,a));return n},Nn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xn(e)(t,n,i)},Pn=e=>(t,n,r)=>xn(e)(t,n,r),Fn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cn(e)(t,n,i)},In=e=>async(t,n,r)=>Cn(e)(t,n,r),Ln=/^[cC][0-9a-z]{6,}$/,Rn=/^[0-9a-z]+$/,zn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bn=/^[0-9a-vA-V]{20}$/,Vn=/^[A-Za-z0-9]{27}$/,Hn=/^[a-zA-Z0-9_-]{21}$/;function Un(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Wn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Jn(){return RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}const Yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Zn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$n=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,er=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,tr=/^https?$/,nr=/^\+[1-9]\d{6,14}$/,rr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function ir(e){return RegExp(`^${e}$`)}const ar=ir(rr);function or(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function sr(e){return RegExp(`^${or(e)}$`)}function cr(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${or({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${or({precision:e.precision})}`:n;return RegExp(`^${rr}T(?:${r})$`)}const lr=/^[\s\S]{0,}$/,ur=/^-?\d+(?:\.\d+)?$/,dr=/^(?:true|false)$/i,fr=/^[^A-Z]*$/,pr=/^[^a-z]*$/,T=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mr=e=>{let t=e.value;return!Qe(t)&&t.length!==void 0},hr={number:`number`,bigint:`bigint`,object:`date`},gr=w(`$ZodCheckLessThan`,(e,t)=>{T.init(e,t);let n=hr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:hr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_r=w(`$ZodCheckGreaterThan`,(e,t)=>{T.init(e,t);let n=hr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:hr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),vr=w(`$ZodCheckMultipleOf`,(e,t)=>{T.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):et(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yr=w(`$ZodCheckNumberFormat`,(e,t)=>{T.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=bt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),br=w(`$ZodCheckMaxLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Rt(r):i)<=t.maximum)return;let a=zt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xr=w(`$ZodCheckMinLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Rt(r):i)>=t.minimum)return;let a=zt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sr=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=mr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Rt(r):i;if(a===t.length)return;let o=zt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cr=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;T.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),wr=w(`$ZodCheckRegex`,(e,t)=>{Cr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Tr=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=fr,Cr.init(e,t)}),Er=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=pr,Cr.init(e,t)}),Dr=w(`$ZodCheckIncludes`,(e,t)=>{T.init(e,t);let n=gt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Or=w(`$ZodCheckStartsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`^${gt(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),kr=w(`$ZodCheckEndsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`.*${gt(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ar=w(`$ZodCheckOverwrite`,(e,t)=>{T.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var jr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
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 qn={major:4,minor:6,patch:5},j=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qn;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=E(t),a;for(let o of n){if(o._zod.def.when){if(Je(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 yt;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ze(t.issues,n,e),i||=E(t,n))});else{if(t.issues.length===n)continue;Ze(t.issues,n,e),i||=E(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(E(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new yt;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 yt;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ot(this,`~standard`,Xn(this))},set"~standard"(e){at(this,`~standard`,e)}}),Jn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Qe(e,t,xt()))}:{value:e.value};async function Yn(e,t){let n={async:!0};return Jn(await e._zod.run({value:t,issues:[]},n),n)}function Xn(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Jn(r,n)}catch{}return Yn(e,t)},vendor:`zod`,version:1}}const Zn=O(`$ZodString`,(e,t)=>{j.init(e,t),e._zod.pattern=t.pattern??wn,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}}),M=O(`$ZodStringFormat`,(e,t)=>{Rn.init(e,t),Zn.init(e,t)}),Qn=O(`$ZodGUID`,(e,t)=>{t.pattern??=on,M.init(e,t)}),$n=O(`$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??=sn(e)}else t.pattern??=sn();M.init(e,t)}),er=O(`$ZodEmail`,(e,t)=>{t.pattern??=cn,M.init(e,t)});function tr(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function nr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?tr(e)||2:rr(e,t)}function rr(e,t){if(!t.normalize&&t.protocol?.source===gn.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 ir=/[\t\n\r]/g;function ar(e){return e.replace(ir,``)}function or(e,t){return t.lastIndex=0,t.test(e.hostname)}function sr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const cr=O(`$ZodURL`,(e,t)=>{M.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=nr(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=ar(r);return}t.hostname&&!or(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&&!sr(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:ar(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),lr=O(`$ZodEmoji`,(e,t)=>{t.pattern??=ln(),M.init(e,t)}),ur=O(`$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?nn:rn(t.length),M.init(e,t)}),dr=O(`$ZodCUID`,(e,t)=>{t.pattern??=Zt,M.init(e,t)}),fr=O(`$ZodCUID2`,(e,t)=>{t.pattern??=Qt,M.init(e,t)}),pr=O(`$ZodULID`,(e,t)=>{t.pattern??=$t,M.init(e,t)}),mr=O(`$ZodXID`,(e,t)=>{t.pattern??=en,M.init(e,t)}),hr=O(`$ZodKSUID`,(e,t)=>{t.pattern??=tn,M.init(e,t)}),gr=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Cn(t),M.init(e,t)}),_r=O(`$ZodISODate`,(e,t)=>{t.pattern??=bn,M.init(e,t)}),vr=O(`$ZodISOTime`,(e,t)=>{t.pattern??=Sn(t),M.init(e,t)}),yr=O(`$ZodISODuration`,(e,t)=>{t.pattern??=an,M.init(e,t)}),br=O(`$ZodIPv4`,(e,t)=>{t.pattern??=un,M.init(e,t)}),xr=/^[0-9a-fA-F:.]+$/;function Sr(e){return xr.test(e)?tr(`http://[${e}]`):!1}const Cr=O(`$ZodIPv6`,(e,t)=>{t.pattern??=dn,M.init(e,t),e._zod.check=n=>{Sr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),wr=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=fn,M.init(e,t)});function Tr(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:Sr(n)}const Er=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=pn,M.init(e,t),e._zod.check=n=>{Tr(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Dr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Or=/^[0-9a-zA-Z+/]*={0,2}$/,kr=O(`$ZodBase64`,(e,t)=>{t.pattern??=Or,M.init(e,t),e._zod.check=n=>{Dr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Ar=/^[A-Za-z0-9_-]*$/;function jr(e){if(!Ar.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Dr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Mr=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ar,M.init(e,t),e._zod.check=n=>{jr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Nr=O(`$ZodE164`,(e,t)=>{t.pattern??=_n,M.init(e,t)});function Pr(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 Fr=O(`$ZodJWT`,(e,t)=>{M.init(e,t),e._zod.check=n=>{Pr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ir=O(`$ZodNumber`,(e,t)=>{j.init(e,t),e._zod.pattern=Tn,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}}),Lr=O(`$ZodNumberFormat`,(e,t)=>{Pn.init(e,t),Ir.init(e,t)}),Rr=O(`$ZodBoolean`,(e,t)=>{j.init(e,t),e._zod.pattern=En,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}}),zr=O(`$ZodUnknown`,(e,t)=>{j.init(e,t),e._zod.parse=e=>e}),Br=O(`$ZodNever`,(e,t)=>{j.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Vr(e,t,n){e.issues.length&&t.issues.push(...Ye(n,e.issues)),t.value[n]=e.value}const Hr=O(`$ZodArray`,(e,t)=>{j.init(e,t);let n=k.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=>Vr(t,r,e)));else if(Vr(c,r,e),s&&c.issues.length!==0&&E(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Ur(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(...Ye(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 Wr=[];function Gr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Wr,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=Ie(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Kr(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(E(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=>Ur(e,n,i,t,d,f))):Ur(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 qr=O(`$ZodObject`,(e,t)=>{j.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=x(()=>Gr(t));D(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)||be(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=ke,o=t.catchall,s,c=k.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(E(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=>Ur(n,t,e,r,a,o))):Ur(s,t,e,r,a,o)}return o?Kr(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Jr=O(`$ZodObjectJIT`,(e,t)=>{qr.init(e,t);let n=e._zod.parse,r=x(()=>Gr(t)),i=k.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Kn([`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 Mr={major:4,minor:6,patch:5},E=w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mr;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=jt(t),a;for(let o of n){if(o._zod.def.when){if(Mt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new rn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ft(t.issues,n,e),i||=jt(t,n))});else{if(t.issues.length===n)continue;Ft(t.issues,n,e),i||=jt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(jt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new rn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new rn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Wt(this,`~standard`,Fr(this))},set"~standard"(e){Ut(this,`~standard`,e)}}),Nr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>It(e,t,sn()))}:{value:e.value};async function Pr(e,t){let n={async:!0};return Nr(await e._zod.run({value:t,issues:[]},n),n)}function Fr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Nr(r,n)}catch{}return Pr(e,t)},vendor:`zod`,version:1}}const Ir=w(`$ZodString`,(e,t)=>{E.init(e,t),e._zod.pattern=t.pattern??lr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),D=w(`$ZodStringFormat`,(e,t)=>{Cr.init(e,t),Ir.init(e,t)}),Lr=w(`$ZodGUID`,(e,t)=>{t.pattern??=Gn,D.init(e,t)}),Rr=w(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Kn(e)}else t.pattern??=Kn();D.init(e,t)}),zr=w(`$ZodEmail`,(e,t)=>{t.pattern??=qn,D.init(e,t)});function Br(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Vr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Br(e)||2:Hr(e,t)}function Hr(e,t){if(!t.normalize&&t.protocol?.source===tr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}const Ur=/[\t\n\r]/g;function Wr(e){return e.replace(Ur,``)}function Gr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Kr(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}const qr=w(`$ZodURL`,(e,t)=>{D.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Vr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Wr(r);return}t.hostname&&!Gr(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Kr(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Wr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Jr=w(`$ZodEmoji`,(e,t)=>{t.pattern??=Jn(),D.init(e,t)}),Yr=w(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Hn:Un(t.length),D.init(e,t)}),Xr=w(`$ZodCUID`,(e,t)=>{t.pattern??=Ln,D.init(e,t)}),Zr=w(`$ZodCUID2`,(e,t)=>{t.pattern??=Rn,D.init(e,t)}),Qr=w(`$ZodULID`,(e,t)=>{t.pattern??=zn,D.init(e,t)}),$r=w(`$ZodXID`,(e,t)=>{t.pattern??=Bn,D.init(e,t)}),ei=w(`$ZodKSUID`,(e,t)=>{t.pattern??=Vn,D.init(e,t)}),ti=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=cr(t),D.init(e,t)}),ni=w(`$ZodISODate`,(e,t)=>{t.pattern??=ar,D.init(e,t)}),ri=w(`$ZodISOTime`,(e,t)=>{t.pattern??=sr(t),D.init(e,t)}),ii=w(`$ZodISODuration`,(e,t)=>{t.pattern??=Wn,D.init(e,t)}),ai=w(`$ZodIPv4`,(e,t)=>{t.pattern??=Yn,D.init(e,t)}),oi=/^[0-9a-fA-F:.]+$/;function si(e){return oi.test(e)?Br(`http://[${e}]`):!1}const ci=w(`$ZodIPv6`,(e,t)=>{t.pattern??=Xn,D.init(e,t),e._zod.check=n=>{si(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),li=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Zn,D.init(e,t)});function ui(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:si(n)}const di=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Qn,D.init(e,t),e._zod.check=n=>{ui(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function fi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const pi=/^[0-9a-zA-Z+/]*={0,2}$/,mi=w(`$ZodBase64`,(e,t)=>{t.pattern??=pi,D.init(e,t),e._zod.check=n=>{fi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),hi=/^[A-Za-z0-9_-]*$/;function gi(e){if(!hi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return fi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const _i=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=hi,D.init(e,t),e._zod.check=n=>{gi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),vi=w(`$ZodE164`,(e,t)=>{t.pattern??=nr,D.init(e,t)});function yi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const bi=w(`$ZodJWT`,(e,t)=>{D.init(e,t),e._zod.check=n=>{yi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),xi=w(`$ZodNumber`,(e,t)=>{E.init(e,t),e._zod.pattern=ur,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Si=w(`$ZodNumberFormat`,(e,t)=>{yr.init(e,t),xi.init(e,t)}),Ci=w(`$ZodBoolean`,(e,t)=>{E.init(e,t),e._zod.pattern=dr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),wi=w(`$ZodUnknown`,(e,t)=>{E.init(e,t),e._zod.parse=e=>e}),Ti=w(`$ZodNever`,(e,t)=>{E.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ei(e,t,n){e.issues.length&&t.issues.push(...Nt(n,e.issues)),t.value[n]=e.value}const Di=w(`$ZodArray`,(e,t)=>{E.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ei(t,r,e)));else if(Ei(c,r,e),s&&c.issues.length!==0&&jt(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Oi(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Nt(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const ki=[];function Ai(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ki,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=yt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ji(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(jt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Oi(e,n,i,t,d,f))):Oi(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Mi=w(`$ZodObject`,(e,t)=>{E.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,`shape`,{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,`shape`,{get:e})}let i=Ze(()=>Ai(t));C(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||tt(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=dt,o=t.catchall,s,c=on.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(jt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Oi(n,t,e,r,a,o))):Oi(s,t,e,r,a,o)}return o?ji(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ni=w(`$ZodObjectJIT`,(e,t)=>{Mi.init(e,t);let n=e._zod.parse,r=Ze(()=>Ai(t)),i=on.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new jr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
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)}]`:ct(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,47 +69,57 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
|
|
|
69
69
|
newResult[${r}] = ${n}.value;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=ke,c=!k.jitless,l=c&&Ae.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?Kr([],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 Yr(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=>!E(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=>Qe(e,r,xt())))}),t)}const Xr=O(`$ZodUnion`,(e,t)=>{j.init(e,t),D(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),D(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(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)))}),D(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=>ve(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=>Yr(t,r,e,i)):Yr(o,r,e,i)}}),Zr=O(`$ZodIntersection`,(e,t)=>{j.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])=>$r(e,t,n)):$r(e,i,a)}});function Qr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(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=Qr(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=Qr(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 $r(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=Qr(t.value,n.value);if(!c.valid){if(E(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const ei=O(`$ZodEnum`,(e,t)=>{j.init(e,t);let n=pe(t.entries),r=new Set(n);e._zod.values=r,D(e,`pattern`,e=>{let t=pe(e.def.entries).filter(e=>Ne.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Pe(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}}),ti=O(`$ZodTransform`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,k.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bt(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 yt;return n.value=i,n}});function ni(e,t){return e.value=t.issues.length?void 0:t.value,e}const ri=O(`$ZodOptional`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(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=>ni(e,t)):ni(e,r)}return t.innerType._zod.run(e,n)}}),ii=O(`$ZodExactOptional`,(e,t)=>{ri.init(e,t),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ai=O(`$ZodNullable`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ve(t.source)}|null)$`):void 0}),D(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)}),oi=O(`$ZodDefault`,(e,t)=>{j.init(e,t),e._zod.optin=`defaulted`,D(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=>si(e,t)):si(r,t)}});function si(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ci=O(`$ZodPrefault`,(e,t)=>{j.init(e,t),e._zod.optin=`defaulted`,D(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))}),li=O(`$ZodNonOptional`,(e,t)=>{j.init(e,t),D(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=>ui(t,e)):ui(i,e)}});function ui(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 di(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Qe(e,r,xt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const fi=O(`$ZodCatch`,(e,t)=>{j.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),D(e,`optout`,e=>e.def.innerType._zod.optout),D(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=>di(e,r,t,n)):di(e,r,t,n)}}),pi=O(`$ZodPipe`,(e,t)=>{j.init(e,t),D(e,`values`,e=>e.def.in._zod.values),D(e,`optin`,e=>e.def.in._zod.optin),D(e,`optout`,e=>e.def.out._zod.optout),D(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=>mi(e,t.in,n)):mi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mi(e,t.out,n)):mi(r,t.out,n)}});function mi(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 hi=O(`$ZodReadonly`,(e,t)=>{j.init(e,t),D(e,`propValues`,e=>e.def.innerType._zod.propValues),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`optin`,e=>e.def.innerType?._zod?.optin),D(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(gi):gi(r)}});function gi(e){return e.memo||(e.value=Object.freeze(e.value)),e}const _i=O(`$ZodCustom`,(e,t)=>{A.init(e,t),j.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=>vi(t,n,r,e));vi(i,n,r,e)}});function vi(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(rt(e))}}var yi=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const bi=`~memo`,xi=[];function Si(e){return typeof e==`object`&&!!e}function Ci(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const wi=new WeakMap;function Ti(e,t,n){let r=wi.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=Ti(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?Ti(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=xe(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?Ti(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),Ei(e,i)}function Ei(e,t){return t!==1&&wi.set(e,t===2),t}function Di(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Oi;const ki=[],Ai={alloc(e,t,n){let r=Oi;if(!r)return n;Oi=void 0;let i={value:n,issues:null};return r.set(t.value,i),ki.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`&&Mi(n,e.value))throw new yi;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=Ti(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(!Si(l))return t(s,c);let u=c[bi];u||(u={buckets:new WeakMap,backEdges:void 0},c[bi]=u);let d;i===c?d=a:(d=Di(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(...Ci(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;Oi=d;let p=ki.length,m=t(s,c);Oi=void 0;let h=ki.length>p?ki.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ci(e.issues):xi),e)):(h&&(h.issues=m.issues.length?Ci(m.issues):xi),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ji(){return Ai}function Mi(e,t){let n=e[bi]?.backEdges;return n!==void 0&&Si(t)&&n.has(t)}const Ni=()=>{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(nt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Fe(e.values[0])}`:`Invalid option: expected one of ${me(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`:``}: ${me(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 Pi(){return{localeError:Ni()}}var Fi,Ii=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 Li(){return new Ii}(Fi=globalThis).__zod_globalRegistry??(Fi.__zod_globalRegistry=Li());const Ri=globalThis.__zod_globalRegistry;function zi(e){return e.checks&&=[...e.checks],e}function Bi(e,t){return new e(zi({type:`string`,...T(t)}))}function Vi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...T(t)})}function Hi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...T(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...T(t)})}function Wi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...T(t)})}function Gi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...T(t)})}function Ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...T(t)})}function qi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...T(t)})}function Ji(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...T(t)})}function Yi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...T(t)})}function Xi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...T(t)})}function Zi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...T(t)})}function Qi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...T(t)})}function $i(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...T(t)})}function ea(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...T(t)})}function ta(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...T(t)})}function na(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...T(t)})}function ra(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...T(t)})}function ia(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...T(t)})}function aa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...T(t)})}function oa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...T(t)})}function sa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...T(t)})}function ca(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...T(t)})}function la(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...T(t)})}function ua(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...T(t)})}function da(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...T(t)})}function fa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...T(t)})}function pa(e,t){return new e(zi({type:`number`,checks:[],...T(t)}))}function ma(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...T(t)})}function ha(e,t){return new e({type:`boolean`,...T(t)})}function ga(e){return new e({type:`unknown`})}function _a(e,t){return new e({type:`never`,...T(t)})}function va(e,t){return new jn({check:`less_than`,...T(t),value:e,inclusive:!1})}function ya(e,t){return new jn({check:`less_than`,...T(t),value:e,inclusive:!0})}function ba(e,t){return new Mn({check:`greater_than`,...T(t),value:e,inclusive:!1})}function xa(e,t){return new Mn({check:`greater_than`,...T(t),value:e,inclusive:!0})}function Sa(e,t){return new Nn({check:`multiple_of`,...T(t),value:e})}function Ca(e,t){return new Fn({check:`max_length`,...T(t),maximum:e})}function wa(e,t){return new In({check:`min_length`,...T(t),minimum:e})}function Ta(e,t){return new Ln({check:`length_equals`,...T(t),length:e})}function Ea(e,t){return new zn({check:`string_format`,format:`regex`,...T(t),pattern:e})}function Da(e){return new Bn({check:`string_format`,format:`lowercase`,...T(e)})}function Oa(e){return new Vn({check:`string_format`,format:`uppercase`,...T(e)})}function ka(e,t){return new Hn({check:`string_format`,format:`includes`,...T(t),includes:e})}function Aa(e,t){return new Un({check:`string_format`,format:`starts_with`,...T(t),prefix:e})}function ja(e,t){return new Wn({check:`string_format`,format:`ends_with`,...T(t),suffix:e})}function Ma(e){return new Gn({check:`overwrite`,tx:e})}function Na(e){return Ma(t=>t.normalize(e))}function Pa(){return Ma(e=>e.trim())}function Fa(){return Ma(e=>e.toLowerCase())}function Ia(){return Ma(e=>e.toUpperCase())}function La(){return Ma(e=>De(e))}function Ra(e,t,n){return new e({type:`array`,element:t,...T(n)})}function za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...T(n)})}function Ba(e,t){let n=Va(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(rt(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(rt(r))}},e(t.value,t)),t);return n}function Va(e,t){let n=new A({check:`custom`,...T(t)});return n._zod.check=e,n}function Ha(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&be(e,t,n[t]);return e}function Ua(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??Ri,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 Wa(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 N(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,N(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ha(o.schema,c),t.io===`input`&&P(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 Ga(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ka(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}/${Ga(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+Ga(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=dt,c=!on.jitless,l=c&&ft.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ji([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Pi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!jt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>It(e,r,sn())))}),t)}const Fi=w(`$ZodUnion`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),C(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),C(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),C(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>$e(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Pi(t,r,e,i)):Pi(o,r,e,i)}}),Ii=w(`$ZodIntersection`,(e,t)=>{E.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ri(e,t,n)):Ri(e,i,a)}});function Li(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pt(e)&&pt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Li(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Li(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ri(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Li(t.value,n.value);if(!c.valid){if(jt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const zi=w(`$ZodEnum`,(e,t)=>{E.init(e,t);let n=qe(t.entries),r=new Set(n);e._zod.values=r,C(e,`pattern`,e=>{let t=qe(e.def.entries).filter(e=>ht.has(typeof e));return RegExp(t.length?`^(${t.map(e=>gt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Bi=w(`$ZodTransform`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,on.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new an(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new rn;return n.value=i,n}});function Vi(e,t){return e.value=t.issues.length?void 0:t.value,e}const Hi=w(`$ZodOptional`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,C(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),C(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${$e(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Vi(e,t)):Vi(e,r)}return t.innerType._zod.run(e,n)}}),Ui=w(`$ZodExactOptional`,(e,t)=>{Hi.init(e,t),C(e,`values`,e=>e.def.innerType._zod.values),C(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Wi=w(`$ZodNullable`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin),C(e,`optout`,e=>e.def.innerType._zod.optout),C(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${$e(t.source)}|null)$`):void 0}),C(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Gi=w(`$ZodDefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ki(e,t)):Ki(r,t)}});function Ki(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const qi=w(`$ZodPrefault`,(e,t)=>{E.init(e,t),e._zod.optin=`defaulted`,C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ji=w(`$ZodNonOptional`,(e,t)=>{E.init(e,t),C(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Yi(t,e)):Yi(i,e)}});function Yi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Xi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>It(e,r,sn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Zi=w(`$ZodCatch`,(e,t)=>{E.init(e,t),C(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),C(e,`optout`,e=>e.def.innerType._zod.optout),C(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Xi(e,r,t,n)):Xi(e,r,t,n)}}),Qi=w(`$ZodPipe`,(e,t)=>{E.init(e,t),C(e,`values`,e=>e.def.in._zod.values),C(e,`optin`,e=>e.def.in._zod.optin),C(e,`optout`,e=>e.def.out._zod.optout),C(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>$i(e,t.in,n)):$i(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>$i(e,t.out,n)):$i(r,t.out,n)}});function $i(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ea=w(`$ZodReadonly`,(e,t)=>{E.init(e,t),C(e,`propValues`,e=>e.def.innerType._zod.propValues),C(e,`values`,e=>e.def.innerType._zod.values),C(e,`optin`,e=>e.def.innerType?._zod?.optin),C(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ta):ta(r)}});function ta(e){return e.memo||(e.value=Object.freeze(e.value)),e}const na=w(`$ZodCustom`,(e,t)=>{T.init(e,t),E.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ra(t,n,r,e));ra(i,n,r,e)}});function ra(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Vt(e))}}var ia=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const aa=`~memo`,oa=[];function sa(e){return typeof e==`object`&&!!e}function ca(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const la=new WeakMap;function ua(e,t,n){let r=la.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=ua(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?ua(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=nt(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ua(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),da(e,i)}function da(e,t){return t!==1&&la.set(e,t===2),t}function fa(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let pa;const ma=[],ha={alloc(e,t,n){let r=pa;if(!r)return n;pa=void 0;let i={value:n,issues:null};return r.set(t.value,i),ma.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&_a(n,e.value))throw new ia;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ua(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!sa(l))return t(s,c);let u=c[aa];u||(u={buckets:new WeakMap,backEdges:void 0},c[aa]=u);let d;i===c?d=a:(d=fa(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ca(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;pa=d;let p=ma.length,m=t(s,c);pa=void 0;let h=ma.length>p?ma.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ca(e.issues):oa),e)):(h&&(h.issues=m.issues.length?ca(m.issues):oa),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function ga(){return ha}function _a(e,t){let n=e[aa]?.backEdges;return n!==void 0&&sa(t)&&n.has(t)}const va=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Bt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${vt(e.values[0])}`:`Invalid option: expected one of ${Je(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Je(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ya(){return{localeError:va()}}var ba,xa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Sa(){return new xa}(ba=globalThis).__zod_globalRegistry??(ba.__zod_globalRegistry=Sa());const Ca=globalThis.__zod_globalRegistry;function wa(e){return e.checks&&=[...e.checks],e}function Ta(e,t){return new e(wa({type:`string`,...S(t)}))}function Ea(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...S(t)})}function Da(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...S(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...S(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...S(t)})}function Aa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...S(t)})}function ja(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...S(t)})}function Ma(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...S(t)})}function Na(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...S(t)})}function Pa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...S(t)})}function Fa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...S(t)})}function Ia(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...S(t)})}function La(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...S(t)})}function Ra(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...S(t)})}function za(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...S(t)})}function Ba(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...S(t)})}function Va(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...S(t)})}function Ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...S(t)})}function Ua(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...S(t)})}function Wa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...S(t)})}function Ga(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...S(t)})}function Ka(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...S(t)})}function qa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...S(t)})}function Ja(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...S(t)})}function Ya(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...S(t)})}function Xa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...S(t)})}function Za(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...S(t)})}function Qa(e,t){return new e(wa({type:`number`,checks:[],...S(t)}))}function $a(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...S(t)})}function eo(e,t){return new e({type:`boolean`,...S(t)})}function to(e){return new e({type:`unknown`})}function no(e,t){return new e({type:`never`,...S(t)})}function ro(e,t){return new gr({check:`less_than`,...S(t),value:e,inclusive:!1})}function io(e,t){return new gr({check:`less_than`,...S(t),value:e,inclusive:!0})}function ao(e,t){return new _r({check:`greater_than`,...S(t),value:e,inclusive:!1})}function oo(e,t){return new _r({check:`greater_than`,...S(t),value:e,inclusive:!0})}function so(e,t){return new vr({check:`multiple_of`,...S(t),value:e})}function co(e,t){return new br({check:`max_length`,...S(t),maximum:e})}function lo(e,t){return new xr({check:`min_length`,...S(t),minimum:e})}function uo(e,t){return new Sr({check:`length_equals`,...S(t),length:e})}function fo(e,t){return new wr({check:`string_format`,format:`regex`,...S(t),pattern:e})}function po(e){return new Tr({check:`string_format`,format:`lowercase`,...S(e)})}function mo(e){return new Er({check:`string_format`,format:`uppercase`,...S(e)})}function ho(e,t){return new Dr({check:`string_format`,format:`includes`,...S(t),includes:e})}function go(e,t){return new Or({check:`string_format`,format:`starts_with`,...S(t),prefix:e})}function _o(e,t){return new kr({check:`string_format`,format:`ends_with`,...S(t),suffix:e})}function vo(e){return new Ar({check:`overwrite`,tx:e})}function yo(e){return vo(t=>t.normalize(e))}function bo(){return vo(e=>e.trim())}function xo(){return vo(e=>e.toLowerCase())}function So(){return vo(e=>e.toUpperCase())}function Co(){return vo(e=>lt(e))}function wo(e,t,n){return new e({type:`array`,element:t,...S(n)})}function To(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...S(n)})}function Eo(e,t){let n=Do(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Vt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Vt(r))}},e(t.value,t)),t);return n}function Do(e,t){let n=new T({check:`custom`,...S(t)});return n._zod.check=e,n}function Oo(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&tt(e,t,n[t]);return e}function ko(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ca,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Ao(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function O(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,O(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Oo(o.schema,c),t.io===`input`&&k(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function jo(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Mo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${jo(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+jo(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
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 qa(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;qa(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 Ja=new Set([`type`,`properties`,`required`,`additionalProperties`]),Ya=[`oneOf`,`anyOf`];function Xa(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Za(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ja.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]??Xa(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}be(n,r,e.length===1?e[0]:Za(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=Xa(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 Qa(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ja)if(t in e)return;let n=t.filter(e=>Ya.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Za(t);else{let e=n[0],i=Ya.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=>Za([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ha(e,r))}function $a(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)):Ha(i,s),Ha(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())qa(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)??[])Qa(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)}Ha(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,be(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:to(t,`input`,e.processors),output:to(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function P(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 P(r.element,n);if(r.type===`set`)return P(r.valueType,n);if(r.type===`lazy`)return P(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 P(r.innerType,n);if(r.type===`intersection`)return P(r.left,n)||P(r.right,n);if(r.type===`record`||r.type===`map`)return P(r.keyType,n)||P(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:P(r.in,n)||P(r.out,n);if(r.type===`object`){for(let e in r.shape)if(P(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(P(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(P(e,n))return!0;return!!(r.rest&&P(r.rest,n))}return!1}const eo=(e,t={})=>n=>{let r=Ua({...n,processors:t});return N(e,r),Ka(r,e),$a(r,e)},to=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ua({...i??{},target:a,io:t,processors:n});return N(e,o),Ka(o,e),$a(o,e)},no=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},ro=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},io=(e,t)=>{no(e,`minimum`,t),ro(e,`maximum`,t)},ao=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},oo=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},so=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},co=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},lo=(e,t)=>no(e,`minimum`,t.minimum),uo=(e,t)=>ro(e,`maximum`,t.maximum),fo=e=>(t,n)=>{co(t,n.format);let[r,i]=e[n.format];no(t,`minimum`,r),ro(t,`maximum`,i)},po={greater_than:(e,t)=>no(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>ro(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>ao(e,t.value),number_format:fo(Le),bigint_format:fo(Re),min_length:lo,max_length:uo,length_equals:(e,t)=>io(e,t.length),min_size:lo,max_size:uo,size_equals:(e,t)=>io(e,t.size),string_format:(e,t)=>{co(e,t.format),t.pattern&&oo(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)=>so(e,t.mime)};function F(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)po[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&no(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&no(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&ro(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&ro(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&ao(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&so(t,i.mime);for(let e of i.patterns??[])oo(t,e);return t}const mo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ho=new Map([[Or,mn],[Ar,hn]]),go=e=>ho.get(e)??e,_o=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=F(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=mo[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(go);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}))])}},vo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=F(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)):Wa(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}))])}},yo=(e,t,n,r)=>{n.type=`boolean`},bo=(e,t,n,r)=>{n.not={}},xo=(e,t,n,r)=>{let i=e._zod.def,a=pe(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},So=(e,t,n,r)=>{Wa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{Wa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},wo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=F(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=N(a.element,t,{...r,path:[...r.path,`items`]})};function To(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?To(t.out):t.type===`catch`?To(t.innerType):e._zod.optin}const Eo=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Wa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)be(i.properties,e,N(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`?To(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=N(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Do=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>N(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Oo=(e,t,n,r)=>{let i=e._zod.def,a=N(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=N(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)},ko=(e,t,n,r)=>{let i=e._zod.def,a=N(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`}]},Ao=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jo=Symbol();function Mo(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Wa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),jo):JSON.parse(o)}const No=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Mo(i.defaultValue,e,t,n,r);o!==jo&&(n.default=o)},Po=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Mo(i.defaultValue,e,t,n,r);o!==jo&&(n._prefault=o)},Fo=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Wa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Io=(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;N(o,t,r);let s=t.seen.get(e);s.ref=o},Lo=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ro=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zo=new WeakSet([Object.prototype,Error.prototype]);function Bo(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 I=O(`ZodError`,(e,t)=>{Ot.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);zo.has(n)||(zo.add(n),Bo(n,`format`,e=>t=>jt(e,t)),Bo(n,`flatten`,e=>t=>At(e,t)),Bo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,he,2)}),Bo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,he,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Vo=Nt(I),Ho=Pt(I),Uo=Ft(I),Wo=Lt(I),Go=Ut(I),Ko=Wt(I),qo=Gt(I),Jo=Kt(I),Yo=qt(I),Xo=Jt(I),Zo=Yt(I),Qo=Xt(I);function $o(){k.localeError||xt(Pi())}function es(){k.memoizer||xt({memoizer:ji()})}const L=O(`ZodType`,(e,t)=>($o(),j.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 w(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fc(e,t))},superRefine(e,t){return this.check(pc(e,t))},overwrite(e){return this.check(Ma(e))},optional(){return Js(this)},exactOptional(){return Xs(this)},nullable(){return Qs(this)},nullish(){return Js(Qs(this))},nonoptional(e){return ic(this,e)},array(){return Is(this)},or(e){return Bs([this,e])},and(e){return Hs(this,e)},transform(e){return cc(this,Ks(e))},default(e){return ec(this,e)},prefault(e){return nc(this,e)},catch(e){return oc(this,e)},pipe(e){return cc(this,e)},readonly(){return uc(this)},describe(e){let t=this.clone();return Ri.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ri.get(this);let t=this.clone();return Ri.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 ot(this,`~standard`,{...Xn(this),jsonSchema:{input:to(this,`input`),output:to(this,`output`)}})},set"~standard"(e){at(this,`~standard`,e)},parse:function e(t,n){return Vo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ho(this,t,n,{callee:e})},safeParse(e,t){return Uo(this,e,t)},async safeParseAsync(e,t){return Wo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){at(this,`spa`,e)},validate(e,t){return Bt(this,e,t)},validateAsync(e,t){return Ht(this,e,t)},encode:function e(t,n){return Go(this,t,n,{callee:e})},decode:function e(t,n){return Ko(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await qo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Jo(this,t,n,{callee:e})},safeEncode(e,t){return Yo(this,e,t)},safeDecode(e,t){return Xo(this,e,t)},async safeEncodeAsync(e,t){return Zo(this,e,t)},async safeDecodeAsync(e,t){return Qo(this,e,t)},toJSONSchema(e){return eo(this,{})(e)},get description(){return Ri.get(this)?.description},get _def(){return this._zod.def}}),ts=O(`_ZodString`,(e,t)=>{Zn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)},st({format:e=>F(e).format??null,minLength:e=>F(e).minimum??null,maxLength:e=>F(e).maximum??null},{regex(...e){return this.check(Ea(...e))},includes(...e){return this.check(ka(...e))},startsWith(...e){return this.check(Aa(...e))},endsWith(...e){return this.check(ja(...e))},min(...e){return this.check(wa(...e))},max(...e){return this.check(Ca(...e))},length(...e){return this.check(Ta(...e))},nonempty(...e){return this.check(wa(1,...e))},lowercase(e){return this.check(Da(e))},uppercase(e){return this.check(Oa(e))},trim(){return this.check(Pa())},normalize(...e){return this.check(Na(...e))},toLowerCase(){return this.check(Fa())},toUpperCase(){return this.check(Ia())},slugify(){return this.check(La())}})),ns=O(`ZodString`,(e,t)=>{Zn.init(e,t),ts.init(e,t)},{email(e){return this.check(Vi(ss,e))},url(e){return this.check(qi(us,e))},jwt(e){return this.check(ca(Ts,e))},emoji(e){return this.check(Ji(ds,e))},guid(e){return this.check(Hi(cs,e))},uuid(e){return this.check(Ui(ls,e))},uuidv4(e){return this.check(Wi(ls,e))},uuidv6(e){return this.check(Gi(ls,e))},uuidv7(e){return this.check(Ki(ls,e))},nanoid(e){return this.check(Yi(fs,e))},cuid(e){return this.check(Xi(ps,e))},cuid2(e){return this.check(Zi(ms,e))},ulid(e){return this.check(Qi(hs,e))},base64(e){return this.check(aa(Ss,e))},base64url(e){return this.check(oa(Cs,e))},xid(e){return this.check($i(gs,e))},ksuid(e){return this.check(ea(_s,e))},ipv4(e){return this.check(ta(vs,e))},ipv6(e){return this.check(na(ys,e))},cidrv4(e){return this.check(ra(bs,e))},cidrv6(e){return this.check(ia(xs,e))},e164(e){return this.check(sa(ws,e))},datetime(e){return this.check(la(rs,e))},date(e){return this.check(ua(is,e))},time(e){return this.check(da(as,e))},duration(e){return this.check(fa(os,e))}});function R(e){return Bi(ns,e)}const z=O(`ZodStringFormat`,(e,t)=>{M.init(e,t),ts.init(e,t)}),rs=O(`ZodISODateTime`,(e,t)=>{gr.init(e,t),z.init(e,t)}),is=O(`ZodISODate`,(e,t)=>{_r.init(e,t),z.init(e,t)}),as=O(`ZodISOTime`,(e,t)=>{vr.init(e,t),z.init(e,t)}),os=O(`ZodISODuration`,(e,t)=>{yr.init(e,t),z.init(e,t)}),ss=O(`ZodEmail`,(e,t)=>{er.init(e,t),z.init(e,t)}),cs=O(`ZodGUID`,(e,t)=>{Qn.init(e,t),z.init(e,t)}),ls=O(`ZodUUID`,(e,t)=>{$n.init(e,t),z.init(e,t)}),us=O(`ZodURL`,(e,t)=>{cr.init(e,t),z.init(e,t)}),ds=O(`ZodEmoji`,(e,t)=>{lr.init(e,t),z.init(e,t)}),fs=O(`ZodNanoID`,(e,t)=>{ur.init(e,t),z.init(e,t)}),ps=O(`ZodCUID`,(e,t)=>{dr.init(e,t),z.init(e,t)}),ms=O(`ZodCUID2`,(e,t)=>{fr.init(e,t),z.init(e,t)}),hs=O(`ZodULID`,(e,t)=>{pr.init(e,t),z.init(e,t)}),gs=O(`ZodXID`,(e,t)=>{mr.init(e,t),z.init(e,t)}),_s=O(`ZodKSUID`,(e,t)=>{hr.init(e,t),z.init(e,t)}),vs=O(`ZodIPv4`,(e,t)=>{br.init(e,t),z.init(e,t)}),ys=O(`ZodIPv6`,(e,t)=>{Cr.init(e,t),z.init(e,t)}),bs=O(`ZodCIDRv4`,(e,t)=>{wr.init(e,t),z.init(e,t)}),xs=O(`ZodCIDRv6`,(e,t)=>{Er.init(e,t),z.init(e,t)}),Ss=O(`ZodBase64`,(e,t)=>{kr.init(e,t),z.init(e,t)}),Cs=O(`ZodBase64URL`,(e,t)=>{Mr.init(e,t),z.init(e,t)}),ws=O(`ZodE164`,(e,t)=>{Nr.init(e,t),z.init(e,t)}),Ts=O(`ZodJWT`,(e,t)=>{Fr.init(e,t),z.init(e,t)}),Es=O(`ZodNumber`,(e,t)=>{Ir.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.isFinite=!0},st({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=F(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=F(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=F(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>F(e).format??null},{gt(e,t){return this.check(ba(e,t))},gte(e,t){return this.check(xa(e,t))},min(e,t){return this.check(xa(e,t))},lt(e,t){return this.check(va(e,t))},lte(e,t){return this.check(ya(e,t))},max(e,t){return this.check(ya(e,t))},int(e){return this.check(ks(e))},safe(e){return this.check(ks(e))},positive(e){return this.check(ba(0,e))},nonnegative(e){return this.check(xa(0,e))},negative(e){return this.check(va(0,e))},nonpositive(e){return this.check(ya(0,e))},multipleOf(e,t){return this.check(Sa(e,t))},step(e,t){return this.check(Sa(e,t))},finite(){return this}}));function Ds(e){return pa(Es,e)}const Os=O(`ZodNumberFormat`,(e,t)=>{Lr.init(e,t),Es.init(e,t)});function ks(e){return ma(Os,e)}const As=O(`ZodBoolean`,(e,t)=>{Rr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function B(e){return ha(As,e)}const js=O(`ZodUnknown`,(e,t)=>{zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ms(){return ga(js)}const Ns=O(`ZodNever`,(e,t)=>{Br.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r)});function Ps(e){return _a(Ns,e)}const Fs=O(`ZodArray`,(e,t)=>{es(),Hr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.element=t.element},{min(e,t){return this.check(wa(e,t))},nonempty(e){return this.check(wa(1,e))},max(e,t){return this.check(Ca(e,t))},length(e,t){return this.check(Ta(e,t))},unwrap(){return this.element}});function Is(e,t){return Ra(Fs,e,t)}const Ls=O(`ZodObject`,(e,t)=>{es(),Jr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),pt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ws(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:Ms()}))},loose(){return this.clone(C(this._zod.def,{catchall:Ms()}))},strict(){return this.clone(C(this._zod.def,{catchall:Ps()}))},strip(){return this.clone(C(this._zod.def,{catchall:void 0}))},extend(e){return He(this,e)},safeExtend(e){return We(this,e)},merge(e){return Ge(this,e)},pick(e){return ze(this,e)},omit(e){return Ve(this,e)},partial(...e){return Ke(qs,this,e[0])},exactPartial(...e){return Ke(Ys,this,e[0],`exactPartial`)},required(...e){return qe(rc,this,e[0])}});function Rs(e,t){return new Ls({type:`object`,shape:e??{},...T(t)})}const zs=O(`ZodUnion`,(e,t)=>{Xr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.options=t.options});function Bs(e,t){return new zs({type:`union`,options:e,...T(t)})}const Vs=O(`ZodIntersection`,(e,t)=>{Zr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r)});function Hs(e,t){return new Vs({type:`intersection`,left:e,right:t})}const Us=O(`ZodEnum`,(e,t)=>{ei.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(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 Us({...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 Us({...t,checks:[],...T(r),entries:i})}});function Ws(e,t){return new Us({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...T(t)})}const Gs=O(`ZodTransform`,(e,t)=>{es(),ti.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(rt(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(rt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ks(e){return new Gs({type:`transform`,transform:e})}const qs=O(`ZodOptional`,(e,t)=>{ri.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Js(e){return new qs({type:`optional`,innerType:e})}const Ys=O(`ZodExactOptional`,(e,t)=>{ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xs(e){return new Ys({type:`optional`,innerType:e})}const Zs=O(`ZodNullable`,(e,t)=>{ai.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e){return new Zs({type:`nullable`,innerType:e})}const $s=O(`ZodDefault`,(e,t)=>{oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ec(e,t){return new $s({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Me(t)}})}const tc=O(`ZodPrefault`,(e,t)=>{ci.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nc(e,t){return new tc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Me(t)}})}const rc=O(`ZodNonOptional`,(e,t)=>{li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ic(e,t){return new rc({type:`nonoptional`,innerType:e,...T(t)})}const ac=O(`ZodCatch`,(e,t)=>{fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oc(e,t){return new ac({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:mt(t)})}const sc=O(`ZodPipe`,(e,t)=>{pi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.in=t.in,e.out=t.out});function cc(e,t){return new sc({type:`pipe`,in:e,out:t})}const lc=O(`ZodReadonly`,(e,t)=>{hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uc(e){return new lc({type:`readonly`,innerType:e})}const dc=O(`ZodCustom`,(e,t)=>{_i.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r)});function fc(e,t={}){return za(dc,e,t)}function pc(e,t){return Ba(e,t)}var V=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}},mc=class extends V{constructor(){super(`You are not signed in.`,{suggestion:"Run `skilless init` to sign in, or set SKILLESS_TOKEN."})}},hc=class extends V{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>.`})}};let gc=()=>{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:()=>Ge});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)?ee(e,t):m(e)?ne(e,t):te(e,t),ee=(e,t)=>{let n={};for(let t of e){if(t.length!==1)throw Error(`Invalid character: "${t}"`);let e=t.charCodeAt(0);n[e]=!0}return e=>{let r=e.index,i=e.input;for(;e.index<i.length&&i.charCodeAt(e.index)in n;)e.index+=1;let a=e.index;if(a>r){if(!h(t)&&!e.options.silent){let n=e.input.slice(r,a),o=l(t)?t(n,i,String(r)):t;h(o)||e.output.push(o)}e.indexMax=Math.max(e.indexMax,e.index)}return!0}},te=(e,t)=>{let n=e.source,r=e.flags.replace(/y|$/,`y`),i=new RegExp(n,r);return 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},re=(e,t,n,r)=>{let i=ue(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})))},ie=(e,t)=>re(e,0,1),ae=(e,t)=>re(e,0,1/0),oe=(e,t)=>{let n=e.map(ue);return le(ce(se(e=>{for(let t=0,r=n.length;t<r;t++)if(!n[t](e))return!1;return!0})))},y=(e,t)=>{let n=e.map(ue);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=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}},ce=(e,t)=>ue(e),le=(()=>{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}}}})(),b=e=>{let t;return n=>(t||=ue(e()),t(n))},ue=g(e=>{if(l(e))return u(e)?b(e):e;if(m(e)||p(e))return v(e);if(c(e))return oe(e);if(f(e))return y(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},he=(e,t,n)=>me(e,t).map(e=>String(e).padStart(n,`0`)),ge=(e,t)=>me(pe(e),pe(t)).map(fe),x=e=>e,_e=e=>ve(t=>_(t,e,{memoization:!1}).join(``)),ve=e=>{let t={};return n=>t[n]??(t[n]=e(n))},ye=v(/^\*\*\/\*$/,`.*`),be=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/,(e,t,n)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}`),xe=v(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/,(e,t,n,r)=>`.*${t?``:`(?:^|/)`}${n.replaceAll(`.`,`\\.`)}(?:${r.replaceAll(`,`,`|`).replaceAll(`.`,`\\.`)})`),S=v(/\\./,x),Se=v(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ce=v(/./,x),we=y([v(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${Be(t)}$).*?`),v(/^(!!)+/,``)]),Te=y([v(/\/(\*\*\/)+/,`(?:/.+/|/)`),v(/^(\*\*\/)+/,`(?:^|.*/)`),v(/\/(\*\*)$/,`(?:/.*|$)`),v(/\*\*/,`.*`)]),C=y([v(/\*\/(?!\*\*\/)/,`[^/]*/`),v(/\*/,`[^/]*`)]),Ee=v(`?`,`[^/]`),De=v(`[`,x),Oe=v(`]`,x),ke=v(/[!^]/,`^/`),Ae=v(/[a-z]-[a-z]|[0-9]-[0-9]/i,x),je=y([S,v(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ae,v(/[^\]]/,x)]),Me=oe([De,ie(ke),ae(je),Oe]),Ne=v(`{`,`(?:`),Pe=v(`}`,`)`),w=oe([Ne,y([v(/(\d+)\.\.(\d+)/,(e,t,n)=>he(+t,+n,Math.min(t.length,n.length)).join(`|`)),v(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ge(t,n).join(`|`)),v(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ge(t.toLowerCase(),n.toLowerCase()).join(`|`).toUpperCase())]),Pe]),T=v(`{`,`(?:`),Fe=v(`}`,`)`),Ie=v(`,`,`|`),Le=v(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),Re=v(/[^}]/,x),ze=oe([T,ae(y([Te,C,Ee,Me,w,b(()=>ze),S,Le,Ie,Re])),Fe]),Be=_e(ae(y([ye,be,xe,we,Te,C,Ee,Me,w,ze,S,Se,Ce]))),Ve=v(/\\./,x),He=v(/./,x),Ue=_e(ae(y([Ve,v(/\*\*\*+/,`*`),v(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),v(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),He]))),We=(e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return!1;let r=n.map(We.compile),i=n.every(e=>/(\/(?:\*\*)?|\[\/\])$/.test(e)),a=t.replace(/[\\\/]+/g,`/`).replace(/\/$/,i?`/`:``);return r.some(e=>e.test(a))};We.compile=e=>RegExp(`^${Be(Ue(e))}$`,`s`);var Ge=We;return o(s)})();return e.default||e},_c;const vc=(e,t)=>(_c||(_c=gc(),gc=null),_c(e,t)),yc=/^[A-Za-z]:\//;function bc(e=``){return e&&e.replace(/\\/g,`/`).replace(yc,e=>e.toUpperCase())}const xc=/^[/\\]{2}/,Sc=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Cc=/^[A-Za-z]:$/,wc=/^\/([A-Za-z]:)?$/,Tc=/.(\.[^./]+|\.)$/,Ec=/^[/\\]|^[a-zA-Z]:[/\\]/,Dc=function(e){if(e.length===0)return`.`;e=bc(e);let t=e.match(xc),n=Mc(e),r=e[e.length-1]===`/`;return e=jc(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Cc.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!Mc(e)?`/${e}`:e)},Oc=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 Dc(t)};function kc(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Ac=function(...e){e=e.map(e=>bc(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:kc();!i||i.length===0||(t=`${i}/${t}`,n=Mc(i))}return t=jc(t,!n),n&&!Mc(t)?`/${t}`:t.length>0?t:`.`};function jc(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 Mc=function(e){return Sc.test(e)},Nc=function(e){return bc(e)},Pc=function(e){if(e===`..`)return``;let t=Tc.exec(bc(e));return t&&t[1]||``},Fc=function(e,t){let n=Ac(e).replace(wc,`$1`).split(`/`),r=Ac(t).replace(wc,`$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(`/`)},Ic=function(e){let t=bc(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Cc.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(Mc(e)?`/`:`.`)},Lc=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 bc(e.root?Ac(...n):n.join(`/`))},Rc=function(e,t){let n=bc(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},zc={__proto__:null,basename:Rc,dirname:Ic,extname:Pc,format:Lc,isAbsolute:Mc,join:Oc,matchesGlob:(e,t)=>vc(t,Dc(e)),normalize:Dc,normalizeString:jc,parse:function(e){let t=Ec.exec(e)?.[0]?.replace(/\\/g,`/`)||``,n=Rc(e),r=Pc(n);return{root:t,dir:Ic(e),base:n,ext:r,name:n.slice(0,n.length-r.length)}},relative:Fc,resolve:Ac,sep:`/`,toNamespacedPath:Nc},Bc=globalThis.process?.platform===`win32`?`;`:`:`,Vc={posix:void 0,win32:void 0},Hc=(e=Bc)=>new Proxy(zc,{get(t,n){return n===`delimiter`?e:n===`posix`?H:n===`win32`?Uc:Vc[n]||zc[n]}}),H=Hc(`:`),Uc=Hc(`;`);function U(e){try{return r.lstatSync(e),!0}catch{return!1}}function Wc(e){try{return r.lstatSync(e).isSymbolicLink()}catch{return!1}}function Gc(e){return Wc(e)?!r.existsSync(e):!1}function Kc(e){r.mkdirSync(e,{recursive:!0})}function W(e){U(e)&&r.rmSync(e,{recursive:!0,force:!0})}function qc(e,t){let n=[],i=(e,a)=>{let o=r.readdirSync(e,{withFileTypes:!0});for(let r of o){if(t(r.name))continue;let o=a?H.join(a,r.name):r.name,s=H.join(e,r.name);r.isDirectory()?i(s,o):r.isFile()&&n.push(o)}};return i(e,``),n.sort()}function Jc(e,t){Kc(H.dirname(e)),r.writeFileSync(e,t,`utf8`)}function Yc(e,t){try{return JSON.parse(r.readFileSync(e,`utf8`))}catch{return t}}function Xc(e,t,n){Kc(H.dirname(e)),r.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function Zc(e,t){Kc(t),r.cpSync(e,t,{recursive:!0,dereference:!0})}const Qc=process.env.SKILLESS_HOME?H.resolve(process.env.SKILLESS_HOME):H.join(i.homedir(),`.skilless`),$c=H.join(Qc,`skills`),el=H.join(Qc,`auth.json`),tl=H.join(Qc,`state.json`),nl=H.join(Qc,`conflicts`);function G(e){return H.join($c,e)}const rl=`.agents/skills`,il=`.claude/skills`,al=`.agents/skills/.skilless.json`;function ol(e,n){try{return t(`git`,e,{cwd:n,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function sl(e){let t=ol([`rev-parse`,`--show-toplevel`],e);return t?H.normalize(t):null}function cl(e){return ol([`remote`,`get-url`,`origin`],e)}function ll(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 ul(e){let t=cl(e);return t?ll(t):null}function dl(e){let t=ol([`rev-parse`,`--git-common-dir`],e);return t?H.isAbsolute(t)?H.normalize(t):H.resolve(e,t):null}function fl(e){let t=dl(e);return t?H.join(t,`info`,`exclude`):null}function pl(e,t){return ol([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function ml(e,t){let n=fl(e);if(!n)return!1;let i=U(n)?r.readFileSync(n,`utf8`):``,a=new Set(i.split(`
|
|
75
|
-
`).map(e=>e.trim()).filter(Boolean)),o=t.filter(e=>!
|
|
74
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function No(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;No(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Po=new Set([`type`,`properties`,`required`,`additionalProperties`]),Fo=[`oneOf`,`anyOf`];function Io(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Lo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Po.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Io(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}tt(n,r,e.length===1?e[0]:Lo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Io(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Ro(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Po)if(t in e)return;let n=t.filter(e=>Fo.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Lo(t);else{let e=n[0],i=Fo.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Lo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Oo(e,r))}function zo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Oo(i,s),Oo(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())No(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Ro(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Oo(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,tt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Vo(t,`input`,e.processors),output:Vo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function k(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return k(r.element,n);if(r.type===`set`)return k(r.valueType,n);if(r.type===`lazy`)return k(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`||r.type===`catch`)return k(r.innerType,n);if(r.type===`intersection`)return k(r.left,n)||k(r.right,n);if(r.type===`record`||r.type===`map`)return k(r.keyType,n)||k(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:k(r.in,n)||k(r.out,n);if(r.type===`object`){for(let e in r.shape)if(k(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(k(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(k(e,n))return!0;return!!(r.rest&&k(r.rest,n))}return!1}const Bo=(e,t={})=>n=>{let r=ko({...n,processors:t});return O(e,r),Mo(r,e),zo(r,e)},Vo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ko({...i??{},target:a,io:t,processors:n});return O(e,o),Mo(o,e),zo(o,e)},Ho=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Uo=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Wo=(e,t)=>{Ho(e,`minimum`,t),Uo(e,`maximum`,t)},Go=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ko=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},qo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Jo=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Yo=(e,t)=>Ho(e,`minimum`,t.minimum),Xo=(e,t)=>Uo(e,`maximum`,t.maximum),Zo=e=>(t,n)=>{Jo(t,n.format);let[r,i]=e[n.format];Ho(t,`minimum`,r),Uo(t,`maximum`,i)},Qo={greater_than:(e,t)=>Ho(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Uo(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Go(e,t.value),number_format:Zo(bt),bigint_format:Zo(xt),min_length:Yo,max_length:Xo,length_equals:(e,t)=>Wo(e,t.length),min_size:Yo,max_size:Xo,size_equals:(e,t)=>Wo(e,t.size),string_format:(e,t)=>{Jo(e,t.format),t.pattern&&Ko(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>qo(e,t.mime)};function $o(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Qo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ho(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ho(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Uo(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Uo(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Go(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&qo(t,i.mime);for(let e of i.patterns??[])Ko(t,e);return t}const es={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ts=new Map([[pi,$n],[hi,er]]),ns=e=>ts.get(e)??e,rs=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=$o(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=es[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ns);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},is=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=$o(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ao(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},as=(e,t,n,r)=>{n.type=`boolean`},os=(e,t,n,r)=>{n.not={}},ss=(e,t,n,r)=>{let i=e._zod.def,a=qe(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},cs=(e,t,n,r)=>{Ao(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{Ao(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=$o(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=O(a.element,t,{...r,path:[...r.path,`items`]})};function ds(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ds(t.out):t.type===`catch`?ds(t.innerType):e._zod.optin}const fs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ao(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;for(let e in i.type=`object`,i.properties={},o)tt(i.properties,e,O(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ds(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=O(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>O(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ms=(e,t,n,r)=>{let i=e._zod.def,a=O(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=O(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},hs=(e,t,n,r)=>{let i=e._zod.def,a=O(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},gs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_s=Symbol();function vs(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ao(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),_s):JSON.parse(o)}const ys=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=vs(i.defaultValue,e,t,n,r);o!==_s&&(n.default=o)},bs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=vs(i.defaultValue,e,t,n,r);o!==_s&&(n._prefault=o)},xs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ao(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Ss=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;O(o,t,r);let s=t.seen.get(e);s.ref=o},Cs=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ws=(e,t,n,r)=>{let i=e._zod.def;O(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ts=new WeakSet([Object.prototype,Error.prototype]);function Es(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Ds=w(`ZodError`,(e,t)=>{mn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Ts.has(n)||(Ts.add(n),Es(n,`format`,e=>t=>_n(e,t)),Es(n,`flatten`,e=>t=>gn(e,t)),Es(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ye,2)}),Es(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ye,2)}),Object.defineProperty(n,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Os=yn(Ds),ks=bn(Ds),As=xn(Ds),js=Cn(Ds),Ms=kn(Ds),Ns=An(Ds),Ps=jn(Ds),Fs=Mn(Ds),Is=Nn(Ds),Ls=Pn(Ds),Rs=Fn(Ds),zs=In(Ds);function Bs(){on.localeError||sn(ya())}function Vs(){on.memoizer||sn({memoizer:ga()})}const A=w(`ZodType`,(e,t)=>(Bs(),E.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(x(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _t(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($c(e,t))},superRefine(e,t){return this.check(el(e,t))},overwrite(e){return this.check(vo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return Cc(this)},or(e){return Dc([this,e])},and(e){return kc(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Zc(this)},describe(e){let t=this.clone();return Ca.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ca.get(this);let t=this.clone();return Ca.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Wt(this,`~standard`,{...Fr(this),jsonSchema:{input:Vo(this,`input`),output:Vo(this,`output`)}})},set"~standard"(e){Ut(this,`~standard`,e)},parse:function e(t,n){return Os(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ks(this,t,n,{callee:e})},safeParse(e,t){return As(this,e,t)},async safeParseAsync(e,t){return js(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ut(this,`spa`,e)},validate(e,t){return En(this,e,t)},validateAsync(e,t){return On(this,e,t)},encode:function e(t,n){return Ms(this,t,n,{callee:e})},decode:function e(t,n){return Ns(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ps(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Fs(this,t,n,{callee:e})},safeEncode(e,t){return Is(this,e,t)},safeDecode(e,t){return Ls(this,e,t)},async safeEncodeAsync(e,t){return Rs(this,e,t)},async safeDecodeAsync(e,t){return zs(this,e,t)},toJSONSchema(e){return Bo(this,{})(e)},get description(){return Ca.get(this)?.description},get _def(){return this._zod.def}}),Hs=w(`_ZodString`,(e,t)=>{Ir.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)},Gt({format:e=>$o(e).format??null,minLength:e=>$o(e).minimum??null,maxLength:e=>$o(e).maximum??null},{regex(...e){return this.check(fo(...e))},includes(...e){return this.check(ho(...e))},startsWith(...e){return this.check(go(...e))},endsWith(...e){return this.check(_o(...e))},min(...e){return this.check(lo(...e))},max(...e){return this.check(co(...e))},length(...e){return this.check(uo(...e))},nonempty(...e){return this.check(lo(1,...e))},lowercase(e){return this.check(po(e))},uppercase(e){return this.check(mo(e))},trim(){return this.check(bo())},normalize(...e){return this.check(yo(...e))},toLowerCase(){return this.check(xo())},toUpperCase(){return this.check(So())},slugify(){return this.check(Co())}})),Us=w(`ZodString`,(e,t)=>{Ir.init(e,t),Hs.init(e,t)},{email(e){return this.check(Ea(Js,e))},url(e){return this.check(Ma(Zs,e))},jwt(e){return this.check(qa(fc,e))},emoji(e){return this.check(Na(Qs,e))},guid(e){return this.check(Da(Ys,e))},uuid(e){return this.check(Oa(Xs,e))},uuidv4(e){return this.check(ka(Xs,e))},uuidv6(e){return this.check(Aa(Xs,e))},uuidv7(e){return this.check(ja(Xs,e))},nanoid(e){return this.check(Pa($s,e))},cuid(e){return this.check(Fa(ec,e))},cuid2(e){return this.check(Ia(tc,e))},ulid(e){return this.check(La(nc,e))},base64(e){return this.check(Wa(lc,e))},base64url(e){return this.check(Ga(uc,e))},xid(e){return this.check(Ra(rc,e))},ksuid(e){return this.check(za(ic,e))},ipv4(e){return this.check(Ba(ac,e))},ipv6(e){return this.check(Va(oc,e))},cidrv4(e){return this.check(Ha(sc,e))},cidrv6(e){return this.check(Ua(cc,e))},e164(e){return this.check(Ka(dc,e))},datetime(e){return this.check(Ja(Ws,e))},date(e){return this.check(Ya(Gs,e))},time(e){return this.check(Xa(Ks,e))},duration(e){return this.check(Za(qs,e))}});function j(e){return Ta(Us,e)}const M=w(`ZodStringFormat`,(e,t)=>{D.init(e,t),Hs.init(e,t)}),Ws=w(`ZodISODateTime`,(e,t)=>{ti.init(e,t),M.init(e,t)}),Gs=w(`ZodISODate`,(e,t)=>{ni.init(e,t),M.init(e,t)}),Ks=w(`ZodISOTime`,(e,t)=>{ri.init(e,t),M.init(e,t)}),qs=w(`ZodISODuration`,(e,t)=>{ii.init(e,t),M.init(e,t)}),Js=w(`ZodEmail`,(e,t)=>{zr.init(e,t),M.init(e,t)}),Ys=w(`ZodGUID`,(e,t)=>{Lr.init(e,t),M.init(e,t)}),Xs=w(`ZodUUID`,(e,t)=>{Rr.init(e,t),M.init(e,t)}),Zs=w(`ZodURL`,(e,t)=>{qr.init(e,t),M.init(e,t)}),Qs=w(`ZodEmoji`,(e,t)=>{Jr.init(e,t),M.init(e,t)}),$s=w(`ZodNanoID`,(e,t)=>{Yr.init(e,t),M.init(e,t)}),ec=w(`ZodCUID`,(e,t)=>{Xr.init(e,t),M.init(e,t)}),tc=w(`ZodCUID2`,(e,t)=>{Zr.init(e,t),M.init(e,t)}),nc=w(`ZodULID`,(e,t)=>{Qr.init(e,t),M.init(e,t)}),rc=w(`ZodXID`,(e,t)=>{$r.init(e,t),M.init(e,t)}),ic=w(`ZodKSUID`,(e,t)=>{ei.init(e,t),M.init(e,t)}),ac=w(`ZodIPv4`,(e,t)=>{ai.init(e,t),M.init(e,t)}),oc=w(`ZodIPv6`,(e,t)=>{ci.init(e,t),M.init(e,t)}),sc=w(`ZodCIDRv4`,(e,t)=>{li.init(e,t),M.init(e,t)}),cc=w(`ZodCIDRv6`,(e,t)=>{di.init(e,t),M.init(e,t)}),lc=w(`ZodBase64`,(e,t)=>{mi.init(e,t),M.init(e,t)}),uc=w(`ZodBase64URL`,(e,t)=>{_i.init(e,t),M.init(e,t)}),dc=w(`ZodE164`,(e,t)=>{vi.init(e,t),M.init(e,t)}),fc=w(`ZodJWT`,(e,t)=>{bi.init(e,t),M.init(e,t)}),pc=w(`ZodNumber`,(e,t)=>{xi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.isFinite=!0},Gt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=$o(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=$o(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=$o(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>$o(e).format??null},{gt(e,t){return this.check(ao(e,t))},gte(e,t){return this.check(oo(e,t))},min(e,t){return this.check(oo(e,t))},lt(e,t){return this.check(ro(e,t))},lte(e,t){return this.check(io(e,t))},max(e,t){return this.check(io(e,t))},int(e){return this.check(gc(e))},safe(e){return this.check(gc(e))},positive(e){return this.check(ao(0,e))},nonnegative(e){return this.check(oo(0,e))},negative(e){return this.check(ro(0,e))},nonpositive(e){return this.check(io(0,e))},multipleOf(e,t){return this.check(so(e,t))},step(e,t){return this.check(so(e,t))},finite(){return this}}));function mc(e){return Qa(pc,e)}const hc=w(`ZodNumberFormat`,(e,t)=>{Si.init(e,t),pc.init(e,t)});function gc(e){return $a(hc,e)}const _c=w(`ZodBoolean`,(e,t)=>{Ci.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function N(e){return eo(_c,e)}const vc=w(`ZodUnknown`,(e,t)=>{wi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function yc(){return to(vc)}const bc=w(`ZodNever`,(e,t)=>{Ti.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function xc(e){return no(bc,e)}const Sc=w(`ZodArray`,(e,t)=>{Vs(),Di.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.element=t.element},{min(e,t){return this.check(lo(e,t))},nonempty(e){return this.check(lo(1,e))},max(e,t){return this.check(co(e,t))},length(e,t){return this.check(uo(e,t))},unwrap(){return this.element}});function Cc(e,t){return wo(Sc,e,t)}const wc=w(`ZodObject`,(e,t)=>{Vs(),Ni.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),Zt(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return jc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(x(this._zod.def,{catchall:e}))},passthrough(){return this.clone(x(this._zod.def,{catchall:yc()}))},loose(){return this.clone(x(this._zod.def,{catchall:yc()}))},strict(){return this.clone(x(this._zod.def,{catchall:xc()}))},strip(){return this.clone(x(this._zod.def,{catchall:void 0}))},extend(e){return Tt(this,e)},safeExtend(e){return Dt(this,e)},merge(e){return Ot(this,e)},pick(e){return St(this,e)},omit(e){return wt(this,e)},partial(...e){return kt(Pc,this,e[0])},exactPartial(...e){return kt(Ic,this,e[0],`exactPartial`)},required(...e){return At(Wc,this,e[0])}});function Tc(e,t){return new wc({type:`object`,shape:e??{},...S(t)})}const Ec=w(`ZodUnion`,(e,t)=>{Fi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.options=t.options});function Dc(e,t){return new Ec({type:`union`,options:e,...S(t)})}const Oc=w(`ZodIntersection`,(e,t)=>{Ii.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function kc(e,t){return new Oc({type:`intersection`,left:e,right:t})}const Ac=w(`ZodEnum`,(e,t)=>{zi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ac({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ac({...t,checks:[],...S(r),entries:i})}});function jc(e,t){return new Ac({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...S(t)})}const Mc=w(`ZodTransform`,(e,t)=>{Vs(),Bi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new an(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Vt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Vt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}const Pc=w(`ZodOptional`,(e,t)=>{Hi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}const Ic=w(`ZodExactOptional`,(e,t)=>{Ui.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}const Rc=w(`ZodNullable`,(e,t)=>{Wi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}const Bc=w(`ZodDefault`,(e,t)=>{Gi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}const Hc=w(`ZodPrefault`,(e,t)=>{qi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}const Wc=w(`ZodNonOptional`,(e,t)=>{Ji.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...S(t)})}const Kc=w(`ZodCatch`,(e,t)=>{Zi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Qt(t)})}const Jc=w(`ZodPipe`,(e,t)=>{Qi.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}const Xc=w(`ZodReadonly`,(e,t)=>{ea.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`readonly`,innerType:e})}const Qc=w(`ZodCustom`,(e,t)=>{na.init(e,t),A.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r)});function $c(e,t={}){return To(Qc,e,t)}function el(e,t){return Eo(e,t)}var P=class extends Error{suggestion;constructor(e,t){super(e,{cause:t?.cause}),this.name=`SkillessError`,this.suggestion=t?.suggestion}toString(){return this.suggestion?`${this.message}\n${this.suggestion}`:this.message}},tl=class extends P{constructor(){super(`You are not signed in.`,{suggestion:"Run `skilless auth` to sign in, or set SKILLESS_TOKEN."})}},nl=class extends P{constructor(){super(`This directory has no git remote, so it has no project key.`,{suggestion:`skilless identifies a project by its git remote. Add one, or pass --project <key>.`})}},rl=class extends P{url;constructor(e,t){super(`Couldn't reach ${e}.`,{suggestion:`Check your connection, or set SKILLESS_API_URL to point elsewhere.`,cause:t}),this.url=e}};function F(e){try{return a.lstatSync(e),!0}catch{return!1}}function il(e){try{return a.lstatSync(e).isSymbolicLink()}catch{return!1}}function al(e){a.mkdirSync(e,{recursive:!0})}function I(e){if(F(e)){if(il(e)){try{a.unlinkSync(e)}catch{a.rmdirSync(e)}return}a.rmSync(e,{recursive:!0,force:!0})}}function ol(e,t){let n=[],r=(e,i)=>{let o=a.readdirSync(e,{withFileTypes:!0});for(let a of o){if(t(a.name))continue;let o=i?b.join(i,a.name):a.name,s=b.join(e,a.name);a.isDirectory()?r(s,o):a.isFile()&&n.push(o)}};return r(e,``),n.sort()}function sl(e,t){al(b.dirname(e)),a.writeFileSync(e,t,`utf8`)}function cl(e,t){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return t}}function ll(e,t,n){al(b.dirname(e)),a.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,{encoding:`utf8`,mode:n})}function ul(e,t){al(t),a.cpSync(e,t,{recursive:!0,dereference:!0})}function dl(e,t){try{return n(`git`,e,{cwd:t,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function fl(e){let t=dl([`rev-parse`,`--show-toplevel`],e);return t?b.normalize(t):null}function pl(e){return dl([`remote`,`get-url`,`origin`],e)}function ml(e){let t=e.trim().replace(/\.git$/i,``);if(!t)return null;let n,r,i=/^(?:[^@/]+@)?([^/:]+):(.+)$/.exec(t);if(i&&!t.includes(`://`))n=i[1]??``,r=i[2]??``;else{t.includes(`://`)||(t=`https://${t}`);let e;try{e=new URL(t)}catch{return null}n=e.hostname,r=e.pathname}return n=n.replace(/:\d+$/,``).toLowerCase(),r=r.replace(/^\/+|\/+$/g,``).toLowerCase(),!n||!r?null:`${n}/${r}`}function hl(e){let t=pl(e);return t?ml(t):null}function gl(e){let t=dl([`rev-parse`,`--git-common-dir`],e);return t?b.isAbsolute(t)?b.normalize(t):b.resolve(e,t):null}function _l(e){let t=gl(e);return t?b.join(t,`info`,`exclude`):null}function vl(e,t){return dl([`ls-files`,`--error-unmatch`,`--`,t],e)!==null}function yl(e,t){let n=_l(e);if(!n)return!1;let r=F(n)?a.readFileSync(n,`utf8`):``,i=new Set(r.split(`
|
|
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
|
-
`,c=
|
|
77
|
+
`,c=r.length>0&&!r.endsWith(`
|
|
78
78
|
`)?`
|
|
79
|
-
`:``;return
|
|
80
|
-
`)}\n`,`utf8`),!0}function
|
|
81
|
-
`).filter(e=>!
|
|
82
|
-
`),`utf8`)}const gl=`SKILL.md`,_l=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),vl=/^[a-z0-9][a-z0-9._-]*$/;function yl(e){return _l.has(e)}function bl(e){return e.length<=64&&vl.test(e)}function xl(e){if(!bl(e))throw new V(`\`${e}\` is not a valid skill name.`,{suggestion:`Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit.`})}function Sl(e){let t=a.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 Cl(e,t){if(!U(H.join(e,gl)))throw new V(`\`${t}\` has no ${gl}.`,{suggestion:`Every skill needs a ${gl} at its root.`});let n=qc(e,yl),i=[],a=0,o=0;for(let s of n){let n=H.join(e,s),c=r.readFileSync(n);if(c.includes(0))throw new V(`\`${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 V(`\`${t}\` is larger than 1MB.`,{suggestion:`Skills are prose — move large assets out of the skill directory.`});i.push({path:s,contents:c.toString(`utf8`)}),a=Math.max(a,r.statSync(n).mtimeMs)}return{name:t,dir:e,files:i,contentHash:Sl(i),editedAt:a}}function wl(e,t,n){let i=G(e);W(i),Kc(i);for(let e of t)Jc(H.join(i,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)r.utimesSync(H.join(i,n.path),e,e)}}function Tl(){return U($c)?r.readdirSync($c,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!yl(e.name)).map(e=>e.name).sort():[]}function El(){return Tl().map(e=>Cl(G(e),e))}function Dl(e){let t=G(e);return U(t)?Cl(t,e):null}function Ol(e,t){return[{path:gl,contents:`---\nname: ${e}\ndescription: ${t}\n---\n\n# ${e}\n\nDescribe what this skill does and when an agent should reach for it.\n`}]}const kl={version:1,mode:`link`,skills:[]};function Al(e){return H.join(e,al)}function jl(e){let t=Yc(Al(e),kl);return{version:1,mode:t.mode??`link`,skills:t.skills??[]}}function Ml(e,t){if(t.skills.length===0){W(Al(e));return}Xc(Al(e),t)}function Nl(e,t){return H.join(e,rl,t)}function Pl(e,t){return H.join(e,il,t)}function Fl(e){return[`/${al}`,...e.flatMap(e=>[`/${rl}/${e}`,`/${il}/${e}`])]}function Il(e,t,n){Kc(H.dirname(t));try{r.symlinkSync(e,t,`dir`)}catch{n()}}function Ll(e,t,n){let r=jl(e),i=new Set(r.skills),a=[],o=[];for(let r of t){let t=`${rl}/${r.name}`,s=`${il}/${r.name}`;if(pl(e,t)||pl(e,s)){o.push({name:r.name,reason:`tracked`});continue}let c=Nl(e,r.name),l=Pl(e,r.name);if(U(c)&&!i.has(r.name)&&!Wc(c)){o.push({name:r.name,reason:`occupied`});continue}if(W(c),W(l),n.copy){Kc(c);for(let e of r.files??[])Jc(H.join(c,e.path),e.contents)}else{let e=G(r.name);Il(e,c,()=>Zc(e,c))}Il(H.relative(H.dirname(l),c),l,()=>Zc(c,l)),i.add(r.name),a.push(r.name)}return Ml(e,{version:1,mode:n.copy?`copy`:`link`,skills:[...i].sort()}),ml(e,Fl([...i])),{written:a,skipped:o}}function Rl(e,t){let n=jl(e),r=new Set(n.skills),i=[];for(let n of t)r.has(n)&&(W(Nl(e,n)),W(Pl(e,n)),r.delete(n),i.push(n));return Ml(e,{version:1,mode:n.mode,skills:[...r].sort()}),hl(e,Fl(i)),i}function zl(e){let t=jl(e).skills.filter(t=>{let n=Nl(e,t);return Gc(n)||!U(n)});return t.length===0?[]:Rl(e,t)}function Bl(e){return sl(e)??e}const Vl={version:1,skills:{}};function Hl(){return{version:1,skills:Yc(tl,Vl).skills??{}}}function Ul(e){Xc(tl,e)}function Wl(e){return e??!U($c)}async function Gl(e,t,n={}){let r=Wl(n.copy),i=[];if(!r){let e=Hl();for(let n of t)Dl(n.name)||(wl(n.name,n.files,n.editedAt),e.skills[n.name]={contentHash:n.contentHash,editedAt:n.editedAt,syncedAt:Date.now()},i.push(n.name));Ul(e)}return{...Ll(e,t,{copy:r}),fetched:i}}var Kl=p(((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})})),ql=p(((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}))
|
|
79
|
+
`:``;return al(b.dirname(n)),a.appendFileSync(n,`${c}${s}${o.join(`
|
|
80
|
+
`)}\n`,`utf8`),!0}function bl(e,t){let n=_l(e);if(!n||!F(n))return;let r=new Set(t),i=a.readFileSync(n,`utf8`).split(`
|
|
81
|
+
`).filter(e=>!r.has(e.trim()));a.writeFileSync(n,i.join(`
|
|
82
|
+
`),`utf8`)}const xl=process.env.SKILLESS_HOME?b.resolve(process.env.SKILLESS_HOME):b.join(s.homedir(),`.skilless`),Sl=b.join(xl,`skills`),Cl=b.join(xl,`auth.json`),wl=b.join(xl,`state.json`),Tl=b.join(xl,`cache.json`),El=b.join(xl,`sources.json`),Dl=b.join(xl,`pending.json`),Ol=b.join(xl,`config.json`),kl=b.join(xl,`conflicts`);function Al(e){return b.join(Sl,e)}const jl=`.agents/skills`,Ml=`.claude/skills`;function Nl(){return process.env.CLAUDE_CONFIG_DIR?b.resolve(process.env.CLAUDE_CONFIG_DIR):b.join(s.homedir(),`.claude`)}function Pl(){return b.join(s.homedir(),jl)}function Fl(){return b.join(Nl(),`skills`)}function Il(){let e=cl(Tl,{});return{version:1,library:e.library?.map(e=>({...e,source:e.source??null}))??null,projects:e.projects??{}}}function Ll(e){let t=Il();t.library=e.map(({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})=>({name:e,contentHash:t,editedAt:n,updatedAt:r,global:i,source:a})),ll(Tl,t)}function Rl(e,t){let n=Il();n.projects[e]=t.filter(e=>!e.global).map(e=>e.name),ll(Tl,n)}const zl=`SKILL.md`,Bl=new Set([`.git`,`node_modules`,`.DS_Store`,`.skilless.json`]),Vl=/^[a-z0-9][a-z0-9._-]*$/;function Hl(e){return Bl.has(e)}function Ul(e){return e.length<=64&&Vl.test(e)}function Wl(e){if(!Ul(e))throw new P(`${e} is not a valid skill name.`,{suggestion:`Use lowercase letters, digits, dots, dashes and underscores, starting with a letter or digit.`})}function Gl(e){let t=c.createHash(`sha256`);for(let n of[...e].sort((e,t)=>e.path.localeCompare(t.path)))t.update(n.path),t.update(`\0`),t.update(n.contents),t.update(`\0`);return t.digest(`hex`)}function Kl(e,t){if(!F(b.join(e,zl)))throw new P(`${t} has no ${zl}.`,{suggestion:`Every skill needs a ${zl} at its root.`});let n=ol(e,Hl),r=[],i=0,o=0;for(let s of n){let n=b.join(e,s),c=a.readFileSync(n);if(c.includes(0))throw new P(`${t}/${s} looks like a binary file.`,{suggestion:`v0 syncs text only. Remove the file or keep it outside the skill.`});if(o+=c.byteLength,o>1048576)throw new P(`${t} is larger than 1MB.`,{suggestion:`Skills are prose. Move large assets out of the skill directory.`});r.push({path:s,contents:c.toString(`utf8`)}),i=Math.max(i,a.statSync(n).mtimeMs)}return{name:t,dir:e,files:r,contentHash:Gl(r),editedAt:i}}function ql(e,t,n){let r=Al(e);I(r),al(r);for(let e of t)sl(b.join(r,e.path),e.contents);if(n!==void 0){let e=new Date(n);for(let n of t)a.utimesSync(b.join(r,n.path),e,e)}}function Jl(){return F(Sl)?a.readdirSync(Sl,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!Hl(e.name)).map(e=>e.name).sort():[]}function Yl(){return Jl().map(e=>Kl(Al(e),e))}function Xl(e){let t=Al(e);return F(t)?Kl(t,e):null}function Zl(e,t){return[{path:zl,contents:`---\nname: ${e}\ndescription: ${t}\n---\n\n# ${e}\n\nDescribe what this skill does and when an agent should reach for it.\n`}]}function Ql(e){return{agents:b.join(e,jl),claude:b.join(e,Ml),repo:e}}function $l(){return{agents:Pl(),claude:Fl(),repo:null}}function eu(e){return typeof e==`string`?Ql(e):e}const tu=`.agents/skills/.skilless.json`;function nu(e){let t;try{t=b.normalize(a.realpathSync(e))}catch{t=b.normalize(e)}return process.platform===`win32`?t.toLowerCase():t}function ru(e,t){try{return nu(b.resolve(b.dirname(e),a.readlinkSync(e)))===nu(t)}catch{return!1}}function iu(e,t){let n=b.join(e.agents,t);return ru(n,Al(t))?!0:ru(b.join(e.claude,t),n)}function au(e){let t=eu(e);return F(t.agents)?a.readdirSync(t.agents).filter(e=>!e.startsWith(`.`)).filter(e=>iu(t,e)).sort():[]}function ou(e){return F(e.claude)&&nu(e.claude)===nu(e.agents)}function su(e,t){let n=b.join(e.agents,t),r=b.join(e.claude,t),i=[];return F(n)&&!iu(e,t)&&i.push(n),!ou(e)&&F(r)&&!ru(r,n)&&i.push(r),i}function cu(e){return e.flatMap(e=>[`/${jl}/${e}`,`/${Ml}/${e}`])}function lu(e,t){process.platform===`win32`?a.symlinkSync(b.resolve(b.dirname(t),e),t,`junction`):a.symlinkSync(e,t,`dir`)}function uu(e,t,n){al(b.dirname(t));try{lu(e,t)}catch{n()}}function du(e,t,n){let r=eu(e),{repo:i}=r;i&&I(b.join(i,tu));let a=[],o=[];for(let e of t){if(i&&(vl(i,`${jl}/${e.name}`)||vl(i,`${Ml}/${e.name}`))){o.push({name:e.name,reason:`tracked`});continue}let t=su(r,e.name);if(t.length>0){o.push({name:e.name,reason:`occupied`,...i?{}:{user:!0},occupied:{paths:t,scope:r,skill:e}});continue}fu(r,e,n),a.push(e.name)}return i&&(bl(i,[`/${tu}`]),yl(i,cu(au(r)))),{written:a,skipped:o}}function fu(e,t,n){let r=b.join(e.agents,t.name),i=b.join(e.claude,t.name),a=!ou(e);if(I(r),a&&I(i),n.copy){al(r);for(let e of t.files??[])sl(b.join(r,e.path),e.contents)}else{let e=Al(t.name);uu(e,r,()=>ul(e,r))}a&&uu(b.relative(b.dirname(i),r),i,()=>ul(r,i))}function pu(e,t){if(!e.occupied)return;let{scope:n,skill:r,paths:i}=e.occupied;for(let e of i)I(e);fu(n,r,t),n.repo&&yl(n.repo,cu([r.name]))}function mu(e,t){let n=eu(e),r=[];for(let e of t){if(!iu(n,e))continue;let t=b.join(n.agents,e),i=b.join(n.claude,e);!ou(n)&&ru(i,t)&&I(i),I(t),r.push(e)}return n.repo&&bl(n.repo,cu(r)),r}function hu(e){let t=eu(e),n=au(t).filter(e=>!a.existsSync(b.join(t.agents,e)));return n.length===0?[]:mu(t,n)}function gu(e){return fl(e)??e}const _u={version:1,skills:{}};function vu(){return{version:1,skills:cl(wl,_u).skills??{}}}function yu(e){ll(wl,e)}function bu(e){return e??!F(Sl)}async function xu(e,t,n={}){let r=bu(n.copy),i=[];if(!r){let e=vu();for(let n of t)Xl(n.name)||(ql(n.name,n.files,n.editedAt),e.skills[n.name]={contentHash:n.contentHash,editedAt:n.editedAt,syncedAt:Date.now()},i.push(n.name));yu(e)}let a=du(e,t,{copy:r}),o=n.reconcile?mu(e,au(e).filter(e=>!t.some(t=>t.name===e))):[];return{...a,fetched:i,removed:o}}async function Su(e,t,n){let r=hu(e),i=new Set(au(e)),a=await xu(e,t,{copy:n.copy,reconcile:!0});return{...a,pruned:r,added:a.written.filter(e=>!i.has(e))}}async function Cu(e,t,n,r={}){let i=await e.getBindings(n);return Rl(n,i),wu(t,i,r)}async function wu(e,t,n={}){let r=await Su(e,t.filter(e=>!e.global),n),i=await Su($l(),t.filter(e=>e.global),n);return{project:r,user:i,skipped:[...r.skipped,...i.skipped],count:t.length}}function Tu(e){let t=$l(),n=hu(t),r=new Set(au(t)),i=du(t,e.filter(e=>F(Al(e))).map(e=>({name:e})),{copy:!1}),a=mu(t,au(t).filter(t=>!e.includes(t)));return{...i,fetched:[],removed:a,pruned:n,added:i.written.filter(e=>!r.has(e))}}function Eu(){let e=cl(Dl,{});return{version:1,projects:e.projects??{},globals:e.globals??{},sources:e.sources??{},deletes:e.deletes??[]}}function Du(e){if(Ou(e)){I(Dl);return}ll(Dl,e)}function Ou(e){return Object.keys(e.projects).length===0&&Object.keys(e.globals).length===0&&Object.keys(e.sources).length===0&&e.deletes.length===0}function ku(e,t){return e.projects[t]??={add:[],remove:[]},e.projects[t]}function Au(e,t){let n=Eu(),r=ku(n,e);r.add=[...new Set([...r.add,...t])],r.remove=r.remove.filter(e=>!t.includes(e)),Du(n)}function ju(e,t){let n=Eu(),r=ku(n,e);r.remove=[...new Set([...r.remove,...t])],r.add=r.add.filter(e=>!t.includes(e)),Du(n)}function Mu(e,t){let n=Eu();for(let r of e)n.globals[r]=t;Du(n)}function Nu(e,t){let n=Eu();n.sources[e]=t,Du(n)}function Pu(e){let t=Eu();t.deletes=[...new Set([...t.deletes,...e])];for(let n of e)delete t.globals[n],delete t.sources[n];for(let n of Object.values(t.projects))n.add=n.add.filter(t=>!e.includes(t));Du(t)}async function Fu(e){let t=Eu();if(Ou(t))return 0;let n=new Set((await e.listSkills()).map(e=>e.name)),r=e=>Jl().includes(e),i=0;for(let r of[...t.deletes])n.has(r)&&(await e.deleteSkill(r),n.delete(r),i++),t.deletes=t.deletes.filter(e=>e!==r),Du(t);for(let[a,o]of Object.entries(t.globals)){if(n.has(a))await e.setGlobal(a,o),i++;else if(r(a))continue;delete t.globals[a],Du(t)}for(let[a,o]of Object.entries(t.sources)){if(n.has(a))await e.setSource(a,o),i++;else if(r(a))continue;delete t.sources[a],Du(t)}for(let[n,a]of Object.entries(t.projects)){let o=(await e.getBindings(n)).filter(e=>!e.global).map(e=>e.name),s=[...new Set([...o,...a.add])].filter(e=>!a.remove.includes(e)),c=await e.setBindings(n,s),l=new Set(c.unknown);i+=a.add.filter(e=>!l.has(e)).length+a.remove.length,a.add=a.add.filter(e=>l.has(e)&&r(e)),a.remove=[],a.add.length===0&&delete t.projects[n],Du(t)}return i}function Iu(){return cl(El,{}).skills??{}}function Lu(e){if(Object.keys(e).length===0){I(El);return}ll(El,{version:1,skills:e})}function Ru(e,t){return e?.url===t?.url&&e?.ref===t?.ref&&e?.path===t?.path&&e?.hash===t?.hash}function zu(e,t){let n=Iu();Ru(n[e],t)||(t?n[e]=t:delete n[e],Lu(n),Nu(e,t))}function Bu(e){let t=Iu();for(let n of e)delete t[n];Lu(t)}function Vu(e){let t=Iu(),n=Eu().sources,r=new Set(e.map(e=>e.name)),i=new Set(Jl());for(let r of e)r.name in n||(r.source?t[r.name]=r.source:delete t[r.name]);for(let e of Object.keys(t))!r.has(e)&&!i.has(e)&&!(e in n)&&delete t[e];Lu(t)}async function L(e){await e.try(e=>Fu(e))}async function R(e){let t=await e.try(e=>e.listSkills());t&&(Ll(t),Vu(t));let n=t??Il().library??[],r=Eu(),i=vu(),a=Iu(),o=new Map(Yl().map(e=>[e.name,e])),s=new Map(n.map(e=>[e.name,e]));return{entries:[...new Set([...o.keys(),...s.keys()])].filter(e=>!r.deletes.includes(e)).sort().map(e=>{let t=o.get(e)??null,n=s.get(e)??null;return{name:e,global:r.globals[e]??n?.global??!1,local:t,remote:n,unsynced:t!==null&&i.skills[e]?.contentHash!==t.contentHash,source:a[e]??null}}),live:t!==void 0}}async function Hu(e,t){let n=await e.try(e=>e.getBindings(t));n&&Rl(t,n);let r=n?n.filter(e=>!e.global).map(e=>e.name):Il().projects[t]??[],i=Eu(),a=i.projects[t]??{add:[],remove:[]};return[...new Set([...r,...a.add])].filter(e=>!a.remove.includes(e)&&!i.deletes.includes(e)).sort()}function Uu(e,t){let n=new Set(t);return e.entries.filter(e=>e.global||n.has(e.name))}async function Wu(e,t,n,r={}){let i=await e.try(e=>e.getBindings(n));if(i)return Rl(n,i),{...await wu(t,i,{copy:r.copy}),missing:[]};let a=Uu(await R(e),await Hu(e,n)),o=a.filter(e=>!e.global),s=a.filter(e=>e.global),c=Eu(),l=new Set(c.deletes),u=e=>Gu(c,e),d=bu(r.copy),f=Ku(t,o,new Set([...c.projects[n]?.remove??[],...l,...u(!0)]),d),p=Ku($l(),s,new Set([...l,...u(!1)]),d);return{project:f,user:p,skipped:[...f.skipped,...p.skipped],missing:a.filter(e=>!e.local).map(e=>e.name)}}function Gu(e,t){return Object.entries(e.globals).filter(([,e])=>e===t).map(([e])=>e)}function Ku(e,t,n,r){let i=new Set(t.map(e=>e.name));hu(e);let a=mu(e,au(e).filter(e=>n.has(e)&&!i.has(e)));return{...du(e,t.flatMap(e=>e.local?[e.local]:[]),{copy:r}),removed:a}}async function qu(e){let t=await R(e),n=t.entries.filter(e=>e.global),r=n.filter(e=>!e.local).map(e=>e.name);if(t.live)return{...Tu(n.map(e=>e.name)),missing:r};let i=Eu(),a=new Set([...i.deletes,...Gu(i,!1)]);return{...Ku($l(),n,a,!1),missing:r}}async function Ju(e,t,n,r=new Map){let i=vu();for(let a of t){zu(a.name,r.get(a.name)??null),ql(a.name,a.files,a.editedAt);let t=await e.try(e=>e.putSkill(a.name,a.files,a.editedAt)),o=n.get(a.name)?.remote;t?i.skills[a.name]={contentHash:a.contentHash,editedAt:a.editedAt,syncedAt:Date.now()}:o?i.skills[a.name]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:Date.now()}:delete i.skills[a.name]}return yu(i),await L(e),t.map(e=>e.name)}var Yu=v(((e,t)=>{let n=typeof process<`u`&&process.env.TERM_PROGRAM===`Hyper`,r=typeof process<`u`&&process.platform===`win32`,i=typeof process<`u`&&process.platform===`linux`,a={ballotDisabled:`☒`,ballotOff:`☐`,ballotOn:`☑`,bullet:`•`,bulletWhite:`◦`,fullBlock:`█`,heart:`❤`,identicalTo:`≡`,line:`─`,mark:`※`,middot:`·`,minus:`-`,multiplication:`×`,obelus:`÷`,pencilDownRight:`✎`,pencilRight:`✏`,pencilUpRight:`✐`,percent:`%`,pilcrow2:`❡`,pilcrow:`¶`,plusMinus:`±`,question:`?`,section:`§`,starsOff:`☆`,starsOn:`★`,upDownArrow:`↕`},o=Object.assign({},a,{check:`√`,cross:`×`,ellipsisLarge:`...`,ellipsis:`...`,info:`i`,questionSmall:`?`,pointer:`>`,pointerSmall:`»`,radioOff:`( )`,radioOn:`(*)`,warning:`‼`}),s=Object.assign({},a,{ballotCross:`✘`,check:`✔`,cross:`✖`,ellipsisLarge:`⋯`,ellipsis:`…`,info:`ℹ`,questionFull:`?`,questionSmall:`﹖`,pointer:i?`▸`:`❯`,pointerSmall:i?`‣`:`›`,radioOff:`◯`,radioOn:`◉`,warning:`⚠`});t.exports=r&&!n?o:s,Reflect.defineProperty(t.exports,`common`,{enumerable:!1,value:a}),Reflect.defineProperty(t.exports,`windows`,{enumerable:!1,value:o}),Reflect.defineProperty(t.exports,`other`,{enumerable:!1,value:s})})),Xu=v(((e,t)=>{let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,i=()=>typeof process<`u`?process.env.FORCE_COLOR!==`0`:!1,a=()=>{let e={enabled:i(),visible:!0,styles:{},keys:{}},t=e=>{let t=e.open=`\u001b[${e.codes[0]}m`,n=e.close=`\u001b[${e.codes[1]}m`,r=e.regex=RegExp(`\\u001b\\[${e.codes[1]}m`,`g`);return e.wrap=(e,i)=>{e.includes(n)&&(e=e.replace(r,n+t));let a=t+e+n;return i?a.replace(/\r*\n/g,`${n}$&${t}`):a},e},a=(e,t,n)=>typeof e==`function`?e(t):e.wrap(t,n),o=(t,n)=>{if(t===``||t==null)return``;if(e.enabled===!1)return t;if(e.visible===!1)return``;let r=``+t,i=r.includes(`
|
|
83
|
+
`),o=n.length;for(o>0&&n.includes(`unstyle`)&&(n=[...new Set([`unstyle`,...n])].reverse());o-- >0;)r=a(e.styles[n[o]],r,i);return r},s=(n,r,i)=>{e.styles[n]=t({name:n,codes:r}),(e.keys[i]||(e.keys[i]=[])).push(n),Reflect.defineProperty(e,n,{configurable:!0,enumerable:!0,set(t){e.alias(n,t)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(n):[n],t}})};return s(`reset`,[0,0],`modifier`),s(`bold`,[1,22],`modifier`),s(`dim`,[2,22],`modifier`),s(`italic`,[3,23],`modifier`),s(`underline`,[4,24],`modifier`),s(`inverse`,[7,27],`modifier`),s(`hidden`,[8,28],`modifier`),s(`strikethrough`,[9,29],`modifier`),s(`black`,[30,39],`color`),s(`red`,[31,39],`color`),s(`green`,[32,39],`color`),s(`yellow`,[33,39],`color`),s(`blue`,[34,39],`color`),s(`magenta`,[35,39],`color`),s(`cyan`,[36,39],`color`),s(`white`,[37,39],`color`),s(`gray`,[90,39],`color`),s(`grey`,[90,39],`color`),s(`bgBlack`,[40,49],`bg`),s(`bgRed`,[41,49],`bg`),s(`bgGreen`,[42,49],`bg`),s(`bgYellow`,[43,49],`bg`),s(`bgBlue`,[44,49],`bg`),s(`bgMagenta`,[45,49],`bg`),s(`bgCyan`,[46,49],`bg`),s(`bgWhite`,[47,49],`bg`),s(`blackBright`,[90,39],`bright`),s(`redBright`,[91,39],`bright`),s(`greenBright`,[92,39],`bright`),s(`yellowBright`,[93,39],`bright`),s(`blueBright`,[94,39],`bright`),s(`magentaBright`,[95,39],`bright`),s(`cyanBright`,[96,39],`bright`),s(`whiteBright`,[97,39],`bright`),s(`bgBlackBright`,[100,49],`bgBright`),s(`bgRedBright`,[101,49],`bgBright`),s(`bgGreenBright`,[102,49],`bgBright`),s(`bgYellowBright`,[103,49],`bgBright`),s(`bgBlueBright`,[104,49],`bgBright`),s(`bgMagentaBright`,[105,49],`bgBright`),s(`bgCyanBright`,[106,49],`bgBright`),s(`bgWhiteBright`,[107,49],`bgBright`),e.ansiRegex=r,e.hasColor=e.hasAnsi=t=>(e.ansiRegex.lastIndex=0,typeof t==`string`&&t!==``&&e.ansiRegex.test(t)),e.alias=(t,n)=>{let r=typeof n==`string`?e[n]:n;if(typeof r!=`function`)throw TypeError(`Expected alias to be the name of an existing color (string) or a function`);r.stack||=(Reflect.defineProperty(r,`name`,{value:t}),e.styles[t]=r,[t]),Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,set(n){e.alias(t,n)},get(){let t=e=>o(e,t.stack);return Reflect.setPrototypeOf(t,e),t.stack=this.stack?this.stack.concat(r.stack):r.stack,t}})},e.theme=t=>{if(!n(t))throw TypeError(`Expected theme to be an object`);for(let n of Object.keys(t))e.alias(n,t[n]);return e},e.alias(`unstyle`,t=>typeof t==`string`&&t!==``?(e.ansiRegex.lastIndex=0,t.replace(e.ansiRegex,``)):``),e.alias(`noop`,e=>e),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Yu(),e.define=s,e};t.exports=a(),t.exports.create=a})),z=v((e=>{let t=Object.prototype.toString,n=Xu(),r=!1,i=new Set,a={yellow:`blue`,cyan:`red`,green:`magenta`,black:`white`,blue:`yellow`,red:`cyan`,magenta:`green`,white:`black`};e.longest=(e,t)=>e.reduce((e,n)=>Math.max(e,t?n[t].length:n.length),0),e.hasColor=e=>!!e&&n.hasColor(e);let o=e.isObject=e=>typeof e==`object`&&!!e&&!Array.isArray(e);e.nativeType=e=>t.call(e).slice(8,-1).toLowerCase().replace(/\s/g,``),e.isAsyncFn=t=>e.nativeType(t)===`asyncfunction`,e.isPrimitive=e=>e!=null&&typeof e!=`object`&&typeof e!=`function`,e.resolve=(e,t,...n)=>typeof t==`function`?t.call(e,...n):t,e.scrollDown=(e=[])=>[...e.slice(1),e[0]],e.scrollUp=(e=[])=>[e.pop(),...e],e.reorder=(e=[])=>{let t=e.slice();return t.sort((e,t)=>e.index>t.index?1:e.index<t.index?-1:0),t},e.swap=(e,t,n)=>{let r=e.length,i=n===r?0:n<0?r-1:n,a=e[t];e[t]=e[i],e[i]=a},e.width=(e,t=80)=>{let n=e&&e.columns?e.columns:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[0]),process.platform===`win32`?n-1:n},e.height=(e,t=20)=>{let n=e&&e.rows?e.rows:t;return e&&typeof e.getWindowSize==`function`&&(n=e.getWindowSize()[1]),n},e.wordWrap=(e,t={})=>{if(!e)return e;typeof t==`number`&&(t={width:t});let{indent:n=``,newline:r=`
|
|
84
|
+
`+n,width:i=80}=t,a=(r+n).match(/[^\S\n]/g)||[];i-=a.length;let o=`.{1,${i}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,s=e.trim(),c=new RegExp(o,`g`),l=s.match(c)||[];return l=l.map(e=>e.replace(/\n$/,``)),t.padEnd&&(l=l.map(e=>e.padEnd(i,` `))),t.padStart&&(l=l.map(e=>e.padStart(i,` `))),n+l.join(r)},e.unmute=e=>{let t=e.stack.find(e=>n.keys.color.includes(e));return t?n[t]:e.stack.find(e=>e.slice(2)===`bg`)?n[t.slice(2)]:e=>e},e.pascal=e=>e?e[0].toUpperCase()+e.slice(1):``,e.inverse=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e));if(r){let i=n[`bg`+e.pascal(r)];return i?i.black:t}let i=t.stack.find(e=>e.slice(0,2)===`bg`);return i?n[i.slice(2).toLowerCase()]||t:n.none},e.complement=t=>{if(!t||!t.stack)return t;let r=t.stack.find(e=>n.keys.color.includes(e)),i=t.stack.find(e=>e.slice(0,2)===`bg`);if(r&&!i)return n[a[r]||r];if(i){let r=a[i.slice(2).toLowerCase()];return r&&n[`bg`+e.pascal(r)]||t}return n.none},e.meridiem=e=>{let t=e.getHours(),n=e.getMinutes(),r=t>=12?`pm`:`am`;t%=12;let i=t===0?12:t,a=n<10?`0`+n:n;return i+`:`+a+` `+r},e.set=(t={},n=``,r)=>n.split(`.`).reduce((t,n,i,a)=>{let o=a.length-1>i?t[n]||{}:r;return!e.isObject(o)&&i<a.length-1&&(o={}),t[n]=o},t),e.get=(e={},t=``,n)=>(e[t]==null?t.split(`.`).reduce((e,t)=>e&&e[t],e):e[t])??n,e.mixin=(t,n)=>{if(!o(t))return n;if(!o(n))return t;for(let r of Object.keys(n)){let i=Object.getOwnPropertyDescriptor(n,r);if(hasOwnProperty.call(i,`value`))if(hasOwnProperty.call(t,r)&&o(i.value)){let a=Object.getOwnPropertyDescriptor(t,r);o(a.value)&&a.value!==i.value?t[r]=e.merge({},t[r],n[r]):Reflect.defineProperty(t,r,i)}else Reflect.defineProperty(t,r,i);else Reflect.defineProperty(t,r,i)}return t},e.merge=(...t)=>{let n={};for(let r of t)e.mixin(n,r);return n},e.mixinEmitter=(t,n)=>{let r=n.constructor.prototype;for(let i of Object.keys(r)){let a=r[i];typeof a==`function`?e.define(t,i,a.bind(n)):e.define(t,i,a)}};let s=(e,t)=>{r||(r=!0,i.forEach(e=>e()),e===!0&&process.exit(128+t))},c=s.bind(null,!0,15),l=s.bind(null,!0,2);e.onExit=e=>(i.size===0&&(process.once(`SIGTERM`,c),process.once(`SIGINT`,l),process.once(`exit`,s)),i.add(e),()=>{i.delete(e),i.size===0&&(process.off(`SIGTERM`,c),process.off(`SIGINT`,l),process.off(`exit`,s))}),e.define=(e,t,n)=>{Reflect.defineProperty(e,t,{value:n})},e.defineExport=(e,t,n)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(e){r=e},get(){return r?r():n()}})}})),Zu=v(((e,t)=>{t.exports=({onlyFirst:e=!1}={})=>{let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}})),Qu=v(((e,t)=>{let n=Zu();t.exports=e=>typeof e==`string`?e.replace(n(),``):e})),$u=v((e=>{e.ctrl={a:`first`,b:`backward`,c:`cancel`,d:`deleteForward`,e:`last`,f:`forward`,g:`reset`,i:`tab`,k:`cutForward`,l:`reset`,n:`newItem`,m:`cancel`,j:`submit`,p:`search`,r:`remove`,s:`save`,u:`undo`,w:`cutLeft`,x:`toggleCursor`,v:`paste`},e.shift={up:`shiftUp`,down:`shiftDown`,left:`shiftLeft`,right:`shiftRight`,tab:`prev`},e.fn={up:`pageUp`,down:`pageDown`,left:`pageLeft`,right:`pageRight`,delete:`deleteForward`},e.option={b:`backward`,f:`forward`,d:`cutRight`,left:`cutLeft`,up:`altUp`,down:`altDown`},e.keys={pageup:`pageUp`,pagedown:`pageDown`,home:`home`,end:`end`,cancel:`cancel`,delete:`deleteForward`,backspace:`delete`,down:`down`,enter:`submit`,escape:`cancel`,left:`left`,space:`space`,number:`number`,return:`submit`,right:`right`,tab:`next`,up:`up`}})),ed=v(((e,t)=>{t.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(e){this._jobRunner=e}enqueue=(...e)=>{this._queue.push(e),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){this._executing||!this._queue.length||(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}})),td=v(((e,t)=>{let n=ne(`readline`),r=$u(),i=ed(),a=/^(?:\x1b)([a-zA-Z0-9])$/,o=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,s={OP:`f1`,OQ:`f2`,OR:`f3`,OS:`f4`,"[11~":`f1`,"[12~":`f2`,"[13~":`f3`,"[14~":`f4`,"[[A":`f1`,"[[B":`f2`,"[[C":`f3`,"[[D":`f4`,"[[E":`f5`,"[15~":`f5`,"[17~":`f6`,"[18~":`f7`,"[19~":`f8`,"[20~":`f9`,"[21~":`f10`,"[23~":`f11`,"[24~":`f12`,"[A":`up`,"[B":`down`,"[C":`right`,"[D":`left`,"[E":`clear`,"[F":`end`,"[H":`home`,OA:`up`,OB:`down`,OC:`right`,OD:`left`,OE:`clear`,OF:`end`,OH:`home`,"[1~":`home`,"[2~":`insert`,"[3~":`delete`,"[4~":`end`,"[5~":`pageup`,"[6~":`pagedown`,"[[5~":`pageup`,"[[6~":`pagedown`,"[7~":`home`,"[8~":`end`,"[a":`up`,"[b":`down`,"[c":`right`,"[d":`left`,"[e":`clear`,"[2$":`insert`,"[3$":`delete`,"[5$":`pageup`,"[6$":`pagedown`,"[7$":`home`,"[8$":`end`,Oa:`up`,Ob:`down`,Oc:`right`,Od:`left`,Oe:`clear`,"[2^":`insert`,"[3^":`delete`,"[5^":`pageup`,"[6^":`pagedown`,"[7^":`home`,"[8^":`end`,"[Z":`tab`};function c(e){return[`[a`,`[b`,`[c`,`[d`,`[e`,`[2$`,`[3$`,`[5$`,`[6$`,`[7$`,`[8$`,`[Z`].includes(e)}function l(e){return[`Oa`,`Ob`,`Oc`,`Od`,`Oe`,`[2^`,`[3^`,`[5^`,`[6^`,`[7^`,`[8^`].includes(e)}let u=(e=``,t={})=>{let n,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B`+String(e)):e=String(e):e!==void 0&&typeof e!=`string`?e=String(e):e||=r.sequence||``,r.sequence=r.sequence||e||r.name,e===`\r`)r.raw=void 0,r.name=`return`;else if(e===`
|
|
85
|
+
`)r.name=`enter`;else if(e===` `)r.name=`tab`;else if(e===`\b`||e===``||e===`\x1B`||e===`\x1B\b`)r.name=`backspace`,r.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)r.name=`escape`,r.meta=e.length===2;else if(e===` `||e===`\x1B `)r.name=`space`,r.meta=e.length===2;else if(e<=``)r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)r.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)r.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)r.name=e.toLowerCase(),r.shift=!0;else if(n=a.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=o.exec(e)){let t=[...e];t[0]===`\x1B`&&t[1]===`\x1B`&&(r.option=!0);let i=[n[1],n[2],n[4],n[6]].filter(Boolean).join(``),a=(n[3]||n[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=i,r.name=s[i],r.shift=c(i)||r.shift,r.ctrl=l(i)||r.ctrl}return r};u.listen=(e={},t)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw Error(`Invalid stream passed`);let a=n.createInterface({terminal:!0,input:r});n.emitKeypressEvents(r,a);let o=new i((e,n)=>t(e,u(e,n),a)),s=r.isRaw;return r.isTTY&&r.setRawMode(!0),r.on(`keypress`,o.enqueue),a.resume(),()=>{r.isTTY&&r.setRawMode(s),r.removeListener(`keypress`,o.enqueue),o.destroy(),a.pause(),a.close()}},u.action=(e,t,n)=>{let i={...r,...n};return t.ctrl?(t.action=i.ctrl[t.name],t):t.option&&i.option?(t.action=i.option[t.name],t):t.shift?(t.action=i.shift[t.name],t):(t.action=i.keys[t.name],t)},t.exports=u})),nd=v(((e,t)=>{t.exports=e=>{e.timers=e.timers||{};let t=e.options.timers;if(t)for(let r of Object.keys(t)){let i=t[r];typeof i==`number`&&(i={interval:i}),n(e,r,i)}};function n(e,t,n={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},i=n.interval||120;r.frames=n.frames||[],r.loading=!0;let a=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},i);return r.stop=()=>{r.loading=!1,clearInterval(a)},Reflect.defineProperty(r,`interval`,{value:a}),e.once(`close`,()=>r.stop()),r.stop}})),rd=v(((e,t)=>{let{define:n,width:r}=z();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`}}})),id=v(((e,t)=>{let n=z(),r=Xu(),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})),ad=v(((e,t)=>{let n=process.platform===`win32`,r=Xu(),i=z(),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})),od=v(((e,t)=>{let n=id(),r=ad(),i=z();t.exports=e=>{e.options=i.merge({},e.options.theme,e.options),e.symbols=r.merge(e.options),e.styles=n.merge(e.options)}})),sd=v(((e,t)=>{let n=process.env.TERM_PROGRAM===`Apple_Terminal`,r=Qu(),i=z(),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)}})),cd=v(((e,t)=>{let n=ne(`events`),r=Qu(),i=td(),a=nd(),o=rd(),s=od(),c=z(),l=sd();var u=class e extends n{constructor(e={}){super(),this.name=e.name,this.type=e.type,this.options=e,s(this),a(this),this.state=new o(this),this.initial=[e.initial,e.default].find(e=>e!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=f(this.options.margin),this.setMaxListeners(0),d(this)}async keypress(e,t={}){this.keypressed=!0;let n=i.action(e,i(e,t),this.options.actions);this.state.keypress=n,this.emit(`keypress`,e,n),this.emit(`state`,this.state.clone());let r=this.options[n.action]||this[n.action]||this.dispatch;if(typeof r==`function`)return await r.call(this,e,n);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit(`alert`):this.stdout.write(l.code.beep)}cursorHide(){this.stdout.write(l.cursor.hide());let e=c.onExit(()=>this.cursorShow());this.on(`close`,()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(l.cursor.show())}write(e){e&&(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer=``,!(!t&&!e||this.options.show===!1)&&this.stdout.write(l.cursor.down(e)+l.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:n}=this.sections(),{cursor:r,initial:i=``,input:a=``,value:o=``}=this,s={after:t,cursor:r,initial:i,input:a,prompt:e,size:this.state.size=n.length,value:o},c=l.cursor.restore(s);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:n}=this.state;n=r(n);let i=r(e),a=i.indexOf(n),o=i.slice(0,a),s=i.slice(a).split(`
|
|
86
86
|
`),c=s[0],l=s[s.length-1],u=(n+(t?` `+t:``)).length;return{header:o,prompt:c,after:u<c.length?c.slice(u+1):``,rest:s.slice(1),last:l}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
|
|
87
87
|
`+this.symbols.pointer+` `;typeof e==`string`?t+=e.trim():t+=`Invalid input`,this.state.error=`
|
|
88
88
|
`+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit(`submit`,this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==`function`&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit(`cancel`,await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(l.cursor.down(e.rest.length)),this.write(`
|
|
89
89
|
`.repeat(t))}catch{}this.emit(`close`)}start(){!this.stop&&this.options.show!==!1&&(this.stop=i.listen(this,this.keypress.bind(this)),this.once(`close`,this.stop),this.emit(`start`,this))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip==`function`&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:t,result:n}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>n.call(this,this.value),typeof t.initial==`function`&&(this.initial=await t.initial.call(this,this)),typeof t.onRun==`function`&&await t.onRun.call(this,this),typeof t.onSubmit==`function`){let e=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await e(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw Error(`expected prompt to have a custom render method`)}run(){return new Promise(async(e,t)=>{if(this.once(`submit`,e),this.once(`cancel`,t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit(`run`)})}async element(e,t,n){let{options:r,state:i,symbols:a,timers:o}=this;i.timer=o&&o[e];let s=r[e]||i[e]||a[e],c=t&&t[e]!=null?t[e]:await s;if(c===``)return c;let l=await this.resolve(c,i,t,n);return!l&&t&&t[e]?this.resolve(s,i,t,n):l}async prefix(){let e=await this.element(`prefix`)||this.symbols,t=this.timers&&this.timers.prefix,n=this.state;return n.timer=t,c.isObject(e)&&(e=e[n.status]||e.pending),c.hasColor(e)?e:(this.styles[n.status]||this.styles.pending)(e)}async message(){let e=await this.element(`message`);return c.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element(`separator`)||this.symbols,t=this.timers&&this.timers.separator,n=this.state;n.timer=t;let r=e[n.status]||e.pending||n.separator,i=await this.resolve(r,n);return c.isObject(i)&&(i=i[n.status]||i.pending),c.hasColor(i)?i:this.styles.muted(i)}async pointer(e,t){let n=await this.element(`pointer`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let e=this.styles,r=this.index===t,i=r?e.primary:e=>e,a=await this.resolve(n[r?`on`:`off`]||n,this.state),o=c.hasColor(a)?a:i(a);return r?o:` `.repeat(a.length)}}async indicator(e,t){let n=await this.element(`indicator`,e,t);if(typeof n==`string`&&c.hasColor(n))return n;if(n){let t=this.styles,r=e.enabled===!0,i=r?t.success:t.dark,a=n[r?`on`:`off`]||n;return c.hasColor(a)?a:i(a)}return``}body(){return null}footer(){if(this.state.status===`pending`)return this.element(`footer`)}header(){if(this.state.status===`pending`)return this.element(`header`)}async hint(){if(this.state.status===`pending`&&!this.isValue(this.state.input)){let e=await this.element(`hint`);return c.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?``:e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==``}resolve(e,...t){return c.resolve(this,e,...t)}get base(){return e.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||c.height(this.stdout,25)}get width(){return this.options.columns||c.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,n=[t,e].find(this.isValue.bind(this));return this.isValue(n)?n:this.initial}static get prompt(){return e=>new this(e).run()}};function d(e){let t=t=>e[t]===void 0||typeof e[t]==`function`,n=[`actions`,`choices`,`initial`,`margin`,`roles`,`styles`,`symbols`,`theme`,`timers`,`value`],r=[`body`,`footer`,`error`,`header`,`hint`,`indicator`,`message`,`prefix`,`separator`,`skip`];for(let i of Object.keys(e.options)){if(n.includes(i)||/^on[A-Z]/.test(i))continue;let a=e.options[i];typeof a==`function`&&t(i)?r.includes(i)||(e[i]=a.bind(e)):typeof e[i]!=`function`&&(e[i]=a)}}function f(e){typeof e==`number`&&(e=[e,e,e,e]);let t=[].concat(e||[]),n=e=>e%2==0?`
|
|
90
|
-
`:` `,r=[];for(let e=0;e<4;e++){let i=n(e);t[e]?r.push(i.repeat(t[e])):r.push(``)}return r}t.exports=u})),ou=p(((e,t)=>{let n=K(),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}})),su=p(((e,t)=>{let n=Yl(),r=au(),i=ou(),a=K(),{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})),cu=p(((e,t)=>{let n=su(),r=K();t.exports=class extends n{constructor(e){super(e),this.emptyError=this.options.emptyError||`No items were selected`}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):``}indicator(e,t){return this.multiple?super.indicator(e,t):``}choiceMessage(e,t){let n=this.resolve(e.message,this.state,e,t);return e.role===`heading`&&!r.hasColor(n)&&(n=this.styles.strong(n)),this.resolve(n,this.state,e,t)}choiceSeparator(){return`:`}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,i=await this.pointer(e,t),a=await this.indicator(e,t)+(e.pad||``),o=await this.resolve(e.hint,this.state,e,t);o&&!r.hasColor(o)&&(o=this.styles.muted(o));let s=this.indent(e),c=await this.choiceMessage(e,t),l=()=>[this.margin[3],s+i+a,c,this.margin[1],o].filter(Boolean).join(` `);return e.role===`heading`?l():e.disabled?(r.hasColor(c)||(c=this.styles.disabled(c)),l()):(n&&(c=this.styles.em(c)),l())}async renderChoices(){if(this.state.loading===`choices`)return this.styles.warning(`Loading choices`);if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);t.length||t.push(this.styles.danger(`No matching choices`));let n=this.margin[0]+t.join(`
|
|
90
|
+
`:` `,r=[];for(let e=0;e<4;e++){let i=n(e);t[e]?r.push(i.repeat(t[e])):r.push(``)}return r}t.exports=u})),ld=v(((e,t)=>{let n=z(),r={default(e,t){return t},checkbox(e,t){throw Error(`checkbox role is not implemented yet`)},editable(e,t){throw Error(`editable role is not implemented yet`)},expandable(e,t){throw Error(`expandable role is not implemented yet`)},heading(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||``,t},input(e,t){throw Error(`input role is not implemented yet`)},option(e,t){return r.default(e,t)},radio(e,t){throw Error(`radio role is not implemented yet`)},separator(e,t){return t.disabled=``,t.indicator=[t.indicator,` `].find(e=>e!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};t.exports=(e,t={})=>{let i=n.merge({},r,t.roles);return i[e]||i.default}})),ud=v(((e,t)=>{let n=Qu(),r=cd(),i=ld(),a=z(),{reorder:o,scrollUp:s,scrollDown:c,isObject:l,swap:u}=a;var d=class extends r{constructor(e){super(e),this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=``}async initialize(){typeof this.options.initial==`function`&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:n,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(e=>e.enabled=!1),typeof r!=`function`&&this.selectable.length===0)throw Error(`At least one choice must be selectable`);l(t)&&(t=Object.keys(t)),Array.isArray(t)?(n!=null&&(this.index=this.findIndex(n)),t.forEach(e=>this.enable(this.find(e))),await this.render()):(n!=null&&(t=n),typeof t==`string`&&(t=this.findIndex(t)),typeof t==`number`&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let n=[],r=0,i=async(e,t)=>{typeof e==`function`&&(e=await e.call(this)),e instanceof Promise&&(e=await e);for(let a=0;a<e.length;a++){let o=e[a]=await this.toChoice(e[a],r++,t);n.push(o),o.choices&&await i(o.choices,o)}return n};return i(e,t).then(e=>(this.state.loadingChoices=!1,e))}async toChoice(e,t,r){if(typeof e==`function`&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e==`string`&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value;if(e=i(e.role,this.options)(this,e),typeof e.disabled==`string`&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint=`(disabled)`),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||``,e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input=``,e.index=t,e.cursor=0,a.define(e,`parent`,r),e.level=r?r.level+1:1,e.indent??=r?r.indent+` `:e.indent||``,e.path=r?r.path+`.`+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,n(e.message).length));let s={...e};return e.reset=(t=s.input,n=s.value)=>{for(let t of Object.keys(s))e[t]=s[t];e.input=t,e.value=n},o==null&&typeof e.initial==`function`&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit(`choice`,e,t,this),typeof e.onChoice==`function`&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,n){let r=await this.toChoice(e,t,n);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,n){let r={name:`New choice name?`,editable:!0,newChoice:!0,...e},i=await this.addChoice(r,t,n);return i.updateChoice=()=>{delete i.newChoice,i.name=i.message=i.input,i.input=``,i.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?` `.repeat(e.level-1):``:e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!=`boolean`&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!this.isDisabled(e),e)}space(){if(!this.multiple)return this.alert();if(this.focused)return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(e=>e.enabled);return this.choices.forEach(t=>t.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(){if(!this.choices.some(e=>!!e.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!=`boolean`&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(e=>this.toggle(e,t));let n=e.parent;for(;n;){let e=n.choices.filter(e=>this.isDisabled(e));n.enabled=e.every(e=>e.enabled===!0),n=n.parent}return f(this,this.choices),this.emit(`toggle`,e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=e=>{let t=Number(e);if(t>this.choices.length-1)return this.alert();let n=this.focused,r=this.choices.find(e=>t===e.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(r)===-1){let e=o(this.choices),t=e.indexOf(r);if(n.index>t){let n=e.slice(t,t+this.limit),r=e.filter(e=>!n.includes(e));this.choices=n.concat(r)}else{let n=t-this.limit+1;this.choices=e.slice(n).concat(e.slice(0,n))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(e=>{let n=this.choices.length,r=this.num,i=(n=!1,i)=>{clearTimeout(this.numberTimeout),n&&(i=t(r)),this.num=``,e(i)};if(r===`0`||r.length===1&&Number(r+`0`)>n)return i(!0);if(Number(r)>n)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=o(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=o(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===0?this.alert():e>t&&n===0?this.scrollUp():(this.index=(n-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,n=this.index;return this.options.scroll===!1&&n===t-1?this.alert():e>t&&n===t-1?this.scrollDown():(this.index=(n+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=s(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=c(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){u(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every(e=>this.isDisabled(e))}isDisabled(e=this.focused){return e&&[`disabled`,`collapsed`,`hidden`,`completing`,`readonly`].some(t=>e[t]===!0)?!0:e&&e.role===`heading`}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(e=>this.isEnabled(e));if(e.choices){let t=e.choices.filter(e=>!this.isDisabled(e));return e.enabled&&t.every(e=>this.isEnabled(e))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t=`value`){return[].concat(e||[]).reduce((e,n)=>(e[n]=this.find(n,t),e),{})}filter(e,t){let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=(this.options.multiple?this.state._choices:this.choices).filter(n);return t?r.map(e=>e[t]):r}find(e,t){if(l(e))return t?e[t]:e;let n=typeof e==`function`?e:(t,n)=>[t.name,n].includes(e),r=this.choices.find(n);if(r)return t?r[t]:r}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(e=>e.newChoice))return this.alert();let{reorder:t,sort:n}=this.options,r=this.multiple===!0,i=this.selected;return i===void 0?this.alert():(Array.isArray(i)&&t!==!1&&n!==!0&&(i=a.reorder(i)),this.value=r?i.map(e=>e.name):i.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(e=>e.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let e=this.initial;if(typeof e==`string`||typeof e==`number`){let t=this.find(e);t&&(this.initial=t.index,this.focus(t,!0))}}}get choices(){return f(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:n}=this,r=e.limit||this._limit||t.limit||n.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){return typeof super.value!=`string`&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function f(e,t){if(t instanceof Promise)return t;if(typeof t==`function`){if(a.isAsyncFn(t))return t;t=t.call(e,e)}for(let n of t)Array.isArray(n.choices)&&(n.enabled=n.choices.filter(t=>!e.isDisabled(t)).every(e=>e.enabled===!0)),e.isDisabled(n)===!0&&delete n.enabled;return t}t.exports=d})),dd=v(((e,t)=>{let n=ud(),r=z();t.exports=class extends n{constructor(e){super(e),this.emptyError=this.options.emptyError||`No items were selected`}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):``}indicator(e,t){return this.multiple?super.indicator(e,t):``}choiceMessage(e,t){let n=this.resolve(e.message,this.state,e,t);return e.role===`heading`&&!r.hasColor(n)&&(n=this.styles.strong(n)),this.resolve(n,this.state,e,t)}choiceSeparator(){return`:`}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,i=await this.pointer(e,t),a=await this.indicator(e,t)+(e.pad||``),o=await this.resolve(e.hint,this.state,e,t);o&&!r.hasColor(o)&&(o=this.styles.muted(o));let s=this.indent(e),c=await this.choiceMessage(e,t),l=()=>[this.margin[3],s+i+a,c,this.margin[1],o].filter(Boolean).join(` `);return e.role===`heading`?l():e.disabled?(r.hasColor(c)||(c=this.styles.disabled(c)),l()):(n&&(c=this.styles.em(c)),l())}async renderChoices(){if(this.state.loading===`choices`)return this.styles.warning(`Loading choices`);if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);t.length||t.push(this.styles.danger(`No matching choices`));let n=this.margin[0]+t.join(`
|
|
91
91
|
`),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,n].filter(Boolean).join(`
|
|
92
92
|
`)}format(){return!this.state.submitted||this.state.cancelled?``:Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(`, `):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,n=``,r=await this.header(),i=await this.prefix(),a=await this.separator(),o=await this.message();this.options.promptLine!==!1&&(n=[i,o,a,``].join(` `),this.state.prompt=n);let s=await this.format(),c=await this.error()||await this.hint(),l=await this.renderChoices(),u=await this.footer();s&&(n+=s),c&&!n.includes(c)&&(n+=` `+c),e&&!s&&!l.trim()&&this.multiple&&this.emptyError!=null&&(n+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,n,l,u].filter(Boolean).join(`
|
|
93
|
-
`)),this.write(this.margin[2]),this.restore()}}})),
|
|
94
|
-
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),
|
|
93
|
+
`)),this.write(this.margin[2]),this.restore()}}})),fd=v(((e,t)=>{let n=dd(),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()}}})),pd=v(((e,t)=>{let n=z();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}})),md=v(((e,t)=>{let n=Qu(),r=dd(),i=pd();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,ee=l?`success`:`dark`;await h.call(e,v,this.state)!==!0&&(ee=`danger`);let te=a[ee],ne=te(await this.indicator(e,t))+(e.pad||``),re=this.indent(e),ie=()=>[re,ne,_+g,l].filter(Boolean).join(` `);if(r.submitted)return _=n(_),l=d(l),ie();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())),ie()}async submit(){return this.value=this.values,super.base.submit.call(this)}}})),hd=v(((e,t)=>{let n=md(),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()})),gd=v(((e,t)=>{let n=hd();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()})),_d=v(((e,t)=>{let n=cd(),{isPrimitive:r,hasColor:i}=z();t.exports=class extends n{constructor(e){super(e),this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:t,state:n}=this;return n.submitted?t.success(e):t.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return r(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status===`pending`){let e=await this.element(`hint`);return i(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),this.styles.muted(this.default),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=this.value=this.cast(e),s=await this.format(o),c=await this.error()||await this.hint(),l=await this.footer();c&&!i.includes(c)&&(s+=` `+c),i+=` `+s,this.clear(t),this.write([a,i,l].filter(Boolean).join(`
|
|
94
|
+
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}})),vd=v(((e,t)=>{let n=_d();t.exports=class extends n{constructor(e){super(e),this.default=this.options.default||(this.initial?`(Y/n)`:`(y/N)`)}}})),yd=v(((e,t)=>{let n=dd(),r=md().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)}}})),bd=v(((e,t)=>{let n=cd(),r=td(),i=pd(),{isPrimitive:a}=z();t.exports=class extends n{constructor(e){super(e),this.initial=a(this.initial)?String(this.initial):``,this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout===void 0?null:this.options.keypressTimeout}async keypress(e,t=e?r(e,{}):{}){let n=Date.now(),i=n-this.lastKeypress;this.lastKeypress=n;let a=t.name===`return`||t.name===`enter`,o=this.state.prevKeypress,s;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&a){if(i<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||``,this.state.multilineBuffer+=e,s=!0,o=null}return(s||this.options.multiline&&a)&&(!o||o.name!==`return`)?this.append(`
|
|
95
95
|
`,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value=``,this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:n}=this.state;this.input=`${n}`.slice(0,t)+e+`${n}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),n=this.input.slice(e),r=t.split(` `);this.state.clipboard.push(r.pop()),this.input=r.join(` `),this.cursor=this.input.length,this.input+=n,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial==null?``:String(this.initial);if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):i(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),n=await this.separator(),r=[t,await this.message(),n].filter(Boolean).join(` `);this.state.prompt=r;let i=await this.header(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer();o&&!a.includes(o)&&(a+=` `+o),r+=` `+a,this.clear(e),this.write([i,r,s].filter(Boolean).join(`
|
|
96
|
-
`)),this.restore()}}})),
|
|
96
|
+
`)),this.restore()}}})),xd=v(((e,t)=>{let n=e=>e.filter((t,n)=>e.lastIndexOf(t)===n),r=e=>n(e).filter(Boolean);t.exports=(e,t={},n=``)=>{let{past:i=[],present:a=``}=t,o,s;switch(e){case`prev`:case`undo`:return o=i.slice(0,i.length-1),s=i[i.length-1]||``,{past:r([n,...o]),present:s};case`next`:case`redo`:return o=i.slice(1),s=i[0]||``,{past:r([...o,n]),present:s};case`save`:return{past:r([...i,n]),present:``};case`remove`:return s=r(i.filter(e=>e!==n)),a=``,s.length&&(a=s.pop()),{past:s,present:a};default:throw Error(`Invalid action: "${e}"`)}}})),Sd=v(((e,t)=>{let n=bd(),r=xd();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()}}})),Cd=v(((e,t)=>{let n=bd();t.exports=class extends n{format(){return``}}})),wd=v(((e,t)=>{let n=bd();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()}}})),Td=v(((e,t)=>{let n=dd();t.exports=class extends n{constructor(e){super({...e,multiple:!0})}}})),Ed=v(((e,t)=>{let n=bd();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()}}})),Dd=v(((e,t)=>{t.exports=Ed()})),Od=v(((e,t)=>{let n=bd();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)):``}}})),kd=v(((e,t)=>{let n=Qu(),r=ud(),i=z();t.exports=class extends r{constructor(e={}){super(e),this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||`left`),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
|
|
97
97
|
`;let t=e.startNumber||1;typeof this.scale==`number`&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((e,n)=>({name:n+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let e=0;e<this.scale.length;e++)t.scale.push({index:e})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,n){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return``}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.index)).join(`, `):``}pointer(){return``}renderScaleKey(){return this.scaleKey===!1||this.state.submitted?``:[``,...this.scale.map(e=>` ${e.name} - ${e.message}`)].map(e=>this.styles.muted(e)).join(`
|
|
98
98
|
`)}renderScaleHeading(e){let t=this.scale.map(e=>e.name);typeof this.options.renderScaleHeading==`function`&&(t=this.options.renderScaleHeading.call(this,e));let n=this.scaleLength-t.join(``).length,r=Math.round(n/(t.length-1)),i=t.map(e=>this.styles.strong(e)).join(` `.repeat(r)),a=` `.repeat(this.widths[0]);return this.margin[3]+a+this.margin[1]+i}scaleIndicator(e,t,n){if(typeof this.options.scaleIndicator==`function`)return this.options.scaleIndicator.call(this,e,t,n);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let n=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term===`Hyper`?``:` `;return n.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let r=this.index===t,a=await this.pointer(e,t),o=await e.hint;o&&!i.hasColor(o)&&(o=this.styles.muted(o));let s=e=>this.margin[3]+e.replace(/\s+$/,``).padEnd(this.widths[0],` `),c=this.newline,l=this.indent(e),u=await this.resolve(e.message,this.state,e,t),d=await this.renderScale(e,t),f=this.margin[1]+this.margin[3];this.scaleLength=n(d).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-f.length);let p=i.wordWrap(u,{width:this.widths[0],newline:c}).split(`
|
|
99
99
|
`).map(e=>s(e)+this.margin[1]);return r&&(d=this.styles.info(d),p=p.map(e=>this.styles.info(e))),p[0]+=d,this.linebreak&&p.push(``),[l+a,p.join(`
|
|
100
100
|
`)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return``;this.tableize();let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e),n=await this.renderScaleHeading();return this.margin[0]+[n,...t.map(e=>e.join(` `))].join(`
|
|
101
101
|
`)}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=await this.message(),a=``;this.options.promptLine!==!1&&(a=[n,i,r,``].join(` `),this.state.prompt=a);let o=await this.header(),s=await this.format(),c=await this.renderScaleKey(),l=await this.error()||await this.hint(),u=await this.renderChoices(),d=await this.footer(),f=this.emptyError;s&&(a+=s),l&&!a.includes(l)&&(a+=` `+l),e&&!s&&!u.trim()&&this.multiple&&f!=null&&(a+=this.styles.danger(f)),this.clear(t),this.write([o,a,c,u,d].filter(Boolean).join(`
|
|
102
|
-
`)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}})),
|
|
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)}}})),Ad=v(((e,t)=>{let n=Qu(),r=(e=``)=>typeof e==`string`?e.replace(/^['"]|['"]$/g,``):``;var i=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=r(e.initial||this.field.initial||``),this.message=e.message||this.name,this.cursor=0,this.input=``,this.lines=[]}};let a=async(e={},t={},n=e=>e)=>{let r=new Set,a=e.fields||[],o=e.template,s=[],c=[],l=[],u=1;typeof o==`function`&&(o=await o());let d=-1,f=()=>o[++d],p=()=>o[d+1],m=e=>{e.line=u,s.push(e)};for(m({type:`bos`,value:``});d<o.length-1;){let e=f();if(/^[^\S\n ]$/.test(e)){m({type:`text`,value:e});continue}if(e===`
|
|
103
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),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(`
|
|
104
104
|
`).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(`
|
|
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))}})),
|
|
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))}})),jd=v(((e,t)=>{let n=Qu(),r=Ad(),i=cd();t.exports=class extends i{constructor(e){super(e),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await r(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let n=this.getItem();this.input=n.input=`${n.input.slice(0,this.cursor)}${e}${n.input.slice(this.cursor)}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor);this.input=e.input=`${e.input.slice(0,this.cursor-1)}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:n,size:r}=this.state,i=[this.options.newline,`
|
|
106
106
|
`].find(e=>e!=null),a=await this.prefix(),o=await this.separator(),s=[a,await this.message(),o].filter(Boolean).join(` `);this.state.prompt=s;let c=await this.header(),l=await this.error()||``,u=await this.hint()||``,d=n?``:await this.interpolate(this.state),f=this.state.key=t[e]||``,p=await this.format(f),m=await this.footer();p&&(s+=` `+p),u&&!p&&this.state.completed===0&&(s+=` `+u),this.clear(r);let h=[c,s,d,m,l.trim()];this.write(h.filter(Boolean).join(i)),this.restore()}getItem(e){let{items:t,keys:n,index:r}=this.state,i=t.find(e=>e.name===n[r]);return i&&i.input!=null&&(this.input=i.input,this.cursor=i.cursor),i}async submit(){typeof this.interpolate!=`function`&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:r,values:i}=this.state;if(e.size){let t=``;for(let[n,r]of e)t+=`Invalid ${n}: ${r}\n`;return this.state.error=t,super.submit()}return t.size?(this.state.error=`Required: `+[...t.keys()].join(`, `),super.submit()):(this.value={values:i,result:n(r).split(`
|
|
107
107
|
`).map(e=>e.slice(1)).join(`
|
|
108
|
-
`)},super.submit())}}})),
|
|
108
|
+
`)},super.submit())}}})),Md=v(((e,t)=>{let n=dd();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()}}})),Nd=v(((e,t)=>{let n=ud();var r=class extends n{constructor(e={}){if(super(e),this.emptyError=e.emptyError||`No items were selected`,this.term=process.env.TERM_PROGRAM,!this.options.header){let e=[``,`4 - Strongly Agree`,`3 - Agree`,`2 - Neutral`,`1 - Disagree`,`0 - Strongly Disagree`,``];e=e.map(e=>this.styles.muted(e)),this.state.header=e.join(`
|
|
109
109
|
`)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let e of t)e.scale=i(5,this.options),e.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],n=t.selected;return e.scale.forEach(e=>e.selected=!1),t.selected=!n,this.render()}indicator(){return``}pointer(){return``}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return` `}async renderChoice(e,t){await this.onChoice(e,t);let n=this.index===t,r=this.term===`Hyper`,i=r?9:8,a=r?``:` `,o=this.symbols.line.repeat(i),s=` `.repeat(i+(r?0:1)),c=e=>(e?this.styles.success(`◉`):`◯`)+a,l=t+1+`.`,u=n?this.styles.heading:this.styles.noop,d=await this.resolve(e.message,this.state,e,t),f=this.indent(e),p=f+e.scale.map((t,n)=>c(n===e.scaleIdx)).join(o),m=t=>t===e.scaleIdx?u(t):t,h=f+e.scale.map((e,t)=>m(t)).join(s);return n&&(p=this.styles.cyan(p),h=this.styles.cyan(h)),[[l,d].filter(Boolean).join(` `),p,h,` `].filter(Boolean).join(`
|
|
110
110
|
`)}async renderChoices(){if(this.state.submitted)return``;let e=this.visible.map(async(e,t)=>await this.renderChoice(e,t)),t=await Promise.all(e);return t.length||t.push(this.styles.danger(`No matching choices`)),t.join(`
|
|
111
111
|
`)}format(){return this.state.submitted?this.choices.map(e=>this.styles.info(e.scaleIdx)).join(`, `):``}async render(){let{submitted:e,size:t}=this.state,n=await this.prefix(),r=await this.separator(),i=[n,await this.message(),r].filter(Boolean).join(` `);this.state.prompt=i;let a=await this.header(),o=await this.format(),s=await this.error()||await this.hint(),c=await this.renderChoices(),l=await this.footer();(o||!s)&&(i+=` `+o),s&&!i.includes(s)&&(i+=` `+s),e&&!o&&!c&&this.multiple&&this.type!==`form`&&(i+=this.styles.danger(this.emptyError)),this.clear(t),this.write([i,a,c,l].filter(Boolean).join(`
|
|
112
|
-
`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function i(e,t={}){if(Array.isArray(t.scale))return t.scale.map(e=>({...e}));let n=[];for(let t=1;t<e+1;t++)n.push({i:t,selected:!1});return n}t.exports=r})),
|
|
113
|
-
`)),this.write(this.margin[2]),this.restore()}}})),
|
|
114
|
-
|
|
115
|
-
`)}))}function od(e){process.env[ad]===`1`?console.trace(e):J.error(q.default.red(e.toString())),process.exit(1)}async function $(e){try{return await e()}catch(e){return e instanceof V?od(e):od(new V(e instanceof Error?e.message:String(e),{suggestion:`Run with ${ad}=1 for a stack trace.`,cause:e}))}}function sd(){let e=td();if(!e)throw new mc;return new ed(e,id())}function cd(e,t){if(t)return t;let n=ul(e);if(!n)throw new hc;return n}const ld=X.extend({project:R().optional(),copy:B().optional()}),ud=new b(`add`).description(`Add skills from your library to this project.`).argument(`[skills...]`,`Skills to add. Omit to pick from a list.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(ld,t);J.intro(Y),await $(async()=>{let t=sd(),r=cd(n.cwd,n.project),i=await t.listSkills(),a=new Set((await t.getBindings(r)).map(e=>e.name)),o=e;if(o.length===0){let e=i.filter(e=>!a.has(e.name));if(e.length===0){J.info(`Every skill in your library is already in this project.`);return}if(o=await Wu(`Add to ${r}`,e.map(e=>({name:e.name}))),o.length===0){J.info(`Nothing selected.`);return}}let s=new Set(i.map(e=>e.name)),c=o.filter(e=>!s.has(e));if(c.length>0)throw new V(`Not in your library: ${c.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let l=await t.setBindings(r,[...new Set([...a,...o])]),u=await Gl(Bl(n.cwd),await t.getBindings(r),{copy:n.copy});for(let e of o)l.bound.includes(e)&&J.step(`Added \`${e}\`.`);for(let e of u.skipped)J.warn(e.reason===`tracked`?`\`${e.name}\` is tracked by git here — left alone.`:`\`${e.name}\` already exists here and is not ours — left alone.`)})});function dd(e){let t=process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`;try{n(t,[e],{stdio:`ignore`,detached:!0,shell:process.platform===`win32`}).unref()}catch{}}async function fd(){let e=a.randomBytes(16).toString(`hex`),t=id(),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,s=new Promise((e,t)=>{i={resolve:e,reject:t}}),c=o.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)})}),l=setTimeout(()=>{i.reject(new V(`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)=>{c.once(`error`,t),c.listen(0,`127.0.0.1`,e)});let{port:n}=c.address(),r=`${t}/cli/auth?port=${n}&state=${e}`;J.info(`Opening your browser to sign in…`),J.dim(r),J.blank(),dd(r),nd(await s)}finally{clearTimeout(l),c.close()}}const pd=X.extend({logout:B(),token:R().optional()}),md=new b(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new de(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new de(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(Z.cwd).action(async e=>{let t=Q(pd,e);J.intro(Y),await $(async()=>{if(t.logout){if(!td()){J.info(`You were not signed in.`);return}rd(),J.step(`Signed out.`);return}if(t.token){nd(t.token),J.step(`Token saved.`);return}await fd(),J.step(`Signed in.`)})}),hd=X.extend({description:R().optional(),project:R().optional()}),gd=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.`).option(`-d, --description <description>`,`What the skill does, for the frontmatter.`).addOption(Z.project).addOption(Z.cwd).action(async(e,t)=>{let n=Q(hd,t);J.intro(Y),await $(async()=>{xl(e);let t=sd();if(Dl(e))throw new V(`\`${e}\` already exists in your library.`,{suggestion:`Edit it at ${G(e)}`});if(await t.getSkill(e))throw new V(`\`${e}\` already exists in your library.`,{suggestion:"Run `skilless sync` to bring it down to this machine."});wl(e,Ol(e,n.description??await Uu(`What does this skill do?`,``)));let r=Cl(G(e),e);await t.putSkill(e,r.files,r.editedAt);let i=Hl();i.skills[e]={contentHash:r.contentHash,editedAt:r.editedAt,syncedAt:Date.now()},Ul(i),J.step(`Created \`${e}\`.`);let a=n.project??ul(n.cwd);if(a){let i=(await t.getBindings(a)).map(e=>e.name);await t.setBindings(a,[...new Set([...i,e])]),await Gl(Bl(n.cwd),[{...r,updatedAt:Date.now(),files:r.files}]),J.step(`Added to ${a}.`)}else J.warn(`No git remote here, so it was not added to a project.`);J.blank(),J.dim(`Edit it at ${H.join(G(e),`SKILL.md`)}`),J.dim("Run `skilless sync` when you are happy with it.")})}),_d=X.extend({yes:B(),overwrite:B()});function vd(e){return r.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:H.join(e,t.name)})).filter(e=>U(H.join(e.dir,gl))).sort((e,t)=>e.name.localeCompare(t.name))}const yd=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(Z.yes).addOption(Z.cwd).action(async(e,t)=>{let n=Q(_d,t);J.intro(Y),await $(async()=>{let t=sd(),r=H.resolve(n.cwd,e);if(!U(r))throw new V(`${r} does not exist.`);let i=vd(r);if(i.length===0)throw new V(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${gl}.`});let a=new Set((await t.listSkills()).map(e=>e.name)),o=[],s=[];for(let e of i){if(!bl(e.name)){s.push({name:e.name,reason:`invalid name`});continue}if(a.has(e.name)&&!n.overwrite){s.push({name:e.name,reason:`already in your library`});continue}try{o.push(Cl(e.dir,e.name))}catch(t){s.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of s)J.warn(`${e.name} — ${e.reason}`);if(o.length===0){J.info(`Nothing to import.`);return}if(J.blank(),J.info(`Importing: ${o.map(e=>e.name).join(`, `)}`),!(n.yes||await Hu(`Import ${o.length} skill(s)?`,!0)))return;let c=Hl();for(let e of o)wl(e.name,e.files,e.editedAt),await t.putSkill(e.name,e.files,e.editedAt),c.skills[e.name]={contentHash:e.contentHash,editedAt:e.editedAt,syncedAt:Date.now()},J.step(`Imported \`${e.name}\`.`);Ul(c),J.blank(),J.dim("Add them to a project with `skilless add <skill>`.")})}),bd=X.extend({}),xd=new b(`init`).description(`Create the local skilless directory and sign in.`).addOption(Z.cwd).action(async e=>{Q(bd,e),J.intro(Y),await $(async()=>{let e=!U($c);if(Kc($c),J.step(`${e?`Created`:`Found`} your library at ${Qc}`),td()&&!await Hu(`You are already signed in. Sign in again?`,!1)){J.blank(),J.dim("Nothing to do. Try `skilless create <name>`.");return}await fd(),J.step(`Signed in.`),J.blank(),J.dim("Next: `skilless create <name>` or `skilless add <skill>`.")})}),Sd=X.extend({project:R().optional(),copy:B().optional()}),Cd=new b(`install`).description(`Install every skill added to this project.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(Z.project).addOption(Z.cwd).action(async e=>{let t=Q(Sd,e);J.intro(Y),await $(async()=>{let e=sd(),n=cd(t.cwd,t.project),r=Bl(t.cwd),i=zl(r);for(let e of i)J.dim(`pruned ${e} (no longer in your library)`);let a=await e.getBindings(n);if(a.length===0){J.info(`No skills added to ${n} yet.`),J.dim("Add one with `skilless add <skill>`.");return}let o=await Gl(r,a,{copy:t.copy});for(let e of o.fetched)J.dim(`fetched ${e}`);for(let e of o.written)J.step(`Installed \`${e}\`.`);for(let e of o.skipped)J.warn(e.reason===`tracked`?`\`${e.name}\` is tracked by git here — left alone.`:`\`${e.name}\` already exists here and is not ours — left alone.`);J.blank(),J.dim(Wl(t.copy)?`Wrote real files.`:`Linked from your library.`)})}),wd=X.extend({project:Bs([B(),R()]).optional()}),Td=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(Z.cwd).action(async e=>{let t=Q(wd,e);J.intro(Y),await $(async()=>{let e=sd();if(t.project!==void 0){let n=cd(t.cwd,typeof t.project==`string`?t.project:void 0),r=await e.getBindings(n);if(J.info(`${q.default.bold(n)}`),J.blank(),r.length===0){J.dim("No skills added yet. Try `skilless add <skill>`.");return}for(let e of r)J.dim(` ${e.name}`);return}let n=await e.listSkills();if(n.length===0){J.dim("Your library is empty. Try `skilless create <name>`.");return}for(let e of n){let t=new Date(e.updatedAt).toISOString().slice(0,10);J.dim(` ${e.name.padEnd(28)} ${q.default.gray(t)}`)}})}),Ed=X.extend({yes:B()}),Dd=new b(`remove`).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(Ed,t);J.intro(Y),await $(async()=>{let t=sd();if(J.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),!(n.yes||await Hu(`Delete ${e.length} skill(s)?`,!1))){J.info(`Nothing was deleted.`);return}let r=Hl(),i=Bl(n.cwd);for(let n of e)await t.deleteSkill(n),W(G(n)),delete r.skills[n],J.step(`Deleted \`${n}\`.`);Ul(r),Rl(i,e),J.blank(),J.dim("Other checkouts will clean up on their next `skilless install`."),J.dim(`Restore within 30 days at skilless.dev.`)})});function Od(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 kd(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=H.join(nl,e,`${r}-${t===`push`?`remote`:`local`}`);for(let e of n)Jc(H.join(i,e.path),e.contents);return i}async function Ad(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now();for(let a of t){let{name:t}=a,o=n.local.get(t);switch(a.type){case`noop`:o&&(n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i});break;case`push`:case`conflict-push`:if(!o)break;if(a.type===`conflict-push`){let n=await e.getSkill(t);n&&r.conflicts.push({name:t,kept:`push`,stashedAt:kd(t,`push`,n.files)})}await e.putSkill(t,o.files,o.editedAt),n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i};break;case`pull`:case`conflict-pull`:{let s=await e.getSkill(t);if(!s)break;a.type===`conflict-pull`&&o&&r.conflicts.push({name:t,kept:`pull`,stashedAt:kd(t,`pull`,o.files)}),wl(t,s.files,s.editedAt),n.state.skills[t]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i};break}case`delete-local`:if(!(n.yes||await Hu(`Delete \`${t}\`? It was removed elsewhere.`,!0))){r.skipped.push(t);continue}W(G(t)),delete n.state.skills[t];break;case`delete-remote`:if(!(n.yes||await Hu(`Delete \`${t}\` everywhere? It was removed here.`,!0))){r.skipped.push(t);continue}await e.deleteSkill(t),delete n.state.skills[t];break}r.actions.push(a)}return r}function jd(e){switch(e.type){case`push`:return`pushed ${e.name}`;case`pull`:return`pulled ${e.name}`;case`conflict-push`:return`${e.name} — kept your local copy`;case`conflict-pull`:return`${e.name} — kept the remote copy`;case`delete-local`:return`deleted ${e.name} locally`;case`delete-remote`:return`deleted ${e.name} everywhere`;default:return null}}const Md=X.extend({yes:B(),push:B().optional(),pull:B().optional()}),Nd=new b(`sync`).description(`Sync your library with skilless.dev, in both directions.`).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(Md,e);J.intro(Y),await $(async()=>{let e=sd(),n=new Map(El().map(e=>[e.name,e])),r=new Map((await e.listSkills()).map(e=>[e.name,e])),i=Hl(),a=await Ad(e,Od(n,r,i,t.push?`push`:t.pull?`pull`:void 0),{local:n,state:i,yes:t.yes});Ul(i);let o=a.actions.map(jd).filter(e=>e!==null);if(o.length===0){J.info(`Everything is already in sync.`);return}for(let e of o)J.step(e);if(a.conflicts.length>0){J.blank(),J.warn(`${a.conflicts.length} conflict(s) resolved by last write. Losing copies kept:`);for(let e of a.conflicts)J.dim(` ${e.stashedAt}`)}a.skipped.length>0&&(J.blank(),J.dim(`Skipped: ${a.skipped.join(`, `)}`))})});ie.name(qu).description(Ju).version(Y).addCommand(xd).addCommand(md).addCommand(gd).addCommand(ud).addCommand(Dd).addCommand(Cd).addCommand(Nd).addCommand(yd).addCommand(Td).parse();export{};
|
|
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})),Pd=v(((e,t)=>{t.exports=Sd()})),Fd=v(((e,t)=>{let n=_d();t.exports=class extends n{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||`no`,this.enabled=this.options.enabled||`yes`,await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e=``,t){switch(e.toLowerCase()){case` `:return this.toggle();case`1`:case`y`:case`t`:return this.enable();case`0`:case`n`:case`f`:return this.disable();default:return this.alert()}}format(){let e=e=>this.styles.primary.underline(e);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(` / `))}async render(){let{size:e}=this.state,t=await this.header(),n=await this.prefix(),r=await this.separator(),i=await this.message(),a=await this.format(),o=await this.error()||await this.hint(),s=await this.footer(),c=[n,i,r,a].join(` `);this.state.prompt=c,o&&!c.includes(o)&&(c+=` `+o),this.clear(e),this.write([t,c,s].filter(Boolean).join(`
|
|
113
|
+
`)),this.write(this.margin[2]),this.restore()}}})),Id=v(((e,t)=>{let n=dd();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)}}}})),Ld=v((e=>{let t=z(),n=(n,r)=>{t.defineExport(e,n,r),t.defineExport(e,n.toLowerCase(),r)};n(`AutoComplete`,()=>fd()),n(`BasicAuth`,()=>gd()),n(`Confirm`,()=>vd()),n(`Editable`,()=>yd()),n(`Form`,()=>md()),n(`Input`,()=>Sd()),n(`Invisible`,()=>Cd()),n(`List`,()=>wd()),n(`MultiSelect`,()=>Td()),n(`Numeral`,()=>Dd()),n(`Password`,()=>Od()),n(`Scale`,()=>kd()),n(`Select`,()=>dd()),n(`Snippet`,()=>jd()),n(`Sort`,()=>Md()),n(`Survey`,()=>Nd()),n(`Text`,()=>Pd()),n(`Toggle`,()=>Fd()),n(`Quiz`,()=>Id())})),Rd=v(((e,t)=>{t.exports={ArrayPrompt:ud(),AuthPrompt:hd(),BooleanPrompt:_d(),NumberPrompt:Ed(),StringPrompt:bd()}})),zd=te(v(((e,t)=>{let n=ne(`assert`),r=ne(`events`),i=z();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||cd()}static get prompts(){return Ld()}static get types(){return Rd()}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 Bd=(e=0)=>t=>`\u001B[${t+e}m`,Vd=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,Hd=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,B={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(B.modifier);const Ud=Object.keys(B.color),Wd=Object.keys(B.bgColor);[...Ud,...Wd];function Gd(){let e=new Map;for(let[t,n]of Object.entries(B)){for(let[t,r]of Object.entries(n))B[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=B[t],e.set(r[0],r[1]);Object.defineProperty(B,t,{value:n,enumerable:!1})}return Object.defineProperty(B,`codes`,{value:e,enumerable:!1}),B.color.close=`\x1B[39m`,B.bgColor.close=`\x1B[49m`,B.color.ansi=Bd(),B.color.ansi256=Vd(),B.color.ansi16m=Hd(),B.bgColor.ansi=Bd(10),B.bgColor.ansi256=Vd(10),B.bgColor.ansi16m=Hd(10),Object.defineProperties(B,{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=>B.rgbToAnsi256(...B.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)=>B.ansi256ToAnsi(B.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>B.ansi256ToAnsi(B.hexToAnsi256(e)),enumerable:!1}}),B}var Kd=Gd();function V(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:H}=o;let qd;V(`no-color`)||V(`no-colors`)||V(`color=false`)||V(`color=never`)?qd=0:(V(`color`)||V(`colors`)||V(`color=true`)||V(`color=always`))&&(qd=1);function Jd(){if(`FORCE_COLOR`in H)return H.FORCE_COLOR===`true`?1:H.FORCE_COLOR===`false`?0:H.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(H.FORCE_COLOR,10),3)}function Yd(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Xd(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Jd();r!==void 0&&(qd=r);let i=n?qd:r;if(i===0)return 0;if(n){if(V(`color=16m`)||V(`color=full`)||V(`color=truecolor`))return 3;if(V(`color=256`))return 2}if(`TF_BUILD`in H&&`AGENT_NAME`in H)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(H.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 H)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in H)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in H)||H.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in H)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(H.TEAMCITY_VERSION)?1:0;if(H.COLORTERM===`truecolor`||H.TERM===`xterm-kitty`||H.TERM===`xterm-ghostty`||H.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in H){let e=Number.parseInt((H.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(H.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(H.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(H.TERM)||`COLORTERM`in H?1:a}function Zd(e,t={}){return Yd(Xd(e,{streamIsTTY:e&&e.isTTY,...t}))}var Qd={stdout:Zd({isTTY:u.isatty(1)}),stderr:Zd({isTTY:u.isatty(2)})};function $d(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 ef(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
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
116
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:tf,stderr:nf}=Qd,rf=Symbol(`GENERATOR`),af=Symbol(`STYLER`),of=Symbol(`IS_EMPTY`),sf=[`ansi`,`ansi`,`ansi256`,`ansi16m`],cf=Object.create(null),lf=(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=tf?tf.level:0;e.level=t.level===void 0?n:t.level},uf=e=>{let t=(...e)=>e.join(` `);return lf(t,e),Object.setPrototypeOf(t,df.prototype),t};function df(e){return uf(e)}Object.setPrototypeOf(df.prototype,Function.prototype);for(let[e,t]of Object.entries(Kd))cf[e]={get(){let n=hf(this,mf(t.open,t.close,this[af]),this[of]);return Object.defineProperty(this,e,{value:n}),n}};cf.visible={get(){let e=hf(this,this[af],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const ff=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?Kd[n].ansi16m(...r):t===`ansi256`?Kd[n].ansi256(Kd.rgbToAnsi256(...r)):Kd[n].ansi(Kd.rgbToAnsi(...r)):e===`hex`?ff(`rgb`,t,n,...Kd.hexToRgb(...r)):Kd[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){cf[e]={get(){let{level:t}=this;return function(...n){let r=mf(ff(e,sf[t],`color`,...n),Kd.color.close,this[af]);return hf(this,r,this[of])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);cf[t]={get(){let{level:t}=this;return function(...n){let r=mf(ff(e,sf[t],`bgColor`,...n),Kd.bgColor.close,this[af]);return hf(this,r,this[of])}}}}const pf=Object.defineProperties(()=>{},{...cf,level:{enumerable:!0,get(){return this[rf].level},set(e){this[rf].level=e}}}),mf=(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}},hf=(e,t,n)=>{let r=(...e)=>gf(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,pf),r[rf]=e,r[af]=t,r[of]=n,r},gf=(e,t)=>{if(e.level<=0||!t)return e[of]?``:t;let n=e[af];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=$d(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
117
|
+
`);return a!==-1&&(t=ef(t,i,r,a)),r+t+i};Object.defineProperties(df.prototype,cf);const _f=df();df({level:nf?nf.level:0});var vf=_f;const yf=(e,t,n,r)=>{if(n===`length`||n===`prototype`||n===`arguments`||n===`caller`)return;let i=Object.getOwnPropertyDescriptor(e,n),a=Object.getOwnPropertyDescriptor(t,n);!bf(i,a)&&r||Object.defineProperty(e,n,a)},bf=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},xf=(e,t)=>{let n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Sf=(e,t)=>`/* Wrapped ${e}*/\n${t}`,Cf=Object.getOwnPropertyDescriptor(Function.prototype,`toString`),wf=Object.getOwnPropertyDescriptor(Function.prototype.toString,`name`),Tf=(e,t,n)=>{let r=n===``?``:`with ${n.trim()}() `,i=Sf.bind(null,r,t.toString());Object.defineProperty(i,`name`,wf);let{writable:a,enumerable:o,configurable:s}=Cf;Object.defineProperty(e,`toString`,{value:i,writable:a,enumerable:o,configurable:s})};function Ef(e,t,{ignoreNonConfigurable:n=!1}={}){let{name:r}=e;for(let r of Reflect.ownKeys(t))yf(e,t,r,n);return xf(e,t),Tf(e,t,r),e}const Df=new WeakMap,Of=(e,t={})=>{if(typeof e!=`function`)throw TypeError(`Expected a function`);let n,r=0,i=e.displayName||e.name||`<anonymous>`,a=function(...o){if(Df.set(a,++r),r===1)n=e.apply(this,o),e=void 0;else if(t.throw===!0)throw Error(`Function \`${i}\` can only be called once`);return n};return Ef(a,e),Df.set(a,r),a};Of.callCount=e=>{if(!Df.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Df.get(e)};var kf=Of;const Af=[];Af.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Af.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Af.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const jf=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Mf=Symbol.for(`signal-exit emitter`),Nf=globalThis,Pf=Object.defineProperty.bind(Object);var Ff=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Nf[Mf])return Nf[Mf];Pf(Nf,Mf,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},If=class{};const Lf=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var Rf=class extends If{onExit(){return()=>{}}load(){}unload(){}},zf=class extends If{#e=Bf.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Ff;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Af)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!jf(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Af)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Af.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return jf(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&jf(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}};const Bf=globalThis.process,{onExit:Vf,load:Hf,unload:Uf}=Lf(jf(Bf)?new zf(Bf):new Rf),Wf=o.stderr.isTTY?o.stderr:o.stdout.isTTY?o.stdout:void 0;var Gf=Wf?kf(()=>{Vf(()=>{Wf.write(`\x1B[?25h`)},{alwaysLast:!0})}):()=>{};let Kf=!1;const qf={};qf.show=(e=o.stderr)=>{e.isTTY&&(Kf=!1,e.write(`\x1B[?25h`))},qf.hide=(e=o.stderr)=>{e.isTTY&&(Gf(),Kf=!0,e.write(`\x1B[?25l`))},qf.toggle=(e,t)=>{e!==void 0&&(Kf=e),Kf?qf.show(t):qf.hide(t)};var Jf=qf,Yf={dots:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]},dots2:{interval:80,frames:[`⣾`,`⣽`,`⣻`,`⢿`,`⡿`,`⣟`,`⣯`,`⣷`]},dots3:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠞`,`⠖`,`⠦`,`⠴`,`⠲`,`⠳`,`⠓`]},dots4:{interval:80,frames:[`⠄`,`⠆`,`⠇`,`⠋`,`⠙`,`⠸`,`⠰`,`⠠`,`⠰`,`⠸`,`⠙`,`⠋`,`⠇`,`⠆`]},dots5:{interval:80,frames:[`⠋`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`]},dots6:{interval:80,frames:[`⠁`,`⠉`,`⠙`,`⠚`,`⠒`,`⠂`,`⠂`,`⠒`,`⠲`,`⠴`,`⠤`,`⠄`,`⠄`,`⠤`,`⠴`,`⠲`,`⠒`,`⠂`,`⠂`,`⠒`,`⠚`,`⠙`,`⠉`,`⠁`]},dots7:{interval:80,frames:[`⠈`,`⠉`,`⠋`,`⠓`,`⠒`,`⠐`,`⠐`,`⠒`,`⠖`,`⠦`,`⠤`,`⠠`,`⠠`,`⠤`,`⠦`,`⠖`,`⠒`,`⠐`,`⠐`,`⠒`,`⠓`,`⠋`,`⠉`,`⠈`]},dots8:{interval:80,frames:`⠁.⠁.⠉.⠙.⠚.⠒.⠂.⠂.⠒.⠲.⠴.⠤.⠄.⠄.⠤.⠠.⠠.⠤.⠦.⠖.⠒.⠐.⠐.⠒.⠓.⠋.⠉.⠈.⠈`.split(`.`)},dots9:{interval:80,frames:[`⢹`,`⢺`,`⢼`,`⣸`,`⣇`,`⡧`,`⡗`,`⡏`]},dots10:{interval:80,frames:[`⢄`,`⢂`,`⢁`,`⡁`,`⡈`,`⡐`,`⡠`]},dots11:{interval:100,frames:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`]},dots12:{interval:80,frames:`⢀⠀.⡀⠀.⠄⠀.⢂⠀.⡂⠀.⠅⠀.⢃⠀.⡃⠀.⠍⠀.⢋⠀.⡋⠀.⠍⠁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⢈⠩.⡀⢙.⠄⡙.⢂⠩.⡂⢘.⠅⡘.⢃⠨.⡃⢐.⠍⡐.⢋⠠.⡋⢀.⠍⡁.⢋⠁.⡋⠁.⠍⠉.⠋⠉.⠋⠉.⠉⠙.⠉⠙.⠉⠩.⠈⢙.⠈⡙.⠈⠩.⠀⢙.⠀⡙.⠀⠩.⠀⢘.⠀⡘.⠀⠨.⠀⢐.⠀⡐.⠀⠠.⠀⢀.⠀⡀`.split(`.`)},dots13:{interval:80,frames:[`⣼`,`⣹`,`⢻`,`⠿`,`⡟`,`⣏`,`⣧`,`⣶`]},dots14:{interval:80,frames:[`⠉⠉`,`⠈⠙`,`⠀⠹`,`⠀⢸`,`⠀⣰`,`⢀⣠`,`⣀⣀`,`⣄⡀`,`⣆⠀`,`⡇⠀`,`⠏⠀`,`⠋⠁`]},dots8Bit:{interval:80,frames:`⠀.⠁.⠂.⠃.⠄.⠅.⠆.⠇.⡀.⡁.⡂.⡃.⡄.⡅.⡆.⡇.⠈.⠉.⠊.⠋.⠌.⠍.⠎.⠏.⡈.⡉.⡊.⡋.⡌.⡍.⡎.⡏.⠐.⠑.⠒.⠓.⠔.⠕.⠖.⠗.⡐.⡑.⡒.⡓.⡔.⡕.⡖.⡗.⠘.⠙.⠚.⠛.⠜.⠝.⠞.⠟.⡘.⡙.⡚.⡛.⡜.⡝.⡞.⡟.⠠.⠡.⠢.⠣.⠤.⠥.⠦.⠧.⡠.⡡.⡢.⡣.⡤.⡥.⡦.⡧.⠨.⠩.⠪.⠫.⠬.⠭.⠮.⠯.⡨.⡩.⡪.⡫.⡬.⡭.⡮.⡯.⠰.⠱.⠲.⠳.⠴.⠵.⠶.⠷.⡰.⡱.⡲.⡳.⡴.⡵.⡶.⡷.⠸.⠹.⠺.⠻.⠼.⠽.⠾.⠿.⡸.⡹.⡺.⡻.⡼.⡽.⡾.⡿.⢀.⢁.⢂.⢃.⢄.⢅.⢆.⢇.⣀.⣁.⣂.⣃.⣄.⣅.⣆.⣇.⢈.⢉.⢊.⢋.⢌.⢍.⢎.⢏.⣈.⣉.⣊.⣋.⣌.⣍.⣎.⣏.⢐.⢑.⢒.⢓.⢔.⢕.⢖.⢗.⣐.⣑.⣒.⣓.⣔.⣕.⣖.⣗.⢘.⢙.⢚.⢛.⢜.⢝.⢞.⢟.⣘.⣙.⣚.⣛.⣜.⣝.⣞.⣟.⢠.⢡.⢢.⢣.⢤.⢥.⢦.⢧.⣠.⣡.⣢.⣣.⣤.⣥.⣦.⣧.⢨.⢩.⢪.⢫.⢬.⢭.⢮.⢯.⣨.⣩.⣪.⣫.⣬.⣭.⣮.⣯.⢰.⢱.⢲.⢳.⢴.⢵.⢶.⢷.⣰.⣱.⣲.⣳.⣴.⣵.⣶.⣷.⢸.⢹.⢺.⢻.⢼.⢽.⢾.⢿.⣸.⣹.⣺.⣻.⣼.⣽.⣾.⣿`.split(`.`)},dotsCircle:{interval:80,frames:[`⢎ `,`⠎⠁`,`⠊⠑`,`⠈⠱`,` ⡱`,`⢀⡰`,`⢄⡠`,`⢆⡀`]},sand:{interval:80,frames:`⠁.⠂.⠄.⡀.⡈.⡐.⡠.⣀.⣁.⣂.⣄.⣌.⣔.⣤.⣥.⣦.⣮.⣶.⣷.⣿.⡿.⠿.⢟.⠟.⡛.⠛.⠫.⢋.⠋.⠍.⡉.⠉.⠑.⠡.⢁`.split(`.`)},line:{interval:130,frames:[`-`,`\\`,`|`,`/`]},line2:{interval:100,frames:[`⠂`,`-`,`–`,`—`,`–`,`-`]},rollingLine:{interval:80,frames:[`/ `,` - `,` \\ `,` |`,` |`,` \\ `,` - `,`/ `]},pipe:{interval:100,frames:[`┤`,`┘`,`┴`,`└`,`├`,`┌`,`┬`,`┐`]},simpleDots:{interval:400,frames:[`. `,`.. `,`...`,` `]},simpleDotsScrolling:{interval:200,frames:[`. `,`.. `,`...`,` ..`,` .`,` `]},star:{interval:70,frames:[`✶`,`✸`,`✹`,`✺`,`✹`,`✷`]},star2:{interval:80,frames:[`+`,`x`,`*`]},flip:{interval:70,frames:[`_`,`_`,`_`,`-`,"`","`",`'`,`´`,`-`,`_`,`_`,`_`]},hamburger:{interval:100,frames:[`☱`,`☲`,`☴`]},growVertical:{interval:120,frames:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`▆`,`▅`,`▄`,`▃`]},growHorizontal:{interval:120,frames:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`▊`,`▋`,`▌`,`▍`,`▎`]},balloon:{interval:140,frames:[` `,`.`,`o`,`O`,`@`,`*`,` `]},balloon2:{interval:120,frames:[`.`,`o`,`O`,`°`,`O`,`o`,`.`]},noise:{interval:100,frames:[`▓`,`▒`,`░`]},bounce:{interval:120,frames:[`⠁`,`⠂`,`⠄`,`⠂`]},boxBounce:{interval:120,frames:[`▖`,`▘`,`▝`,`▗`]},boxBounce2:{interval:100,frames:[`▌`,`▀`,`▐`,`▄`]},triangle:{interval:50,frames:[`◢`,`◣`,`◤`,`◥`]},binary:{interval:80,frames:[`010010`,`001100`,`100101`,`111010`,`111101`,`010111`,`101011`,`111000`,`110011`,`110101`]},arc:{interval:100,frames:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`]},circle:{interval:120,frames:[`◡`,`⊙`,`◠`]},squareCorners:{interval:180,frames:[`◰`,`◳`,`◲`,`◱`]},circleQuarters:{interval:120,frames:[`◴`,`◷`,`◶`,`◵`]},circleHalves:{interval:50,frames:[`◐`,`◓`,`◑`,`◒`]},squish:{interval:100,frames:[`╫`,`╪`]},toggle:{interval:250,frames:[`⊶`,`⊷`]},toggle2:{interval:80,frames:[`▫`,`▪`]},toggle3:{interval:120,frames:[`□`,`■`]},toggle4:{interval:100,frames:[`■`,`□`,`▪`,`▫`]},toggle5:{interval:100,frames:[`▮`,`▯`]},toggle6:{interval:300,frames:[`ဝ`,`၀`]},toggle7:{interval:80,frames:[`⦾`,`⦿`]},toggle8:{interval:100,frames:[`◍`,`◌`]},toggle9:{interval:100,frames:[`◉`,`◎`]},toggle10:{interval:100,frames:[`㊂`,`㊀`,`㊁`]},toggle11:{interval:50,frames:[`⧇`,`⧆`]},toggle12:{interval:120,frames:[`☗`,`☖`]},toggle13:{interval:80,frames:[`=`,`*`,`-`]},arrow:{interval:100,frames:[`←`,`↖`,`↑`,`↗`,`→`,`↘`,`↓`,`↙`]},arrow2:{interval:80,frames:[`⬆️ `,`↗️ `,`➡️ `,`↘️ `,`⬇️ `,`↙️ `,`⬅️ `,`↖️ `]},arrow3:{interval:120,frames:[`▹▹▹▹▹`,`▸▹▹▹▹`,`▹▸▹▹▹`,`▹▹▸▹▹`,`▹▹▹▸▹`,`▹▹▹▹▸`]},bouncingBar:{interval:80,frames:[`[ ]`,`[= ]`,`[== ]`,`[=== ]`,`[====]`,`[ ===]`,`[ ==]`,`[ =]`,`[ ]`,`[ =]`,`[ ==]`,`[ ===]`,`[====]`,`[=== ]`,`[== ]`,`[= ]`]},bouncingBall:{interval:80,frames:[`( ● )`,`( ● )`,`( ● )`,`( ● )`,`( ●)`,`( ● )`,`( ● )`,`( ● )`,`( ● )`,`(● )`]},smiley:{interval:200,frames:[`😄 `,`😝 `]},monkey:{interval:300,frames:[`🙈 `,`🙈 `,`🙉 `,`🙊 `]},hearts:{interval:100,frames:[`💛 `,`💙 `,`💜 `,`💚 `,`💗 `]},clock:{interval:100,frames:[`🕛 `,`🕐 `,`🕑 `,`🕒 `,`🕓 `,`🕔 `,`🕕 `,`🕖 `,`🕗 `,`🕘 `,`🕙 `,`🕚 `]},earth:{interval:180,frames:[`🌍 `,`🌎 `,`🌏 `]},material:{interval:17,frames:`█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁.███████▁▁▁▁▁▁▁▁▁▁▁▁▁.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.██████████▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.█████████████▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁██████████████▁▁▁▁.▁▁▁██████████████▁▁▁.▁▁▁▁█████████████▁▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁██████████████▁▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁██████████████▁.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁██████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁█████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁████████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁███████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁██████████.▁▁▁▁▁▁▁▁▁▁▁▁████████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.██████▁▁▁▁▁▁▁▁▁▁▁▁▁█.████████▁▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.█████████▁▁▁▁▁▁▁▁▁▁▁.███████████▁▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.████████████▁▁▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.██████████████▁▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁██████████████▁▁▁▁▁.▁▁▁█████████████▁▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁████████████▁▁▁.▁▁▁▁▁▁███████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁█████████▁▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁█████████▁▁.▁▁▁▁▁▁▁▁▁▁█████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁████████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁███████▁.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁███████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁.▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁`.split(`.`)},moon:{interval:80,frames:[`🌑 `,`🌒 `,`🌓 `,`🌔 `,`🌕 `,`🌖 `,`🌗 `,`🌘 `]},runner:{interval:140,frames:[`🚶 `,`🏃 `]},pong:{interval:80,frames:`▐⠂ ▌.▐⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂▌.▐ ⠠▌.▐ ⡀▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐ ⠠ ▌.▐ ⠂ ▌.▐ ⠈ ▌.▐ ⠂ ▌.▐ ⠠ ▌.▐ ⡀ ▌.▐⠠ ▌`.split(`.`)},shark:{interval:120,frames:`▐|\\____________▌.▐_|\\___________▌.▐__|\\__________▌.▐___|\\_________▌.▐____|\\________▌.▐_____|\\_______▌.▐______|\\______▌.▐_______|\\_____▌.▐________|\\____▌.▐_________|\\___▌.▐__________|\\__▌.▐___________|\\_▌.▐____________|\\▌.▐____________/|▌.▐___________/|_▌.▐__________/|__▌.▐_________/|___▌.▐________/|____▌.▐_______/|_____▌.▐______/|______▌.▐_____/|_______▌.▐____/|________▌.▐___/|_________▌.▐__/|__________▌.▐_/|___________▌.▐/|____________▌`.split(`.`)},dqpb:{interval:100,frames:[`d`,`q`,`p`,`b`]},weather:{interval:100,frames:[`☀️ `,`☀️ `,`☀️ `,`🌤 `,`⛅️ `,`🌥 `,`☁️ `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`🌧 `,`🌨 `,`⛈ `,`🌨 `,`🌧 `,`🌨 `,`☁️ `,`🌥 `,`⛅️ `,`🌤 `,`☀️ `,`☀️ `]},christmas:{interval:400,frames:[`🌲`,`🎄`]},grenade:{interval:80,frames:[`، `,`′ `,` ´ `,` ‾ `,` ⸌`,` ⸊`,` |`,` ⁎`,` ⁕`,` ෴ `,` ⁓`,` `,` `,` `]},point:{interval:125,frames:[`∙∙∙`,`●∙∙`,`∙●∙`,`∙∙●`,`∙∙∙`]},layer:{interval:150,frames:[`-`,`=`,`≡`]},betaWave:{interval:80,frames:[`ρββββββ`,`βρβββββ`,`ββρββββ`,`βββρβββ`,`ββββρββ`,`βββββρβ`,`ββββββρ`]},fingerDance:{interval:160,frames:[`🤘 `,`🤟 `,`🖖 `,`✋ `,`🤚 `,`👆 `]},fistBump:{interval:80,frames:[`🤜 🤛 `,`🤜 🤛 `,`🤜 🤛 `,` 🤜 🤛 `,` 🤜🤛 `,` 🤜✨🤛 `,`🤜 ✨ 🤛 `]},soccerHeader:{interval:80,frames:[` 🧑⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `,`🧑 ⚽️ 🧑 `]},mindblown:{interval:160,frames:[`😐 `,`😐 `,`😮 `,`😮 `,`😦 `,`😦 `,`😧 `,`😧 `,`🤯 `,`💥 `,`✨ `,` `,` `,` `]},speaker:{interval:160,frames:[`🔈 `,`🔉 `,`🔊 `,`🔉 `]},orangePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `]},bluePulse:{interval:100,frames:[`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},orangeBluePulse:{interval:100,frames:[`🔸 `,`🔶 `,`🟠 `,`🟠 `,`🔶 `,`🔹 `,`🔷 `,`🔵 `,`🔵 `,`🔷 `]},timeTravel:{interval:100,frames:[`🕛 `,`🕚 `,`🕙 `,`🕘 `,`🕗 `,`🕖 `,`🕕 `,`🕔 `,`🕓 `,`🕒 `,`🕑 `,`🕐 `]},aesthetic:{interval:80,frames:[`▰▱▱▱▱▱▱`,`▰▰▱▱▱▱▱`,`▰▰▰▱▱▱▱`,`▰▰▰▰▱▱▱`,`▰▰▰▰▰▱▱`,`▰▰▰▰▰▰▱`,`▰▰▰▰▰▰▰`,`▰▱▱▱▱▱▱`]},dwarfFortress:{interval:80,frames:` ██████£££ .☺██████£££ .☺██████£££ .☺▓█████£££ .☺▓█████£££ .☺▒█████£££ .☺▒█████£££ .☺░█████£££ .☺░█████£££ .☺ █████£££ . ☺█████£££ . ☺█████£££ . ☺▓████£££ . ☺▓████£££ . ☺▒████£££ . ☺▒████£££ . ☺░████£££ . ☺░████£££ . ☺ ████£££ . ☺████£££ . ☺████£££ . ☺▓███£££ . ☺▓███£££ . ☺▒███£££ . ☺▒███£££ . ☺░███£££ . ☺░███£££ . ☺ ███£££ . ☺███£££ . ☺███£££ . ☺▓██£££ . ☺▓██£££ . ☺▒██£££ . ☺▒██£££ . ☺░██£££ . ☺░██£££ . ☺ ██£££ . ☺██£££ . ☺██£££ . ☺▓█£££ . ☺▓█£££ . ☺▒█£££ . ☺▒█£££ . ☺░█£££ . ☺░█£££ . ☺ █£££ . ☺█£££ . ☺█£££ . ☺▓£££ . ☺▓£££ . ☺▒£££ . ☺▒£££ . ☺░£££ . ☺░£££ . ☺ £££ . ☺£££ . ☺£££ . ☺▓££ . ☺▓££ . ☺▒££ . ☺▒££ . ☺░££ . ☺░££ . ☺ ££ . ☺££ . ☺££ . ☺▓£ . ☺▓£ . ☺▒£ . ☺▒£ . ☺░£ . ☺░£ . ☺ £ . ☺£ . ☺£ . ☺▓ . ☺▓ . ☺▒ . ☺▒ . ☺░ . ☺░ . ☺ . ☺ &. ☺ ☼&. ☺ ☼ &. ☺☼ &. ☺☼ & . ‼ & . ☺ & . ‼ & . ☺ & . ‼ & . ☺ & .‼ & . & . & . & ░ . & ▒ . & ▓ . & £ . & ░£ . & ▒£ . & ▓£ . & ££ . & ░££ . & ▒££ .& ▓££ .& £££ . ░£££ . ▒£££ . ▓£££ . █£££ . ░█£££ . ▒█£££ . ▓█£££ . ██£££ . ░██£££ . ▒██£££ . ▓██£££ . ███£££ . ░███£££ . ▒███£££ . ▓███£££ . ████£££ . ░████£££ . ▒████£££ . ▓████£££ . █████£££ . ░█████£££ . ▒█████£££ . ▓█████£££ . ██████£££ . ██████£££ `.split(`.`)},fish:{interval:80,frames:`~~~~~~~~~~~~~~~~~~~~.> ~~~~~~~~~~~~~~~~~~.º> ~~~~~~~~~~~~~~~~~.(º> ~~~~~~~~~~~~~~~~.((º> ~~~~~~~~~~~~~~~.<((º> ~~~~~~~~~~~~~~.><((º> ~~~~~~~~~~~~~. ><((º> ~~~~~~~~~~~~.~ ><((º> ~~~~~~~~~~~.~~ <>((º> ~~~~~~~~~~.~~~ ><((º> ~~~~~~~~~.~~~~ <>((º> ~~~~~~~~.~~~~~ ><((º> ~~~~~~~.~~~~~~ <>((º> ~~~~~~.~~~~~~~ ><((º> ~~~~~.~~~~~~~~ <>((º> ~~~~.~~~~~~~~~ ><((º> ~~~.~~~~~~~~~~ <>((º> ~~.~~~~~~~~~~~ ><((º> ~.~~~~~~~~~~~~ <>((º> .~~~~~~~~~~~~~ ><((º>.~~~~~~~~~~~~~~ <>((º.~~~~~~~~~~~~~~~ ><((.~~~~~~~~~~~~~~~~ <>(.~~~~~~~~~~~~~~~~~ ><.~~~~~~~~~~~~~~~~~~ <.~~~~~~~~~~~~~~~~~~~~`.split(`.`)}};const Xf=u?.WriteStream?.prototype?.hasColors?.()??!1,U=(e,t)=>{if(!Xf)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}};U(0,0),U(1,22),U(2,22),U(3,23),U(4,24),U(`4:2`,24),U(`4:3`,24),U(`4:4`,24),U(`4:5`,24),U(53,55),U(7,27),U(8,28),U(9,29),U(30,39);const Zf=U(31,39),Qf=U(32,39),$f=U(33,39),ep=U(34,39);U(35,39),U(36,39),U(37,39),U(90,39),U(40,49),U(41,49),U(42,49),U(43,49),U(44,49),U(45,49),U(46,49),U(47,49),U(100,49),U(91,39),U(92,39),U(93,39),U(94,39),U(95,39),U(96,39),U(97,39),U(101,49),U(102,49),U(103,49),U(104,49),U(105,49),U(106,49),U(107,49),U(`58;5;0`,59),U(`58;5;1`,59),U(`58;5;2`,59),U(`58;5;3`,59),U(`58;5;4`,59),U(`58;5;5`,59),U(`58;5;6`,59),U(`58;5;7`,59),U(`58;5;8`,59),U(`58;5;9`,59),U(`58;5;10`,59),U(`58;5;11`,59),U(`58;5;12`,59),U(`58;5;13`,59),U(`58;5;14`,59),U(`58;5;15`,59);function tp(){let{env:e}=o,{TERM:t,TERM_PROGRAM:n}=e;return o.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const np=tp(),rp=ep(np?`ℹ`:`i`),ip=Qf(np?`✔`:`√`),ap=$f(np?`⚠`:`‼`),op=Zf(np?`✖`:`×`);function sp({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const cp=sp();function lp(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(cp,``)}const up=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],dp=[12288,12288,65281,65376,65504,65510],fp=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141],pp=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},mp=19968,[hp,gp]=_p(fp);function _p(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(mp>=i&&mp<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}const vp=e=>e<161||e>1114109?!1:pp(up,e),yp=e=>e<12288||e>65510?!1:pp(dp,e),bp=e=>e>=hp&&e<=gp?!0:e<4352||e>262141?!1:pp(fp,e);function xp(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Sp(e,{ambiguousAsWide:t=!1}={}){return xp(e),yp(e)||bp(e)||t&&vp(e)?2:1}const Cp=new Intl.Segmenter,wp=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Tp=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Ep=/\p{Spacing_Mark}/v,Dp=/^\p{RGI_Emoji}$/v,Op=/^[\d#*]\u20E3$/,kp=/\p{Extended_Pictographic}/gu;function Ap(e){if(e.length>50)return!1;if(Op.test(e))return!0;if(e.includes(``)){let t=e.match(kp);return t!==null&&t.length>=2}return!1}function jp(e){return e.replace(Tp,``)}function Mp(e){return wp.test(e)}function Np(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Pp(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Fp(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Ip(e){return Np(e)||Pp(e)||Fp(e)}function Lp(e,t){let n=[];for(let t of e)wp.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!Ip(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=Sp(n[i],t);return r}if(Np(i)&&Pp(n[e+1])){r+=2,e+=Fp(n[e+2])?2:1;continue}r+=Sp(i,t)}return r}function Rp(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(Ep.test(i)||i>=``&&i<=``)&&(n+=Sp(i.codePointAt(0),t))}return n}function zp(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(``))&&(i=lp(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of Cp.segment(i)){if(Mp(e))continue;if(Dp.test(e)||Ap(e)){a+=2;continue}let t=jp(e),n=Lp(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=Sp(r,o),a+=Rp(t,o)}return a}function Bp({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!==`dumb`&&!(`CI`in process.env))}const Vp=new class{#e=0;#t;#n=!1;#r=!1;#i=e=>{e?.length&&(typeof e==`string`?e.codePointAt(0):e[0])===3&&o.kill(o.pid,`SIGINT`)};start(){this.#e++,this.#e===1&&this.#a()}stop(){this.#e!==0&&--this.#e===0&&this.#o()}#a(){let{stdin:e}=o;if(o.platform===`win32`||!e?.isTTY||typeof e.setRawMode!=`function`){this.#t=void 0;return}this.#t=e,this.#n=e.isPaused(),this.#r=!!e.isRaw,e.setRawMode(!0),e.prependListener(`data`,this.#i),this.#n&&e.resume()}#o(){if(!this.#t)return;let e=this.#t;e.off(`data`,this.#i),e.isTTY&&e.setRawMode?.(this.#r),this.#n&&e.pause(),this.#t=void 0,this.#n=!1,this.#r=!1}};var Hp=Object.freeze(Vp);const Up=new Map,Wp=new Set([`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`gray`]);var Gp=class{#e=0;#t=-1;#n=0;#r;#i;#a;#o;#s=new Map;#c=!1;#l;#u;#d=!1;#f;#p(e){this.#c=!0;try{return e()}finally{this.#c=!1}}#m(){this.isSpinning&&this.render()}#h(e,t){if(e==null)return``;if(typeof e==`string`)return e;if(Buffer.isBuffer(e)||ArrayBuffer.isView(e)){let n=typeof t==`string`&&t&&t!==`buffer`?t:`utf8`;return Buffer.from(e).toString(n)}return String(e)}#g(e){if(!e)return!1;let t=e.at(-1);return t===`
|
|
118
|
+
`||t===`\r`}#_(){this.#u||(this.#u=setTimeout(()=>{this.#u=void 0,this.isSpinning&&this.#m()},200),typeof this.#u?.unref==`function`&&this.#u.unref())}#v(){this.#u&&=(clearTimeout(this.#u),void 0)}#y(e,t,n,r){let i=this.#x(n,` `),a=typeof t==`string`?(e?` `:``)+t:``,o=this.#S(r,` `);return i+e+a+o}constructor(e){if(typeof e==`string`&&(e={text:e}),this.#r={color:`cyan`,stream:o.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#r.color,this.#a=this.#r.stream,typeof this.#r.isEnabled!=`boolean`&&(this.#r.isEnabled=Bp({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(!tp())this.#i=Yf.line;else if(e===void 0)this.#i=Yf.dots;else if(e!==`default`&&Yf[e])this.#i=Yf[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 l(e).split(`
|
|
119
|
+
`))n+=Math.max(1,Math.ceil(zp(r)/t));return n}get color(){return this.#f}set color(e){if(e!==void 0&&e!==!1&&!Wp.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=vf[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;Up.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),Up.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,Up.get(e)===this&&Up.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
|
+
`),t=a-1;n=[...e.slice(0,t),`... (content truncated to fit terminal)`].join(`
|
|
121
|
+
`)}this.#p(()=>this.#a.write(n))===!1&&this.#a.isTTY&&(this.#l=()=>{this.#l=void 0,this.#m()},this.#a.once(`drain`,this.#l)),this.#e=this.#C(n,r)}finally{t&&this.#p(()=>this.#a.write(`\x1B[?2026l`))}return this}start(e){if(e!==void 0&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let e=this.text?`-`:``,t=` `.repeat(this.#r.indent)+this.#y(e,this.text,this.#r.prefixText,this.#r.suffixText);return t.trim()!==``&&this.#p(()=>this.#a.write(t+`
|
|
122
|
+
`)),this}return this.isSpinning?this:(this.#r.hideCursor&&Jf.hide(this.#a),this.#r.discardStdin&&o.stdin.isTTY&&(Hp.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&&Jf.show(this.#a)),this.#d&&(this.#d=!1,Hp.stop()),this}succeed(e){return this.stopAndPersist({symbol:ip,text:e})}fail(e){return this.stopAndPersist({symbol:op,text:e})}warn(e){return this.stopAndPersist({symbol:ap,text:e})}info(e){return this.stopAndPersist({symbol:rp,text:e})}stopAndPersist(e={}){if(this.isSilent)return this;let t=e.symbol??` `,n=e.text??this.text,r=e.prefixText??this.#r.prefixText,i=e.suffixText??this.#r.suffixText,a=this.#y(t,n,r,i)+`
|
|
123
|
+
`;return this.stop(),this.#p(()=>this.#a.write(a)),this}};function Kp(e){return new Gp(e)}var W=te(v(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}))(),1);const qp=zd.default.prompt;function Jp(){process.stdout.write(`\r\x1B[0J`),process.stdin.isTTY&&process.stdin.setRawMode(!1),Zp()}const Yp={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 Xp(e,t){im();try{return await qp({...e,cancel:Jp})}catch{return Zp(),t}finally{am()}}function Zp(){im(),process.stdout.write(`${W.default.yellow(`!`)} Cancelled\n`),process.exit(1)}async function Qp(e,t=!1){return(await Xp({type:`confirm`,name:`value`,message:e,initial:t},{value:!1})).value}const $p=!!(process.stdin.isTTY&&process.stdout.isTTY);async function em(e,t={}){return(await Xp({type:`input`,name:`value`,message:e,initial:t.initial,validate:t.validate?e=>t.validate((e??``).trim()):void 0},{value:``})).value.trim()}async function tm(e,t){return t.length===0?[]:(await Xp({type:`multiselect`,name:`value`,message:e,choices:t,...Yp},{value:[]})).value}async function nm(e,t,n){let r=n?t.findIndex(e=>e.name===n):-1;return(await Xp({type:`select`,name:`value`,message:e,choices:t,initial:r===-1?0:r,...Yp},{value:``})).value}let G=null;function rm(e){let t=e.step%3+1;return`${e.message}${`.`.repeat(t)}${` `.repeat(3-t)}`}function im(){G?.ora.isSpinning&&G.ora.stop()}function am(){G&&!G.ora.isSpinning&&G.ora.start(rm(G))}async function K(e,t){if(!process.stdout.isTTY||!process.stdout.columns)return t();if(G){let n=G.message;G.message=e;try{return await t()}finally{G&&(G.message=n)}}let n={ora:Kp({stream:process.stdout,color:`cyan`,discardStdin:!1}),message:e,step:0,dots:setInterval(()=>{n.step++,n.ora.text=rm(n)},300)};G=n,am();try{return await t()}finally{clearInterval(n.dots),im(),G=null}}function om(e,t){let n=G?.ora.isSpinning===!0;n&&G.ora.clear(),e.write(t),n&&G.ora.render()}const q={intro(e){om(process.stdout,`${W.default.bgWhite(W.default.black(` skilless `))}${W.default.gray(` v${e}`)}\n\n`)},info(e){om(process.stdout,`${W.default.blue(`·`)} ${e}\n`)},step(e){om(process.stdout,`${W.default.green(`✓`)} ${e}\n`)},warn(e){om(process.stdout,`${W.default.yellow(`!`)} ${e}\n`)},error(e){om(process.stderr,`${W.default.red(`✖`)} ${e}\n`)},dim(e){om(process.stdout,`${W.default.gray(e)}\n`)},blank(){om(process.stdout,`
|
|
124
|
+
`)}},sm=Tc({path:j(),contents:j()}),cm=Tc({url:j(),ref:j().optional(),path:j(),hash:j()}),lm=Tc({name:j(),contentHash:j(),editedAt:mc(),updatedAt:mc(),global:N(),source:cm.nullable().default(null)}),um=lm.extend({files:Cc(sm)}),dm=Tc({bound:Cc(j()),unknown:Cc(j())}),fm=Tc({error:j(),message:j().optional()}),pm=new Set([502,503,504]);function mm(e){try{return JSON.parse(e)}catch{return null}}var hm=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 rl(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(pm.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 rl(this.#t,r)}async#i(e,t,n,r){let i=await this.#r(e,t,r);if(i.status===401)throw new tl;if(i.status<200||i.status>=300){let n=fm.safeParse(mm(i.text));throw new P(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(mm(i.text));if(!a.success)throw new P(`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`,Cc(lm))}async getSkill(e){return await this.#i(`GET`,`/skills/${encodeURIComponent(e)}`,um.nullable())}async putSkill(e,t,n){return await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}`,lm,{files:t,editedAt:n})}async setGlobal(e,t){await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}/global`,yc(),{global:t})}async setSource(e,t){await this.#i(`PUT`,`/skills/${encodeURIComponent(e)}/source`,yc(),{source:t})}async deleteSkill(e){await this.#i(`DELETE`,`/skills/${encodeURIComponent(e)}`,yc())}async getBindings(e){return await this.#i(`GET`,`/projects/skills?key=${encodeURIComponent(e)}`,Cc(um))}async setBindings(e,t){return await this.#i(`PUT`,`/projects/skills`,dm,{key:e,names:t})}};function gm(){return process.env.SKILLESS_TOKEN||cl(Cl,{}).token}function _m(e){ll(Cl,{token:e},384)}function vm(){I(Cl)}function ym(){return(process.env.SKILLESS_API_URL??`https://skilless.dev`).replace(/\/$/,``)}var bm=class{api;#e=null;constructor(){let e=gm();this.api=e?new hm(e,ym()):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 rl||e instanceof tl){this.#e=e;return}throw e}}report(){if(this.#e){if(q.blank(),this.#e instanceof rl){q.warn(`Couldn't reach ${this.#e.url}. Run \`skilless sync\` to sync your skills with the cloud.`);return}q.warn(`Your sign-in was rejected, so this only changed this machine.`),q.dim("Run `skilless auth` to sign in again, then `skilless sync` to sync your skills.")}}};function xm(e){return e.includes(`/`)||e.includes(`:`)}function Sm(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 P(`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)?Cm(t,n):/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||/^[^@/\s]+@[^:/\s]+:/.test(t)?{url:t,ref:n}:wm(t,n),a.subpath&&=Tm(a.subpath),{...a,label:ml(a.url)??a.url}}function Cm(e,t){let n;try{n=new URL(e)}catch{throw new P(`${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 wm(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 P(`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 Tm(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);if(t.includes(`..`))throw new P(`${e} reaches outside the repository.`);return t.join(`/`)}async function Em(e,t,r){let i=a.mkdtempSync(b.join(s.tmpdir(),`skilless-`));try{let o=[`clone`,`--depth`,`1`,`--quiet`];e.ref&&o.push(`--branch`,e.ref),o.push(`--`,e.url,i);try{await K(`Cloning ${e.label}${e.ref?`#${e.ref}`:``}`,()=>Dm(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 Om(e,t);I(i),a.mkdirSync(i);try{n(`git`,o,{stdio:[`inherit`,`ignore`,`pipe`],encoding:`utf8`})}catch(t){throw Om(e,t)}}return await t(i)}finally{I(i)}}function Dm(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 Om(e,t){let n=t.stderr?.trim();return new P(`Couldn't clone ${e.label}.`,{suggestion:n||`Check the address, and that you have access to the repository.`,cause:t})}const km=new Set([`node_modules`,`.git`,`dist`,`build`,`__pycache__`]),Am=[`skills`,`skills/.curated`,`skills/.experimental`,`skills/.system`,`.agents/skills`,`.claude/skills`];function jm(e,t){let n=t?b.join(e,t):e;if(!F(n))throw new P(`${t} does not exist in the repository.`);let r=new Map,i=e=>{let t=Fm(e);r.has(t.name)||r.set(t.name,t)};if(Nm(n))return i(n),[...r.values()];Pm(n,1,i);for(let e of Am)Pm(b.join(n,e),3,i);return r.size===0&&Pm(n,5,i),[...r.values()].sort((e,t)=>e.name.localeCompare(t.name))}function Mm(e,t,n){try{let n=Tm(t);if(Nm(b.join(e,n)))return{dir:b.join(e,n),path:n}}catch{}let r=jm(e).find(e=>e.name===n);return r?{dir:r.dir,path:b.relative(e,r.dir)}:null}function Nm(e){return a.existsSync(b.join(e,zl))}function Pm(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()||km.has(i.name))continue;let r=b.join(e,i.name);Nm(r)?n(r):t>1&&Pm(r,t-1,n)}}function Fm(e){let t=Im(a.readFileSync(b.join(e,zl),`utf8`)),n=t.name?.toLowerCase().replace(/[\s_]+/g,`-`);return{name:n&&Ul(n)?n:b.basename(e).toLowerCase(),dir:e,description:t.description}}function Im(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 Lm=`skilless`,Rm=`Author skills once, sync them everywhere, install them per project.`;const J=`0.0.2`,zm=Lm,Bm=Rm,Vm=`SKILLESS_TRACE`,Y=Tc({cwd:j()}),X={cwd:new _e(`--cwd <path>`,`The current working directory.`).default(process.cwd()),yes:new _e(`-y, --yes`,`Skip confirmation prompts.`).default(!1),project:new _e(`--project <key>`,`Override the project key. Defaults to the normalized git remote.`)};function Z(e,t){let n=e.safeParse(t);return n.success?n.data:Hm(new P(`Invalid options.`,{suggestion:n.error.issues.map(e=>` ${e.message}`).join(`
|
|
125
|
+
`)}))}function Hm(e){process.env[Vm]===`1`?console.trace(e):q.error(W.default.red(e.toString())),process.exit(1)}async function Q(e){try{return await e()}catch(e){return e instanceof P?Hm(e):Hm(new P(e instanceof Error?e.message:String(e),{suggestion:`Run with ${Vm}=1 for a stack trace.`,cause:e}))}}function Um(){let e=gm();if(!e)throw new tl;return new hm(e,ym())}function Wm(e,t){if(t)return t;let n=hl(e);if(!n)throw new nl;return n}const Gm=`~/.agents/skills`;function Km(e){let t=b.normalize(s.homedir());return e===t||e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}async function qm(e,t={}){for(let n of e.skipped){if(n.reason===`tracked`){q.warn(`\`${n.name}\` is tracked by git here, so it was left alone.`);continue}let e=(n.occupied?.paths??[]).map(Km).join(` and `);if(!(t.yes||$p&&await Qp(`Overwrite ${e}?`,!1))){$p?q.dim(`Kept ${e}, so ${n.name} is not linked there.`):(q.warn(`Skipped ${n.name}: ${e} was not made by skilless.`),q.dim(` Run this in a terminal to overwrite it, or pass --yes.`));continue}pu(n,{copy:bu(t.copy)}),q.step(`Overwrote ${e}.`)}for(let t of e.missing??[])q.warn(`${t} is not on this machine yet, so it will be linked on the next sync.`)}const Jm=Y.extend({project:j().optional(),copy:N().optional(),global:N().optional(),notGlobal:N().optional(),overwrite:N(),yes:N()}),Ym=new y(`add`).description(`Add skills to this project, from your library or from a git repository.`).argument(`[skills...]`,"Skills to add, or a repo (`owner/repo` or any git URL) then the skills to take from it. Omit the skills to pick from a list.").option(`-g, --global`,`Make these skills global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has them, including cloud agents.`).option(`--not-global`,`Stop treating these skills as global, and unlink them from your user-level skills.`).option(`--copy`,`Write real files instead of symlinking into the store.`).option(`--overwrite`,`From a repo: replace library skills of the same name.`,!1).addOption(X.yes).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Jm,t);q.intro(J),await Q(async()=>{let t=new bm,[r,...i]=e;if(r&&xm(r)){await Qm(t,Sm(r),i,n);return}let a=e.find(xm);if(a)throw new P(`${a} is a repository, not a skill.`,{suggestion:`Name the repository first: \`skilless add ${a} <skills...>\`.`});let{entries:o,live:s}=await K(`Loading your library`,async()=>(await L(t),R(t))),c=e=>s||e.local!==null,l=e=>{let t=o.filter(t=>e.includes(t.name)&&!c(t)).map(e=>e.name);if(t.length!==0)throw new P(`${t.join(`, `)} ${t.length===1?`is`:`are`} not on this machine, and the server can't be reached to fetch ${t.length===1?`it`:`them`}.`,{suggestion:"Run `skilless sync` once you are back online, then try again."})},u=new Set(o.map(e=>e.name)),d=e.filter(e=>!u.has(e));if(d.length>0)throw new P(`Not in your library: ${d.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(n.global||n.notGlobal){let r=n.global===!0,i=e;if(i.length===0){let e=o.filter(e=>e.global!==r&&(!r||c(e)));if(e.length===0){q.info(r?`Every skill in your library is already global.`:`No skills in your library are global.`);return}if(i=await tm(r?`Make global`:`Stop being global`,e.map(e=>({name:e.name}))),i.length===0){q.info(`Nothing selected.`);return}}r&&l(i),await Xm(t,i,r,n),t.report();return}let f=Wm(n.cwd,n.project),p=new Set(await K(`Loading ${f}`,()=>Hu(t,f))),m=e;if(m.length===0){let e=o.filter(e=>!p.has(e.name)&&c(e));if(e.length===0){q.info(s?`Every skill in your library is already in this project.`:`Every skill on this machine is already in this project.`),t.report();return}if(m=await tm(`Add to ${f}`,e.map(e=>({name:e.name}))),m.length===0){q.info(`Nothing selected.`);return}}let h=o.filter(e=>e.global).map(e=>e.name);l(m.filter(e=>!h.includes(e))),await Zm(t,f,m,h,n),t.report()})});async function Xm(e,t,n,r){Mu(t,n),await K(`Saving to skilless.dev`,()=>L(e));for(let e of t)q.step(n?`${e} is now global, so every project has it.`:`${e} is no longer global.`);let i=r.project??hl(r.cwd),a=gu(r.cwd),[o,s]=await K(`Updating your skills`,async()=>{if(!i){let t=await qu(e);return[t,t]}let t=await Wu(e,a,i,{copy:r.copy});return[t,t.user]});for(let e of s.written.filter(e=>t.includes(e)))q.dim(`Linked ${e} into ${Gm}.`);for(let e of s.removed)q.dim(`Unlinked ${e} from ${Gm}.`);if(`project`in o){for(let e of o.project.removed)q.dim(`Moved ${e} out of this project.`);for(let e of o.project.written.filter(e=>t.includes(e)))q.dim(`${e} is still added to this project, so it is linked here again.`)}await qm(o,r)}async function Zm(e,t,n,r,i){for(let e of n)r.includes(e)&&q.dim(`${e} is global, so it is already in this project.`);let a=n.filter(e=>!r.includes(e));Au(t,a);let o=gu(i.cwd),s=await K(`Updating this project`,async()=>(await L(e),Wu(e,o,t,{copy:i.copy})));for(let e of a)q.step(`Added ${e} to this project.`);await qm(s,i)}async function Qm(e,t,n,r){if(r.notGlobal)throw new P(`--not-global only applies to skills already in your library.`);let i=r.global?null:r.project??hl(r.cwd),a=await K(`Loading your library`,async()=>(await L(e),R(e))),o=new Map(a.entries.map(e=>[e.name,e])),s=[...n,...t.skill?[t.skill]:[]],c=await Em(t,async e=>{let n=jm(e,t.subpath);if(n.length===0)throw new P(`No skills found in ${t.label}.`,{suggestion:`A skill is a directory containing a SKILL.md.`});let i=n;if(s.length>0){let e=e=>n.find(t=>t.name===e.toLowerCase()||t.dir.split(`/`).at(-1)?.toLowerCase()===e.toLowerCase()),r=s.filter(t=>!e(t));if(r.length>0)throw new P(`Not in ${t.label}: ${r.join(`, `)}`,{suggestion:`It has: ${n.map(e=>e.name).join(`, `)}`});i=[...new Set(s.map(t=>e(t)))]}else if(n.length>1&&!r.yes){if(!$p)throw new P(`${t.label} has ${n.length} skills.`,{suggestion:`Name the ones you want after the repository, or pass --yes for all of them: ${n.map(e=>e.name).join(`, `)}`});let e=await tm(`Add from ${t.label}`,n.map(e=>({name:e.name,hint:$m(e.description)})));i=n.filter(t=>e.includes(t.name))}let a=[];for(let t of i)try{Wl(t.name),a.push({skill:Kl(t.dir,t.name),path:b.relative(e,t.dir)})}catch(e){q.warn(`Skipped ${t.name}: ${e instanceof P?e.message:e}`)}return a},{interactive:$p});if(c.length===0){q.info(`Nothing selected.`),e.report();return}let l=[],u=[],d=new Map;for(let{skill:e,path:n}of c){d.set(e.name,{url:t.url,...t.ref?{ref:t.ref}:{},path:n,hash:e.contentHash});let i=o.get(e.name),a=i?.local?.contentHash??i?.remote?.contentHash;if(!i||a===e.contentHash){i?zu(e.name,d.get(e.name)):l.push(e),u.push(e.name);continue}if(!(r.overwrite||$p&&!r.yes&&await Qp(`${e.name} is already in your library. Replace it with the one from ${t.label}?`))){q.warn(`Kept your own ${e.name}. Pass --overwrite to replace it.`);continue}l.push(e),u.push(e.name)}let f=await K(`Saving ${l.length} skill(s) to your library`,()=>Ju(e,l,o,d));for(let e of f)q.step(`Copied ${e} into your library from ${t.label}.`);if(u.length===0){e.report();return}r.global?await Xm(e,u,!0,r):i?await Zm(e,i,u,(await K(`Loading your library`,()=>R(e))).entries.filter(e=>e.global).map(e=>e.name),r):(q.blank(),q.dim(`This directory has no git remote, so ${u.length===1?`it is`:`they are`} only in your library. Run \`skilless add ${u[0]}\` inside a project to add ${u.length===1?`it`:`them`} there.`)),e.report()}function $m(e){if(e)return e.length>60?`${e.slice(0,57)}...`:e}function eh(e){switch(process.platform){case`darwin`:return[`open`,[e]];case`win32`:return[`rundll32`,[`url.dll,FileProtocolHandler`,e]];default:return[`xdg-open`,[e]]}}function th(e){let[t,n]=eh(e);try{let e=r(t,n,{stdio:`ignore`,detached:!0,windowsHide:!0});e.on(`error`,()=>{}),e.unref()}catch{}}async function nh(){let e=c.randomBytes(16).toString(`hex`),t=ym(),n=new URL(t).origin,r={"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`,"Access-Control-Allow-Private-Network":`true`},i,a=new Promise((e,t)=>{i={resolve:e,reject:t}}),o=d.createServer((t,n)=>{if(t.method===`OPTIONS`){n.writeHead(204,r),n.end();return}if(t.method!==`POST`){n.writeHead(405,r),n.end();return}let a=``;t.on(`data`,e=>{a+=e}),t.on(`end`,()=>{let t;try{t=JSON.parse(a)}catch{n.writeHead(400,r),n.end();return}if(t.state!==e||!t.token){n.writeHead(400,r),n.end();return}n.writeHead(200,{...r,"Content-Type":`application/json`}),n.end(JSON.stringify({ok:!0})),i.resolve(t.token)})}),s=setTimeout(()=>{i.reject(new P(`Timed out waiting for sign in.`,{suggestion:"Run `skilless auth` again, or paste a token with `skilless auth --token <token>`."}))},3e5);try{await new Promise((e,t)=>{o.once(`error`,t),o.listen(0,`127.0.0.1`,e)});let{port:n}=o.address(),r=`${t}/cli/auth?port=${n}&state=${e}`;q.info(`Opening your browser to sign in…`),q.dim(r),q.blank(),th(r),_m(await K(`Waiting for you to sign in`,()=>a))}finally{clearTimeout(s),o.close()}}const rh=Y.extend({logout:N(),token:j().optional()}),ih=new y(`auth`).description(`Sign in to skilless.dev, or sign out.`).addOption(new _e(`--logout`,`Sign out on this machine.`).default(!1)).addOption(new _e(`--token <token>`,`Save a token directly, for when the browser flow cannot reach localhost.`)).addOption(X.cwd).action(async e=>{let t=Z(rh,e);q.intro(J),await Q(async()=>{if(t.logout){if(!gm()){q.info(`You were not signed in.`);return}vm(),q.step(`Signed out on this machine.`);return}if(t.token){_m(t.token),q.step(`Token saved. You are signed in to skilless.dev.`);return}await nh(),q.step(`Signed in to skilless.dev.`)})}),ah=s.homedir(),oh=process.env.LOCALAPPDATA??b.join(ah,`AppData`,`Local`),sh=process.env.ProgramFiles??`C:/Program Files`,$={cursor:{label:`Cursor`,cli:`cursor`,fallbacks:{darwin:[`/Applications/Cursor.app/Contents/Resources/app/bin/cursor`,`${ah}/Applications/Cursor.app/Contents/Resources/app/bin/cursor`],win32:[b.join(oh,`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`,`${ah}/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code`],win32:[b.join(oh,`Programs/Microsoft VS Code/bin/code.cmd`),b.join(sh,`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`,`${ah}/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf`],win32:[b.join(oh,`Programs/Windsurf/bin/windsurf.cmd`)],linux:[`/usr/share/windsurf/bin/windsurf`]}},zed:{label:`Zed`,cli:`zed`,fallbacks:{darwin:[`/Applications/Zed.app/Contents/MacOS/cli`,`${ah}/Applications/Zed.app/Contents/MacOS/cli`],win32:[b.join(oh,`Programs/Zed/bin/zed.exe`)],linux:[`${ah}/.local/bin/zed`]}},sublime:{label:`Sublime Text`,cli:`subl`,fallbacks:{darwin:[`/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl`],win32:[b.join(sh,`Sublime Text/subl.exe`)],linux:[`/opt/sublime_text/sublime_text`]}},neovim:{label:`Neovim`,cli:`nvim`,terminal:!0},vim:{label:`Vim`,cli:`vim`,terminal:!0}},ch=Object.keys($);function lh(e){return Object.hasOwn($,e)}function uh(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 dh(e){let t=$[e],n=uh(t.cli);if(n)return n;let r=process.platform;return t.fallbacks?.[r]?.find(e=>F(e))??null}function fh(){return ch.filter(e=>dh(e)!==null)}function ph(e){return $[e].terminal===!0}function mh(e,t){let n=dh(e);if(!n)return Promise.reject(Error(`${$[e].label} was not found. Is \`${$[e].cli}\` on your PATH?`));let i=ph(e);return new Promise((e,a)=>{let o=r(n,[t],{cwd:b.dirname(t),stdio:i?`inherit`:`ignore`,detached:!i,windowsHide:!0,shell:process.platform===`win32`&&/\.(cmd|bat)$/i.test(n)});o.on(`error`,a),i?o.on(`exit`,()=>e()):(o.unref(),setImmediate(e))})}function hh(){let e=cl(Ol,{});return e.editor!==void 0&&!lh(e.editor)&&delete e.editor,e}function gh(e){ll(Ol,e)}function _h(e){let t={...hh(),...e};for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return gh(t),t}const vh=`none`,yh=Tc({unset:N()}),bh=new y(`editor`).description("Choose the editor `skilless create` opens a new skill in.").argument(`[editor]`,`Set it directly: ${ch.join(`, `)}.`).addOption(new _e(`--unset`,`Stop opening new skills in an editor.`).default(!1)).action(async(e,t)=>{let n=Z(yh,t);q.intro(J),await Q(async()=>{let t=hh().editor;if(n.unset){_h({editor:void 0}),q.step(`New skills will no longer open in an editor.`);return}if(e){if(!lh(e))throw new P(`${e} is not an editor skilless knows.`,{suggestion:`Pick one of: ${ch.join(`, `)}.`});_h({editor:e}),q.step(`New skills will open in ${$[e].label}.`);return}if(!$p){q.info(t?`Editor: ${$[t].label}`:`No editor set.`);return}let r=fh();if(r.length===0)throw new P(`None of the editors skilless knows are installed.`,{suggestion:`skilless looks for: ${ch.map(e=>$[e].cli).join(`, `)}.`});let i=await nm(`Open new skills in`,[...r.map(e=>({name:e,message:$[e].label,hint:e===t?W.default.gray(`current`):void 0})),{name:vh,message:`None`,hint:t?void 0:W.default.gray(`current`)}],t??vh);if(i===vh){_h({editor:void 0}),q.step(`New skills will not open in an editor.`);return}lh(i)&&(_h({editor:i}),q.step(`New skills will open in ${$[i].label}.`))})}),xh=new y(`config`).description(`View or change your skilless settings.`).addCommand(bh).action(async()=>{q.intro(J),await Q(async()=>{let e=hh();q.info(`editor ${e.editor?$[e.editor].label:W.default.gray(`not set`)}`),q.blank(),q.dim(`Stored in ${Ol}`)})}),Sh=Y.extend({description:j().optional(),project:j().optional(),global:N().optional(),open:N()}),Ch=new y(`create`).description(`Create a skill, add it to this project, and print the path to edit it.`).argument(`[name]`,`The name of the skill. You will be asked if you leave it out.`).option(`-d, --description <description>`,`What the skill does, for the frontmatter.`).option(`-g, --global`,`Make it global: linked once into ~/.agents/skills and ~/.claude/skills, so every project has it, including cloud agents.`).option(`--no-open`,"Do not open SKILL.md in your editor (see `skilless config editor`).").addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Sh,t);q.intro(J),await Q(async()=>{let t=new bm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Set(r.entries.map(e=>e.name)),a=e;if(!a){if(!$p)throw new P(`No name given.`,{suggestion:"Run `skilless create <name>`."});a=await em(`Name`,{validate:e=>e?Ul(e)?i.has(e)?`${e} already exists in your library.`:!0:`Use lowercase letters, digits, dots, dashes and underscores.`:`A name is required.`})}if(Wl(a),Xl(a))throw new P(`${a} already exists in your library.`,{suggestion:`Edit it at ${b.join(Al(a),`SKILL.md`)}`});if(i.has(a))throw new P(`${a} already exists in your library.`,{suggestion:`Run \`skilless sync\` to bring ${a} down to this machine.`});let o=n.description??await em(`What does this skill do?`);ql(a,Zl(a,o));let s=Kl(Al(a),a);if(await K(`Creating ${a}`,()=>t.try(e=>e.putSkill(a,s.files,s.editedAt)))){let e=vu();e.skills[a]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:Date.now()},yu(e)}q.step(`Created ${a} in your library.`),n.global&&Mu([a],!0);let c=n.project??hl(n.cwd);if(c){n.global||Au(c,[a]);let e=gu(n.cwd);await qm(await K(`Updating this project`,async()=>(await L(t),Wu(t,e,c))))}else n.global?await qm(await K(`Linking your global skills`,async()=>(await L(t),qu(t)))):await K(`Saving to skilless.dev`,()=>L(t));n.global?q.step(`${a} is now global, so every project has it.`):c?q.step(`Added ${a} to ${c}.`):q.warn(`No git remote here, so ${a} was not added to a project.`);let l=b.join(Al(a),`SKILL.md`),u=n.open?hh().editor:void 0,d=u&&(!ph(u)||$p);if(q.blank(),u&&d)try{q.dim(`Opening ${a} in ${$[u].label}...`),await mh(u,l)}catch(e){q.warn(e instanceof Error?e.message:String(e)),q.dim(`Edit ${a} at ${l}`)}else q.dim(`Edit ${a} at ${l}`);t.api&&q.dim("Run `skilless sync` to save your changes."),t.report()})}),wh=Y.extend({yes:N()}),Th=new y(`delete`).description(`Delete skills from your library, everywhere.`).argument(`<skills...>`,`Skills to delete.`).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(wh,t);q.intro(J),await Q(async()=>{let t=new bm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Set(r.entries.map(e=>e.name)),a=e.filter(e=>!i.has(e));if(a.length>0)throw new P(`Not in your library: ${a.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});if(q.warn(`This deletes ${e.join(`, `)} from every project, on every machine.`),q.dim(`Run \`skilless remove ${e.join(` `)}\` to take ${e.length===1?`it`:`them`} out of just this project.`),!(n.yes||await Qp(`Delete ${e.join(`, `)}?`,!1))){q.info(`Nothing was deleted.`);return}Pu(e),Bu(e);let o=vu(),s=gu(n.cwd);for(let t of e)I(Al(t)),delete o.skills[t],q.step(`Deleted ${t} from your library.`);yu(o),mu(s,e),mu($l(),e),await K(`Deleting from skilless.dev`,()=>L(t)),q.blank(),q.dim("Other checkouts will clean up on their next `skilless install`."),q.dim(`Restore at skilless.dev/skills within 30 days.`),t.report()})}),Eh=Y.extend({yes:N(),overwrite:N()});function Dh(e){return a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>({name:t.name,dir:b.join(e,t.name)})).filter(e=>F(b.join(e.dir,zl))).sort((e,t)=>e.name.localeCompare(t.name))}const Oh=new y(`import`).description(`Import a directory of existing skills into your library.`).argument(`<dir>`,`A directory whose subdirectories each contain a SKILL.md.`).option(`--overwrite`,`Replace skills that already exist.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(Eh,t);q.intro(J),await Q(async()=>{let t=new bm,r=b.resolve(n.cwd,e);if(!F(r))throw new P(`${r} does not exist.`);let i=Dh(r);if(i.length===0)throw new P(`No skills found in ${r}.`,{suggestion:`A skill is a directory containing a ${zl}.`});let a=await K(`Loading your library`,async()=>(await L(t),R(t))),o=new Map(a.entries.map(e=>[e.name,e])),s=[],c=[];for(let e of i){if(!Ul(e.name)){c.push({name:e.name,reason:`invalid name`});continue}if(o.has(e.name)&&!n.overwrite){c.push({name:e.name,reason:`already in your library`});continue}try{s.push(Kl(e.dir,e.name))}catch(t){c.push({name:e.name,reason:t instanceof Error?t.message:`unreadable`})}}for(let e of c)q.warn(`Skipped ${e.name}: ${e.reason}.`);if(s.length===0){q.info(`Nothing to import.`),t.report();return}if(q.blank(),q.info(`Importing: ${s.map(e=>e.name).join(`, `)}`),!(n.yes||await Qp(`Import ${s.length} skill(s)?`,!0)))return;let l=await K(`Importing ${s.length} skill(s)`,()=>Ju(t,s,o));for(let e of l)q.step(`Imported ${e} into your library.`);q.blank(),q.dim(`Run \`skilless add ${s[0]?.name??`<skill>`}\` to add one to this project.`),t.report()})}),kh=new y(`init`).description(`Create the local skilless directory.`).addOption(X.cwd).action(async e=>{Z(Y,e),q.intro(J),await Q(async()=>{let e=!F(Sl);al(Sl),q.step(`${e?`Created`:`Found`} your library at ${xl}.`),q.blank(),q.dim("Run `skilless create <name>` to make a skill."),q.dim("Run `skilless import <dir>` to bring in skills you already have."),gm()||q.dim("Run `skilless auth` to sync your skills with the cloud.")})}),Ah=Y.extend({project:j().optional(),copy:N().optional()}),jh=new y(`install`).description(`Install every skill added to this project, and your global skills at the user level.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async e=>{let t=Z(Ah,e);q.intro(J),await Q(async()=>{let e=Um(),n=Wm(t.cwd,t.project),r=gu(t.cwd),i=await K(`Installing ${n}'s skills`,async()=>(await Fu(e),Cu(e,r,n,{copy:t.copy}))),{project:a,user:o}=i;for(let e of[...a.pruned,...o.pruned])q.dim(`Pruned ${e}, which is no longer in your library.`);for(let e of[...a.fetched,...o.fetched])q.dim(`Fetched ${e} from your library.`);for(let e of a.removed)q.dim(`Removed ${e}, which is no longer in this project.`);for(let e of o.removed)q.dim(`Removed ${e} from ${Gm}, since it is no longer global.`);for(let e of a.written)q.step(`Installed ${e}.`);for(let e of o.written)q.step(`Installed ${e} globally.`);if(i.count===0){q.info(`No skills added to ${n} yet.`),q.dim("Run `skilless add <skill>` to add one.");return}await qm(i,{copy:t.copy}),q.blank(),q.dim(bu(t.copy)?`Wrote real files into .agents/skills, and global skills into ~/.agents/skills.`:`Linked .agents/skills, and global skills in ~/.agents/skills, to your library.`)})}),Mh=Y.extend({project:Dc([N(),j()]).optional()});function Nh(e,t){let n=[];return e.global&&n.push(`global`),e.source&&n.push(`from ${ml(e.source.url)??e.source.url}`),e.local?t&&e.unsynced&&n.push(`not synced`):n.push(`not on this machine`),n.map(e=>` · ${e}`).join(``)}const Ph=new y(`list`).description(`List your skills, or the ones added to this project.`).option(`-p, --project [key]`,`List this project’s skills instead of your library.`).addOption(X.cwd).action(async e=>{let t=Z(Mh,e);q.intro(J),await Q(async()=>{let e=new bm,n=await K(`Loading your library`,async()=>(await L(e),R(e)));if(t.project!==void 0){let r=Wm(t.cwd,typeof t.project==`string`?t.project:void 0),i=Uu(n,await K(`Loading ${r}`,()=>Hu(e,r)));q.info(`${W.default.bold(r)}`),q.blank(),i.length===0&&q.dim("No skills in this project. Run `skilless add <skill>` to add one.");for(let t of i)q.dim(` ${t.name}${W.default.gray(Nh(t,e.api!==null))}`);e.report();return}n.entries.length===0&&q.dim("Your library is empty. Run `skilless create <name>` to make one.");for(let t of n.entries){let n=t.local?.editedAt??t.remote?.updatedAt??0,r=new Date(n).toISOString().slice(0,10);q.dim(` ${t.name.padEnd(28)} ${W.default.gray(r+Nh(t,e.api!==null))}`)}e.report()})}),Fh=Y.extend({yes:N(),user:N().optional()});function Ih(e,t){return F(e)?a.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.isSymbolicLink()).map(n=>({name:n.name,dir:b.join(e,n.name),scope:t})).filter(e=>F(b.join(e.dir,zl))):[]}const Lh=new y(`migrate`).description(`Move this project's skills into your library and link them back. Offers your user-level skills too, as globals linked back at the user level.`).option(`--user`,`Migrate your user-level skills too, without asking.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(Fh,e);q.intro(J),await Q(async()=>{let e=new bm,n=gu(t.cwd),r=hl(t.cwd),i=r?[jl,Ml].flatMap(e=>Ih(b.join(n,e),`project`).filter(e=>{let t=vl(n,b.relative(n,e.dir));return t&&q.warn(`${e.name} is committed to this repo, so it was left alone. Remove it from git first to migrate it.`),!t})):[],a=[...Ih(Fl(),`user`),...Ih(Pl(),`user`)];if(r||q.dim(`No git remote here, so there are no project skills to migrate.`),i.length===0&&a.length===0){q.info(`Nothing to migrate.`);return}let o=await K(`Loading your library`,async()=>(await L(e),R(e))),s=new Map(o.entries.map(e=>[e.name,e])),c=async e=>{let t=new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);let n=[];for(let[e,r]of[...t].sort(([e],[t])=>e.localeCompare(t))){if(!Ul(e)){q.warn(`Skipped ${e}: not a valid skill name.`);continue}let t;try{t=r.map(t=>Kl(t.dir,e))}catch(t){q.warn(`Skipped ${e}: ${t instanceof Error?t.message:`unreadable`}.`);continue}let i=t[0];if(!i)continue;if(t.some(e=>e.contentHash!==i.contentHash)){q.warn(`Skipped ${e}: found more than one version (${r.map(e=>e.dir).join(`, `)}).`);continue}let a=s.get(e),o=a?.local?.contentHash??a?.remote?.contentHash;if(o&&o!==i.contentHash){q.warn(`Skipped ${e}: a different ${e} is already in your library. Rename one to migrate it.`);continue}n.push({skill:i,dirs:r.map(e=>e.dir),scope:r.some(e=>e.scope===`user`)?`user`:`project`,adopted:o!==void 0})}return n},l=await c(i);if(l.length>0&&(q.info(`Project skills in ${r}: ${l.map(e=>e.skill.name).join(`, `)}`),t.yes||await Qp(`Move ${l.length} skill(s) into skilless and link them here?`,!0)||(l=[])),a.length>0){let e=[...new Set(a.map(e=>e.name))].sort();if(q.info(`User-level skills: ${e.join(`, `)}`),t.user||!t.yes&&$p&&await Qp(`Would you also like to migrate your user-level skills? They become global and are linked back into ~/.agents/skills, so every project still gets them.`,!1)){let e=new Set(l.map(e=>e.skill.name)),t=await c([...a,...i.filter(e=>a.some(t=>t.name===e.name))]);l=[...l.filter(e=>!t.some(t=>t.skill.name===e.skill.name)),...t];for(let t of e)l.some(e=>e.skill.name===t)||q.warn(`Skipped ${t}: its project and user-level copies differ.`)}}if(l.length===0){q.info(`Nothing was migrated.`);return}let u=vu();for(let{skill:t,adopted:n}of l)ql(t.name,t.files,t.editedAt),!n&&(await K(`Saving ${t.name} to your library`,()=>e.try(e=>e.putSkill(t.name,t.files,t.editedAt)))?u.skills[t.name]={contentHash:t.contentHash,editedAt:t.editedAt,syncedAt:Date.now()}:delete u.skills[t.name]);yu(u);for(let{dirs:e}of l)for(let t of e)I(t);let d=l.filter(e=>e.scope===`user`).map(e=>e.skill.name),f=l.filter(e=>e.scope===`project`).map(e=>e.skill.name);d.length>0&&Mu(d,!0),r&&f.length>0&&Au(r,f),await K(`Saving to skilless.dev`,()=>L(e));for(let e of f)q.step(`Migrated ${e} into your library and this project.`);for(let e of d)q.step(`Migrated ${e} into your library as a global skill.`);r?await qm(await K(`Updating this project`,()=>Wu(e,n,r)),{yes:t.yes}):d.length>0&&await qm(await K(`Linking your global skills`,()=>qu(e)),{yes:t.yes}),e.report()})}),Rh=Y.extend({project:j().optional(),copy:N().optional()}),zh=new y(`remove`).description(`Remove skills from this project. They stay in your library.`).argument(`<skills...>`,`Skills to remove.`).option(`--copy`,`Write real files instead of symlinking into the store.`).addOption(X.project).addOption(X.cwd).action(async(e,t)=>{let n=Z(Rh,t);q.intro(J),await Q(async()=>{let t=new bm,r=Wm(n.cwd,n.project),[i,a]=await K(`Loading your library`,async()=>(await L(t),[await R(t),new Set(await Hu(t,r))])),o=new Set(i.entries.filter(e=>e.global).map(e=>e.name)),s=[];for(let t of e){if(o.has(t)){q.warn(`${t} is global, so it is in every project.`),q.dim(` Run \`skilless add --not-global ${t}\` to take it out of every project.`);continue}if(!a.has(t)){q.warn(`${t} is not in this project.`);continue}s.push(t)}if(s.length===0){t.report();return}ju(r,s);let c=gu(n.cwd),l=await K(`Updating this project`,async()=>(await L(t),Wu(t,c,r,{copy:n.copy})));for(let e of s)q.step(`Removed ${e} from this project.`);await qm(l,{copy:n.copy}),q.blank(),q.dim(`Run \`skilless delete ${s.join(` `)}\` to delete ${s.length===1?`it`:`them`}.`),t.report()})});function Bh(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 Vh(e,t,n){return Hh(e,t===`push`?`remote`:`local`,n)}function Hh(e,t,n){let r=new Date().toISOString().replace(/[:.]/g,`-`),i=b.join(kl,e,`${r}-${t}`);for(let e of n)sl(b.join(i,e.path),e.contents);return i}async function Uh(e,t,n){let r={actions:[],conflicts:[],skipped:[]},i=Date.now();for(let a of t){let{name:t}=a,o=n.local.get(t);switch(a.type){case`noop`:o&&(n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i});break;case`push`:case`conflict-push`:if(!o)break;if(a.type===`conflict-push`){let n=await e.getSkill(t);n&&r.conflicts.push({name:t,kept:`push`,stashedAt:Vh(t,`push`,n.files)})}await e.putSkill(t,o.files,o.editedAt),n.state.skills[t]={contentHash:o.contentHash,editedAt:o.editedAt,syncedAt:i};break;case`pull`:case`conflict-pull`:{let s=await e.getSkill(t);if(!s)break;a.type===`conflict-pull`&&o&&r.conflicts.push({name:t,kept:`pull`,stashedAt:Vh(t,`pull`,o.files)}),ql(t,s.files,s.editedAt),n.state.skills[t]={contentHash:s.contentHash,editedAt:s.editedAt,syncedAt:i};break}case`delete-local`:if(!(n.yes||await Qp(`Delete ${t} from this machine? It was deleted elsewhere.`,!0))){r.skipped.push(t);continue}I(Al(t)),delete n.state.skills[t];break;case`delete-remote`:if(!(n.yes||await Qp(`Delete ${t} everywhere? It was deleted on this machine.`,!0))){r.skipped.push(t);continue}await e.deleteSkill(t),delete n.state.skills[t];break}r.actions.push(a)}return r}function Wh(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 Gh=Y.extend({yes:N(),push:N().optional(),pull:N().optional()}),Kh=new y(`sync`).description(`Sync your library with skilless.dev, in both directions, and update this project's skills and your global ones.`).option(`--push`,`On a conflict, keep the local copy.`).option(`--pull`,`On a conflict, keep the remote copy.`).addOption(X.yes).addOption(X.cwd).action(async e=>{let t=Z(Gh,e);q.intro(J),await Q(async()=>{let e=Um(),[n,r]=await K(`Checking skilless.dev`,async()=>[await Fu(e),await e.listSkills()]),i=new Map(Yl().map(e=>[e.name,e])),a=new Map(r.map(e=>[e.name,e])),o=vu(),s=Bh(i,a,o,t.push?`push`:t.pull?`pull`:void 0),c=await K(`Syncing your library`,()=>Uh(e,s,{local:i,state:o,yes:t.yes}));yu(o);let l=c.actions.map(Wh).filter(e=>e!==null);for(let e of l)q.step(e);let[u,d]=await K(`Syncing your library`,async()=>{let t=n+await Fu(e);return[t,l.length>0||t>0?await e.listSkills():r]});u>0&&q.step(`Sent ${u} change(s) made while offline.`),Ll(d),Vu(d);let f=hl(t.cwd),p=await K(f?`Updating this project`:`Updating your global skills`,async()=>{if(!f)return{user:Tu(d.filter(e=>e.global).map(e=>e.name))};let n=await Cu(e,gu(t.cwd),f);return{...n,project:n.project}}),m=`project`in p?p.project:void 0,{user:h}=p;if(m){for(let e of m.added)q.step(`Linked ${e} into this project.`);for(let e of m.removed)q.step(`Unlinked ${e}, which is no longer in this project.`);for(let e of m.pruned)q.step(`Unlinked ${e}, which is no longer in your library.`)}for(let e of h.added)q.step(`Linked ${e} into ${Gm}.`);for(let e of h.removed)q.step(`Unlinked ${e} from ${Gm}, since it is no longer global.`);for(let e of h.pruned)q.step(`Unlinked ${e} from ${Gm}, since it is no longer in your library.`);let g=[m,h].reduce((e,t)=>e+(t?t.added.length+t.removed.length+t.pruned.length:0),0);if(l.length===0&&g===0&&u===0&&q.info(`Everything is already in sync.`),c.conflicts.length>0){q.blank(),q.warn(`${c.conflicts.length} skill(s) changed in two places. The copy that lost is kept here:`);for(let e of c.conflicts)q.dim(` ${e.stashedAt}`)}await qm({skipped:[...m?.skipped??[],...h.skipped]},{yes:t.yes}),c.skipped.length>0&&(q.blank(),q.dim(`Skipped ${c.skipped.join(`, `)}.`))})}),qh=Y.extend({yes:N(),force:N()});function Jh(e){let t=ml(e.url)??e.url;return e.ref?`${t}#${e.ref}`:t}const Yh=new y(`update`).description(`Update skills added from a git repository to what the repository has now.`).argument(`[skills...]`,`Skills to update. Omit to update every skill added from a repository.`).option(`-f, --force`,`Replace skills you have edited too. Your copy is kept first.`,!1).addOption(X.yes).addOption(X.cwd).action(async(e,t)=>{let n=Z(qh,t);q.intro(J),await Q(async()=>{let t=new bm,r=await K(`Loading your library`,async()=>(await L(t),R(t))),i=new Map(r.entries.map(e=>[e.name,e])),a=r.entries.filter(e=>e.source!==null);if(e.length>0){let t=e.filter(e=>!i.has(e));if(t.length>0)throw new P(`Not in your library: ${t.join(`, `)}`,{suggestion:"Run `skilless list` to see what you have."});let n=e.filter(e=>!i.get(e)?.source);if(n.length>0)throw new P(`${n.join(`, `)} ${n.length===1?`was`:`were`} not added from a repository, so there is nothing to update from.`)}let o=e.length>0?a.filter(t=>e.includes(t.name)):a;if(o.length===0){q.info(`None of your skills were added from a repository.`),q.dim("Run `skilless add owner/repo` to add some."),t.report();return}let s=new Map;for(let e of o){let t=`${e.source.url}#${e.source.ref??``}`;s.set(t,[...s.get(t)??[],e])}let c=[],l=new Map,u=[],d=[],f=[],p=[];for(let e of s.values()){let r=e[0].source,i=Jh(r);await Em({url:r.url,ref:r.ref,label:i},async r=>{for(let a of e){let e=Mm(r,a.source.path,a.name);if(!e){q.warn(`${a.name} is no longer in ${i}.`);continue}let o;try{o=Kl(e.dir,a.name)}catch(e){q.warn(`Skipped ${a.name}: ${e instanceof Error?e.message:e}`);continue}let s={...a.source,path:e.path,hash:o.contentHash},p=a.local?.contentHash??a.remote?.contentHash;if(o.contentHash===a.source.hash||p===o.contentHash){zu(a.name,s),u.push(a.name);continue}if(p!==a.source.hash){if(!(n.force||$p&&!n.yes&&await Qp(`You have edited ${a.name} since it came from ${i}. Replace your edits with what it has now?`))){d.push(a.name);continue}let e=a.local?.files??(await K(`Fetching your copy of ${a.name}`,()=>t.try(e=>e.getSkill(a.name))))?.files;if(!e){q.warn(`Couldn't fetch your copy of ${a.name} to keep it, so it was left alone.`);continue}f.push({name:a.name,dir:Hh(a.name,`update`,e)})}c.push(o),l.set(a.name,s)}},{interactive:$p}).then(()=>!0,e=>{if(!(e instanceof P))throw e;return q.warn(e.toString()),!1})||p.push(...e.map(e=>e.name))}q.blank();let m=await K(`Saving ${c.length} skill(s) to your library`,()=>Ju(t,c,i,l));for(let e of m)q.step(`Updated ${e}.`);if(u.length>0&&q.info(u.length===1?`${u[0]} is already up to date.`:`${u.length} skills are already up to date.`),d.length>0&&q.warn(`Kept your edits to ${d.join(`, `)}. Run \`skilless update ${d.join(` `)} --force\` to replace them.`),p.length>0&&q.warn(`Couldn't check ${p.join(`, `)}.`),f.length>0){q.blank(),q.dim(`Your edited copies are kept here:`);for(let e of f)q.dim(` ${e.dir}`)}t.report()})});le.name(zm).description(Bm).version(J).addCommand(kh).addCommand(ih).addCommand(Ch).addCommand(Ym).addCommand(Yh).addCommand(zh).addCommand(Th).addCommand(jh).addCommand(Kh).addCommand(Oh).addCommand(Lh).addCommand(Ph).addCommand(xh).parse();export{};
|