hataraku
Version:
An autonomous coding agent for building AI-powered development tools. The name "Hataraku" (働く) means "to work" in Japanese.
27 lines • 6.3 MB
JavaScript
#!/usr/bin/env node
var w6e=Object.create;var j1=Object.defineProperty;var D6e=Object.getOwnPropertyDescriptor;var k6e=Object.getOwnPropertyNames;var _6e=Object.getPrototypeOf,T6e=Object.prototype.hasOwnProperty;var UO=r=>t=>{var n=r[t];if(n)return n();throw new Error("Module not found in bundle: "+t)};var ur=(r,t)=>()=>(r&&(t=r(r=0)),t);var ze=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),mo=(r,t)=>{for(var n in t)j1(r,n,{get:t[n],enumerable:!0})},qO=(r,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k6e(t))!T6e.call(r,o)&&o!==n&&j1(r,o,{get:()=>t[o],enumerable:!(a=D6e(t,o))||a.enumerable});return r};var mr=(r,t,n)=>(n=r!=null?w6e(_6e(r)):{},qO(t||!r||!r.__esModule?j1(n,"default",{value:r,enumerable:!0}):n,r)),Zr=r=>qO(j1({},"__esModule",{value:!0}),r);var ug=ze(MA=>{var V1=class extends Error{constructor(t,n,a){super(a),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=t,this.nestedError=void 0}},LA=class extends V1{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};MA.CommanderError=V1;MA.InvalidArgumentError=LA});var X1=ze(qA=>{var{InvalidArgumentError:P6e}=ug(),UA=class{constructor(t,n){switch(this.description=n||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,a)=>{if(!this.argChoices.includes(n))throw new P6e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,a):n},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function R6e(r){let t=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+t+">":"["+t+"]"}qA.Argument=UA;qA.humanReadableArgName=R6e});var HA=ze(GA=>{var{humanReadableArgName:I6e}=X1(),WA=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let n=t.commands.filter(o=>!o._hidden),a=t._getHelpCommand();return a&&!a._hidden&&n.push(a),this.sortSubcommands&&n.sort((o,s)=>o.name().localeCompare(s.name())),n}compareOptions(t,n){let a=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return a(t).localeCompare(a(n))}visibleOptions(t){let n=t.options.filter(o=>!o.hidden),a=t._getHelpOption();if(a&&!a.hidden){let o=a.short&&t._findOption(a.short),s=a.long&&t._findOption(a.long);!o&&!s?n.push(a):a.long&&!s?n.push(t.createOption(a.long,a.description)):a.short&&!o&&n.push(t.createOption(a.short,a.description))}return this.sortOptions&&n.sort(this.compareOptions),n}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let n=[];for(let a=t.parent;a;a=a.parent){let o=a.options.filter(s=>!s.hidden);n.push(...o)}return this.sortOptions&&n.sort(this.compareOptions),n}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(n=>{n.description=n.description||t._argsDescription[n.name()]||""}),t.registeredArguments.find(n=>n.description)?t.registeredArguments:[]}subcommandTerm(t){let n=t.registeredArguments.map(a=>I6e(a)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,n){return n.visibleCommands(t).reduce((a,o)=>Math.max(a,this.displayWidth(n.styleSubcommandTerm(n.subcommandTerm(o)))),0)}longestOptionTermLength(t,n){return n.visibleOptions(t).reduce((a,o)=>Math.max(a,this.displayWidth(n.styleOptionTerm(n.optionTerm(o)))),0)}longestGlobalOptionTermLength(t,n){return n.visibleGlobalOptions(t).reduce((a,o)=>Math.max(a,this.displayWidth(n.styleOptionTerm(n.optionTerm(o)))),0)}longestArgumentTermLength(t,n){return n.visibleArguments(t).reduce((a,o)=>Math.max(a,this.displayWidth(n.styleArgumentTerm(n.argumentTerm(o)))),0)}commandUsage(t){let n=t._name;t._aliases[0]&&(n=n+"|"+t._aliases[0]);let a="";for(let o=t.parent;o;o=o.parent)a=o.name()+" "+a;return a+n+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let n=[];return t.argChoices&&n.push(`choices: ${t.argChoices.map(a=>JSON.stringify(a)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&n.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&n.push(`env: ${t.envVar}`),n.length>0?`${t.description} (${n.join(", ")})`:t.description}argumentDescription(t){let n=[];if(t.argChoices&&n.push(`choices: ${t.argChoices.map(a=>JSON.stringify(a)).join(", ")}`),t.defaultValue!==void 0&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),n.length>0){let a=`(${n.join(", ")})`;return t.description?`${t.description} ${a}`:a}return t.description}formatHelp(t,n){let a=n.padWidth(t,n),o=n.helpWidth??80;function s(w,i){return n.formatItem(w,a,i,n)}let e=[`${n.styleTitle("Usage:")} ${n.styleUsage(n.commandUsage(t))}`,""],A=n.commandDescription(t);A.length>0&&(e=e.concat([n.boxWrap(n.styleCommandDescription(A),o),""]));let B=n.visibleArguments(t).map(w=>s(n.styleArgumentTerm(n.argumentTerm(w)),n.styleArgumentDescription(n.argumentDescription(w))));B.length>0&&(e=e.concat([n.styleTitle("Arguments:"),...B,""]));let q=n.visibleOptions(t).map(w=>s(n.styleOptionTerm(n.optionTerm(w)),n.styleOptionDescription(n.optionDescription(w))));if(q.length>0&&(e=e.concat([n.styleTitle("Options:"),...q,""])),n.showGlobalOptions){let w=n.visibleGlobalOptions(t).map(i=>s(n.styleOptionTerm(n.optionTerm(i)),n.styleOptionDescription(n.optionDescription(i))));w.length>0&&(e=e.concat([n.styleTitle("Global Options:"),...w,""]))}let m=n.visibleCommands(t).map(w=>s(n.styleSubcommandTerm(n.subcommandTerm(w)),n.styleSubcommandDescription(n.subcommandDescription(w))));return m.length>0&&(e=e.concat([n.styleTitle("Commands:"),...m,""])),e.join(`
`)}displayWidth(t){return WO(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(n=>n==="[options]"?this.styleOptionText(n):n==="[command]"?this.styleSubcommandText(n):n[0]==="["||n[0]==="<"?this.styleArgumentText(n):this.styleCommandText(n)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(n=>n==="[options]"?this.styleOptionText(n):n[0]==="["||n[0]==="<"?this.styleArgumentText(n):this.styleSubcommandText(n)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,n){return Math.max(n.longestOptionTermLength(t,n),n.longestGlobalOptionTermLength(t,n),n.longestSubcommandTermLength(t,n),n.longestArgumentTermLength(t,n))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,n,a,o){let e=" ".repeat(2);if(!a)return e+t;let A=t.padEnd(n+t.length-o.displayWidth(t)),B=2,m=(this.helpWidth??80)-n-B-2,w;return m<this.minWidthToWrap||o.preformatted(a)?w=a:w=o.boxWrap(a,m).replace(/\n/g,`
`+" ".repeat(n+B)),e+A+" ".repeat(B)+w.replace(/\n/g,`
${e}`)}boxWrap(t,n){if(n<this.minWidthToWrap)return t;let a=t.split(/\r\n|\n/),o=/[\s]*[^\s]+/g,s=[];return a.forEach(e=>{let A=e.match(o);if(A===null){s.push("");return}let B=[A.shift()],q=this.displayWidth(B[0]);A.forEach(m=>{let w=this.displayWidth(m);if(q+w<=n){B.push(m),q+=w;return}s.push(B.join(""));let i=m.trimStart();B=[i],q=this.displayWidth(i)}),s.push(B.join(""))}),s.join(`
`)}};function WO(r){let t=/\x1b\[\d*(;\d*)*m/g;return r.replace(t,"")}GA.Help=WA;GA.stripColor=WO});var XA=ze(VA=>{var{InvalidArgumentError:B6e}=ug(),zA=class{constructor(t,n){this.flags=t,this.description=n||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let a=O6e(t);this.short=a.shortFlag,this.long=a.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let n=t;return typeof t=="string"&&(n={[t]:!0}),this.implied=Object.assign(this.implied||{},n),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,a)=>{if(!this.argChoices.includes(n))throw new B6e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,a):n},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?GO(this.name().replace(/^no-/,"")):GO(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},jA=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(n=>{n.negate?this.negativeOptions.set(n.attributeName(),n):this.positiveOptions.set(n.attributeName(),n)}),this.negativeOptions.forEach((n,a)=>{this.positiveOptions.has(a)&&this.dualOptions.add(a)})}valueFromOption(t,n){let a=n.attributeName();if(!this.dualOptions.has(a))return!0;let o=this.negativeOptions.get(a).presetArg,s=o!==void 0?o:!1;return n.negate===(s===t)}};function GO(r){return r.split("-").reduce((t,n)=>t+n[0].toUpperCase()+n.slice(1))}function O6e(r){let t,n,a=/^-[^-]$/,o=/^--[^-]/,s=r.split(/[ |,]+/).concat("guard");if(a.test(s[0])&&(t=s.shift()),o.test(s[0])&&(n=s.shift()),!t&&a.test(s[0])&&(t=s.shift()),!t&&o.test(s[0])&&(t=n,n=s.shift()),s[0].startsWith("-")){let e=s[0],A=`option creation failed due to '${e}' in option flags '${r}'`;throw/^-[^-][^-]/.test(e)?new Error(`${A}
- a short flag is a single dash and a single character
- either use a single dash and a single character (for a short flag)
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):a.test(e)?new Error(`${A}
- too many short flags`):o.test(e)?new Error(`${A}
- too many long flags`):new Error(`${A}
- unrecognised flag format`)}if(t===void 0&&n===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:t,longFlag:n}}VA.Option=zA;VA.DualOptions=jA});var zO=ze(HO=>{function N6e(r,t){if(Math.abs(r.length-t.length)>3)return Math.max(r.length,t.length);let n=[];for(let a=0;a<=r.length;a++)n[a]=[a];for(let a=0;a<=t.length;a++)n[0][a]=a;for(let a=1;a<=t.length;a++)for(let o=1;o<=r.length;o++){let s=1;r[o-1]===t[a-1]?s=0:s=1,n[o][a]=Math.min(n[o-1][a]+1,n[o][a-1]+1,n[o-1][a-1]+s),o>1&&a>1&&r[o-1]===t[a-2]&&r[o-2]===t[a-1]&&(n[o][a]=Math.min(n[o][a],n[o-2][a-2]+1))}return n[r.length][t.length]}function L6e(r,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let n=r.startsWith("--");n&&(r=r.slice(2),t=t.map(e=>e.slice(2)));let a=[],o=3,s=.4;return t.forEach(e=>{if(e.length<=1)return;let A=N6e(r,e),B=Math.max(r.length,e.length);(B-A)/B>s&&(A<o?(o=A,a=[e]):A===o&&a.push(e))}),a.sort((e,A)=>e.localeCompare(A)),n&&(a=a.map(e=>`--${e}`)),a.length>1?`
(Did you mean one of ${a.join(", ")}?)`:a.length===1?`
(Did you mean ${a[0]}?)`:""}HO.suggestSimilar=L6e});var $O=ze(ZA=>{var M6e=require("node:events").EventEmitter,$A=require("node:child_process"),Qs=require("node:path"),$1=require("node:fs"),Rt=require("node:process"),{Argument:U6e,humanReadableArgName:q6e}=X1(),{CommanderError:YA}=ug(),{Help:W6e,stripColor:G6e}=HA(),{Option:jO,DualOptions:H6e}=XA(),{suggestSimilar:VO}=zO(),KA=class r extends M6e{constructor(t){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=t||"",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:n=>Rt.stdout.write(n),writeErr:n=>Rt.stderr.write(n),outputError:(n,a)=>a(n),getOutHelpWidth:()=>Rt.stdout.isTTY?Rt.stdout.columns:void 0,getErrHelpWidth:()=>Rt.stderr.isTTY?Rt.stderr.columns:void 0,getOutHasColors:()=>JA()??(Rt.stdout.isTTY&&Rt.stdout.hasColors?.()),getErrHasColors:()=>JA()??(Rt.stderr.isTTY&&Rt.stderr.hasColors?.()),stripColor:n=>G6e(n)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let n=this;n;n=n.parent)t.push(n);return t}command(t,n,a){let o=n,s=a;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,e,A]=t.match(/([^ ]+) *(.*)/),B=this.createCommand(e);return o&&(B.description(o),B._executableHandler=!0),s.isDefault&&(this._defaultCommandName=B._name),B._hidden=!!(s.noHelp||s.hidden),B._executableFile=s.executableFile||null,A&&B.arguments(A),this._registerCommand(B),B.parent=this,B.copyInheritedSettings(this),o?this:B}createCommand(t){return new r(t)}createHelp(){return Object.assign(new W6e,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,n){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=t._name),(n.noHelp||n.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,n){return new U6e(t,n)}argument(t,n,a,o){let s=this.createArgument(t,n);return typeof a=="function"?s.default(o).argParser(a):s.default(a),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(t){let n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,n){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";let[,a,o]=t.match(/([^ ]+) *(.*)/),s=n??"display help for command",e=this.createCommand(a);return e.helpOption(!1),o&&e.arguments(o),s&&e.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=e,this}addHelpCommand(t,n){return typeof t!="object"?(this.helpCommand(t,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=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(t,n){let a=["preSubcommand","preAction","postAction"];if(!a.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
Expecting one of '${a.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(n):this._lifeCycleHooks[t]=[n],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(t,n,a){this._exitCallback&&this._exitCallback(new YA(t,n,a)),Rt.exit(t)}action(t){let n=a=>{let o=this.registeredArguments.length,s=a.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=n,this}createOption(t,n){return new jO(t,n)}_callParseArg(t,n,a,o){try{return t.parseArg(n,a)}catch(s){if(s.code==="commander.invalidArgument"){let e=`${o} ${s.message}`;this.error(e,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let n=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(n){let a=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${a}'
- already used by option '${n.flags}'`)}this.options.push(t)}_registerCommand(t){let n=o=>[o.name()].concat(o.aliases()),a=n(t).find(o=>this._findCommand(o));if(a){let o=n(this._findCommand(a)).join("|"),s=n(t).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);let n=t.name(),a=t.attributeName();if(t.negate){let s=t.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(a,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(a,t.defaultValue,"default");let o=(s,e,A)=>{s==null&&t.presetArg!==void 0&&(s=t.presetArg);let B=this.getOptionValue(a);s!==null&&t.parseArg?s=this._callParseArg(t,s,B,e):s!==null&&t.variadic&&(s=t._concatValue(s,B)),s==null&&(t.negate?s=!1:t.isBoolean()||t.optional?s=!0:s=""),this.setOptionValueWithSource(a,s,A)};return this.on("option:"+n,s=>{let e=`error: option '${t.flags}' argument '${s}' is invalid.`;o(s,e,"cli")}),t.envVar&&this.on("optionEnv:"+n,s=>{let e=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;o(s,e,"env")}),this}_optionEx(t,n,a,o,s){if(typeof n=="object"&&n instanceof jO)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let e=this.createOption(n,a);if(e.makeOptionMandatory(!!t.mandatory),typeof o=="function")e.default(s).argParser(o);else if(o instanceof RegExp){let A=o;o=(B,q)=>{let m=A.exec(B);return m?m[0]:q},e.default(s).argParser(o)}else e.default(o);return this.addOption(e)}option(t,n,a,o){return this._optionEx({},t,n,a,o)}requiredOption(t,n,a,o){return this._optionEx({mandatory:!0},t,n,a,o)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,n){return this.setOptionValueWithSource(t,n,void 0)}setOptionValueWithSource(t,n,a){return this._storeOptionsAsProperties?this[t]=n:this._optionValues[t]=n,this._optionValueSources[t]=a,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let n;return this._getCommandAndAncestors().forEach(a=>{a.getOptionValueSource(t)!==void 0&&(n=a.getOptionValueSource(t))}),n}_prepareUserArgs(t,n){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},t===void 0&&n.from===void 0){Rt.versions?.electron&&(n.from="electron");let o=Rt.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(n.from="eval")}t===void 0&&(t=Rt.argv),this.rawArgs=t.slice();let a;switch(n.from){case void 0:case"node":this._scriptPath=t[1],a=t.slice(2);break;case"electron":Rt.defaultApp?(this._scriptPath=t[1],a=t.slice(2)):a=t.slice(1);break;case"user":a=t.slice(0);break;case"eval":a=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",a}parse(t,n){this._prepareForParse();let a=this._prepareUserArgs(t,n);return this._parseCommand([],a),this}async parseAsync(t,n){this._prepareForParse();let a=this._prepareUserArgs(t,n);return await this._parseCommand([],a),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 new Error(`Can not call parse again when storeOptionsAsProperties is true.
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,n,a){if($1.existsSync(t))return;let o=n?`searched for local subcommand relative to directory '${n}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${t}' does not exist
- if '${a}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- ${o}`;throw new Error(s)}_executeSubCommand(t,n){n=n.slice();let a=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(m,w){let i=Qs.resolve(m,w);if($1.existsSync(i))return i;if(o.includes(Qs.extname(w)))return;let G=o.find(V=>$1.existsSync(`${i}${V}`));if(G)return`${i}${G}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let e=t._executableFile||`${this._name}-${t._name}`,A=this._executableDir||"";if(this._scriptPath){let m;try{m=$1.realpathSync(this._scriptPath)}catch{m=this._scriptPath}A=Qs.resolve(Qs.dirname(m),A)}if(A){let m=s(A,e);if(!m&&!t._executableFile&&this._scriptPath){let w=Qs.basename(this._scriptPath,Qs.extname(this._scriptPath));w!==this._name&&(m=s(A,`${w}-${t._name}`))}e=m||e}a=o.includes(Qs.extname(e));let B;Rt.platform!=="win32"?a?(n.unshift(e),n=XO(Rt.execArgv).concat(n),B=$A.spawn(Rt.argv[0],n,{stdio:"inherit"})):B=$A.spawn(e,n,{stdio:"inherit"}):(this._checkForMissingExecutable(e,A,t._name),n.unshift(e),n=XO(Rt.execArgv).concat(n),B=$A.spawn(Rt.execPath,n,{stdio:"inherit"})),B.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(w=>{Rt.on(w,()=>{B.killed===!1&&B.exitCode===null&&B.kill(w)})});let q=this._exitCallback;B.on("close",m=>{m=m??1,q?q(new YA(m,"commander.executeSubCommandAsync","(close)")):Rt.exit(m)}),B.on("error",m=>{if(m.code==="ENOENT")this._checkForMissingExecutable(e,A,t._name);else if(m.code==="EACCES")throw new Error(`'${e}' not executable`);if(!q)Rt.exit(1);else{let w=new YA(1,"commander.executeSubCommandAsync","(error)");w.nestedError=m,q(w)}}),this.runningCommand=B}_dispatchSubcommand(t,n,a){let o=this._findCommand(t);o||this.help({error:!0}),o._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,n.concat(a));else return o._parseCommand(n,a)}),s}_dispatchHelpCommand(t){t||this.help();let n=this._findCommand(t);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,n)=>{t.required&&this.args[n]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(a,o,s)=>{let e=o;if(o!==null&&a.parseArg){let A=`error: command-argument value '${o}' is invalid for argument '${a.name()}'.`;e=this._callParseArg(a,o,s,A)}return e};this._checkNumberOfArguments();let n=[];this.registeredArguments.forEach((a,o)=>{let s=a.defaultValue;a.variadic?o<this.args.length?(s=this.args.slice(o),a.parseArg&&(s=s.reduce((e,A)=>t(a,A,e),a.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],a.parseArg&&(s=t(a,s,a.defaultValue))),n[o]=s}),this.processedArgs=n}_chainOrCall(t,n){return t&&t.then&&typeof t.then=="function"?t.then(()=>n()):n()}_chainOrCallHooks(t,n){let a=t,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[n]!==void 0).forEach(s=>{s._lifeCycleHooks[n].forEach(e=>{o.push({hookedCommand:s,callback:e})})}),n==="postAction"&&o.reverse(),o.forEach(s=>{a=this._chainOrCall(a,()=>s.callback(s.hookedCommand,this))}),a}_chainOrCallSubCommandHook(t,n,a){let o=t;return this._lifeCycleHooks[a]!==void 0&&this._lifeCycleHooks[a].forEach(s=>{o=this._chainOrCall(o,()=>s(this,n))}),o}_parseCommand(t,n){let a=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(a.operands),n=a.unknown,this.args=t.concat(n),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),n);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,t,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(a.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{a.unknown.length>0&&this.unknownOption(a.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let e;return e=this._chainOrCallHooks(e,"preAction"),e=this._chainOrCall(e,()=>this._actionHandler(this.processedArgs)),this.parent&&(e=this._chainOrCall(e,()=>{this.parent.emit(s,t,n)})),e=this._chainOrCallHooks(e,"postAction"),e}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,t,n);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,n);this.listenerCount("command:*")?this.emit("command:*",t,n):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(n=>n._name===t||n._aliases.includes(t))}_findOption(t){return this.options.find(n=>n.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(n=>{n.mandatory&&t.getOptionValue(n.attributeName())===void 0&&t.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(a=>{let o=a.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});t.filter(a=>a.conflictsWith.length>0).forEach(a=>{let o=t.find(s=>a.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(a,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let n=[],a=[],o=n,s=t.slice();function e(B){return B.length>1&&B[0]==="-"}let A=null;for(;s.length;){let B=s.shift();if(B==="--"){o===a&&o.push(B),o.push(...s);break}if(A&&!e(B)){this.emit(`option:${A.name()}`,B);continue}if(A=null,e(B)){let q=this._findOption(B);if(q){if(q.required){let m=s.shift();m===void 0&&this.optionMissingArgument(q),this.emit(`option:${q.name()}`,m)}else if(q.optional){let m=null;s.length>0&&!e(s[0])&&(m=s.shift()),this.emit(`option:${q.name()}`,m)}else this.emit(`option:${q.name()}`);A=q.variadic?q:null;continue}}if(B.length>2&&B[0]==="-"&&B[1]!=="-"){let q=this._findOption(`-${B[1]}`);if(q){q.required||q.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${q.name()}`,B.slice(2)):(this.emit(`option:${q.name()}`),s.unshift(`-${B.slice(2)}`));continue}}if(/^--[^=]+=/.test(B)){let q=B.indexOf("="),m=this._findOption(B.slice(0,q));if(m&&(m.required||m.optional)){this.emit(`option:${m.name()}`,B.slice(q+1));continue}}if(e(B)&&(o=a),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&a.length===0){if(this._findCommand(B)){n.push(B),s.length>0&&a.push(...s);break}else if(this._getHelpCommand()&&B===this._getHelpCommand().name()){n.push(B),s.length>0&&n.push(...s);break}else if(this._defaultCommandName){a.push(B),s.length>0&&a.push(...s);break}}if(this._passThroughOptions){o.push(B),s.length>0&&o.push(...s);break}o.push(B)}return{operands:n,unknown:a}}opts(){if(this._storeOptionsAsProperties){let t={},n=this.options.length;for(let a=0;a<n;a++){let o=this.options[a].attributeName();t[o]=o===this._versionOptionName?this._version:this[o]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,n)=>Object.assign(t,n.opts()),{})}error(t,n){this._outputConfiguration.outputError(`${t}
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
`),this.outputHelp({error:!0}));let a=n||{},o=a.exitCode||1,s=a.code||"commander.error";this._exit(o,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Rt.env){let n=t.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Rt.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new H6e(this.options),n=a=>this.getOptionValue(a)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(a));this.options.filter(a=>a.implied!==void 0&&n(a.attributeName())&&t.valueFromOption(this.getOptionValue(a.attributeName()),a)).forEach(a=>{Object.keys(a.implied).filter(o=>!n(o)).forEach(o=>{this.setOptionValueWithSource(o,a.implied[o],"implied")})})}missingArgument(t){let n=`error: missing required argument '${t}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(t){let n=`error: option '${t.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let n=`error: required option '${t.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,n){let a=e=>{let A=e.attributeName(),B=this.getOptionValue(A),q=this.options.find(w=>w.negate&&A===w.attributeName()),m=this.options.find(w=>!w.negate&&A===w.attributeName());return q&&(q.presetArg===void 0&&B===!1||q.presetArg!==void 0&&B===q.presetArg)?q:m||e},o=e=>{let A=a(e),B=A.attributeName();return this.getOptionValueSource(B)==="env"?`environment variable '${A.envVar}'`:`option '${A.flags}'`},s=`error: ${o(t)} cannot be used with ${o(n)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let n="";if(t.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let e=s.createHelp().visibleOptions(s).filter(A=>A.long).map(A=>A.long);o=o.concat(e),s=s.parent}while(s&&!s._enablePositionalOptions);n=VO(t,o)}let a=`error: unknown option '${t}'${n}`;this.error(a,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let n=this.registeredArguments.length,a=n===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${a} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],n="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),n=VO(t,o)}let a=`error: unknown command '${t}'${n}`;this.error(a,{code:"commander.unknownCommand"})}version(t,n,a){if(t===void 0)return this._version;this._version=t,n=n||"-V, --version",a=a||"output the version number";let o=this.createOption(n,a);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${t}
`),this._exit(0,"commander.version",t)}),this}description(t,n){return t===void 0&&n===void 0?this._description:(this._description=t,n&&(this._argsDescription=n),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),t===n._name)throw new Error("Command alias can't be the same as its name");let a=this.parent?._findCommand(t);if(a){let o=[a.name()].concat(a.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${o}'`)}return n._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(n=>this.alias(n)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(a=>q6e(a));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=Qs.basename(t,Qs.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let n=this.createHelp(),a=this._getOutputContext(t);n.prepareContext({error:a.error,helpWidth:a.helpWidth,outputHasColors:a.hasColors});let o=n.formatHelp(this,n);return a.hasColors?o:this._outputConfiguration.stripColor(o)}_getOutputContext(t){t=t||{};let n=!!t.error,a,o,s;return n?(a=A=>this._outputConfiguration.writeErr(A),o=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(a=A=>this._outputConfiguration.writeOut(A),o=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:n,write:A=>(o||(A=this._outputConfiguration.stripColor(A)),a(A)),hasColors:o,helpWidth:s}}outputHelp(t){let n;typeof t=="function"&&(n=t,t=void 0);let a=this._getOutputContext(t),o={error:a.error,write:a.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let s=this.helpInformation({error:a.error});if(n&&(s=n(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");a.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",o),this._getCommandAndAncestors().forEach(e=>e.emit("afterAllHelp",o))}helpOption(t,n){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(t,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let n=Number(Rt.exitCode??0);n===0&&t&&typeof t!="function"&&t.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(t,n){let a=["beforeAll","before","after","afterAll"];if(!a.includes(t))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${a.join("', '")}'`);let o=`${t}Help`;return this.on(o,s=>{let e;typeof n=="function"?e=n({error:s.error,command:s.command}):e=n,e&&s.write(`${e}
`)}),this}_outputHelpIfRequested(t){let n=this._getHelpOption();n&&t.find(o=>n.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function XO(r){return r.map(t=>{if(!t.startsWith("--inspect"))return t;let n,a="127.0.0.1",o="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?n=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=s[1],/^\d+$/.test(s[3])?o=s[3]:a=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=s[1],a=s[3],o=s[4]),n&&o!=="0"?`${n}=${a}:${parseInt(o)+1}`:t})}function JA(){if(Rt.env.NO_COLOR||Rt.env.FORCE_COLOR==="0"||Rt.env.FORCE_COLOR==="false")return!1;if(Rt.env.FORCE_COLOR||Rt.env.CLICOLOR_FORCE!==void 0)return!0}ZA.Command=KA;ZA.useColor=JA});var ZO=ze(Li=>{var{Argument:YO}=X1(),{Command:QA}=$O(),{CommanderError:z6e,InvalidArgumentError:KO}=ug(),{Help:j6e}=HA(),{Option:JO}=XA();Li.program=new QA;Li.createCommand=r=>new QA(r);Li.createOption=(r,t)=>new JO(r,t);Li.createArgument=(r,t)=>new YO(r,t);Li.Command=QA;Li.Option=JO;Li.Argument=YO;Li.Help=j6e;Li.CommanderError=z6e;Li.InvalidArgumentError=KO;Li.InvalidOptionArgumentError=KO});var tN=ze((mgr,rN)=>{"use strict";rN.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var ew=ze((vgr,aN)=>{var lg=tN(),nN={};for(let r of Object.keys(lg))nN[lg[r]]=r;var et={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};aN.exports=et;for(let r of Object.keys(et)){if(!("channels"in et[r]))throw new Error("missing channels property: "+r);if(!("labels"in et[r]))throw new Error("missing channel labels property: "+r);if(et[r].labels.length!==et[r].channels)throw new Error("channel and label counts mismatch: "+r);let{channels:t,labels:n}=et[r];delete et[r].channels,delete et[r].labels,Object.defineProperty(et[r],"channels",{value:t}),Object.defineProperty(et[r],"labels",{value:n})}et.rgb.hsl=function(r){let t=r[0]/255,n=r[1]/255,a=r[2]/255,o=Math.min(t,n,a),s=Math.max(t,n,a),e=s-o,A,B;s===o?A=0:t===s?A=(n-a)/e:n===s?A=2+(a-t)/e:a===s&&(A=4+(t-n)/e),A=Math.min(A*60,360),A<0&&(A+=360);let q=(o+s)/2;return s===o?B=0:q<=.5?B=e/(s+o):B=e/(2-s-o),[A,B*100,q*100]};et.rgb.hsv=function(r){let t,n,a,o,s,e=r[0]/255,A=r[1]/255,B=r[2]/255,q=Math.max(e,A,B),m=q-Math.min(e,A,B),w=function(i){return(q-i)/6/m+1/2};return m===0?(o=0,s=0):(s=m/q,t=w(e),n=w(A),a=w(B),e===q?o=a-n:A===q?o=1/3+t-a:B===q&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[o*360,s*100,q*100]};et.rgb.hwb=function(r){let t=r[0],n=r[1],a=r[2],o=et.rgb.hsl(r)[0],s=1/255*Math.min(t,Math.min(n,a));return a=1-1/255*Math.max(t,Math.max(n,a)),[o,s*100,a*100]};et.rgb.cmyk=function(r){let t=r[0]/255,n=r[1]/255,a=r[2]/255,o=Math.min(1-t,1-n,1-a),s=(1-t-o)/(1-o)||0,e=(1-n-o)/(1-o)||0,A=(1-a-o)/(1-o)||0;return[s*100,e*100,A*100,o*100]};function V6e(r,t){return(r[0]-t[0])**2+(r[1]-t[1])**2+(r[2]-t[2])**2}et.rgb.keyword=function(r){let t=nN[r];if(t)return t;let n=1/0,a;for(let o of Object.keys(lg)){let s=lg[o],e=V6e(r,s);e<n&&(n=e,a=o)}return a};et.keyword.rgb=function(r){return lg[r]};et.rgb.xyz=function(r){let t=r[0]/255,n=r[1]/255,a=r[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,a=a>.04045?((a+.055)/1.055)**2.4:a/12.92;let o=t*.4124+n*.3576+a*.1805,s=t*.2126+n*.7152+a*.0722,e=t*.0193+n*.1192+a*.9505;return[o*100,s*100,e*100]};et.rgb.lab=function(r){let t=et.rgb.xyz(r),n=t[0],a=t[1],o=t[2];n/=95.047,a/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,a=a>.008856?a**(1/3):7.787*a+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;let s=116*a-16,e=500*(n-a),A=200*(a-o);return[s,e,A]};et.hsl.rgb=function(r){let t=r[0]/360,n=r[1]/100,a=r[2]/100,o,s,e;if(n===0)return e=a*255,[e,e,e];a<.5?o=a*(1+n):o=a+n-a*n;let A=2*a-o,B=[0,0,0];for(let q=0;q<3;q++)s=t+1/3*-(q-1),s<0&&s++,s>1&&s--,6*s<1?e=A+(o-A)*6*s:2*s<1?e=o:3*s<2?e=A+(o-A)*(2/3-s)*6:e=A,B[q]=e*255;return B};et.hsl.hsv=function(r){let t=r[0],n=r[1]/100,a=r[2]/100,o=n,s=Math.max(a,.01);a*=2,n*=a<=1?a:2-a,o*=s<=1?s:2-s;let e=(a+n)/2,A=a===0?2*o/(s+o):2*n/(a+n);return[t,A*100,e*100]};et.hsv.rgb=function(r){let t=r[0]/60,n=r[1]/100,a=r[2]/100,o=Math.floor(t)%6,s=t-Math.floor(t),e=255*a*(1-n),A=255*a*(1-n*s),B=255*a*(1-n*(1-s));switch(a*=255,o){case 0:return[a,B,e];case 1:return[A,a,e];case 2:return[e,a,B];case 3:return[e,A,a];case 4:return[B,e,a];case 5:return[a,e,A]}};et.hsv.hsl=function(r){let t=r[0],n=r[1]/100,a=r[2]/100,o=Math.max(a,.01),s,e;e=(2-n)*a;let A=(2-n)*o;return s=n*o,s/=A<=1?A:2-A,s=s||0,e/=2,[t,s*100,e*100]};et.hwb.rgb=function(r){let t=r[0]/360,n=r[1]/100,a=r[2]/100,o=n+a,s;o>1&&(n/=o,a/=o);let e=Math.floor(6*t),A=1-a;s=6*t-e,(e&1)!==0&&(s=1-s);let B=n+s*(A-n),q,m,w;switch(e){default:case 6:case 0:q=A,m=B,w=n;break;case 1:q=B,m=A,w=n;break;case 2:q=n,m=A,w=B;break;case 3:q=n,m=B,w=A;break;case 4:q=B,m=n,w=A;break;case 5:q=A,m=n,w=B;break}return[q*255,m*255,w*255]};et.cmyk.rgb=function(r){let t=r[0]/100,n=r[1]/100,a=r[2]/100,o=r[3]/100,s=1-Math.min(1,t*(1-o)+o),e=1-Math.min(1,n*(1-o)+o),A=1-Math.min(1,a*(1-o)+o);return[s*255,e*255,A*255]};et.xyz.rgb=function(r){let t=r[0]/100,n=r[1]/100,a=r[2]/100,o,s,e;return o=t*3.2406+n*-1.5372+a*-.4986,s=t*-.9689+n*1.8758+a*.0415,e=t*.0557+n*-.204+a*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,e=e>.0031308?1.055*e**(1/2.4)-.055:e*12.92,o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),e=Math.min(Math.max(0,e),1),[o*255,s*255,e*255]};et.xyz.lab=function(r){let t=r[0],n=r[1],a=r[2];t/=95.047,n/=100,a/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;let o=116*n-16,s=500*(t-n),e=200*(n-a);return[o,s,e]};et.lab.xyz=function(r){let t=r[0],n=r[1],a=r[2],o,s,e;s=(t+16)/116,o=n/500+s,e=s-a/200;let A=s**3,B=o**3,q=e**3;return s=A>.008856?A:(s-16/116)/7.787,o=B>.008856?B:(o-16/116)/7.787,e=q>.008856?q:(e-16/116)/7.787,o*=95.047,s*=100,e*=108.883,[o,s,e]};et.lab.lch=function(r){let t=r[0],n=r[1],a=r[2],o;o=Math.atan2(a,n)*360/2/Math.PI,o<0&&(o+=360);let e=Math.sqrt(n*n+a*a);return[t,e,o]};et.lch.lab=function(r){let t=r[0],n=r[1],o=r[2]/360*2*Math.PI,s=n*Math.cos(o),e=n*Math.sin(o);return[t,s,e]};et.rgb.ansi16=function(r,t=null){let[n,a,o]=r,s=t===null?et.rgb.hsv(r)[2]:t;if(s=Math.round(s/50),s===0)return 30;let e=30+(Math.round(o/255)<<2|Math.round(a/255)<<1|Math.round(n/255));return s===2&&(e+=60),e};et.hsv.ansi16=function(r){return et.rgb.ansi16(et.hsv.rgb(r),r[2])};et.rgb.ansi256=function(r){let t=r[0],n=r[1],a=r[2];return t===n&&n===a?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(a/255*5)};et.ansi16.rgb=function(r){let t=r%10;if(t===0||t===7)return r>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let n=(~~(r>50)+1)*.5,a=(t&1)*n*255,o=(t>>1&1)*n*255,s=(t>>2&1)*n*255;return[a,o,s]};et.ansi256.rgb=function(r){if(r>=232){let s=(r-232)*10+8;return[s,s,s]}r-=16;let t,n=Math.floor(r/36)/5*255,a=Math.floor((t=r%36)/6)/5*255,o=t%6/5*255;return[n,a,o]};et.rgb.hex=function(r){let n=(((Math.round(r[0])&255)<<16)+((Math.round(r[1])&255)<<8)+(Math.round(r[2])&255)).toString(16).toUpperCase();return"000000".substring(n.length)+n};et.hex.rgb=function(r){let t=r.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=n.split("").map(A=>A+A).join(""));let a=parseInt(n,16),o=a>>16&255,s=a>>8&255,e=a&255;return[o,s,e]};et.rgb.hcg=function(r){let t=r[0]/255,n=r[1]/255,a=r[2]/255,o=Math.max(Math.max(t,n),a),s=Math.min(Math.min(t,n),a),e=o-s,A,B;return e<1?A=s/(1-e):A=0,e<=0?B=0:o===t?B=(n-a)/e%6:o===n?B=2+(a-t)/e:B=4+(t-n)/e,B/=6,B%=1,[B*360,e*100,A*100]};et.hsl.hcg=function(r){let t=r[1]/100,n=r[2]/100,a=n<.5?2*t*n:2*t*(1-n),o=0;return a<1&&(o=(n-.5*a)/(1-a)),[r[0],a*100,o*100]};et.hsv.hcg=function(r){let t=r[1]/100,n=r[2]/100,a=t*n,o=0;return a<1&&(o=(n-a)/(1-a)),[r[0],a*100,o*100]};et.hcg.rgb=function(r){let t=r[0]/360,n=r[1]/100,a=r[2]/100;if(n===0)return[a*255,a*255,a*255];let o=[0,0,0],s=t%1*6,e=s%1,A=1-e,B=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=e,o[2]=0;break;case 1:o[0]=A,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=e;break;case 3:o[0]=0,o[1]=A,o[2]=1;break;case 4:o[0]=e,o[1