@spree/cli 2.4.3 → 2.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +168 -166
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,186 +1,186 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from "node:module";
3
3
  const require = __createRequire(import.meta.url);
4
- var zh=Object.create;var ya=Object.defineProperty;var Vh=Object.getOwnPropertyDescriptor;var Wh=Object.getOwnPropertyNames;var Hh=Object.getPrototypeOf,Kh=Object.prototype.hasOwnProperty;var he=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var A=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var Yh=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Wh(t))!Kh.call(e,n)&&n!==r&&ya(e,n,{get:()=>t[n],enumerable:!(i=Vh(t,n))||i.enumerable});return e};var U=(e,t,r)=>(r=e!=null?zh(Hh(e)):{},Yh(t||!e||!e.__esModule?ya(r,"default",{value:e,enumerable:!0}):r,e));var rr=A(In=>{"use strict";var Ur=class extends Error{constructor(t,r,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},Rn=class extends Ur{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};In.CommanderError=Ur;In.InvalidArgumentError=Rn});var Nr=A(jn=>{"use strict";var{InvalidArgumentError:Jh}=rr(),On=class{constructor(t,r){switch(this.description=r||"",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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new Jh(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Xh(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}jn.Argument=On;jn.humanReadableArgName=Xh});var Mn=A(Ln=>{"use strict";var{humanReadableArgName:Zh}=Nr(),Dn=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 r=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&r.push(i),this.sortSubcommands&&r.sort((n,s)=>n.name().localeCompare(s.name())),r}compareOptions(t,r){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(r))}visibleOptions(t){let r=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);!n&&!s?r.push(i):i.long&&!s?r.push(t.createOption(i.long,i.description)):i.short&&!n&&r.push(t.createOption(i.short,i.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);r.push(...n)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(i=>Zh(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(n)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(n)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,r,i){return r.length===0?[]:[i.styleTitle(t),...r,""]}groupItems(t,r,i){let n=new Map;return t.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[])}),r.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[]),n.get(o).push(s)}),n}formatHelp(t,r){let i=r.padWidth(t,r),n=r.helpWidth??80;function s(u,l){return r.formatItem(u,i,l,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],a=r.commandDescription(t);a.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(a),n),""]));let c=r.visibleArguments(t).map(u=>s(r.styleArgumentTerm(r.argumentTerm(u)),r.styleArgumentDescription(r.argumentDescription(u))));if(o=o.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(t.options,r.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,l)=>{let m=u.map(h=>s(r.styleOptionTerm(r.optionTerm(h)),r.styleOptionDescription(r.optionDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),r.showGlobalOptions){let u=r.visibleGlobalOptions(t).map(l=>s(r.styleOptionTerm(r.optionTerm(l)),r.styleOptionDescription(r.optionDescription(l))));o=o.concat(this.formatItemList("Global Options:",u,r))}return this.groupItems(t.commands,r.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,l)=>{let m=u.map(h=>s(r.styleSubcommandTerm(r.subcommandTerm(h)),r.styleSubcommandDescription(r.subcommandDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),o.join(`
5
- `)}displayWidth(t){return fa(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).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(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).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,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,i,n){let o=" ".repeat(2);if(!i)return o+t;let a=t.padEnd(r+t.length-n.displayWidth(t)),c=2,p=(this.helpWidth??80)-r-c-2,u;return p<this.minWidthToWrap||n.preformatted(i)?u=i:u=n.boxWrap(i,p).replace(/\n/g,`
4
+ var Zh=Object.create;var va=Object.defineProperty;var Qh=Object.getOwnPropertyDescriptor;var ey=Object.getOwnPropertyNames;var ty=Object.getPrototypeOf,ry=Object.prototype.hasOwnProperty;var ye=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var A=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var iy=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ey(t))!ry.call(e,n)&&n!==r&&va(e,n,{get:()=>t[n],enumerable:!(i=Qh(t,n))||i.enumerable});return e};var M=(e,t,r)=>(r=e!=null?Zh(ty(e)):{},iy(t||!e||!e.__esModule?va(r,"default",{value:e,enumerable:!0}):r,e));var sr=A(Bn=>{"use strict";var Hr=class extends Error{constructor(t,r,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},Fn=class extends Hr{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Bn.CommanderError=Hr;Bn.InvalidArgumentError=Fn});var Kr=A(Nn=>{"use strict";var{InvalidArgumentError:ny}=sr(),Un=class{constructor(t,r){switch(this.description=r||"",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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new ny(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function sy(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}Nn.Argument=Un;Nn.humanReadableArgName=sy});var Vn=A(zn=>{"use strict";var{humanReadableArgName:oy}=Kr(),Gn=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 r=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&r.push(i),this.sortSubcommands&&r.sort((n,s)=>n.name().localeCompare(s.name())),r}compareOptions(t,r){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(r))}visibleOptions(t){let r=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);!n&&!s?r.push(i):i.long&&!s?r.push(t.createOption(i.long,i.description)):i.short&&!n&&r.push(t.createOption(i.short,i.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);r.push(...n)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(i=>oy(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(n)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(n)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,r,i){return r.length===0?[]:[i.styleTitle(t),...r,""]}groupItems(t,r,i){let n=new Map;return t.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[])}),r.forEach(s=>{let o=i(s);n.has(o)||n.set(o,[]),n.get(o).push(s)}),n}formatHelp(t,r){let i=r.padWidth(t,r),n=r.helpWidth??80;function s(u,l){return r.formatItem(u,i,l,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],a=r.commandDescription(t);a.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(a),n),""]));let c=r.visibleArguments(t).map(u=>s(r.styleArgumentTerm(r.argumentTerm(u)),r.styleArgumentDescription(r.argumentDescription(u))));if(o=o.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(t.options,r.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,l)=>{let m=u.map(h=>s(r.styleOptionTerm(r.optionTerm(h)),r.styleOptionDescription(r.optionDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),r.showGlobalOptions){let u=r.visibleGlobalOptions(t).map(l=>s(r.styleOptionTerm(r.optionTerm(l)),r.styleOptionDescription(r.optionDescription(l))));o=o.concat(this.formatItemList("Global Options:",u,r))}return this.groupItems(t.commands,r.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,l)=>{let m=u.map(h=>s(r.styleSubcommandTerm(r.subcommandTerm(h)),r.styleSubcommandDescription(r.subcommandDescription(h))));o=o.concat(this.formatItemList(l,m,r))}),o.join(`
5
+ `)}displayWidth(t){return Sa(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).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(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).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,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,i,n){let o=" ".repeat(2);if(!i)return o+t;let a=t.padEnd(r+t.length-n.displayWidth(t)),c=2,p=(this.helpWidth??80)-r-c-2,u;return p<this.minWidthToWrap||n.preformatted(i)?u=i:u=n.boxWrap(i,p).replace(/\n/g,`
6
6
  `+" ".repeat(r+c)),o+a+" ".repeat(c)+u.replace(/\n/g,`
7
7
  ${o}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return i.forEach(o=>{let a=o.match(n);if(a===null){s.push("");return}let c=[a.shift()],d=this.displayWidth(c[0]);a.forEach(p=>{let u=this.displayWidth(p);if(d+u<=r){c.push(p),d+=u;return}s.push(c.join(""));let l=p.trimStart();c=[l],d=this.displayWidth(l)}),s.push(c.join(""))}),s.join(`
8
- `)}};function fa(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}Ln.Help=Dn;Ln.stripColor=fa});var Nn=A(Un=>{"use strict";var{InvalidArgumentError:Qh}=rr(),Fn=class{constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=ey(t);this.short=i.shortFlag,this.long=i.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(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),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}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new Qh(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ga(this.name().replace(/^no-/,"")):ga(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Bn=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,r){let i=r.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,s=n!==void 0?n:!1;return r.negate===(s===t)}};function ga(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function ey(e){let t,r,i=/^-[^-]$/,n=/^--[^-]/,s=e.split(/[ |,]+/).concat("guard");if(i.test(s[0])&&(t=s.shift()),n.test(s[0])&&(r=s.shift()),!t&&i.test(s[0])&&(t=s.shift()),!t&&n.test(s[0])&&(t=r,r=s.shift()),s[0].startsWith("-")){let o=s[0],a=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
8
+ `)}};function Sa(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}zn.Help=Gn;zn.stripColor=Sa});var Yn=A(Kn=>{"use strict";var{InvalidArgumentError:ay}=sr(),Wn=class{constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=cy(t);this.short=i.shortFlag,this.long=i.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(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),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}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new ay(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?qa(this.name().replace(/^no-/,"")):qa(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Hn=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,r){let i=r.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,s=n!==void 0?n:!1;return r.negate===(s===t)}};function qa(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function cy(e){let t,r,i=/^-[^-]$/,n=/^--[^-]/,s=e.split(/[ |,]+/).concat("guard");if(i.test(s[0])&&(t=s.shift()),n.test(s[0])&&(r=s.shift()),!t&&i.test(s[0])&&(t=s.shift()),!t&&n.test(s[0])&&(t=r,r=s.shift()),s[0].startsWith("-")){let o=s[0],a=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
9
9
  - a short flag is a single dash and a single character
10
10
  - either use a single dash and a single character (for a short flag)
11
11
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(o)?new Error(`${a}
12
12
  - too many short flags`):n.test(o)?new Error(`${a}
13
13
  - too many long flags`):new Error(`${a}
14
- - unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}Un.Option=Fn;Un.DualOptions=Bn});var ba=A(_a=>{"use strict";function ty(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let i=0;i<=e.length;i++)r[i]=[i];for(let i=0;i<=t.length;i++)r[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++){let s=1;e[n-1]===t[i-1]?s=0:s=1,r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+s),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(r[n][i]=Math.min(r[n][i],r[n-2][i-2]+1))}return r[e.length][t.length]}function ry(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],n=3,s=.4;return t.forEach(o=>{if(o.length<=1)return;let a=ty(e,o),c=Math.max(e.length,o.length);(c-a)/c>s&&(a<n?(n=a,i=[o]):a===n&&i.push(o))}),i.sort((o,a)=>o.localeCompare(a)),r&&(i=i.map(o=>`--${o}`)),i.length>1?`
14
+ - unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}Kn.Option=Wn;Kn.DualOptions=Hn});var Aa=A($a=>{"use strict";function py(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let i=0;i<=e.length;i++)r[i]=[i];for(let i=0;i<=t.length;i++)r[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++){let s=1;e[n-1]===t[i-1]?s=0:s=1,r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+s),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(r[n][i]=Math.min(r[n][i],r[n-2][i-2]+1))}return r[e.length][t.length]}function dy(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],n=3,s=.4;return t.forEach(o=>{if(o.length<=1)return;let a=py(e,o),c=Math.max(e.length,o.length);(c-a)/c>s&&(a<n?(n=a,i=[o]):a===n&&i.push(o))}),i.sort((o,a)=>o.localeCompare(a)),r&&(i=i.map(o=>`--${o}`)),i.length>1?`
15
15
  (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
16
- (Did you mean ${i[0]}?)`:""}_a.suggestSimilar=ry});var va=A(Hn=>{"use strict";var iy=he("events").EventEmitter,Gn=he("child_process"),He=he("path"),Gr=he("fs"),I=he("process"),{Argument:ny,humanReadableArgName:sy}=Nr(),{CommanderError:zn}=rr(),{Help:oy,stripColor:ay}=Mn(),{Option:wa,DualOptions:cy}=Nn(),{suggestSimilar:xa}=ba(),Vn=class e extends iy{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:r=>I.stdout.write(r),writeErr:r=>I.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>I.stdout.isTTY?I.stdout.columns:void 0,getErrHelpWidth:()=>I.stderr.isTTY?I.stderr.columns:void 0,getOutHasColors:()=>Wn()??(I.stdout.isTTY&&I.stdout.hasColors?.()),getErrHasColors:()=>Wn()??(I.stderr.isTTY&&I.stderr.hasColors?.()),stripColor:r=>ay(r)},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(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 r=this;r;r=r.parent)t.push(r);return t}command(t,r,i){let n=r,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return n&&(c.description(n),c._executableHandler=!0),s.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(s.noHelp||s.hidden),c._executableFile=s.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),n?this:c}createCommand(t){return new e(t)}createHelp(){return Object.assign(new oy,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...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,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
17
- - specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new ny(t,r)}argument(t,r,i,n){let s=this.createArgument(t,r);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.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,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),o=r??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),o&&a.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||r)&&this._initCommandGroup(a),this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(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,r){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
18
- Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,i){this._exitCallback&&this._exitCallback(new zn(t,r,i)),I.exit(t)}action(t){let r=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=r,this}createOption(t,r){return new wa(t,r)}_callParseArg(t,r,i,n){try{return t.parseArg(r,i)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${n} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){let i=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 '${i}'
19
- - already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=n=>[n.name()].concat(n.aliases()),i=r(t).find(n=>this._findCommand(n));if(i){let n=r(this._findCommand(i)).join("|"),s=r(t).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let r=t.name(),i=t.attributeName();if(t.negate){let s=t.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(s,o,a)=>{s==null&&t.presetArg!==void 0&&(s=t.presetArg);let c=this.getOptionValue(i);s!==null&&t.parseArg?s=this._callParseArg(t,s,c,o):s!==null&&t.variadic&&(s=t._collectValue(s,c)),s==null&&(t.negate?s=!1:t.isBoolean()||t.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,a)};return this.on("option:"+r,s=>{let o=`error: option '${t.flags}' argument '${s}' is invalid.`;n(s,o,"cli")}),t.envVar&&this.on("optionEnv:"+r,s=>{let o=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;n(s,o,"env")}),this}_optionEx(t,r,i,n,s){if(typeof r=="object"&&r instanceof wa)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,i);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(s).argParser(n);else if(n instanceof RegExp){let a=n;n=(c,d)=>{let p=a.exec(c);return p?p[0]:d},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(t,r,i,n){return this._optionEx({},t,r,i,n)}requiredOption(t,r,i,n){return this._optionEx({mandatory:!0},t,r,i,n)}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,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,i){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(r=i.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){I.versions?.electron&&(r.from="electron");let n=I.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=I.argv),this.rawArgs=t.slice();let i;switch(r.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":I.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return this._parseCommand([],i),this}async parseAsync(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return await this._parseCommand([],i),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.
20
- - 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,r,i){if(Gr.existsSync(t))return;let n=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${t}' does not exist
16
+ (Did you mean ${i[0]}?)`:""}$a.suggestSimilar=dy});var Ta=A(es=>{"use strict";var uy=ye("events").EventEmitter,Jn=ye("child_process"),He=ye("path"),Yr=ye("fs"),I=ye("process"),{Argument:ly,humanReadableArgName:my}=Kr(),{CommanderError:Xn}=sr(),{Help:hy,stripColor:yy}=Vn(),{Option:Ca,DualOptions:fy}=Yn(),{suggestSimilar:Ea}=Aa(),Zn=class e extends uy{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:r=>I.stdout.write(r),writeErr:r=>I.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>I.stdout.isTTY?I.stdout.columns:void 0,getErrHelpWidth:()=>I.stderr.isTTY?I.stderr.columns:void 0,getOutHasColors:()=>Qn()??(I.stdout.isTTY&&I.stdout.hasColors?.()),getErrHasColors:()=>Qn()??(I.stderr.isTTY&&I.stderr.hasColors?.()),stripColor:r=>yy(r)},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(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 r=this;r;r=r.parent)t.push(r);return t}command(t,r,i){let n=r,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return n&&(c.description(n),c._executableHandler=!0),s.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(s.noHelp||s.hidden),c._executableFile=s.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),n?this:c}createCommand(t){return new e(t)}createHelp(){return Object.assign(new hy,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...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,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
17
+ - specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new ly(t,r)}argument(t,r,i,n){let s=this.createArgument(t,r);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.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,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),o=r??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),o&&a.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||r)&&this._initCommandGroup(a),this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(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,r){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
18
+ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,i){this._exitCallback&&this._exitCallback(new Xn(t,r,i)),I.exit(t)}action(t){let r=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=r,this}createOption(t,r){return new Ca(t,r)}_callParseArg(t,r,i,n){try{return t.parseArg(r,i)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${n} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){let i=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 '${i}'
19
+ - already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=n=>[n.name()].concat(n.aliases()),i=r(t).find(n=>this._findCommand(n));if(i){let n=r(this._findCommand(i)).join("|"),s=r(t).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let r=t.name(),i=t.attributeName();if(t.negate){let s=t.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(s,o,a)=>{s==null&&t.presetArg!==void 0&&(s=t.presetArg);let c=this.getOptionValue(i);s!==null&&t.parseArg?s=this._callParseArg(t,s,c,o):s!==null&&t.variadic&&(s=t._collectValue(s,c)),s==null&&(t.negate?s=!1:t.isBoolean()||t.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,a)};return this.on("option:"+r,s=>{let o=`error: option '${t.flags}' argument '${s}' is invalid.`;n(s,o,"cli")}),t.envVar&&this.on("optionEnv:"+r,s=>{let o=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;n(s,o,"env")}),this}_optionEx(t,r,i,n,s){if(typeof r=="object"&&r instanceof Ca)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,i);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(s).argParser(n);else if(n instanceof RegExp){let a=n;n=(c,d)=>{let p=a.exec(c);return p?p[0]:d},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(t,r,i,n){return this._optionEx({},t,r,i,n)}requiredOption(t,r,i,n){return this._optionEx({mandatory:!0},t,r,i,n)}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,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,i){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(r=i.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){I.versions?.electron&&(r.from="electron");let n=I.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=I.argv),this.rawArgs=t.slice();let i;switch(r.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":I.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return this._parseCommand([],i),this}async parseAsync(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return await this._parseCommand([],i),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.
20
+ - 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,r,i){if(Yr.existsSync(t))return;let n=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${t}' does not exist
21
21
  - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
22
22
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
23
- - ${n}`;throw new Error(s)}_executeSubCommand(t,r){r=r.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,u){let l=He.resolve(p,u);if(Gr.existsSync(l))return l;if(n.includes(He.extname(u)))return;let m=n.find(h=>Gr.existsSync(`${l}${h}`));if(m)return`${l}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=Gr.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=He.resolve(He.dirname(p),a)}if(a){let p=s(a,o);if(!p&&!t._executableFile&&this._scriptPath){let u=He.basename(this._scriptPath,He.extname(this._scriptPath));u!==this._name&&(p=s(a,`${u}-${t._name}`))}o=p||o}i=n.includes(He.extname(o));let c;I.platform!=="win32"?i?(r.unshift(o),r=ka(I.execArgv).concat(r),c=Gn.spawn(I.argv[0],r,{stdio:"inherit"})):c=Gn.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),r.unshift(o),r=ka(I.execArgv).concat(r),c=Gn.spawn(I.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{I.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let d=this._exitCallback;c.on("close",p=>{p=p??1,d?d(new zn(p,"commander.executeSubCommandAsync","(close)")):I.exit(p)}),c.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(p.code==="EACCES")throw new Error(`'${o}' not executable`);if(!d)I.exit(1);else{let u=new zn(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,d(u)}}),this.runningCommand=c}_dispatchSubcommand(t,r,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,r.concat(i));else return n._parseCommand(r,i)}),s}_dispatchHelpCommand(t){t||this.help();let r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==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=(i,n,s)=>{let o=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,s,a)}return o};this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((o,a)=>t(i,a,o),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),r[n]=s}),this.processedArgs=r}_chainOrCall(t,r){return t?.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[r]!==void 0).forEach(s=>{s._lifeCycleHooks[r].forEach(o=>{n.push({hookedCommand:s,callback:o})})}),r==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,r,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,r))}),n}_parseCommand(t,r){let i=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),r=i.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(s,t,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let r=[],i=[],n=r;function s(p){return p.length>1&&p[0]==="-"}let o=p=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(p)?!this._getCommandAndAncestors().some(u=>u.options.map(l=>l.short).some(l=>/^-\d$/.test(l))):!1,a=null,c=null,d=0;for(;d<t.length||c;){let p=c??t[d++];if(c=null,p==="--"){n===i&&n.push(p),n.push(...t.slice(d));break}if(a&&(!s(p)||o(p))){this.emit(`option:${a.name()}`,p);continue}if(a=null,s(p)){let u=this._findOption(p);if(u){if(u.required){let l=t[d++];l===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,l)}else if(u.optional){let l=null;d<t.length&&(!s(t[d])||o(t[d]))&&(l=t[d++]),this.emit(`option:${u.name()}`,l)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),c=`-${p.slice(2)}`);continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),l=this._findOption(p.slice(0,u));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,p.slice(u+1));continue}}if(n===r&&s(p)&&!(this.commands.length===0&&o(p))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(p)){r.push(p),i.push(...t.slice(d));break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){r.push(p,...t.slice(d));break}else if(this._defaultCommandName){i.push(p,...t.slice(d));break}}if(this._passThroughOptions){n.push(p,...t.slice(d));break}n.push(p)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},r=this.options.length;for(let i=0;i<r;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){this._outputConfiguration.outputError(`${t}
23
+ - ${n}`;throw new Error(s)}_executeSubCommand(t,r){r=r.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,u){let l=He.resolve(p,u);if(Yr.existsSync(l))return l;if(n.includes(He.extname(u)))return;let m=n.find(h=>Yr.existsSync(`${l}${h}`));if(m)return`${l}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=Yr.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=He.resolve(He.dirname(p),a)}if(a){let p=s(a,o);if(!p&&!t._executableFile&&this._scriptPath){let u=He.basename(this._scriptPath,He.extname(this._scriptPath));u!==this._name&&(p=s(a,`${u}-${t._name}`))}o=p||o}i=n.includes(He.extname(o));let c;I.platform!=="win32"?i?(r.unshift(o),r=Pa(I.execArgv).concat(r),c=Jn.spawn(I.argv[0],r,{stdio:"inherit"})):c=Jn.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),r.unshift(o),r=Pa(I.execArgv).concat(r),c=Jn.spawn(I.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{I.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let d=this._exitCallback;c.on("close",p=>{p=p??1,d?d(new Xn(p,"commander.executeSubCommandAsync","(close)")):I.exit(p)}),c.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(p.code==="EACCES")throw new Error(`'${o}' not executable`);if(!d)I.exit(1);else{let u=new Xn(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,d(u)}}),this.runningCommand=c}_dispatchSubcommand(t,r,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,r.concat(i));else return n._parseCommand(r,i)}),s}_dispatchHelpCommand(t){t||this.help();let r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==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=(i,n,s)=>{let o=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,s,a)}return o};this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((o,a)=>t(i,a,o),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),r[n]=s}),this.processedArgs=r}_chainOrCall(t,r){return t?.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[r]!==void 0).forEach(s=>{s._lifeCycleHooks[r].forEach(o=>{n.push({hookedCommand:s,callback:o})})}),r==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,r,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,r))}),n}_parseCommand(t,r){let i=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),r=i.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(s,t,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let r=[],i=[],n=r;function s(p){return p.length>1&&p[0]==="-"}let o=p=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(p)?!this._getCommandAndAncestors().some(u=>u.options.map(l=>l.short).some(l=>/^-\d$/.test(l))):!1,a=null,c=null,d=0;for(;d<t.length||c;){let p=c??t[d++];if(c=null,p==="--"){n===i&&n.push(p),n.push(...t.slice(d));break}if(a&&(!s(p)||o(p))){this.emit(`option:${a.name()}`,p);continue}if(a=null,s(p)){let u=this._findOption(p);if(u){if(u.required){let l=t[d++];l===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,l)}else if(u.optional){let l=null;d<t.length&&(!s(t[d])||o(t[d]))&&(l=t[d++]),this.emit(`option:${u.name()}`,l)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),c=`-${p.slice(2)}`);continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),l=this._findOption(p.slice(0,u));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,p.slice(u+1));continue}}if(n===r&&s(p)&&!(this.commands.length===0&&o(p))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(p)){r.push(p),i.push(...t.slice(d));break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){r.push(p,...t.slice(d));break}else if(this._defaultCommandName){i.push(p,...t.slice(d));break}}if(this._passThroughOptions){n.push(p,...t.slice(d));break}n.push(p)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},r=this.options.length;for(let i=0;i<r;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){this._outputConfiguration.outputError(`${t}
24
24
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
25
25
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
26
- `),this.outputHelp({error:!0}));let i=r||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in I.env){let r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,I.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new cy(this.options),r=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&r(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!r(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){let r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){let i=o=>{let a=o.attributeName(),c=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),p=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:p||o},n=o=>{let a=i(o),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(r)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);r=xa(t,n)}let i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,i=r===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],r="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),r=xa(t,n)}let i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",i=i||"output the version number";let n=this.createOption(r,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
27
- `),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(i=>sy(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=He.basename(t,He.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let r=this.createHelp(),i=this._getOutputContext(t);r.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=r.formatHelp(this,r);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let r=!!t.error,i,n,s;return r?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:r,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:s}}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(r&&(s=r(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,r){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",r??"display help for command"),(t||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let r=Number(I.exitCode??0);r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
+ `),this.outputHelp({error:!0}));let i=r||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in I.env){let r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,I.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new fy(this.options),r=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&r(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!r(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){let r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){let i=o=>{let a=o.attributeName(),c=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),p=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:p||o},n=o=>{let a=i(o),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(r)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);r=Ea(t,n)}let i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,i=r===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],r="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),r=Ea(t,n)}let i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",i=i||"output the version number";let n=this.createOption(r,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
27
+ `),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(i=>my(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=He.basename(t,He.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let r=this.createHelp(),i=this._getOutputContext(t);r.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=r.formatHelp(this,r);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let r=!!t.error,i,n,s;return r?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:r,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:s}}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(r&&(s=r(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,r){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",r??"display help for command"),(t||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let r=Number(I.exitCode??0);r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
28
28
  Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,s=>{let o;typeof r=="function"?o=r({error:s.error,command:s.command}):o=r,o&&s.write(`${o}
29
- `)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(n=>r.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ka(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?r=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=s[1],i=s[3],n=s[4]),r&&n!=="0"?`${r}=${i}:${parseInt(n)+1}`:t})}function Wn(){if(I.env.NO_COLOR||I.env.FORCE_COLOR==="0"||I.env.FORCE_COLOR==="false")return!1;if(I.env.FORCE_COLOR||I.env.CLICOLOR_FORCE!==void 0)return!0}Hn.Command=Vn;Hn.useColor=Wn});var Aa=A(_e=>{"use strict";var{Argument:Sa}=Nr(),{Command:Kn}=va(),{CommanderError:py,InvalidArgumentError:qa}=rr(),{Help:dy}=Mn(),{Option:$a}=Nn();_e.program=new Kn;_e.createCommand=e=>new Kn(e);_e.createOption=(e,t)=>new $a(e,t);_e.createArgument=(e,t)=>new Sa(e,t);_e.Command=Kn;_e.Option=$a;_e.Argument=Sa;_e.Help=dy;_e.CommanderError=py;_e.InvalidArgumentError=qa;_e.InvalidOptionArgumentError=qa});var Y=A((pq,Yn)=>{"use strict";var Vr=process||{},Ta=Vr.argv||[],zr=Vr.env||{},uy=!(zr.NO_COLOR||Ta.includes("--no-color"))&&(!!zr.FORCE_COLOR||Ta.includes("--color")||Vr.platform==="win32"||(Vr.stdout||{}).isTTY&&zr.TERM!=="dumb"||!!zr.CI),ly=(e,t,r=e)=>i=>{let n=""+i,s=n.indexOf(t,e.length);return~s?e+my(n,t,r,s)+t:e+n+t},my=(e,t,r,i)=>{let n="",s=0;do n+=e.substring(s,i)+r,s=i+t.length,i=e.indexOf(t,s);while(~i);return n+e.substring(s)},Ra=(e=uy)=>{let t=e?ly:()=>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")}};Yn.exports=Ra();Yn.exports.createColors=Ra});var es=A((gq,Ha)=>{"use strict";var Qn={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let r="";return e<0?r+=`\x1B[${-e}D`:e>0&&(r+=`\x1B[${e}C`),t<0?r+=`\x1B[${-t}A`:t>0&&(r+=`\x1B[${t}B`),r},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Ay={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Cy={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let r=0;r<e;r++)t+=this.line+(r<e-1?Qn.up():"");return e&&(t+=Qn.left),t}};Ha.exports={cursor:Qn,scroll:Ay,erase:Cy,beep:"\x07"}});var Tc=A((DA,Pc)=>{"use strict";Pc.exports=Ec;Ec.sync=eg;var Ac=he("fs");function Qf(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var i=0;i<r.length;i++){var n=r[i].toLowerCase();if(n&&e.substr(-n.length).toLowerCase()===n)return!0}return!1}function Cc(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:Qf(t,r)}function Ec(e,t,r){Ac.stat(e,function(i,n){r(i,i?!1:Cc(n,e,t))})}function eg(e,t){return Cc(Ac.statSync(e),e,t)}});var Dc=A((LA,jc)=>{"use strict";jc.exports=Ic;Ic.sync=tg;var Rc=he("fs");function Ic(e,t,r){Rc.stat(e,function(i,n){r(i,i?!1:Oc(n,t))})}function tg(e,t){return Oc(Rc.statSync(e),t)}function Oc(e,t){return e.isFile()&&rg(e,t)}function rg(e,t){var r=e.mode,i=e.uid,n=e.gid,s=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),o=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),d=parseInt("001",8),p=a|c,u=r&d||r&c&&n===o||r&a&&i===s||r&p&&s===0;return u}});var Mc=A((FA,Lc)=>{"use strict";var MA=he("fs"),bi;process.platform==="win32"||global.TESTING_WINDOWS?bi=Tc():bi=Dc();Lc.exports=_s;_s.sync=ig;function _s(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){_s(e,t||{},function(s,o){s?n(s):i(o)})})}bi(e,t||{},function(i,n){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,n=!1),r(i,n)})}function ig(e,t){try{return bi.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Vc=A((BA,zc)=>{"use strict";var It=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Fc=he("path"),ng=It?";":":",Bc=Mc(),Uc=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Nc=(e,t)=>{let r=t.colon||ng,i=e.match(/\//)||It&&e.match(/\\/)?[""]:[...It?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=It?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=It?n.split(r):[""];return It&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:i,pathExt:s,pathExtExe:n}},Gc=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:i,pathExt:n,pathExtExe:s}=Nc(e,t),o=[],a=d=>new Promise((p,u)=>{if(d===i.length)return t.all&&o.length?p(o):u(Uc(e));let l=i[d],m=/^".*"$/.test(l)?l.slice(1,-1):l,h=Fc.join(m,e),f=!m&&/^\.[\\\/]/.test(e)?e.slice(0,2)+h:h;p(c(f,d,0))}),c=(d,p,u)=>new Promise((l,m)=>{if(u===n.length)return l(a(p+1));let h=n[u];Bc(d+h,{pathExt:s},(f,x)=>{if(!f&&x)if(t.all)o.push(d+h);else return l(d+h);return l(c(d,p,u+1))})});return r?a(0).then(d=>r(null,d),r):a(0)},sg=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:i,pathExtExe:n}=Nc(e,t),s=[];for(let o=0;o<r.length;o++){let a=r[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=Fc.join(c,e),p=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let u=0;u<i.length;u++){let l=p+i[u];try{if(Bc.sync(l,{pathExt:n}))if(t.all)s.push(l);else return l}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw Uc(e)};zc.exports=Gc;Gc.sync=sg});var Hc=A((UA,bs)=>{"use strict";var Wc=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};bs.exports=Wc;bs.exports.default=Wc});var Xc=A((NA,Jc)=>{"use strict";var Kc=he("path"),og=Vc(),ag=Hc();function Yc(e,t){let r=e.options.env||process.env,i=process.cwd(),n=e.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let o;try{o=og.sync(e.command,{path:r[ag({env:r})],pathExt:t?Kc.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=Kc.resolve(n?e.options.cwd:"",o)),o}function cg(e){return Yc(e)||Yc(e,!0)}Jc.exports=cg});var Zc=A((GA,xs)=>{"use strict";var ws=/([()\][%!^"`<>&|;, *?])/g;function pg(e){return e=e.replace(ws,"^$1"),e}function dg(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(ws,"^$1"),t&&(e=e.replace(ws,"^$1")),e}xs.exports.command=pg;xs.exports.argument=dg});var ep=A((zA,Qc)=>{"use strict";Qc.exports=/^#!(.*)/});var rp=A((VA,tp)=>{"use strict";var ug=ep();tp.exports=(e="")=>{let t=e.match(ug);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var np=A((WA,ip)=>{"use strict";var ks=he("fs"),lg=rp();function mg(e){let r=Buffer.alloc(150),i;try{i=ks.openSync(e,"r"),ks.readSync(i,r,0,150,0),ks.closeSync(i)}catch{}return lg(r.toString())}ip.exports=mg});var cp=A((HA,ap)=>{"use strict";var hg=he("path"),sp=Xc(),op=Zc(),yg=np(),fg=process.platform==="win32",gg=/\.(?:com|exe)$/i,_g=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function bg(e){e.file=sp(e);let t=e.file&&yg(e.file);return t?(e.args.unshift(e.file),e.command=t,sp(e)):e.file}function wg(e){if(!fg)return e;let t=bg(e),r=!gg.test(t);if(e.options.forceShell||r){let i=_g.test(t);e.command=hg.normalize(e.command),e.command=op.command(e.command),e.args=e.args.map(s=>op.argument(s,i));let n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function xg(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let i={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?i:wg(i)}ap.exports=xg});var up=A((KA,dp)=>{"use strict";var vs=process.platform==="win32";function Ss(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function kg(e,t){if(!vs)return;let r=e.emit;e.emit=function(i,n){if(i==="exit"){let s=pp(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function pp(e,t){return vs&&e===1&&!t.file?Ss(t.original,"spawn"):null}function vg(e,t){return vs&&e===1&&!t.file?Ss(t.original,"spawnSync"):null}dp.exports={hookChildProcess:kg,verifyENOENT:pp,verifyENOENTSync:vg,notFoundError:Ss}});var hp=A((YA,Ot)=>{"use strict";var lp=he("child_process"),qs=cp(),$s=up();function mp(e,t,r){let i=qs(e,t,r),n=lp.spawn(i.command,i.args,i.options);return $s.hookChildProcess(n,i),n}function Sg(e,t,r){let i=qs(e,t,r),n=lp.spawnSync(i.command,i.args,i.options);return n.error=n.error||$s.verifyENOENTSync(n.status,i),n}Ot.exports=mp;Ot.exports.spawn=mp;Ot.exports.sync=Sg;Ot.exports._parse=qs;Ot.exports._enoent=$s});var Wo=A(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.DEFAULT_COLOR_MAP=void 0;Wt.DEFAULT_COLOR_MAP={red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",white_bold:"\x1B[01m",reset:"\x1B[0m"};var Vo=class{constructor(t=Wt.DEFAULT_COLOR_MAP){this.text="",this.colorMap=t}addCharsWithColor(t,r){let i=this.colorMap[t];this.text+=i!==void 0?`${i}${r}${this.colorMap.reset}`:r}renderConsole(){return this.text}};Wt.default=Vo});var Pr=A(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.DEFAULT_HEADER_ALIGNMENT=Z.DEFAULT_ROW_ALIGNMENT=Z.DEFAULT_HEADER_FONT_COLOR=Z.DEFAULT_ROW_FONT_COLOR=Z.COLORS=Z.ALIGNMENTS=Z.DEFAULT_TABLE_STYLE=Z.DEFAULT_ROW_SEPARATOR=Z.DEFAULT_COLUMN_LEN=void 0;Z.DEFAULT_COLUMN_LEN=20;Z.DEFAULT_ROW_SEPARATOR=!1;Z.DEFAULT_TABLE_STYLE={headerTop:{left:"\u250C",mid:"\u252C",right:"\u2510",other:"\u2500"},headerBottom:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"},tableBottom:{left:"\u2514",mid:"\u2534",right:"\u2518",other:"\u2500"},vertical:"\u2502",rowSeparator:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"}};Z.ALIGNMENTS=["right","left","center"];Z.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];Z.DEFAULT_ROW_FONT_COLOR="white";Z.DEFAULT_HEADER_FONT_COLOR="white_bold";Z.DEFAULT_ROW_ALIGNMENT="right";Z.DEFAULT_HEADER_ALIGNMENT="center"});var gm=A(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});var Gk=[{first:768,last:879},{first:1155,last:1158},{first:1160,last:1161},{first:1425,last:1469},{first:1471,last:1471},{first:1473,last:1474},{first:1476,last:1477},{first:1479,last:1479},{first:1536,last:1539},{first:1552,last:1557},{first:1611,last:1630},{first:1648,last:1648},{first:1750,last:1764},{first:1767,last:1768},{first:1770,last:1773},{first:1807,last:1807},{first:1809,last:1809},{first:1840,last:1866},{first:1958,last:1968},{first:2027,last:2035},{first:2305,last:2306},{first:2364,last:2364},{first:2369,last:2376},{first:2381,last:2381},{first:2385,last:2388},{first:2402,last:2403},{first:2433,last:2433},{first:2492,last:2492},{first:2497,last:2500},{first:2509,last:2509},{first:2530,last:2531},{first:2561,last:2562},{first:2620,last:2620},{first:2625,last:2626},{first:2631,last:2632},{first:2635,last:2637},{first:2672,last:2673},{first:2689,last:2690},{first:2748,last:2748},{first:2753,last:2757},{first:2759,last:2760},{first:2765,last:2765},{first:2786,last:2787},{first:2817,last:2817},{first:2876,last:2876},{first:2879,last:2879},{first:2881,last:2883},{first:2893,last:2893},{first:2902,last:2902},{first:2946,last:2946},{first:3008,last:3008},{first:3021,last:3021},{first:3134,last:3136},{first:3142,last:3144},{first:3146,last:3149},{first:3157,last:3158},{first:3260,last:3260},{first:3263,last:3263},{first:3270,last:3270},{first:3276,last:3277},{first:3298,last:3299},{first:3393,last:3395},{first:3405,last:3405},{first:3530,last:3530},{first:3538,last:3540},{first:3542,last:3542},{first:3633,last:3633},{first:3636,last:3642},{first:3655,last:3662},{first:3761,last:3761},{first:3764,last:3769},{first:3771,last:3772},{first:3784,last:3789},{first:3864,last:3865},{first:3893,last:3893},{first:3895,last:3895},{first:3897,last:3897},{first:3953,last:3966},{first:3968,last:3972},{first:3974,last:3975},{first:3984,last:3991},{first:3993,last:4028},{first:4038,last:4038},{first:4141,last:4144},{first:4146,last:4146},{first:4150,last:4151},{first:4153,last:4153},{first:4184,last:4185},{first:4448,last:4607},{first:4959,last:4959},{first:5906,last:5908},{first:5938,last:5940},{first:5970,last:5971},{first:6002,last:6003},{first:6068,last:6069},{first:6071,last:6077},{first:6086,last:6086},{first:6089,last:6099},{first:6109,last:6109},{first:6155,last:6157},{first:6313,last:6313},{first:6432,last:6434},{first:6439,last:6440},{first:6450,last:6450},{first:6457,last:6459},{first:6679,last:6680},{first:6912,last:6915},{first:6964,last:6964},{first:6966,last:6970},{first:6972,last:6972},{first:6978,last:6978},{first:7019,last:7027},{first:7616,last:7626},{first:7678,last:7679},{first:8203,last:8207},{first:8234,last:8238},{first:8288,last:8291},{first:8298,last:8303},{first:8400,last:8431},{first:12330,last:12335},{first:12441,last:12442},{first:43014,last:43014},{first:43019,last:43019},{first:43045,last:43046},{first:64286,last:64286},{first:65024,last:65039},{first:65056,last:65059},{first:65279,last:65279},{first:65529,last:65531},{first:68097,last:68099},{first:68101,last:68102},{first:68108,last:68111},{first:68152,last:68154},{first:68159,last:68159},{first:119143,last:119145},{first:119155,last:119170},{first:119173,last:119179},{first:119210,last:119213},{first:119362,last:119364},{first:917505,last:917505},{first:917536,last:917631},{first:917760,last:917999}];Ho.default=Gk});var _m=A(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});var zk=(e,t,r)=>{let i=0,n,s=r;if(e<t[0].first||e>t[s].last)return 0;for(;s>=i;)if(n=Math.floor((i+s)/2),e>t[n].last)i=n+1;else if(e<t[n].first)s=n-1;else return 1;return 0};Ko.default=zk});var Yo=A(Tr=>{"use strict";var wm=Tr&&Tr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tr,"__esModule",{value:!0});var bm=wm(gm()),Vk=wm(_m()),Wk=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,Vk.default)(e,bm.default,bm.default.length-1)?0:1+ +(e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141));Tr.default=Wk});var xm=A(Rr=>{"use strict";var Hk=Rr&&Rr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Rr,"__esModule",{value:!0});var Kk=Hk(Yo()),Yk=e=>{let t=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),n=(0,Kk.default)(i);if(n<0)return-1;t+=n}return t};Rr.default=Yk});var vm=A(mt=>{"use strict";var km=mt&&mt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mt,"__esModule",{value:!0});mt.wcswidth=mt.wcwidth=void 0;var Jk=km(xm());mt.wcswidth=Jk.default;var Xk=km(Yo());mt.wcwidth=Xk.default});var Jo=A(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.findWidthInConsole=At.stripAnsi=void 0;var Zk=vm(),Qk=/\x1b\[\d{1,3}(;\d{1,3})*m/g,ev=e=>e.replace(Qk,"");At.stripAnsi=ev;var tv=(e,t)=>{let r=0;return e=(0,At.stripAnsi)(e),t&&Object.entries(t).forEach(([i,n])=>{let s=new RegExp(i,"g");r+=(e.match(s)||[]).length*n,e=e.replace(i,"")}),r+=(0,Zk.wcswidth)(e),r};At.findWidthInConsole=tv});var Zo=A(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.biggestWordInSentence=Be.textWithPadding=Be.splitTextIntoTextsOfMinLen=void 0;var Xo=Jo(),rv=(e,t,r)=>{let i=[];return e.split(/[\n\r]/).forEach(s=>{let o=s.split(" "),a=[],c=0;o.forEach(d=>{let p=(0,Xo.findWidthInConsole)(d,r);c+p<=t?(c+=p+1,a.push(d)):(a.length>0&&i.push(a.join(" ")),a=[d],c=p+1)}),i.push(a.join(" "))}),i};Be.splitTextIntoTextsOfMinLen=rv;var iv=(e,t,r,i)=>{let n=(0,Xo.findWidthInConsole)(e,i),s=Math.floor((r-n)/2),o=r-s-n;if(r<n){let a=(0,Be.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,Be.textWithPadding)(c,t,r,i)).join(`
30
- `)}switch(t){case"left":return e.concat(" ".repeat(r-n));case"center":return" ".repeat(s).concat(e).concat(" ".repeat(o));default:return" ".repeat(r-n).concat(e)}};Be.textWithPadding=iv;var nv=(e,t)=>e.split(" ").reduce((r,i)=>Math.max(r,(0,Xo.findWidthInConsole)(i,t)),0);Be.biggestWordInSentence=nv});var Ir=A(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.getWidthLimitedColumnsArray=N.createHeaderAsRow=N.renderTableHorizontalBorders=N.findLenOfColumn=N.createRow=N.createColumFromOnlyName=N.createTableHorizontalBorders=N.convertRawRowOptionsToStandard=N.evaluateCellText=N.cellText=void 0;var Sm=Jo(),Qo=Zo(),ea=Pr(),Ht=(e,t)=>Math.max(e,t),sv=e=>e==null?"":`${e}`;N.cellText=sv;var ov=(e,t)=>t?`${t(e)}`:(0,N.cellText)(e);N.evaluateCellText=ov;var av=e=>{if(e)return{color:e.color,separator:e.separator||ea.DEFAULT_ROW_SEPARATOR}};N.convertRawRowOptionsToStandard=av;var cv=({left:e,mid:t,right:r,other:i},n)=>{let s=e;return n.forEach(o=>{s+=i.repeat(o+2),s+=t}),s=s.slice(0,-t.length),s+=r,s};N.createTableHorizontalBorders=cv;var pv=e=>({name:e,title:e});N.createColumFromOnlyName=pv;var dv=(e,t,r)=>({color:e,separator:r,text:t});N.createRow=dv;var uv=(e,t,r)=>{let i=e.name,n=e.title,s=e.transform,o=Ht(0,e?.minLen||0);return e.maxLen?(o=Ht(o,Ht(e.maxLen,(0,Qo.biggestWordInSentence)(n,r))),o=t.reduce((a,c)=>Ht(a,(0,Qo.biggestWordInSentence)((0,N.evaluateCellText)(c.text[i],s),r)),o),o):(o=Ht(o,(0,Sm.findWidthInConsole)(n,r)),t.forEach(a=>{o=Ht(o,(0,Sm.findWidthInConsole)((0,N.evaluateCellText)(a.text[i],s),r))}),o)};N.findLenOfColumn=uv;var lv=(e,t)=>(0,N.createTableHorizontalBorders)(e,t);N.renderTableHorizontalBorders=lv;var mv=(e,t)=>{let r=ea.DEFAULT_HEADER_FONT_COLOR,i=e(r,{},!1);return t.forEach(n=>{i.text[n.name]=n.title}),i};N.createHeaderAsRow=mv;var hv=(e,t,r)=>{let i={};return e.forEach(n=>{i[n.name]=(0,Qo.splitTextIntoTextsOfMinLen)((0,N.cellText)(t.text[n.name]),n.length||ea.DEFAULT_COLUMN_LEN,r)}),i};N.getWidthLimitedColumnsArray=hv});var qm=A(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.rawColumnToInternalColumn=Qe.objIfExists=void 0;var yv=Pr(),fv=(e,t)=>t?{[e]:t}:{};Qe.objIfExists=fv;var gv=(e,t)=>{var r;return Object.assign(Object.assign(Object.assign(Object.assign({name:e.name,title:(r=e.title)!==null&&r!==void 0?r:e.name},(0,Qe.objIfExists)("color",e.color||t?.color)),(0,Qe.objIfExists)("maxLen",e.maxLen||t?.maxLen)),(0,Qe.objIfExists)("minLen",e.minLen||t?.minLen)),{alignment:e.alignment||t?.alignment||yv.DEFAULT_ROW_ALIGNMENT,transform:e.transform})};Qe.rawColumnToInternalColumn=gv});var $m=A(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.preProcessRows=Kt.preProcessColumns=void 0;var _v=Ir(),bv=e=>{e.computedColumns.length&&e.computedColumns.forEach(t=>{e.columns.some(i=>i.name===t.name)||(e.addColumn(Object.assign(Object.assign({},t),e.defaultColumnOptions)),e.rows.forEach((i,n,s)=>{let o=s.map(a=>a.text);i.text[t.name]=t.function(i.text,n,o)}))})},wv=e=>{e.enabledColumns.length&&(e.columns=e.columns.filter(t=>e.enabledColumns.includes(t.name)))},xv=e=>{e.disabledColumns.length&&(e.columns=e.columns.filter(t=>!e.disabledColumns.includes(t.name)))},kv=e=>{e.columns.forEach(t=>{t.length=(0,_v.findLenOfColumn)(t,e.rows,e.charLength)})},vv=e=>{bv(e),xv(e),wv(e),kv(e)};Kt.preProcessColumns=vv;var Sv=e=>{let t=e.rows.filter(r=>e.filterFunction(r.text)).sort((r,i)=>e.sortFunction(r.text,i.text));e.rows=t};Kt.preProcessRows=Sv});var ta=A(ke=>{"use strict";var Cm=ke&&ke.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ke,"__esModule",{value:!0});ke.printSimpleTable=ke.renderSimpleTable=ke.renderTable=void 0;var Em=Cm(Wo()),Pm=Zo(),Ce=Pr(),ht=Ir(),qv=Cm(ra()),Am=$m(),$v=(e,t,r,i,n,s,o,a)=>{let c=new Em.default(o);return c.addCharsWithColor("",e.vertical),t.forEach(d=>{let u=r<i[d.name].length?(0,ht.cellText)(i[d.name][r]):"";c.addCharsWithColor(Ce.DEFAULT_ROW_FONT_COLOR," "),c.addCharsWithColor(n&&Ce.DEFAULT_HEADER_FONT_COLOR||d.color||s.color,(0,Pm.textWithPadding)(u,d.alignment||Ce.DEFAULT_ROW_ALIGNMENT,d.length||Ce.DEFAULT_COLUMN_LEN,a)),c.addCharsWithColor("",` ${e.vertical}`)}),c.renderConsole()},Tm=(e,t,r,i,n,s)=>{let o=(0,ht.getWidthLimitedColumnsArray)(t,r,s),a=Object.values(o).reduce((d,p)=>Math.max(d,p.length),0),c=[];for(let d=0;d<a;d+=1){let p=$v(e,t,d,o,n,r,i,s);c.push(p)}return c},Av=(e,t)=>{let r=JSON.parse(JSON.stringify(e)),i={};return t.filter(n=>!!n.transform).forEach(n=>{i[n.name]=n.transform}),Object.keys(i).forEach(n=>{r.text[n]=i[n](r.text[n])}),r},Cv=(e,t)=>{let r=[],i=Av(t,e.columns);return r=r.concat(Tm(e.tableStyle,e.columns,i,e.colorMap,void 0,e.charLength)),r},Ev=e=>{let t=[];if(e.title===void 0)return t;let r=()=>{let s=(o,a)=>o+a+2+1;return e.columns.map(o=>o.length||Ce.DEFAULT_COLUMN_LEN).reduce(s,1)},i=(0,Pm.textWithPadding)(e.title,Ce.DEFAULT_HEADER_ALIGNMENT,r()),n=new Em.default(e.colorMap);return n.addCharsWithColor(Ce.DEFAULT_HEADER_FONT_COLOR,i),t.push(n.renderConsole()),t},Pv=e=>{let t=[];t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.headerTop,e.columns.map(i=>i.length||Ce.DEFAULT_COLUMN_LEN)));let r=(0,ht.createHeaderAsRow)(ht.createRow,e.columns);return t=t.concat(Tm(e.tableStyle,e.columns,r,e.colorMap,!0)),t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.headerBottom,e.columns.map(i=>i.length||Ce.DEFAULT_COLUMN_LEN))),t},Tv=e=>{let t=[];return t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.tableBottom,e.columns.map(r=>r.length||Ce.DEFAULT_COLUMN_LEN))),t},Rv=(e,t)=>{let r=[],i=e.rows.length-1;return e.rows.indexOf(t)!==i&&t.separator&&r.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.rowSeparator,e.columns.map(s=>s.length||Ce.DEFAULT_COLUMN_LEN))),r},Iv=e=>{(0,Am.preProcessColumns)(e),(0,Am.preProcessRows)(e);let t=[];return Ev(e).forEach(r=>t.push(r)),Pv(e).forEach(r=>t.push(r)),e.rows.forEach(r=>{Cv(e,r).forEach(i=>t.push(i)),Rv(e,r).forEach(i=>t.push(i))}),Tv(e).forEach(r=>t.push(r)),t.join(`
31
- `)};ke.renderTable=Iv;var Ov=(e,t)=>{let r=new qv.default(t);return r.addRows(e),(0,ke.renderTable)(r)};ke.renderSimpleTable=Ov;var jv=(e,t)=>{console.log((0,ke.renderSimpleTable)(e,t))};ke.printSimpleTable=jv});var ra=A(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});var Dv=Wo(),Sn=Pr(),ia=Ir(),na=qm(),Lv=ta(),Mv=()=>0,Fv=()=>!0,sa=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:Sn.DEFAULT_ROW_ALIGNMENT}))}initDetailed(t){var r;this.title=t?.title||this.title,this.tableStyle=Object.assign(Object.assign({},this.tableStyle),t?.style),this.sortFunction=t?.sort||this.sortFunction,this.filterFunction=t?.filter||this.filterFunction,this.enabledColumns=t?.enabledColumns||this.enabledColumns,this.disabledColumns=t?.disabledColumns||this.disabledColumns,this.computedColumns=t?.computedColumns||this.computedColumns,this.columns=((r=t?.columns)===null||r===void 0?void 0:r.map(i=>(0,na.rawColumnToInternalColumn)(i,t?.defaultColumnOptions)))||this.columns,this.rowSeparator=t?.rowSeparator||this.rowSeparator,this.charLength=t?.charLength||this.charLength,this.defaultColumnOptions=t?.defaultColumnOptions||this.defaultColumnOptions,t?.shouldDisableColors?this.colorMap={}:t?.colorMap&&(this.colorMap=Object.assign(Object.assign({},this.colorMap),t.colorMap)),t.rows!==void 0&&this.addRows(t.rows)}constructor(t){this.rows=[],this.columns=[],this.title=void 0,this.tableStyle=Sn.DEFAULT_TABLE_STYLE,this.filterFunction=Fv,this.sortFunction=Mv,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=Sn.DEFAULT_ROW_SEPARATOR,this.colorMap=Dv.DEFAULT_COLOR_MAP,this.charLength={},this.defaultColumnOptions=void 0,this.transforms={},t instanceof Array?this.initSimple(t):typeof t=="object"&&this.initDetailed(t)}createColumnFromRow(t){let r=this.columns.map(i=>i.name);Object.keys(t).forEach(i=>{r.includes(i)||this.columns.push((0,na.rawColumnToInternalColumn)((0,ia.createColumFromOnlyName)(i),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,ia.createColumFromOnlyName)(t):t;this.columns.push((0,na.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,ia.createRow)(r?.color||Sn.DEFAULT_ROW_FONT_COLOR,t,r?.separator!==void 0?r?.separator:this.rowSeparator))}addRows(t,r){t.forEach(i=>{this.addRow(i,r)})}renderTable(){return(0,Lv.renderTable)(this)}};oa.default=sa});var Im=A(Or=>{"use strict";var Bv=Or&&Or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Or,"__esModule",{value:!0});var Uv=Bv(ra()),Rm=Ir(),aa=class{constructor(t){this.table=new Uv.default(t)}addColumn(t){return this.table.addColumn(t),this}addColumns(t){return this.table.addColumns(t),this}addRow(t,r){return this.table.addRow(t,(0,Rm.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,Rm.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Or.default=aa});var jr=A(Ue=>{"use strict";var Nv=Ue&&Ue.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.renderTable=Ue.printTable=Ue.Table=void 0;var Gv=Nv(Im());Ue.Table=Gv.default;var Om=ta();Object.defineProperty(Ue,"printTable",{enumerable:!0,get:function(){return Om.printSimpleTable}});Object.defineProperty(Ue,"renderTable",{enumerable:!0,get:function(){return Om.renderSimpleTable}})});var Ca=U(Aa(),1),{program:QS,createCommand:eq,createArgument:tq,createOption:rq,CommanderError:iq,InvalidArgumentError:nq,InvalidOptionArgumentError:sq,Command:Ea,Argument:oq,Option:Pa,Help:aq}=Ca.default;var Uh=U(Y(),1);import re from"fs";import se from"path";import{fileURLToPath as Tk}from"url";import{styleText as ts}from"util";import{stdout as is,stdin as Ya}from"process";import*as rt from"readline";import Ey from"readline";var Ia=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),Oa=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ja=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var hy=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,yy=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Da=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,fy=/\t{1,1000}/y,La=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),gy=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,_y=new RegExp("\\p{M}+","gu"),by={limit:1/0,ellipsis:""},Ma=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",s=t?.ellipsisWidth??(n?Ma(n,by,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,d=r.emojiWidth??2,p=2,u=r.regularWidth??1,l=r.wideWidth??p,m=[[gy,u],[hy,o],[yy,a],[fy,c],[La,d],[Da,l]],h=0,f=0,x=e.length,w=0,S=!1,g=x,R=Math.max(0,i-s),v=0,B=0,j=0,L=0;e:for(;;){if(B>v||f>=x&&f>h){let G=e.slice(v,B)||e.slice(h,f);w=0;for(let H of G.replaceAll(_y,"")){let $=H.codePointAt(0)||0;if(Oa($)?L=p:ja($)?L=l:L=u,j+L>R&&(g=Math.min(g,Math.max(v,h)+w)),j+L>i){S=!0;break e}w+=H.length,j+=L}v=B=0}if(f>=x)break e;for(let G=0,H=m.length;G<H;G++){let[$,Ge]=m[G];if($.lastIndex=f,$.test(e)){if(w=$===Da?Ia(e.slice(f,$.lastIndex)):$===La?1:$.lastIndex-f,L=w*Ge,j+L>R&&(g=Math.min(g,f+Math.floor((R-j)/Ge))),j+L>i){S=!0;break e}j+=L,v=h,B=f,f=h=$.lastIndex;continue e}}f+=1}return{width:S?R:j,index:S?g:x,truncated:S,ellipsed:S&&i>=s}},Fa=Ma;var wy={limit:1/0,ellipsis:"",ellipsisWidth:0},xy=(e,t={})=>Fa(e,wy,t).width,ce=xy;var Wr="\x1B",za="\x9B",ky=39,Xn="\x07",Va="[",vy="]",Wa="m",Zn=`${vy}8;;`,Ba=new RegExp(`(?:\\${Va}(?<code>\\d+)m|\\${Zn}(?<uri>.*)${Xn})`,"y"),Ua=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Na=e=>`${Wr}${Va}${e}${Wa}`,Ga=e=>`${Wr}${Zn}${e}${Xn}`,Jn=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,s=!1,o=e.at(-1),a=o===void 0?0:ce(o),c=i.next(),d=i.next(),p=0;for(;!c.done;){let u=c.value,l=ce(u);a+l<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===Wr||u===za)&&(n=!0,s=t.startsWith(Zn,p+1)),n?s?u===Xn&&(n=!1,s=!1):u===Wa&&(n=!1):(a+=l,a===r&&!d.done&&(e.push(""),a=0)),c=d,d=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Sy=e=>{let t=e.split(" "),r=t.length;for(;r&&!ce(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},qy=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,s,o=e.split(" "),a=[""],c=0;for(let u=0;u<o.length;u++){let l=o[u];if(r.trim!==!1){let h=a.at(-1)??"",f=h.trimStart();h.length!==f.length&&(a[a.length-1]=f,c=ce(f))}u!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let m=ce(l);if(r.hard&&m>t){let h=t-c,f=1+Math.floor((m-h-1)/t);Math.floor((m-1)/t)<f&&a.push(""),Jn(a,l,t),c=ce(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){Jn(a,l,t),c=ce(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){Jn(a,l,t),c=ce(a.at(-1)??"");continue}a[a.length-1]+=l,c+=m}r.trim!==!1&&(a=a.map(u=>Sy(u)));let d=a.join(`
32
- `),p=!1;for(let u=0;u<d.length;u++){let l=d[u];if(i+=l,p)p=!1;else if(p=l>="\uD800"&&l<="\uDBFF",p)continue;if(l===Wr||l===za){Ba.lastIndex=u+1;let h=Ba.exec(d)?.groups;if(h?.code!==void 0){let f=Number.parseFloat(h.code);n=f===ky?void 0:f}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(d[u+1]===`
33
- `){s&&(i+=Ga(""));let m=n?Ua(n):void 0;n&&m&&(i+=Na(m))}else l===`
34
- `&&(n&&Ua(n)&&(i+=Na(n)),s&&(i+=Ga(s)))}return i},$y=/\r?\n/;function Te(e,t,r){return String(e).normalize().split($y).map(i=>qy(i,t,r)).join(`
35
- `)}var oe=U(es(),1);import{ReadStream as Ka}from"tty";function Kr(e,t,r){if(!r.some(o=>!o.disabled))return e;let i=e+t,n=Math.max(r.length-1,0),s=i<0?n:i>n?0:i;return r[s].disabled?Kr(s,t<0?-1:1,r):s}var Py=["up","down","left","right","space","enter","cancel"],Ty=["January","February","March","April","May","June","July","August","September","October","November","December"],ee={actions:new Set(Py),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...Ty],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function ns(e,t){if(typeof e=="string")return ee.aliases.get(e)===t;for(let r of e)if(r!==void 0&&ns(r,t))return!0;return!1}function Ry(e,t){if(e===t)return;let r=e.split(`
29
+ `)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(n=>r.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Pa(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?r=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=s[1],i=s[3],n=s[4]),r&&n!=="0"?`${r}=${i}:${parseInt(n)+1}`:t})}function Qn(){if(I.env.NO_COLOR||I.env.FORCE_COLOR==="0"||I.env.FORCE_COLOR==="false")return!1;if(I.env.FORCE_COLOR||I.env.CLICOLOR_FORCE!==void 0)return!0}es.Command=Zn;es.useColor=Qn});var ja=A(be=>{"use strict";var{Argument:Ra}=Kr(),{Command:ts}=Ta(),{CommanderError:gy,InvalidArgumentError:Ia}=sr(),{Help:_y}=Vn(),{Option:Oa}=Yn();be.program=new ts;be.createCommand=e=>new ts(e);be.createOption=(e,t)=>new Oa(e,t);be.createArgument=(e,t)=>new Ra(e,t);be.Command=ts;be.Option=Oa;be.Argument=Ra;be.Help=_y;be.CommanderError=gy;be.InvalidArgumentError=Ia;be.InvalidOptionArgumentError=Ia});var K=A((bq,rs)=>{"use strict";var Xr=process||{},Fa=Xr.argv||[],Jr=Xr.env||{},by=!(Jr.NO_COLOR||Fa.includes("--no-color"))&&(!!Jr.FORCE_COLOR||Fa.includes("--color")||Xr.platform==="win32"||(Xr.stdout||{}).isTTY&&Jr.TERM!=="dumb"||!!Jr.CI),wy=(e,t,r=e)=>i=>{let n=""+i,s=n.indexOf(t,e.length);return~s?e+xy(n,t,r,s)+t:e+n+t},xy=(e,t,r,i)=>{let n="",s=0;do n+=e.substring(s,i)+r,s=i+t.length,i=e.indexOf(t,s);while(~i);return n+e.substring(s)},Ba=(e=by)=>{let t=e?wy:()=>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")}};rs.exports=Ba();rs.exports.createColors=Ba});var as=A((Aq,tc)=>{"use strict";var os={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let r="";return e<0?r+=`\x1B[${-e}D`:e>0&&(r+=`\x1B[${e}C`),t<0?r+=`\x1B[${-t}A`:t>0&&(r+=`\x1B[${t}B`),r},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},jy={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Dy={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let r=0;r<e;r++)t+=this.line+(r<e-1?os.up():"");return e&&(t+=os.left),t}};tc.exports={cursor:os,scroll:jy,erase:Dy,beep:"\x07"}});var Fc=A((WA,Mc)=>{"use strict";Mc.exports=Lc;Lc.sync=cg;var jc=ye("fs");function ag(e,t){var r=t.pathExt!==void 0?t.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var i=0;i<r.length;i++){var n=r[i].toLowerCase();if(n&&e.substr(-n.length).toLowerCase()===n)return!0}return!1}function Dc(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:ag(t,r)}function Lc(e,t,r){jc.stat(e,function(i,n){r(i,i?!1:Dc(n,e,t))})}function cg(e,t){return Dc(jc.statSync(e),e,t)}});var zc=A((HA,Gc)=>{"use strict";Gc.exports=Uc;Uc.sync=pg;var Bc=ye("fs");function Uc(e,t,r){Bc.stat(e,function(i,n){r(i,i?!1:Nc(n,t))})}function pg(e,t){return Nc(Bc.statSync(e),t)}function Nc(e,t){return e.isFile()&&dg(e,t)}function dg(e,t){var r=e.mode,i=e.uid,n=e.gid,s=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),o=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),d=parseInt("001",8),p=a|c,u=r&d||r&c&&n===o||r&a&&i===s||r&p&&s===0;return u}});var Wc=A((YA,Vc)=>{"use strict";var KA=ye("fs"),qi;process.platform==="win32"||global.TESTING_WINDOWS?qi=Fc():qi=zc();Vc.exports=qs;qs.sync=ug;function qs(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){qs(e,t||{},function(s,o){s?n(s):i(o)})})}qi(e,t||{},function(i,n){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,n=!1),r(i,n)})}function ug(e,t){try{return qi.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Qc=A((JA,Zc)=>{"use strict";var jt=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Hc=ye("path"),lg=jt?";":":",Kc=Wc(),Yc=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Jc=(e,t)=>{let r=t.colon||lg,i=e.match(/\//)||jt&&e.match(/\\/)?[""]:[...jt?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=jt?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=jt?n.split(r):[""];return jt&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:i,pathExt:s,pathExtExe:n}},Xc=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:i,pathExt:n,pathExtExe:s}=Jc(e,t),o=[],a=d=>new Promise((p,u)=>{if(d===i.length)return t.all&&o.length?p(o):u(Yc(e));let l=i[d],m=/^".*"$/.test(l)?l.slice(1,-1):l,h=Hc.join(m,e),f=!m&&/^\.[\\\/]/.test(e)?e.slice(0,2)+h:h;p(c(f,d,0))}),c=(d,p,u)=>new Promise((l,m)=>{if(u===n.length)return l(a(p+1));let h=n[u];Kc(d+h,{pathExt:s},(f,x)=>{if(!f&&x)if(t.all)o.push(d+h);else return l(d+h);return l(c(d,p,u+1))})});return r?a(0).then(d=>r(null,d),r):a(0)},mg=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:i,pathExtExe:n}=Jc(e,t),s=[];for(let o=0;o<r.length;o++){let a=r[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=Hc.join(c,e),p=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let u=0;u<i.length;u++){let l=p+i[u];try{if(Kc.sync(l,{pathExt:n}))if(t.all)s.push(l);else return l}catch{}}}if(t.all&&s.length)return s;if(t.nothrow)return null;throw Yc(e)};Zc.exports=Xc;Xc.sync=mg});var tp=A((XA,$s)=>{"use strict";var ep=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};$s.exports=ep;$s.exports.default=ep});var sp=A((ZA,np)=>{"use strict";var rp=ye("path"),hg=Qc(),yg=tp();function ip(e,t){let r=e.options.env||process.env,i=process.cwd(),n=e.options.cwd!=null,s=n&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd)}catch{}let o;try{o=hg.sync(e.command,{path:r[yg({env:r})],pathExt:t?rp.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=rp.resolve(n?e.options.cwd:"",o)),o}function fg(e){return ip(e)||ip(e,!0)}np.exports=fg});var op=A((QA,Cs)=>{"use strict";var As=/([()\][%!^"`<>&|;, *?])/g;function gg(e){return e=e.replace(As,"^$1"),e}function _g(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(As,"^$1"),t&&(e=e.replace(As,"^$1")),e}Cs.exports.command=gg;Cs.exports.argument=_g});var cp=A((eC,ap)=>{"use strict";ap.exports=/^#!(.*)/});var dp=A((tC,pp)=>{"use strict";var bg=cp();pp.exports=(e="")=>{let t=e.match(bg);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var lp=A((rC,up)=>{"use strict";var Es=ye("fs"),wg=dp();function xg(e){let r=Buffer.alloc(150),i;try{i=Es.openSync(e,"r"),Es.readSync(i,r,0,150,0),Es.closeSync(i)}catch{}return wg(r.toString())}up.exports=xg});var fp=A((iC,yp)=>{"use strict";var kg=ye("path"),mp=sp(),hp=op(),vg=lp(),Sg=process.platform==="win32",qg=/\.(?:com|exe)$/i,$g=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ag(e){e.file=mp(e);let t=e.file&&vg(e.file);return t?(e.args.unshift(e.file),e.command=t,mp(e)):e.file}function Cg(e){if(!Sg)return e;let t=Ag(e),r=!qg.test(t);if(e.options.forceShell||r){let i=$g.test(t);e.command=kg.normalize(e.command),e.command=hp.command(e.command),e.args=e.args.map(s=>hp.argument(s,i));let n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Eg(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);let i={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?i:Cg(i)}yp.exports=Eg});var bp=A((nC,_p)=>{"use strict";var Ps=process.platform==="win32";function Ts(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Pg(e,t){if(!Ps)return;let r=e.emit;e.emit=function(i,n){if(i==="exit"){let s=gp(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function gp(e,t){return Ps&&e===1&&!t.file?Ts(t.original,"spawn"):null}function Tg(e,t){return Ps&&e===1&&!t.file?Ts(t.original,"spawnSync"):null}_p.exports={hookChildProcess:Pg,verifyENOENT:gp,verifyENOENTSync:Tg,notFoundError:Ts}});var kp=A((sC,Dt)=>{"use strict";var wp=ye("child_process"),Rs=fp(),Is=bp();function xp(e,t,r){let i=Rs(e,t,r),n=wp.spawn(i.command,i.args,i.options);return Is.hookChildProcess(n,i),n}function Rg(e,t,r){let i=Rs(e,t,r),n=wp.spawnSync(i.command,i.args,i.options);return n.error=n.error||Is.verifyENOENTSync(n.status,i),n}Dt.exports=xp;Dt.exports.spawn=xp;Dt.exports.sync=Rg;Dt.exports._parse=Rs;Dt.exports._enoent=Is});var Qo=A(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.DEFAULT_COLOR_MAP=void 0;Jt.DEFAULT_COLOR_MAP={red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",white_bold:"\x1B[01m",reset:"\x1B[0m"};var Zo=class{constructor(t=Jt.DEFAULT_COLOR_MAP){this.text="",this.colorMap=t}addCharsWithColor(t,r){let i=this.colorMap[t];this.text+=i!==void 0?`${i}${r}${this.colorMap.reset}`:r}renderConsole(){return this.text}};Jt.default=Zo});var Rr=A(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.DEFAULT_HEADER_ALIGNMENT=Z.DEFAULT_ROW_ALIGNMENT=Z.DEFAULT_HEADER_FONT_COLOR=Z.DEFAULT_ROW_FONT_COLOR=Z.COLORS=Z.ALIGNMENTS=Z.DEFAULT_TABLE_STYLE=Z.DEFAULT_ROW_SEPARATOR=Z.DEFAULT_COLUMN_LEN=void 0;Z.DEFAULT_COLUMN_LEN=20;Z.DEFAULT_ROW_SEPARATOR=!1;Z.DEFAULT_TABLE_STYLE={headerTop:{left:"\u250C",mid:"\u252C",right:"\u2510",other:"\u2500"},headerBottom:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"},tableBottom:{left:"\u2514",mid:"\u2534",right:"\u2518",other:"\u2500"},vertical:"\u2502",rowSeparator:{left:"\u251C",mid:"\u253C",right:"\u2524",other:"\u2500"}};Z.ALIGNMENTS=["right","left","center"];Z.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];Z.DEFAULT_ROW_FONT_COLOR="white";Z.DEFAULT_HEADER_FONT_COLOR="white_bold";Z.DEFAULT_ROW_ALIGNMENT="right";Z.DEFAULT_HEADER_ALIGNMENT="center"});var qm=A(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Jk=[{first:768,last:879},{first:1155,last:1158},{first:1160,last:1161},{first:1425,last:1469},{first:1471,last:1471},{first:1473,last:1474},{first:1476,last:1477},{first:1479,last:1479},{first:1536,last:1539},{first:1552,last:1557},{first:1611,last:1630},{first:1648,last:1648},{first:1750,last:1764},{first:1767,last:1768},{first:1770,last:1773},{first:1807,last:1807},{first:1809,last:1809},{first:1840,last:1866},{first:1958,last:1968},{first:2027,last:2035},{first:2305,last:2306},{first:2364,last:2364},{first:2369,last:2376},{first:2381,last:2381},{first:2385,last:2388},{first:2402,last:2403},{first:2433,last:2433},{first:2492,last:2492},{first:2497,last:2500},{first:2509,last:2509},{first:2530,last:2531},{first:2561,last:2562},{first:2620,last:2620},{first:2625,last:2626},{first:2631,last:2632},{first:2635,last:2637},{first:2672,last:2673},{first:2689,last:2690},{first:2748,last:2748},{first:2753,last:2757},{first:2759,last:2760},{first:2765,last:2765},{first:2786,last:2787},{first:2817,last:2817},{first:2876,last:2876},{first:2879,last:2879},{first:2881,last:2883},{first:2893,last:2893},{first:2902,last:2902},{first:2946,last:2946},{first:3008,last:3008},{first:3021,last:3021},{first:3134,last:3136},{first:3142,last:3144},{first:3146,last:3149},{first:3157,last:3158},{first:3260,last:3260},{first:3263,last:3263},{first:3270,last:3270},{first:3276,last:3277},{first:3298,last:3299},{first:3393,last:3395},{first:3405,last:3405},{first:3530,last:3530},{first:3538,last:3540},{first:3542,last:3542},{first:3633,last:3633},{first:3636,last:3642},{first:3655,last:3662},{first:3761,last:3761},{first:3764,last:3769},{first:3771,last:3772},{first:3784,last:3789},{first:3864,last:3865},{first:3893,last:3893},{first:3895,last:3895},{first:3897,last:3897},{first:3953,last:3966},{first:3968,last:3972},{first:3974,last:3975},{first:3984,last:3991},{first:3993,last:4028},{first:4038,last:4038},{first:4141,last:4144},{first:4146,last:4146},{first:4150,last:4151},{first:4153,last:4153},{first:4184,last:4185},{first:4448,last:4607},{first:4959,last:4959},{first:5906,last:5908},{first:5938,last:5940},{first:5970,last:5971},{first:6002,last:6003},{first:6068,last:6069},{first:6071,last:6077},{first:6086,last:6086},{first:6089,last:6099},{first:6109,last:6109},{first:6155,last:6157},{first:6313,last:6313},{first:6432,last:6434},{first:6439,last:6440},{first:6450,last:6450},{first:6457,last:6459},{first:6679,last:6680},{first:6912,last:6915},{first:6964,last:6964},{first:6966,last:6970},{first:6972,last:6972},{first:6978,last:6978},{first:7019,last:7027},{first:7616,last:7626},{first:7678,last:7679},{first:8203,last:8207},{first:8234,last:8238},{first:8288,last:8291},{first:8298,last:8303},{first:8400,last:8431},{first:12330,last:12335},{first:12441,last:12442},{first:43014,last:43014},{first:43019,last:43019},{first:43045,last:43046},{first:64286,last:64286},{first:65024,last:65039},{first:65056,last:65059},{first:65279,last:65279},{first:65529,last:65531},{first:68097,last:68099},{first:68101,last:68102},{first:68108,last:68111},{first:68152,last:68154},{first:68159,last:68159},{first:119143,last:119145},{first:119155,last:119170},{first:119173,last:119179},{first:119210,last:119213},{first:119362,last:119364},{first:917505,last:917505},{first:917536,last:917631},{first:917760,last:917999}];ea.default=Jk});var $m=A(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});var Xk=(e,t,r)=>{let i=0,n,s=r;if(e<t[0].first||e>t[s].last)return 0;for(;s>=i;)if(n=Math.floor((i+s)/2),e>t[n].last)i=n+1;else if(e<t[n].first)s=n-1;else return 1;return 0};ta.default=Xk});var ra=A(Ir=>{"use strict";var Cm=Ir&&Ir.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ir,"__esModule",{value:!0});var Am=Cm(qm()),Zk=Cm($m()),Qk=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,Zk.default)(e,Am.default,Am.default.length-1)?0:1+ +(e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=196605||e>=196608&&e<=262141));Ir.default=Qk});var Em=A(Or=>{"use strict";var ev=Or&&Or.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Or,"__esModule",{value:!0});var tv=ev(ra()),rv=e=>{let t=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),n=(0,tv.default)(i);if(n<0)return-1;t+=n}return t};Or.default=rv});var Tm=A(mt=>{"use strict";var Pm=mt&&mt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mt,"__esModule",{value:!0});mt.wcswidth=mt.wcwidth=void 0;var iv=Pm(Em());mt.wcswidth=iv.default;var nv=Pm(ra());mt.wcwidth=nv.default});var ia=A(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.findWidthInConsole=Et.stripAnsi=void 0;var sv=Tm(),ov=/\x1b\[\d{1,3}(;\d{1,3})*m/g,av=e=>e.replace(ov,"");Et.stripAnsi=av;var cv=(e,t)=>{let r=0;return e=(0,Et.stripAnsi)(e),t&&Object.entries(t).forEach(([i,n])=>{let s=new RegExp(i,"g");r+=(e.match(s)||[]).length*n,e=e.replace(i,"")}),r+=(0,sv.wcswidth)(e),r};Et.findWidthInConsole=cv});var sa=A(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.biggestWordInSentence=Ue.textWithPadding=Ue.splitTextIntoTextsOfMinLen=void 0;var na=ia(),pv=(e,t,r)=>{let i=[];return e.split(/[\n\r]/).forEach(s=>{let o=s.split(" "),a=[],c=0;o.forEach(d=>{let p=(0,na.findWidthInConsole)(d,r);c+p<=t?(c+=p+1,a.push(d)):(a.length>0&&i.push(a.join(" ")),a=[d],c=p+1)}),i.push(a.join(" "))}),i};Ue.splitTextIntoTextsOfMinLen=pv;var dv=(e,t,r,i)=>{let n=(0,na.findWidthInConsole)(e,i),s=Math.floor((r-n)/2),o=r-s-n;if(r<n){let a=(0,Ue.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,Ue.textWithPadding)(c,t,r,i)).join(`
30
+ `)}switch(t){case"left":return e.concat(" ".repeat(r-n));case"center":return" ".repeat(s).concat(e).concat(" ".repeat(o));default:return" ".repeat(r-n).concat(e)}};Ue.textWithPadding=dv;var uv=(e,t)=>e.split(" ").reduce((r,i)=>Math.max(r,(0,na.findWidthInConsole)(i,t)),0);Ue.biggestWordInSentence=uv});var jr=A(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.getWidthLimitedColumnsArray=N.createHeaderAsRow=N.renderTableHorizontalBorders=N.findLenOfColumn=N.createRow=N.createColumFromOnlyName=N.createTableHorizontalBorders=N.convertRawRowOptionsToStandard=N.evaluateCellText=N.cellText=void 0;var Rm=ia(),oa=sa(),aa=Rr(),Xt=(e,t)=>Math.max(e,t),lv=e=>e==null?"":`${e}`;N.cellText=lv;var mv=(e,t)=>t?`${t(e)}`:(0,N.cellText)(e);N.evaluateCellText=mv;var hv=e=>{if(e)return{color:e.color,separator:e.separator||aa.DEFAULT_ROW_SEPARATOR}};N.convertRawRowOptionsToStandard=hv;var yv=({left:e,mid:t,right:r,other:i},n)=>{let s=e;return n.forEach(o=>{s+=i.repeat(o+2),s+=t}),s=s.slice(0,-t.length),s+=r,s};N.createTableHorizontalBorders=yv;var fv=e=>({name:e,title:e});N.createColumFromOnlyName=fv;var gv=(e,t,r)=>({color:e,separator:r,text:t});N.createRow=gv;var _v=(e,t,r)=>{let i=e.name,n=e.title,s=e.transform,o=Xt(0,e?.minLen||0);return e.maxLen?(o=Xt(o,Xt(e.maxLen,(0,oa.biggestWordInSentence)(n,r))),o=t.reduce((a,c)=>Xt(a,(0,oa.biggestWordInSentence)((0,N.evaluateCellText)(c.text[i],s),r)),o),o):(o=Xt(o,(0,Rm.findWidthInConsole)(n,r)),t.forEach(a=>{o=Xt(o,(0,Rm.findWidthInConsole)((0,N.evaluateCellText)(a.text[i],s),r))}),o)};N.findLenOfColumn=_v;var bv=(e,t)=>(0,N.createTableHorizontalBorders)(e,t);N.renderTableHorizontalBorders=bv;var wv=(e,t)=>{let r=aa.DEFAULT_HEADER_FONT_COLOR,i=e(r,{},!1);return t.forEach(n=>{i.text[n.name]=n.title}),i};N.createHeaderAsRow=wv;var xv=(e,t,r)=>{let i={};return e.forEach(n=>{i[n.name]=(0,oa.splitTextIntoTextsOfMinLen)((0,N.cellText)(t.text[n.name]),n.length||aa.DEFAULT_COLUMN_LEN,r)}),i};N.getWidthLimitedColumnsArray=xv});var Im=A(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.rawColumnToInternalColumn=Qe.objIfExists=void 0;var kv=Rr(),vv=(e,t)=>t?{[e]:t}:{};Qe.objIfExists=vv;var Sv=(e,t)=>{var r;return Object.assign(Object.assign(Object.assign(Object.assign({name:e.name,title:(r=e.title)!==null&&r!==void 0?r:e.name},(0,Qe.objIfExists)("color",e.color||t?.color)),(0,Qe.objIfExists)("maxLen",e.maxLen||t?.maxLen)),(0,Qe.objIfExists)("minLen",e.minLen||t?.minLen)),{alignment:e.alignment||t?.alignment||kv.DEFAULT_ROW_ALIGNMENT,transform:e.transform})};Qe.rawColumnToInternalColumn=Sv});var Om=A(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.preProcessRows=Zt.preProcessColumns=void 0;var qv=jr(),$v=e=>{e.computedColumns.length&&e.computedColumns.forEach(t=>{e.columns.some(i=>i.name===t.name)||(e.addColumn(Object.assign(Object.assign({},t),e.defaultColumnOptions)),e.rows.forEach((i,n,s)=>{let o=s.map(a=>a.text);i.text[t.name]=t.function(i.text,n,o)}))})},Av=e=>{e.enabledColumns.length&&(e.columns=e.columns.filter(t=>e.enabledColumns.includes(t.name)))},Cv=e=>{e.disabledColumns.length&&(e.columns=e.columns.filter(t=>!e.disabledColumns.includes(t.name)))},Ev=e=>{e.columns.forEach(t=>{t.length=(0,qv.findLenOfColumn)(t,e.rows,e.charLength)})},Pv=e=>{$v(e),Cv(e),Av(e),Ev(e)};Zt.preProcessColumns=Pv;var Tv=e=>{let t=e.rows.filter(r=>e.filterFunction(r.text)).sort((r,i)=>e.sortFunction(r.text,i.text));e.rows=t};Zt.preProcessRows=Tv});var ca=A(ve=>{"use strict";var Dm=ve&&ve.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ve,"__esModule",{value:!0});ve.printSimpleTable=ve.renderSimpleTable=ve.renderTable=void 0;var Lm=Dm(Qo()),Mm=sa(),Ee=Rr(),ht=jr(),Rv=Dm(pa()),jm=Om(),Iv=(e,t,r,i,n,s,o,a)=>{let c=new Lm.default(o);return c.addCharsWithColor("",e.vertical),t.forEach(d=>{let u=r<i[d.name].length?(0,ht.cellText)(i[d.name][r]):"";c.addCharsWithColor(Ee.DEFAULT_ROW_FONT_COLOR," "),c.addCharsWithColor(n&&Ee.DEFAULT_HEADER_FONT_COLOR||d.color||s.color,(0,Mm.textWithPadding)(u,d.alignment||Ee.DEFAULT_ROW_ALIGNMENT,d.length||Ee.DEFAULT_COLUMN_LEN,a)),c.addCharsWithColor("",` ${e.vertical}`)}),c.renderConsole()},Fm=(e,t,r,i,n,s)=>{let o=(0,ht.getWidthLimitedColumnsArray)(t,r,s),a=Object.values(o).reduce((d,p)=>Math.max(d,p.length),0),c=[];for(let d=0;d<a;d+=1){let p=Iv(e,t,d,o,n,r,i,s);c.push(p)}return c},Ov=(e,t)=>{let r=JSON.parse(JSON.stringify(e)),i={};return t.filter(n=>!!n.transform).forEach(n=>{i[n.name]=n.transform}),Object.keys(i).forEach(n=>{r.text[n]=i[n](r.text[n])}),r},jv=(e,t)=>{let r=[],i=Ov(t,e.columns);return r=r.concat(Fm(e.tableStyle,e.columns,i,e.colorMap,void 0,e.charLength)),r},Dv=e=>{let t=[];if(e.title===void 0)return t;let r=()=>{let s=(o,a)=>o+a+2+1;return e.columns.map(o=>o.length||Ee.DEFAULT_COLUMN_LEN).reduce(s,1)},i=(0,Mm.textWithPadding)(e.title,Ee.DEFAULT_HEADER_ALIGNMENT,r()),n=new Lm.default(e.colorMap);return n.addCharsWithColor(Ee.DEFAULT_HEADER_FONT_COLOR,i),t.push(n.renderConsole()),t},Lv=e=>{let t=[];t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.headerTop,e.columns.map(i=>i.length||Ee.DEFAULT_COLUMN_LEN)));let r=(0,ht.createHeaderAsRow)(ht.createRow,e.columns);return t=t.concat(Fm(e.tableStyle,e.columns,r,e.colorMap,!0)),t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.headerBottom,e.columns.map(i=>i.length||Ee.DEFAULT_COLUMN_LEN))),t},Mv=e=>{let t=[];return t.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.tableBottom,e.columns.map(r=>r.length||Ee.DEFAULT_COLUMN_LEN))),t},Fv=(e,t)=>{let r=[],i=e.rows.length-1;return e.rows.indexOf(t)!==i&&t.separator&&r.push((0,ht.renderTableHorizontalBorders)(e.tableStyle.rowSeparator,e.columns.map(s=>s.length||Ee.DEFAULT_COLUMN_LEN))),r},Bv=e=>{(0,jm.preProcessColumns)(e),(0,jm.preProcessRows)(e);let t=[];return Dv(e).forEach(r=>t.push(r)),Lv(e).forEach(r=>t.push(r)),e.rows.forEach(r=>{jv(e,r).forEach(i=>t.push(i)),Fv(e,r).forEach(i=>t.push(i))}),Mv(e).forEach(r=>t.push(r)),t.join(`
31
+ `)};ve.renderTable=Bv;var Uv=(e,t)=>{let r=new Rv.default(t);return r.addRows(e),(0,ve.renderTable)(r)};ve.renderSimpleTable=Uv;var Nv=(e,t)=>{console.log((0,ve.renderSimpleTable)(e,t))};ve.printSimpleTable=Nv});var pa=A(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});var Gv=Qo(),Cn=Rr(),da=jr(),ua=Im(),zv=ca(),Vv=()=>0,Wv=()=>!0,la=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:Cn.DEFAULT_ROW_ALIGNMENT}))}initDetailed(t){var r;this.title=t?.title||this.title,this.tableStyle=Object.assign(Object.assign({},this.tableStyle),t?.style),this.sortFunction=t?.sort||this.sortFunction,this.filterFunction=t?.filter||this.filterFunction,this.enabledColumns=t?.enabledColumns||this.enabledColumns,this.disabledColumns=t?.disabledColumns||this.disabledColumns,this.computedColumns=t?.computedColumns||this.computedColumns,this.columns=((r=t?.columns)===null||r===void 0?void 0:r.map(i=>(0,ua.rawColumnToInternalColumn)(i,t?.defaultColumnOptions)))||this.columns,this.rowSeparator=t?.rowSeparator||this.rowSeparator,this.charLength=t?.charLength||this.charLength,this.defaultColumnOptions=t?.defaultColumnOptions||this.defaultColumnOptions,t?.shouldDisableColors?this.colorMap={}:t?.colorMap&&(this.colorMap=Object.assign(Object.assign({},this.colorMap),t.colorMap)),t.rows!==void 0&&this.addRows(t.rows)}constructor(t){this.rows=[],this.columns=[],this.title=void 0,this.tableStyle=Cn.DEFAULT_TABLE_STYLE,this.filterFunction=Wv,this.sortFunction=Vv,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=Cn.DEFAULT_ROW_SEPARATOR,this.colorMap=Gv.DEFAULT_COLOR_MAP,this.charLength={},this.defaultColumnOptions=void 0,this.transforms={},t instanceof Array?this.initSimple(t):typeof t=="object"&&this.initDetailed(t)}createColumnFromRow(t){let r=this.columns.map(i=>i.name);Object.keys(t).forEach(i=>{r.includes(i)||this.columns.push((0,ua.rawColumnToInternalColumn)((0,da.createColumFromOnlyName)(i),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,da.createColumFromOnlyName)(t):t;this.columns.push((0,ua.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,da.createRow)(r?.color||Cn.DEFAULT_ROW_FONT_COLOR,t,r?.separator!==void 0?r?.separator:this.rowSeparator))}addRows(t,r){t.forEach(i=>{this.addRow(i,r)})}renderTable(){return(0,zv.renderTable)(this)}};ma.default=la});var Um=A(Dr=>{"use strict";var Hv=Dr&&Dr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Dr,"__esModule",{value:!0});var Kv=Hv(pa()),Bm=jr(),ha=class{constructor(t){this.table=new Kv.default(t)}addColumn(t){return this.table.addColumn(t),this}addColumns(t){return this.table.addColumns(t),this}addRow(t,r){return this.table.addRow(t,(0,Bm.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,Bm.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Dr.default=ha});var Lr=A(Ne=>{"use strict";var Yv=Ne&&Ne.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.renderTable=Ne.printTable=Ne.Table=void 0;var Jv=Yv(Um());Ne.Table=Jv.default;var Nm=ca();Object.defineProperty(Ne,"printTable",{enumerable:!0,get:function(){return Nm.printSimpleTable}});Object.defineProperty(Ne,"renderTable",{enumerable:!0,get:function(){return Nm.renderSimpleTable}})});var Da=M(ja(),1),{program:pq,createCommand:dq,createArgument:uq,createOption:lq,CommanderError:mq,InvalidArgumentError:hq,InvalidOptionArgumentError:yq,Command:La,Argument:fq,Option:Ma,Help:gq}=Da.default;var Yh=M(K(),1);import re from"fs";import oe from"path";import{fileURLToPath as Mk}from"url";import{styleText as cs}from"util";import{stdout as ds,stdin as ic}from"process";import*as rt from"readline";import Ly from"readline";var Ua=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),Na=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ga=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var ky=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,vy=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,za=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Sy=/\t{1,1000}/y,Va=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),qy=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$y=new RegExp("\\p{M}+","gu"),Ay={limit:1/0,ellipsis:""},Wa=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",s=t?.ellipsisWidth??(n?Wa(n,Ay,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,d=r.emojiWidth??2,p=2,u=r.regularWidth??1,l=r.wideWidth??p,m=[[qy,u],[ky,o],[vy,a],[Sy,c],[Va,d],[za,l]],h=0,f=0,x=e.length,w=0,v=!1,g=x,R=Math.max(0,i-s),S=0,U=0,j=0,L=0;e:for(;;){if(U>S||f>=x&&f>h){let G=e.slice(S,U)||e.slice(h,f);w=0;for(let H of G.replaceAll($y,"")){let $=H.codePointAt(0)||0;if(Na($)?L=p:Ga($)?L=l:L=u,j+L>R&&(g=Math.min(g,Math.max(S,h)+w)),j+L>i){v=!0;break e}w+=H.length,j+=L}S=U=0}if(f>=x)break e;for(let G=0,H=m.length;G<H;G++){let[$,Ge]=m[G];if($.lastIndex=f,$.test(e)){if(w=$===za?Ua(e.slice(f,$.lastIndex)):$===Va?1:$.lastIndex-f,L=w*Ge,j+L>R&&(g=Math.min(g,f+Math.floor((R-j)/Ge))),j+L>i){v=!0;break e}j+=L,S=h,U=f,f=h=$.lastIndex;continue e}}f+=1}return{width:v?R:j,index:v?g:x,truncated:v,ellipsed:v&&i>=s}},Ha=Wa;var Cy={limit:1/0,ellipsis:"",ellipsisWidth:0},Ey=(e,t={})=>Ha(e,Cy,t).width,pe=Ey;var Zr="\x1B",Za="\x9B",Py=39,ns="\x07",Qa="[",Ty="]",ec="m",ss=`${Ty}8;;`,Ka=new RegExp(`(?:\\${Qa}(?<code>\\d+)m|\\${ss}(?<uri>.*)${ns})`,"y"),Ya=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ja=e=>`${Zr}${Qa}${e}${ec}`,Xa=e=>`${Zr}${ss}${e}${ns}`,is=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,s=!1,o=e.at(-1),a=o===void 0?0:pe(o),c=i.next(),d=i.next(),p=0;for(;!c.done;){let u=c.value,l=pe(u);a+l<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===Zr||u===Za)&&(n=!0,s=t.startsWith(ss,p+1)),n?s?u===ns&&(n=!1,s=!1):u===ec&&(n=!1):(a+=l,a===r&&!d.done&&(e.push(""),a=0)),c=d,d=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ry=e=>{let t=e.split(" "),r=t.length;for(;r&&!pe(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Iy=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,s,o=e.split(" "),a=[""],c=0;for(let u=0;u<o.length;u++){let l=o[u];if(r.trim!==!1){let h=a.at(-1)??"",f=h.trimStart();h.length!==f.length&&(a[a.length-1]=f,c=pe(f))}u!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let m=pe(l);if(r.hard&&m>t){let h=t-c,f=1+Math.floor((m-h-1)/t);Math.floor((m-1)/t)<f&&a.push(""),is(a,l,t),c=pe(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){is(a,l,t),c=pe(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){is(a,l,t),c=pe(a.at(-1)??"");continue}a[a.length-1]+=l,c+=m}r.trim!==!1&&(a=a.map(u=>Ry(u)));let d=a.join(`
32
+ `),p=!1;for(let u=0;u<d.length;u++){let l=d[u];if(i+=l,p)p=!1;else if(p=l>="\uD800"&&l<="\uDBFF",p)continue;if(l===Zr||l===Za){Ka.lastIndex=u+1;let h=Ka.exec(d)?.groups;if(h?.code!==void 0){let f=Number.parseFloat(h.code);n=f===Py?void 0:f}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(d[u+1]===`
33
+ `){s&&(i+=Xa(""));let m=n?Ya(n):void 0;n&&m&&(i+=Ja(m))}else l===`
34
+ `&&(n&&Ya(n)&&(i+=Ja(n)),s&&(i+=Xa(s)))}return i},Oy=/\r?\n/;function Re(e,t,r){return String(e).normalize().split(Oy).map(i=>Iy(i,t,r)).join(`
35
+ `)}var ae=M(as(),1);import{ReadStream as rc}from"tty";function ei(e,t,r){if(!r.some(o=>!o.disabled))return e;let i=e+t,n=Math.max(r.length-1,0),s=i<0?n:i>n?0:i;return r[s].disabled?ei(s,t<0?-1:1,r):s}var My=["up","down","left","right","space","enter","cancel"],Fy=["January","February","March","April","May","June","July","August","September","October","November","December"],te={actions:new Set(My),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...Fy],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function us(e,t){if(typeof e=="string")return te.aliases.get(e)===t;for(let r of e)if(r!==void 0&&us(r,t))return!0;return!1}function By(e,t){if(e===t)return;let r=e.split(`
36
36
  `),i=t.split(`
37
- `),n=Math.max(r.length,i.length),s=[];for(let o=0;o<n;o++)r[o]!==i[o]&&s.push(o);return{lines:s,numLinesBefore:r.length,numLinesAfter:i.length,numLines:n}}var Iy=globalThis.process.platform.startsWith("win"),rs=Symbol("clack:cancel");function D(e){return e===rs}function Hr(e,t){let r=e;r.isTTY&&r.setRawMode(t)}function Ja({input:e=Ya,output:t=is,overwrite:r=!0,hideCursor:i=!0}={}){let n=rt.createInterface({input:e,output:t,prompt:"",tabSize:1});rt.emitKeypressEvents(e,n),e instanceof Ka&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:c})=>{let d=String(o);if(ns([d,a,c],"cancel")){i&&t.write(oe.cursor.show),process.exit(0);return}if(!r)return;rt.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{rt.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(oe.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(oe.cursor.show),e instanceof Ka&&e.isTTY&&!Iy&&e.setRawMode(!1),n.terminal=!1,n.close()}}var ir=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,ss=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function nr(e,t,r,i=r,n){let s=ir(e??is);return Te(t,s-r.length,{hard:!0,trim:!1}).split(`
37
+ `),n=Math.max(r.length,i.length),s=[];for(let o=0;o<n;o++)r[o]!==i[o]&&s.push(o);return{lines:s,numLinesBefore:r.length,numLinesAfter:i.length,numLines:n}}var Uy=globalThis.process.platform.startsWith("win"),ps=Symbol("clack:cancel");function D(e){return e===ps}function Qr(e,t){let r=e;r.isTTY&&r.setRawMode(t)}function nc({input:e=ic,output:t=ds,overwrite:r=!0,hideCursor:i=!0}={}){let n=rt.createInterface({input:e,output:t,prompt:"",tabSize:1});rt.emitKeypressEvents(e,n),e instanceof rc&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:c})=>{let d=String(o);if(us([d,a,c],"cancel")){i&&t.write(ae.cursor.show),process.exit(0);return}if(!r)return;rt.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{rt.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(ae.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(ae.cursor.show),e instanceof rc&&e.isTTY&&!Uy&&e.setRawMode(!1),n.terminal=!1,n.close()}}var or=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,ls=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function ar(e,t,r,i=r,n){let s=or(e??ds);return Re(t,s-r.length,{hard:!0,trim:!1}).split(`
38
38
  `).map((o,a)=>{let c=n?n(o,a):o;return`${a===0?i:r}${c}`}).join(`
39
- `)}var Qr=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:r=Ya,output:i=is,render:n,signal:s,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=t,this._abortSignal=s,this.input=r,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],i=[];for(let n of r)n.cb(...t),n.once&&i.push(()=>r.splice(r.indexOf(n),1));for(let n of i)n()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(rs);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Ey.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Hr(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(oe.cursor.show),this.output.off("resize",this.render),Hr(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(oe.cursor.show),this.output.off("resize",this.render),Hr(this.input,!1),e(rs)})})}_isActionKey(e,t){return e===" "}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&ee.aliases.has(t.name)&&this.emit("cursor",ee.aliases.get(t.name)),ee.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e?.toLowerCase(),t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let r=this.opts.validate(this.value);r&&(this.error=r instanceof Error?r.message:r,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ns([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
40
- `),Hr(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Te(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
41
- `).length-1;this.output.write(oe.cursor.move(-999,e*-1))}render(){let e=Te(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(oe.cursor.hide);else{let t=Ry(this._prevFrame,e),r=ss(this.output);if(this.restoreCursor(),t){let i=Math.max(0,t.numLinesAfter-r),n=Math.max(0,t.numLinesBefore-r),s=t.lines.find(o=>o>=i);if(s===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(oe.cursor.move(0,s-n)),this.output.write(oe.erase.lines(1));let o=e.split(`
42
- `);this.output.write(o[s]),this._prevFrame=e,this.output.write(oe.cursor.move(0,o.length-s-1));return}else if(t.lines.length>1){if(i<n)s=i;else{let a=s-n;a>0&&this.output.write(oe.cursor.move(0,a))}this.output.write(oe.erase.down());let o=e.split(`
39
+ `)}var si=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:r=ic,output:i=ds,render:n,signal:s,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=t,this._abortSignal=s,this.input=r,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],i=[];for(let n of r)n.cb(...t),n.once&&i.push(()=>r.splice(r.indexOf(n),1));for(let n of i)n()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(ps);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Ly.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Qr(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(ae.cursor.show),this.output.off("resize",this.render),Qr(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(ae.cursor.show),this.output.off("resize",this.render),Qr(this.input,!1),e(ps)})})}_isActionKey(e,t){return e===" "}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&te.aliases.has(t.name)&&this.emit("cursor",te.aliases.get(t.name)),te.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e?.toLowerCase(),t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let r=this.opts.validate(this.value);r&&(this.error=r instanceof Error?r.message:r,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}us([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
40
+ `),Qr(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Re(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
41
+ `).length-1;this.output.write(ae.cursor.move(-999,e*-1))}render(){let e=Re(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(ae.cursor.hide);else{let t=By(this._prevFrame,e),r=ls(this.output);if(this.restoreCursor(),t){let i=Math.max(0,t.numLinesAfter-r),n=Math.max(0,t.numLinesBefore-r),s=t.lines.find(o=>o>=i);if(s===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(ae.cursor.move(0,s-n)),this.output.write(ae.erase.lines(1));let o=e.split(`
42
+ `);this.output.write(o[s]),this._prevFrame=e,this.output.write(ae.cursor.move(0,o.length-s-1));return}else if(t.lines.length>1){if(i<n)s=i;else{let a=s-n;a>0&&this.output.write(ae.cursor.move(0,a))}this.output.write(ae.erase.down());let o=e.split(`
43
43
  `).slice(s);this.output.write(o.join(`
44
- `)),this._prevFrame=e;return}}this.output.write(oe.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Yr=class extends Qr{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(oe.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Jr=class extends Qr{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${ts(["inverse","hidden"],"_")}`;let r=this.masked,i=r.slice(0,this.cursor),n=r.slice(this.cursor);return`${i}${ts("inverse",n[0])}${n.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...r}){super(r),this._mask=t??"\u2022",this.on("userInput",i=>{this._setValue(i)})}},Xr=class extends Qr{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let r=this.options.findIndex(({value:n})=>n===t.initialValue),i=r===-1?0:r;this.cursor=this.options[i].disabled?Kr(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Kr(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Kr(this.cursor,1,this.options);break}this.changeValue()})}};var Zr=class extends Qr{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[i,...n]=t.slice(this.cursor);return`${r}${ts("inverse",i)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as y,stripVTControlCharacters as Oq}from"util";import be from"process";var sr=U(es(),1);import{existsSync as Fq,lstatSync as Bq,readdirSync as Uq}from"fs";import{dirname as Gq,join as zq}from"path";function Oy(){return be.platform!=="win32"?be.env.TERM!=="linux":!!be.env.CI||!!be.env.WT_SESSION||!!be.env.TERMINUS_SUBLIME||be.env.ConEmuTask==="{cmd::Cmder}"||be.env.TERM_PROGRAM==="Terminus-Sublime"||be.env.TERM_PROGRAM==="vscode"||be.env.TERM==="xterm-256color"||be.env.TERM==="alacritty"||be.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var os=Oy(),jy=()=>process.env.CI==="true";var M=(e,t)=>os?e:t,Dy=M("\u25C6","*"),Za=M("\u25A0","x"),Qa=M("\u25B2","x"),ri=M("\u25C7","o"),Ly=M("\u250C","T"),C=M("\u2502","|"),it=M("\u2514","\u2014"),Vq=M("\u2510","T"),Wq=M("\u2518","\u2014"),as=M("\u25CF",">"),ti=M("\u25CB"," "),Hq=M("\u25FB","[\u2022]"),Kq=M("\u25FC","[+]"),Yq=M("\u25FB","[ ]"),My=M("\u25AA","\u2022"),Xa=M("\u2500","-"),Fy=M("\u256E","+"),By=M("\u251C","+"),Uy=M("\u256F","+"),Ny=M("\u2570","+"),Jq=M("\u256D","+"),Gy=M("\u25CF","\u2022"),zy=M("\u25C6","*"),Vy=M("\u25B2","!"),Wy=M("\u25A0","x"),ii=e=>{switch(e){case"initial":case"active":return y("cyan",Dy);case"cancel":return y("red",Za);case"error":return y("yellow",Qa);case"submit":return y("green",ri)}},Hy=e=>{switch(e){case"initial":case"active":return y("cyan",C);case"cancel":return y("red",C);case"error":return y("yellow",C);case"submit":return y("green",C)}},Ky=(e,t,r,i,n)=>{let s=t,o=0;for(let a=r;a<i;a++){let c=e[a];if(s=s-c.length,o++,s<=n)break}return{lineCount:s,removals:o}},Yy=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=ir(i)-s,c=ss(i),d=y("dim","..."),p=Math.max(c-o,0),u=Math.max(Math.min(n,p),5),l=0;e>=u-3&&(l=Math.max(Math.min(e-u+3,t.length-u),0));let m=u<t.length&&l>0,h=u<t.length&&l+u<t.length,f=Math.min(l+u,t.length),x=[],w=0;m&&w++,h&&w++;let S=l+(m?1:0),g=f-(h?1:0);for(let v=S;v<g;v++){let B=Te(r(t[v],v===e),a,{hard:!0,trim:!1}).split(`
45
- `);x.push(B),w+=B.length}if(w>p){let v=0,B=0,j=w,L=e-S,G=(H,$)=>Ky(x,j,H,$,p);m?({lineCount:j,removals:v}=G(0,L),j>p&&({lineCount:j,removals:B}=G(L+1,x.length))):({lineCount:j,removals:B}=G(L+1,x.length),j>p&&({lineCount:j,removals:v}=G(0,L))),v>0&&(m=!0,x.splice(0,v)),B>0&&(h=!0,x.splice(x.length-B,B))}let R=[];m&&R.push(d);for(let v of x)for(let B of v)R.push(B);return h&&R.push(d),R};var Ke=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new Yr({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??ee.withGuide,n=`${ii(this.state)} `,s=i?`${y("gray",C)} `:"",o=nr(e.output,e.message,s,n),a=`${i?`${y("gray",C)}
44
+ `)),this._prevFrame=e;return}}this.output.write(ae.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var ti=class extends si{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(ae.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var ri=class extends si{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${cs(["inverse","hidden"],"_")}`;let r=this.masked,i=r.slice(0,this.cursor),n=r.slice(this.cursor);return`${i}${cs("inverse",n[0])}${n.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...r}){super(r),this._mask=t??"\u2022",this.on("userInput",i=>{this._setValue(i)})}},ii=class extends si{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let r=this.options.findIndex(({value:n})=>n===t.initialValue),i=r===-1?0:r;this.cursor=this.options[i].disabled?ei(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=ei(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ei(this.cursor,1,this.options);break}this.changeValue()})}};var ni=class extends si{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[i,...n]=t.slice(this.cursor);return`${r}${cs("inverse",i)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}};import{styleText as y,stripVTControlCharacters as zq}from"util";import we from"process";var cr=M(as(),1);import{existsSync as Yq,lstatSync as Jq,readdirSync as Xq}from"fs";import{dirname as Qq,join as e$}from"path";function Ny(){return we.platform!=="win32"?we.env.TERM!=="linux":!!we.env.CI||!!we.env.WT_SESSION||!!we.env.TERMINUS_SUBLIME||we.env.ConEmuTask==="{cmd::Cmder}"||we.env.TERM_PROGRAM==="Terminus-Sublime"||we.env.TERM_PROGRAM==="vscode"||we.env.TERM==="xterm-256color"||we.env.TERM==="alacritty"||we.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ms=Ny(),Gy=()=>process.env.CI==="true";var F=(e,t)=>ms?e:t,zy=F("\u25C6","*"),oc=F("\u25A0","x"),ac=F("\u25B2","x"),ci=F("\u25C7","o"),Vy=F("\u250C","T"),C=F("\u2502","|"),it=F("\u2514","\u2014"),t$=F("\u2510","T"),r$=F("\u2518","\u2014"),hs=F("\u25CF",">"),ai=F("\u25CB"," "),i$=F("\u25FB","[\u2022]"),n$=F("\u25FC","[+]"),s$=F("\u25FB","[ ]"),Wy=F("\u25AA","\u2022"),sc=F("\u2500","-"),Hy=F("\u256E","+"),Ky=F("\u251C","+"),Yy=F("\u256F","+"),Jy=F("\u2570","+"),o$=F("\u256D","+"),Xy=F("\u25CF","\u2022"),Zy=F("\u25C6","*"),Qy=F("\u25B2","!"),ef=F("\u25A0","x"),pi=e=>{switch(e){case"initial":case"active":return y("cyan",zy);case"cancel":return y("red",oc);case"error":return y("yellow",ac);case"submit":return y("green",ci)}},tf=e=>{switch(e){case"initial":case"active":return y("cyan",C);case"cancel":return y("red",C);case"error":return y("yellow",C);case"submit":return y("green",C)}},rf=(e,t,r,i,n)=>{let s=t,o=0;for(let a=r;a<i;a++){let c=e[a];if(s=s-c.length,o++,s<=n)break}return{lineCount:s,removals:o}},nf=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=or(i)-s,c=ls(i),d=y("dim","..."),p=Math.max(c-o,0),u=Math.max(Math.min(n,p),5),l=0;e>=u-3&&(l=Math.max(Math.min(e-u+3,t.length-u),0));let m=u<t.length&&l>0,h=u<t.length&&l+u<t.length,f=Math.min(l+u,t.length),x=[],w=0;m&&w++,h&&w++;let v=l+(m?1:0),g=f-(h?1:0);for(let S=v;S<g;S++){let U=Re(r(t[S],S===e),a,{hard:!0,trim:!1}).split(`
45
+ `);x.push(U),w+=U.length}if(w>p){let S=0,U=0,j=w,L=e-v,G=(H,$)=>rf(x,j,H,$,p);m?({lineCount:j,removals:S}=G(0,L),j>p&&({lineCount:j,removals:U}=G(L+1,x.length))):({lineCount:j,removals:U}=G(L+1,x.length),j>p&&({lineCount:j,removals:S}=G(0,L))),S>0&&(m=!0,x.splice(0,S)),U>0&&(h=!0,x.splice(x.length-U,U))}let R=[];m&&R.push(d);for(let S of x)for(let U of S)R.push(U);return h&&R.push(d),R};var Ke=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new ti({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??te.withGuide,n=`${pi(this.state)} `,s=i?`${y("gray",C)} `:"",o=ar(e.output,e.message,s,n),a=`${i?`${y("gray",C)}
46
46
  `:""}${o}
47
47
  `,c=this.value?t:r;switch(this.state){case"submit":{let d=i?`${y("gray",C)} `:"";return`${a}${d}${y("dim",c)}`}case"cancel":{let d=i?`${y("gray",C)} `:"";return`${a}${d}${y(["strikethrough","dim"],c)}${i?`
48
- ${y("gray",C)}`:""}`}default:{let d=i?`${y("cyan",C)} `:"",p=i?y("cyan",it):"";return`${a}${d}${this.value?`${y("green",as)} ${t}`:`${y("dim",ti)} ${y("dim",t)}`}${e.vertical?i?`
48
+ ${y("gray",C)}`:""}`}default:{let d=i?`${y("cyan",C)} `:"",p=i?y("cyan",it):"";return`${a}${d}${this.value?`${y("green",hs)} ${t}`:`${y("dim",ai)} ${y("dim",t)}`}${e.vertical?i?`
49
49
  ${y("cyan",C)} `:`
50
- `:` ${y("dim","/")} `}${this.value?`${y("dim",ti)} ${y("dim",r)}`:`${y("green",as)} ${r}`}
50
+ `:` ${y("dim","/")} `}${this.value?`${y("dim",ai)} ${y("dim",r)}`:`${y("green",hs)} ${r}`}
51
51
  ${p}
52
- `}}}}).prompt()};var b={message:(e=[],{symbol:t=y("gray",C),secondarySymbol:r=y("gray",C),output:i=process.stdout,spacing:n=1,withGuide:s}={})=>{let o=[],a=s??ee.withGuide,c=a?r:"",d=a?`${t} `:"",p=a?`${r} `:"";for(let l=0;l<n;l++)o.push(c);let u=Array.isArray(e)?e:e.split(`
52
+ `}}}}).prompt()};var b={message:(e=[],{symbol:t=y("gray",C),secondarySymbol:r=y("gray",C),output:i=process.stdout,spacing:n=1,withGuide:s}={})=>{let o=[],a=s??te.withGuide,c=a?r:"",d=a?`${t} `:"",p=a?`${r} `:"";for(let l=0;l<n;l++)o.push(c);let u=Array.isArray(e)?e:e.split(`
53
53
  `);if(u.length>0){let[l,...m]=u;l.length>0?o.push(`${d}${l}`):o.push(a?t:"");for(let h of m)h.length>0?o.push(`${p}${h}`):o.push(a?r:"")}i.write(`${o.join(`
54
54
  `)}
55
- `)},info:(e,t)=>{b.message(e,{...t,symbol:y("blue",Gy)})},success:(e,t)=>{b.message(e,{...t,symbol:y("green",zy)})},step:(e,t)=>{b.message(e,{...t,symbol:y("green",ri)})},warn:(e,t)=>{b.message(e,{...t,symbol:y("yellow",Vy)})},warning:(e,t)=>{b.warn(e,t)},error:(e,t)=>{b.message(e,{...t,symbol:y("red",Wy)})}},O=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??ee.withGuide?`${y("gray",it)} `:"";r.write(`${i}${y("red",e)}
55
+ `)},info:(e,t)=>{b.message(e,{...t,symbol:y("blue",Xy)})},success:(e,t)=>{b.message(e,{...t,symbol:y("green",Zy)})},step:(e,t)=>{b.message(e,{...t,symbol:y("green",ci)})},warn:(e,t)=>{b.message(e,{...t,symbol:y("yellow",Qy)})},warning:(e,t)=>{b.warn(e,t)},error:(e,t)=>{b.message(e,{...t,symbol:y("red",ef)})}},O=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??te.withGuide?`${y("gray",it)} `:"";r.write(`${i}${y("red",e)}
56
56
 
57
- `)},ni=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??ee.withGuide?`${y("gray",Ly)} `:"";r.write(`${i}${e}
58
- `)},Et=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??ee.withGuide?`${y("gray",C)}
57
+ `)},di=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??te.withGuide?`${y("gray",Vy)} `:"";r.write(`${i}${e}
58
+ `)},Tt=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??te.withGuide?`${y("gray",C)}
59
59
  ${y("gray",it)} `:"";r.write(`${i}${e}
60
60
 
61
- `)};var Jy=e=>y("dim",e),Xy=(e,t,r)=>{let i={hard:!0,trim:!1},n=Te(e,t,i).split(`
62
- `),s=n.reduce((c,d)=>Math.max(ce(d),c),0),o=n.map(r).reduce((c,d)=>Math.max(ce(d),c),0),a=t-(o-s);return Te(e,a,i)},W=(e="",t="",r)=>{let i=r?.output??be.stdout,n=r?.withGuide??ee.withGuide,s=r?.format??Jy,o=["",...Xy(e,ir(i)-6,s).split(`
63
- `).map(s),""],a=ce(t),c=Math.max(o.reduce((l,m)=>{let h=ce(m);return h>l?h:l},0),a)+2,d=o.map(l=>`${y("gray",C)} ${l}${" ".repeat(c-ce(l))}${y("gray",C)}`).join(`
61
+ `)};var sf=e=>y("dim",e),of=(e,t,r)=>{let i={hard:!0,trim:!1},n=Re(e,t,i).split(`
62
+ `),s=n.reduce((c,d)=>Math.max(pe(d),c),0),o=n.map(r).reduce((c,d)=>Math.max(pe(d),c),0),a=t-(o-s);return Re(e,a,i)},W=(e="",t="",r)=>{let i=r?.output??we.stdout,n=r?.withGuide??te.withGuide,s=r?.format??sf,o=["",...of(e,or(i)-6,s).split(`
63
+ `).map(s),""],a=pe(t),c=Math.max(o.reduce((l,m)=>{let h=pe(m);return h>l?h:l},0),a)+2,d=o.map(l=>`${y("gray",C)} ${l}${" ".repeat(c-pe(l))}${y("gray",C)}`).join(`
64
64
  `),p=n?`${y("gray",C)}
65
- `:"",u=n?By:Ny;i.write(`${p}${y("green",ri)} ${y("reset",t)} ${y("gray",Xa.repeat(Math.max(c-a-1,1))+Fy)}
65
+ `:"",u=n?Ky:Jy;i.write(`${p}${y("green",ci)} ${y("reset",t)} ${y("gray",sc.repeat(Math.max(c-a-1,1))+Hy)}
66
66
  ${d}
67
- ${y("gray",u+Xa.repeat(c+2)+Uy)}
68
- `)},si=e=>new Jr({validate:e.validate,mask:e.mask??My,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??ee.withGuide,r=`${t?`${y("gray",C)}
69
- `:""}${ii(this.state)} ${e.message}
67
+ ${y("gray",u+sc.repeat(c+2)+Yy)}
68
+ `)},ui=e=>new ri({validate:e.validate,mask:e.mask??Wy,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??te.withGuide,r=`${t?`${y("gray",C)}
69
+ `:""}${pi(this.state)} ${e.message}
70
70
  `,i=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let s=t?`${y("yellow",C)} `:"",o=t?`${y("yellow",it)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${r.trim()}
71
71
  ${s}${a}
72
72
  ${o}${y("yellow",this.error)}
73
73
  `}case"submit":{let s=t?`${y("gray",C)} `:"",o=n?y("dim",n):"";return`${r}${s}${o}`}case"cancel":{let s=t?`${y("gray",C)} `:"",o=n?y(["strikethrough","dim"],n):"";return`${r}${s}${o}${n&&t?`
74
74
  ${y("gray",C)}`:""}`}default:{let s=t?`${y("cyan",C)} `:"",o=t?y("cyan",it):"";return`${r}${s}${i}
75
75
  ${o}
76
- `}}}}).prompt();var Zy=e=>y("magenta",e),E=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:s=os?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=os?80:120,signal:a,...c}={})=>{let d=jy(),p,u,l=!1,m=!1,h="",f,x=performance.now(),w=ir(r),S=c?.styleFrame??Zy,g=V=>{let ue=V>1?n??ee.messages.error:i??ee.messages.cancel;m=V===1,l&&(ze(ue,V),m&&typeof t=="function"&&t())},R=()=>g(2),v=()=>g(1),B=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",g),a&&a.addEventListener("abort",v)},j=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",v),process.removeListener("SIGTERM",v),process.removeListener("exit",g),a&&a.removeEventListener("abort",v)},L=()=>{if(f===void 0)return;d&&r.write(`
77
- `);let V=Te(f,w,{hard:!0,trim:!1}).split(`
78
- `);V.length>1&&r.write(sr.cursor.up(V.length-1)),r.write(sr.cursor.to(0)),r.write(sr.erase.down())},G=V=>V.replace(/\.+$/,""),H=V=>{let ue=(performance.now()-V)/1e3,Ve=Math.floor(ue/60),We=Math.floor(ue%60);return Ve>0?`[${Ve}m ${We}s]`:`[${We}s]`},$=c.withGuide??ee.withGuide,Ge=(V="")=>{l=!0,p=Ja({output:r}),h=G(V),x=performance.now(),$&&r.write(`${y("gray",C)}
79
- `);let ue=0,Ve=0;B(),u=setInterval(()=>{if(d&&h===f)return;L(),f=h;let We=S(s[ue]),Br;if(d)Br=`${We} ${h}...`;else if(e==="timer")Br=`${We} ${h} ${H(x)}`;else{let Gh=".".repeat(Math.floor(Ve)).slice(0,3);Br=`${We} ${h}${Gh}`}let Nh=Te(Br,w,{hard:!0,trim:!1});r.write(Nh),ue=ue+1<s.length?ue+1:0,Ve=Ve<4?Ve+.125:0},o)},ze=(V="",ue=0,Ve=!1)=>{if(!l)return;l=!1,clearInterval(u),L();let We=ue===0?y("green",ri):ue===1?y("red",Za):y("red",Qa);h=V??h,Ve||(e==="timer"?r.write(`${We} ${h} ${H(x)}
76
+ `}}}}).prompt();var af=e=>y("magenta",e),E=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:s=ms?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ms?80:120,signal:a,...c}={})=>{let d=Gy(),p,u,l=!1,m=!1,h="",f,x=performance.now(),w=or(r),v=c?.styleFrame??af,g=V=>{let ue=V>1?n??te.messages.error:i??te.messages.cancel;m=V===1,l&&(ze(ue,V),m&&typeof t=="function"&&t())},R=()=>g(2),S=()=>g(1),U=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",S),process.on("SIGTERM",S),process.on("exit",g),a&&a.addEventListener("abort",S)},j=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",S),process.removeListener("SIGTERM",S),process.removeListener("exit",g),a&&a.removeEventListener("abort",S)},L=()=>{if(f===void 0)return;d&&r.write(`
77
+ `);let V=Re(f,w,{hard:!0,trim:!1}).split(`
78
+ `);V.length>1&&r.write(cr.cursor.up(V.length-1)),r.write(cr.cursor.to(0)),r.write(cr.erase.down())},G=V=>V.replace(/\.+$/,""),H=V=>{let ue=(performance.now()-V)/1e3,Ve=Math.floor(ue/60),We=Math.floor(ue%60);return Ve>0?`[${Ve}m ${We}s]`:`[${We}s]`},$=c.withGuide??te.withGuide,Ge=(V="")=>{l=!0,p=nc({output:r}),h=G(V),x=performance.now(),$&&r.write(`${y("gray",C)}
79
+ `);let ue=0,Ve=0;U(),u=setInterval(()=>{if(d&&h===f)return;L(),f=h;let We=v(s[ue]),Wr;if(d)Wr=`${We} ${h}...`;else if(e==="timer")Wr=`${We} ${h} ${H(x)}`;else{let Xh=".".repeat(Math.floor(Ve)).slice(0,3);Wr=`${We} ${h}${Xh}`}let Jh=Re(Wr,w,{hard:!0,trim:!1});r.write(Jh),ue=ue+1<s.length?ue+1:0,Ve=Ve<4?Ve+.125:0},o)},ze=(V="",ue=0,Ve=!1)=>{if(!l)return;l=!1,clearInterval(u),L();let We=ue===0?y("green",ci):ue===1?y("red",oc):y("red",ac);h=V??h,Ve||(e==="timer"?r.write(`${We} ${h} ${H(x)}
80
80
  `):r.write(`${We} ${h}
81
- `)),j(),p()};return{start:Ge,stop:(V="")=>ze(V,0),message:(V="")=>{h=G(V??h)},cancel:(V="")=>ze(V,1),error:(V="")=>ze(V,2),clear:()=>ze("",0,!0),get isCancelled(){return m}}},Xq={light:M("\u2500","-"),heavy:M("\u2501","="),block:M("\u2588","#")};var ei=(e,t)=>e.includes(`
81
+ `)),j(),p()};return{start:Ge,stop:(V="")=>ze(V,0),message:(V="")=>{h=G(V??h)},cancel:(V="")=>ze(V,1),error:(V="")=>ze(V,2),clear:()=>ze("",0,!0),get isCancelled(){return m}}},a$={light:F("\u2500","-"),heavy:F("\u2501","="),block:F("\u2588","#")};var oi=(e,t)=>e.includes(`
82
82
  `)?e.split(`
83
83
  `).map(r=>t(r)).join(`
84
- `):t(e),oi=e=>{let t=(r,i)=>{let n=r.label??String(r.value);switch(i){case"disabled":return`${y("gray",ti)} ${ei(n,s=>y("gray",s))}${r.hint?` ${y("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${ei(n,s=>y("dim",s))}`;case"active":return`${y("green",as)} ${n}${r.hint?` ${y("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${ei(n,s=>y(["strikethrough","dim"],s))}`;default:return`${y("dim",ti)} ${ei(n,s=>y("dim",s))}`}};return new Xr({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??ee.withGuide,i=`${ii(this.state)} `,n=`${Hy(this.state)} `,s=nr(e.output,e.message,n,i),o=`${r?`${y("gray",C)}
84
+ `):t(e),li=e=>{let t=(r,i)=>{let n=r.label??String(r.value);switch(i){case"disabled":return`${y("gray",ai)} ${oi(n,s=>y("gray",s))}${r.hint?` ${y("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${oi(n,s=>y("dim",s))}`;case"active":return`${y("green",hs)} ${n}${r.hint?` ${y("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${oi(n,s=>y(["strikethrough","dim"],s))}`;default:return`${y("dim",ai)} ${oi(n,s=>y("dim",s))}`}};return new ii({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??te.withGuide,i=`${pi(this.state)} `,n=`${tf(this.state)} `,s=ar(e.output,e.message,n,i),o=`${r?`${y("gray",C)}
85
85
  `:""}${s}
86
- `;switch(this.state){case"submit":{let a=r?`${y("gray",C)} `:"",c=nr(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${c}`}case"cancel":{let a=r?`${y("gray",C)} `:"",c=nr(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${c}${r?`
86
+ `;switch(this.state){case"submit":{let a=r?`${y("gray",C)} `:"",c=ar(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${c}`}case"cancel":{let a=r?`${y("gray",C)} `:"",c=ar(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${c}${r?`
87
87
  ${y("gray",C)}`:""}`}default:{let a=r?`${y("cyan",C)} `:"",c=r?y("cyan",it):"",d=o.split(`
88
- `).length,p=r?2:1;return`${o}${a}${Yy({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:d+p,style:(u,l)=>t(u,u.disabled?"disabled":l?"active":"inactive")}).join(`
88
+ `).length,p=r?2:1;return`${o}${a}${nf({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:d+p,style:(u,l)=>t(u,u.disabled?"disabled":l?"active":"inactive")}).join(`
89
89
  ${a}`)}
90
90
  ${c}
91
- `}}}}).prompt()};var Zq=`${y("gray",C)} `;var le=e=>new Zr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??ee.withGuide,r=`${`${t?`${y("gray",C)}
92
- `:""}${ii(this.state)} `}${e.message}
91
+ `}}}}).prompt()};var c$=`${y("gray",C)} `;var le=e=>new ni({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??te.withGuide,r=`${`${t?`${y("gray",C)}
92
+ `:""}${pi(this.state)} `}${e.message}
93
93
  `,i=e.placeholder?y("inverse",e.placeholder[0])+y("dim",e.placeholder.slice(1)):y(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${y("yellow",this.error)}`:"",a=t?`${y("yellow",C)} `:"",c=t?y("yellow",it):"";return`${r.trim()}
94
94
  ${a}${n}
95
95
  ${c}${o}
96
96
  `}case"submit":{let o=s?` ${y("dim",s)}`:"",a=t?y("gray",C):"";return`${r}${a}${o}`}case"cancel":{let o=s?` ${y(["strikethrough","dim"],s)}`:"",a=t?y("gray",C):"";return`${r}${a}${o}${s.trim()?`
97
97
  ${a}`:""}`}default:{let o=t?`${y("cyan",C)} `:"",a=t?y("cyan",it):"";return`${r}${o}${n}
98
98
  ${a}
99
- `}}}}).prompt();function K(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}import{fileURLToPath as Qy}from"url";var Pt=(e,t)=>{let r=ps(ef(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},ef=e=>cs(e)?e.toString():e,cs=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,ps=e=>e instanceof URL?Qy(e):e;var ai=(e,t=[],r={})=>{let i=Pt(e,"First argument"),[n,s]=K(t)?[[],t]:[t,r];if(!Array.isArray(n))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${n}`);if(n.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${n}`);let o=n.map(String),a=o.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!K(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[i,o,s]};import{ChildProcess as cf}from"child_process";import{StringDecoder as tf}from"string_decoder";var{toString:ec}=Object.prototype,tc=e=>ec.call(e)==="[object ArrayBuffer]",Q=e=>ec.call(e)==="[object Uint8Array]",Ye=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),rf=new TextEncoder,rc=e=>rf.encode(e),nf=new TextDecoder,ci=e=>nf.decode(e),ic=(e,t)=>sf(e,t).join(""),sf=(e,t)=>{if(t==="utf8"&&e.every(s=>typeof s=="string"))return e;let r=new tf(t),i=e.map(s=>typeof s=="string"?rc(s):s).map(s=>r.write(s)),n=r.end();return n===""?i:[...i,n]},or=e=>e.length===1&&Q(e[0])?e[0]:ds(of(e)),of=e=>e.map(t=>typeof t=="string"?rc(t):t),ds=e=>{let t=new Uint8Array(af(e)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t},af=e=>{let t=0;for(let r of e)t+=r.length;return t};var ac=e=>Array.isArray(e)&&Array.isArray(e.raw),cc=(e,t)=>{let r=[];for(let[s,o]of e.entries())r=pf({templates:e,expressions:t,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[i,...n]=r;return[i,n,{}]},pf=({templates:e,expressions:t,tokens:r,index:i,template:n})=>{if(n===void 0)throw new TypeError(`Invalid backslash sequence: ${e.raw[i]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=df(n,e.raw[i]),c=sc(r,s,o);if(i===t.length)return c;let d=t[i],p=Array.isArray(d)?d.map(u=>oc(u)):[oc(d)];return sc(c,p,a)},df=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],i=0,n=nc.has(t[0]);for(let o=0,a=0;o<e.length;o+=1,a+=1){let c=t[a];if(nc.has(c))i!==o&&r.push(e.slice(i,o)),i=o+1;else if(c==="\\"){let d=t[a+1];d===`
100
- `?(o-=1,a+=1):d==="u"&&t[a+2]==="{"?a=t.indexOf("}",a+3):a+=uf[d]??1}}let s=i===e.length;return s||r.push(e.slice(i)),{nextTokens:r,leadingWhitespaces:n,trailingWhitespaces:s}},nc=new Set([" "," ","\r",`
101
- `]),uf={x:3,u:5},sc=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],oc=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(K(e)&&("stdout"in e||"isMaxBuffer"in e))return lf(e);throw e instanceof cf||Object.prototype.toString.call(e)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${t}" in template expression`)},lf=({stdout:e})=>{if(typeof e=="string")return e;if(Q(e))return ci(e);throw e===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof e}" stdout in template expression`)};import{spawnSync as fx}from"child_process";import{debuglog as mf}from"util";import us from"process";var ve=e=>pi.includes(e),pi=[us.stdin,us.stdout,us.stderr],we=["stdin","stdout","stderr"],di=e=>we[e]??`stdio[${e}]`;var dc=e=>{let t={...e};for(let r of hs)t[r]=ls(e,r);return t},ls=(e,t)=>{let r=Array.from({length:hf(e)+1}),i=yf(e[t],r,t);return wf(i,t)},hf=({stdio:e})=>Array.isArray(e)?Math.max(e.length,we.length):we.length,yf=(e,t,r)=>K(e)?ff(e,t,r):t.fill(e),ff=(e,t,r)=>{for(let i of Object.keys(e).sort(gf))for(let n of _f(i,r,t))t[n]=e[i];return t},gf=(e,t)=>pc(e)<pc(t)?1:-1,pc=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,_f=(e,t,r)=>{if(e==="ipc")return[r.length-1];let i=ms(e);if(i===void 0||i===0)throw new TypeError(`"${t}.${e}" is invalid.
99
+ `}}}}).prompt();function Y(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}import{fileURLToPath as cf}from"url";var Rt=(e,t)=>{let r=fs(pf(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},pf=e=>ys(e)?e.toString():e,ys=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,fs=e=>e instanceof URL?cf(e):e;var mi=(e,t=[],r={})=>{let i=Rt(e,"First argument"),[n,s]=Y(t)?[[],t]:[t,r];if(!Array.isArray(n))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${n}`);if(n.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${n}`);let o=n.map(String),a=o.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!Y(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[i,o,s]};import{ChildProcess as ff}from"child_process";import{StringDecoder as df}from"string_decoder";var{toString:cc}=Object.prototype,pc=e=>cc.call(e)==="[object ArrayBuffer]",ee=e=>cc.call(e)==="[object Uint8Array]",Ye=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),uf=new TextEncoder,dc=e=>uf.encode(e),lf=new TextDecoder,hi=e=>lf.decode(e),uc=(e,t)=>mf(e,t).join(""),mf=(e,t)=>{if(t==="utf8"&&e.every(s=>typeof s=="string"))return e;let r=new df(t),i=e.map(s=>typeof s=="string"?dc(s):s).map(s=>r.write(s)),n=r.end();return n===""?i:[...i,n]},pr=e=>e.length===1&&ee(e[0])?e[0]:gs(hf(e)),hf=e=>e.map(t=>typeof t=="string"?dc(t):t),gs=e=>{let t=new Uint8Array(yf(e)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t},yf=e=>{let t=0;for(let r of e)t+=r.length;return t};var yc=e=>Array.isArray(e)&&Array.isArray(e.raw),fc=(e,t)=>{let r=[];for(let[s,o]of e.entries())r=gf({templates:e,expressions:t,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[i,...n]=r;return[i,n,{}]},gf=({templates:e,expressions:t,tokens:r,index:i,template:n})=>{if(n===void 0)throw new TypeError(`Invalid backslash sequence: ${e.raw[i]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=_f(n,e.raw[i]),c=mc(r,s,o);if(i===t.length)return c;let d=t[i],p=Array.isArray(d)?d.map(u=>hc(u)):[hc(d)];return mc(c,p,a)},_f=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],i=0,n=lc.has(t[0]);for(let o=0,a=0;o<e.length;o+=1,a+=1){let c=t[a];if(lc.has(c))i!==o&&r.push(e.slice(i,o)),i=o+1;else if(c==="\\"){let d=t[a+1];d===`
100
+ `?(o-=1,a+=1):d==="u"&&t[a+2]==="{"?a=t.indexOf("}",a+3):a+=bf[d]??1}}let s=i===e.length;return s||r.push(e.slice(i)),{nextTokens:r,leadingWhitespaces:n,trailingWhitespaces:s}},lc=new Set([" "," ","\r",`
101
+ `]),bf={x:3,u:5},mc=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],hc=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(Y(e)&&("stdout"in e||"isMaxBuffer"in e))return wf(e);throw e instanceof ff||Object.prototype.toString.call(e)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${t}" in template expression`)},wf=({stdout:e})=>{if(typeof e=="string")return e;if(ee(e))return hi(e);throw e===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof e}" stdout in template expression`)};import{spawnSync as Sx}from"child_process";import{debuglog as xf}from"util";import _s from"process";var Se=e=>yi.includes(e),yi=[_s.stdin,_s.stdout,_s.stderr],xe=["stdin","stdout","stderr"],fi=e=>xe[e]??`stdio[${e}]`;var _c=e=>{let t={...e};for(let r of xs)t[r]=bs(e,r);return t},bs=(e,t)=>{let r=Array.from({length:kf(e)+1}),i=vf(e[t],r,t);return Cf(i,t)},kf=({stdio:e})=>Array.isArray(e)?Math.max(e.length,xe.length):xe.length,vf=(e,t,r)=>Y(e)?Sf(e,t,r):t.fill(e),Sf=(e,t,r)=>{for(let i of Object.keys(e).sort(qf))for(let n of $f(i,r,t))t[n]=e[i];return t},qf=(e,t)=>gc(e)<gc(t)?1:-1,gc=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,$f=(e,t,r)=>{if(e==="ipc")return[r.length-1];let i=ws(e);if(i===void 0||i===0)throw new TypeError(`"${t}.${e}" is invalid.
102
102
  It must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(i>=r.length)throw new TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.
103
- Please set the "stdio" option to ensure that file descriptor exists.`);return i==="all"?[1,2]:[i]},ms=e=>{if(e==="all")return e;if(we.includes(e))return we.indexOf(e);let t=bf.exec(e);if(t!==null)return Number(t[1])},bf=/^fd(\d+)$/,wf=(e,t)=>e.map(r=>r===void 0?kf[t]:r),xf=mf("execa").enabled?"full":"none",kf={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:xf,stripFinalNewline:!0},hs=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],Je=(e,t)=>t==="ipc"?e.at(-1):e[t];var Tt=({verbose:e},t)=>ys(e,t)!=="none",Rt=({verbose:e},t)=>!["none","short"].includes(ys(e,t)),uc=({verbose:e},t)=>{let r=ys(e,t);return ui(r)?r:void 0},ys=(e,t)=>t===void 0?vf(e):Je(e,t),vf=e=>e.find(t=>ui(t))??li.findLast(t=>e.includes(t)),ui=e=>typeof e=="function",li=["none","short","full"];import{inspect as Vf}from"util";import{platform as Sf}from"process";import{stripVTControlCharacters as qf}from"util";var lc=(e,t)=>{let r=[e,...t],i=r.join(" "),n=r.map(s=>Tf(mc(s))).join(" ");return{command:i,escapedCommand:n}},ar=e=>qf(e).split(`
104
- `).map(t=>mc(t)).join(`
105
- `),mc=e=>e.replaceAll(Cf,t=>$f(t)),$f=e=>{let t=Ef[e];if(t!==void 0)return t;let r=e.codePointAt(0),i=r.toString(16);return r<=Pf?`\\u${i.padStart(4,"0")}`:`\\U${i}`},Af=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},Cf=Af(),Ef={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},Pf=65535,Tf=e=>Rf.test(e)?e:Sf==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,Rf=/^[\w./-]+$/;import hc from"process";function fs(){let{env:e}=hc,{TERM:t,TERM_PROGRAM:r}=e;return hc.platform!=="win32"?t!=="linux":!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var yc={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},fc={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},If={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Of={...yc,...fc},jf={...yc,...If},Df=fs(),Lf=Df?Of:jf,mi=Lf,$$=Object.entries(fc);import Mf from"tty";var Ff=Mf?.WriteStream?.prototype?.hasColors?.()??!1,q=(e,t)=>{if(!Ff)return n=>n;let r=`\x1B[${e}m`,i=`\x1B[${t}m`;return n=>{let s=n+"",o=s.indexOf(i);if(o===-1)return r+s+i;let a=r,c=0,p=(t===22?i:"")+r;for(;o!==-1;)a+=s.slice(c,o)+p,c=o+i.length,o=s.indexOf(i,c);return a+=s.slice(c)+i,a}},E$=q(0,0),gc=q(1,22),P$=q(2,22),T$=q(3,23),R$=q(4,24),I$=q(53,55),O$=q(7,27),j$=q(8,28),D$=q(9,29),L$=q(30,39),M$=q(31,39),F$=q(32,39),B$=q(33,39),U$=q(34,39),N$=q(35,39),G$=q(36,39),z$=q(37,39),hi=q(90,39),V$=q(40,49),W$=q(41,49),H$=q(42,49),K$=q(43,49),Y$=q(44,49),J$=q(45,49),X$=q(46,49),Z$=q(47,49),Q$=q(100,49),_c=q(91,39),eA=q(92,39),bc=q(93,39),tA=q(94,39),rA=q(95,39),iA=q(96,39),nA=q(97,39),sA=q(101,49),oA=q(102,49),aA=q(103,49),cA=q(104,49),pA=q(105,49),dA=q(106,49),uA=q(107,49);var kc=({type:e,message:t,timestamp:r,piped:i,commandId:n,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=Bf(r),c=Uf[e]({failed:s,reject:o,piped:i}),d=Nf[e]({reject:o});return`${hi(`[${a}]`)} ${hi(`[${n}]`)} ${d(c)} ${d(t)}`},Bf=e=>`${yi(e.getHours(),2)}:${yi(e.getMinutes(),2)}:${yi(e.getSeconds(),2)}.${yi(e.getMilliseconds(),3)}`,yi=(e,t)=>String(e).padStart(t,"0"),wc=({failed:e,reject:t})=>e?t?mi.cross:mi.warning:mi.tick,Uf={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:wc,duration:wc},xc=e=>e,Nf={command:()=>gc,output:()=>xc,ipc:()=>xc,error:({reject:e})=>e?_c:bc,duration:()=>hi};var vc=(e,t,r)=>{let i=uc(t,r);return e.map(({verboseLine:n,verboseObject:s})=>Gf(n,s,i)).filter(n=>n!==void 0).map(n=>zf(n)).join("")},Gf=(e,t,r)=>{if(r===void 0)return e;let i=r(e,t);if(typeof i=="string")return i},zf=e=>e.endsWith(`
103
+ Please set the "stdio" option to ensure that file descriptor exists.`);return i==="all"?[1,2]:[i]},ws=e=>{if(e==="all")return e;if(xe.includes(e))return xe.indexOf(e);let t=Af.exec(e);if(t!==null)return Number(t[1])},Af=/^fd(\d+)$/,Cf=(e,t)=>e.map(r=>r===void 0?Pf[t]:r),Ef=xf("execa").enabled?"full":"none",Pf={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:Ef,stripFinalNewline:!0},xs=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],Je=(e,t)=>t==="ipc"?e.at(-1):e[t];var It=({verbose:e},t)=>ks(e,t)!=="none",Ot=({verbose:e},t)=>!["none","short"].includes(ks(e,t)),bc=({verbose:e},t)=>{let r=ks(e,t);return gi(r)?r:void 0},ks=(e,t)=>t===void 0?Tf(e):Je(e,t),Tf=e=>e.find(t=>gi(t))??_i.findLast(t=>e.includes(t)),gi=e=>typeof e=="function",_i=["none","short","full"];import{inspect as Qf}from"util";import{platform as Rf}from"process";import{stripVTControlCharacters as If}from"util";var wc=(e,t)=>{let r=[e,...t],i=r.join(" "),n=r.map(s=>Ff(xc(s))).join(" ");return{command:i,escapedCommand:n}},dr=e=>If(e).split(`
104
+ `).map(t=>xc(t)).join(`
105
+ `),xc=e=>e.replaceAll(Df,t=>Of(t)),Of=e=>{let t=Lf[e];if(t!==void 0)return t;let r=e.codePointAt(0),i=r.toString(16);return r<=Mf?`\\u${i.padStart(4,"0")}`:`\\U${i}`},jf=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},Df=jf(),Lf={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},Mf=65535,Ff=e=>Bf.test(e)?e:Rf==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,Bf=/^[\w./-]+$/;import kc from"process";function vs(){let{env:e}=kc,{TERM:t,TERM_PROGRAM:r}=e;return kc.platform!=="win32"?t!=="linux":!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var vc={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},Sc={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},Uf={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Nf={...vc,...Sc},Gf={...vc,...Uf},zf=vs(),Vf=zf?Nf:Gf,bi=Vf,D$=Object.entries(Sc);import Wf from"tty";var Hf=Wf?.WriteStream?.prototype?.hasColors?.()??!1,q=(e,t)=>{if(!Hf)return n=>n;let r=`\x1B[${e}m`,i=`\x1B[${t}m`;return n=>{let s=n+"",o=s.indexOf(i);if(o===-1)return r+s+i;let a=r,c=0,p=(t===22?i:"")+r;for(;o!==-1;)a+=s.slice(c,o)+p,c=o+i.length,o=s.indexOf(i,c);return a+=s.slice(c)+i,a}},F$=q(0,0),qc=q(1,22),B$=q(2,22),U$=q(3,23),N$=q(4,24),G$=q(53,55),z$=q(7,27),V$=q(8,28),W$=q(9,29),H$=q(30,39),K$=q(31,39),Y$=q(32,39),J$=q(33,39),X$=q(34,39),Z$=q(35,39),Q$=q(36,39),eA=q(37,39),wi=q(90,39),tA=q(40,49),rA=q(41,49),iA=q(42,49),nA=q(43,49),sA=q(44,49),oA=q(45,49),aA=q(46,49),cA=q(47,49),pA=q(100,49),$c=q(91,39),dA=q(92,39),Ac=q(93,39),uA=q(94,39),lA=q(95,39),mA=q(96,39),hA=q(97,39),yA=q(101,49),fA=q(102,49),gA=q(103,49),_A=q(104,49),bA=q(105,49),wA=q(106,49),xA=q(107,49);var Pc=({type:e,message:t,timestamp:r,piped:i,commandId:n,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=Kf(r),c=Yf[e]({failed:s,reject:o,piped:i}),d=Jf[e]({reject:o});return`${wi(`[${a}]`)} ${wi(`[${n}]`)} ${d(c)} ${d(t)}`},Kf=e=>`${xi(e.getHours(),2)}:${xi(e.getMinutes(),2)}:${xi(e.getSeconds(),2)}.${xi(e.getMilliseconds(),3)}`,xi=(e,t)=>String(e).padStart(t,"0"),Cc=({failed:e,reject:t})=>e?t?bi.cross:bi.warning:bi.tick,Yf={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:Cc,duration:Cc},Ec=e=>e,Jf={command:()=>qc,output:()=>Ec,ipc:()=>Ec,error:({reject:e})=>e?$c:Ac,duration:()=>wi};var Tc=(e,t,r)=>{let i=bc(t,r);return e.map(({verboseLine:n,verboseObject:s})=>Xf(n,s,i)).filter(n=>n!==void 0).map(n=>Zf(n)).join("")},Xf=(e,t,r)=>{if(r===void 0)return e;let i=r(e,t);if(typeof i=="string")return i},Zf=e=>e.endsWith(`
106
106
  `)?e:`${e}
107
- `;var Re=({type:e,verboseMessage:t,fdNumber:r,verboseInfo:i,result:n})=>{let s=Wf({type:e,result:n,verboseInfo:i}),o=Hf(t,s),a=vc(o,i,r);a!==""&&console.warn(a.slice(0,-1))},Wf=({type:e,result:t,verboseInfo:{escapedCommand:r,commandId:i,rawOptions:{piped:n=!1,...s}}})=>({type:e,escapedCommand:r,commandId:`${i}`,timestamp:new Date,piped:n,result:t,options:s}),Hf=(e,t)=>e.split(`
108
- `).map(r=>Kf({...t,message:r})),Kf=e=>({verboseLine:kc(e),verboseObject:e}),fi=e=>{let t=typeof e=="string"?e:Vf(e);return ar(t).replaceAll(" "," ".repeat(Yf))},Yf=2;var Sc=(e,t)=>{Tt(t)&&Re({type:"command",verboseMessage:e,verboseInfo:t})};var qc=(e,t,r)=>{Zf(e);let i=Jf(e);return{verbose:e,escapedCommand:t,commandId:i,rawOptions:r}},Jf=e=>Tt({verbose:e})?Xf++:void 0,Xf=0n,Zf=e=>{for(let t of e){if(t===!1)throw new TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(t===!0)throw new TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!li.includes(t)&&!ui(t)){let r=li.map(i=>`'${i}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${r} or a function.`)}}};import{hrtime as $c}from"process";var gi=()=>$c.bigint(),gs=e=>Number($c.bigint()-e)/1e6;var _i=(e,t,r)=>{let i=gi(),{command:n,escapedCommand:s}=lc(e,t),o=ls(r,"verbose"),a=qc(o,s,{...r});return Sc(s,a),{command:n,escapedCommand:s,startTime:i,verboseInfo:a}};var qd=U(hp(),1);import j_ from"path";import Sd from"process";import ki from"process";import ft from"path";function wi(e={}){let{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"}import{promisify as qg}from"util";import{execFile as $g,execFileSync as QA}from"child_process";import yp from"path";import{fileURLToPath as Ag}from"url";var rC=qg($g);function xi(e){return e instanceof URL?Ag(e):e}function fp(e){return{*[Symbol.iterator](){let t=yp.resolve(xi(e)),r;for(;r!==t;)yield t,r=t,t=yp.resolve(t,"..")}}}var iC=10*1024*1024;var Cg=({cwd:e=ki.cwd(),path:t=ki.env[wi()],preferLocal:r=!0,execPath:i=ki.execPath,addExecPath:n=!0}={})=>{let s=ft.resolve(xi(e)),o=[],a=t.split(ft.delimiter);return r&&Eg(o,a,s),n&&Pg(o,a,i,s),t===""||t===ft.delimiter?`${o.join(ft.delimiter)}${t}`:[...o,t].join(ft.delimiter)},Eg=(e,t,r)=>{for(let i of fp(r)){let n=ft.join(i,"node_modules/.bin");t.includes(n)||e.push(n)}},Pg=(e,t,r,i)=>{let n=ft.resolve(i,xi(r),"..");t.includes(n)||e.push(n)},gp=({env:e=ki.env,...t}={})=>{e={...e};let r=wi({env:e});return t.path=e[r],e[r]=Cg(t),e};import{setTimeout as Vg}from"timers/promises";var _p=(e,t,r)=>{let i=r?pr:cr,n=e instanceof Se?{}:{cause:e};return new i(t,n)},Se=class extends Error{},bp=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,xp,{value:!0,writable:!1,enumerable:!1,configurable:!1})},wp=e=>vi(e)&&xp in e,xp=Symbol("isExecaError"),vi=e=>Object.prototype.toString.call(e)==="[object Error]",cr=class extends Error{};bp(cr,cr.name);var pr=class extends Error{};bp(pr,pr.name);import{constants as dr}from"os";import{constants as Og}from"os";var kp=()=>{let e=Sp-vp+1;return Array.from({length:e},Tg)},Tg=(e,t)=>({name:`SIGRT${t+1}`,number:vp+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),vp=34,Sp=64;import{constants as Rg}from"os";var qp=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var As=()=>{let e=kp();return[...qp,...e].map(Ig)},Ig=({name:e,number:t,description:r,action:i,forced:n=!1,standard:s})=>{let{signals:{[e]:o}}=Rg,a=o!==void 0;return{name:e,number:a?o:t,description:r,supported:a,action:i,forced:n,standard:s}};var jg=()=>{let e=As();return Object.fromEntries(e.map(Dg))},Dg=({name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o})=>[e,{name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o}],$p=jg(),Lg=()=>{let e=As(),t=65,r=Array.from({length:t},(i,n)=>Mg(n,e));return Object.assign({},...r)},Mg=(e,t)=>{let r=Fg(e,t);if(r===void 0)return{};let{name:i,description:n,supported:s,action:o,forced:a,standard:c}=r;return{[e]:{name:i,number:e,description:n,supported:s,action:o,forced:a,standard:c}}},Fg=(e,t)=>{let r=t.find(({name:i})=>Og.signals[i]===e);return r!==void 0?r:t.find(i=>i.number===e)},wC=Lg();var Cp=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return Pp(e,t)},Ep=e=>e===0?e:Pp(e,"`subprocess.kill()`'s argument"),Pp=(e,t)=>{if(Number.isInteger(e))return Bg(e,t);if(typeof e=="string")return Ng(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
109
- ${Cs()}`)},Bg=(e,t)=>{if(Ap.has(e))return Ap.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.
110
- ${Cs()}`)},Ug=()=>new Map(Object.entries(dr.signals).reverse().map(([e,t])=>[t,e])),Ap=Ug(),Ng=(e,t)=>{if(e in dr.signals)return e;throw e.toUpperCase()in dr.signals?new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):new TypeError(`Invalid ${t} '${e}': this signal name does not exist.
111
- ${Cs()}`)},Cs=()=>`Available signal names: ${Gg()}.
112
- Available signal numbers: ${zg()}.`,Gg=()=>Object.keys(dr.signals).sort().map(e=>`'${e}'`).join(", "),zg=()=>[...new Set(Object.values(dr.signals).sort((e,t)=>e-t))].join(", "),Si=e=>$p[e].description;var Tp=e=>{if(e===!1)return e;if(e===!0)return Wg;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Wg=1e3*5,Rp=({kill:e,options:{forceKillAfterDelay:t,killSignal:r},onInternalError:i,context:n,controller:s},o,a)=>{let{signal:c,error:d}=Hg(o,a,r);Kg(d,i);let p=e(c);return Yg({kill:e,signal:c,forceKillAfterDelay:t,killSignal:r,killResult:p,context:n,controller:s}),p},Hg=(e,t,r)=>{let[i=r,n]=vi(e)?[void 0,e]:[e,t];if(typeof i!="string"&&!Number.isInteger(i))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(i)}`);if(n!==void 0&&!vi(n))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${n}`);return{signal:Ep(i),error:n}},Kg=(e,t)=>{e!==void 0&&t.reject(e)},Yg=async({kill:e,signal:t,forceKillAfterDelay:r,killSignal:i,killResult:n,context:s,controller:o})=>{t===i&&n&&Es({kill:e,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},Es=async({kill:e,forceKillAfterDelay:t,context:r,controllerSignal:i})=>{if(t!==!1)try{await Vg(t,void 0,{signal:i}),e("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};import{once as Jg}from"events";var qi=async(e,t)=>{e.aborted||await Jg(e,"abort",{signal:t})};var Ip=({cancelSignal:e})=>{if(e!==void 0&&Object.prototype.toString.call(e)!=="[object AbortSignal]")throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)},Op=({subprocess:e,cancelSignal:t,gracefulCancel:r,context:i,controller:n})=>t===void 0||r?[]:[Xg(e,t,i,n)],Xg=async(e,t,r,{signal:i})=>{throw await qi(t,i),r.terminationReason??="cancel",e.kill(),t.reason};import{scheduler as __}from"timers/promises";import{promisify as y_}from"util";var jt=({methodName:e,isSubprocess:t,ipc:r,isConnected:i})=>{Zg(e,t,r),Ps(e,t,i)},Zg=(e,t,r)=>{if(!r)throw new Error(`${qe(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Ps=(e,t,r)=>{if(!r)throw new Error(`${qe(e,t)} cannot be used: the ${nt(t)} has already exited or disconnected.`)},jp=e=>{throw new Error(`${qe("getOneMessage",e)} could not complete: the ${nt(e)} exited or disconnected.`)},Dp=e=>{throw new Error(`${qe("sendMessage",e)} failed: the ${nt(e)} is sending a message too, instead of listening to incoming messages.
107
+ `;var Ie=({type:e,verboseMessage:t,fdNumber:r,verboseInfo:i,result:n})=>{let s=eg({type:e,result:n,verboseInfo:i}),o=tg(t,s),a=Tc(o,i,r);a!==""&&console.warn(a.slice(0,-1))},eg=({type:e,result:t,verboseInfo:{escapedCommand:r,commandId:i,rawOptions:{piped:n=!1,...s}}})=>({type:e,escapedCommand:r,commandId:`${i}`,timestamp:new Date,piped:n,result:t,options:s}),tg=(e,t)=>e.split(`
108
+ `).map(r=>rg({...t,message:r})),rg=e=>({verboseLine:Pc(e),verboseObject:e}),ki=e=>{let t=typeof e=="string"?e:Qf(e);return dr(t).replaceAll(" "," ".repeat(ig))},ig=2;var Rc=(e,t)=>{It(t)&&Ie({type:"command",verboseMessage:e,verboseInfo:t})};var Ic=(e,t,r)=>{og(e);let i=ng(e);return{verbose:e,escapedCommand:t,commandId:i,rawOptions:r}},ng=e=>It({verbose:e})?sg++:void 0,sg=0n,og=e=>{for(let t of e){if(t===!1)throw new TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(t===!0)throw new TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!_i.includes(t)&&!gi(t)){let r=_i.map(i=>`'${i}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${r} or a function.`)}}};import{hrtime as Oc}from"process";var vi=()=>Oc.bigint(),Ss=e=>Number(Oc.bigint()-e)/1e6;var Si=(e,t,r)=>{let i=vi(),{command:n,escapedCommand:s}=wc(e,t),o=bs(r,"verbose"),a=Ic(o,s,{...r});return Rc(s,a),{command:n,escapedCommand:s,startTime:i,verboseInfo:a}};var Id=M(kp(),1);import G_ from"path";import Rd from"process";import Ci from"process";import ft from"path";function $i(e={}){let{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"}import{promisify as Ig}from"util";import{execFile as Og,execFileSync as pC}from"child_process";import vp from"path";import{fileURLToPath as jg}from"url";var lC=Ig(Og);function Ai(e){return e instanceof URL?jg(e):e}function Sp(e){return{*[Symbol.iterator](){let t=vp.resolve(Ai(e)),r;for(;r!==t;)yield t,r=t,t=vp.resolve(t,"..")}}}var mC=10*1024*1024;var Dg=({cwd:e=Ci.cwd(),path:t=Ci.env[$i()],preferLocal:r=!0,execPath:i=Ci.execPath,addExecPath:n=!0}={})=>{let s=ft.resolve(Ai(e)),o=[],a=t.split(ft.delimiter);return r&&Lg(o,a,s),n&&Mg(o,a,i,s),t===""||t===ft.delimiter?`${o.join(ft.delimiter)}${t}`:[...o,t].join(ft.delimiter)},Lg=(e,t,r)=>{for(let i of Sp(r)){let n=ft.join(i,"node_modules/.bin");t.includes(n)||e.push(n)}},Mg=(e,t,r,i)=>{let n=ft.resolve(i,Ai(r),"..");t.includes(n)||e.push(n)},qp=({env:e=Ci.env,...t}={})=>{e={...e};let r=$i({env:e});return t.path=e[r],e[r]=Dg(t),e};import{setTimeout as Qg}from"timers/promises";var $p=(e,t,r)=>{let i=r?lr:ur,n=e instanceof qe?{}:{cause:e};return new i(t,n)},qe=class extends Error{},Ap=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Ep,{value:!0,writable:!1,enumerable:!1,configurable:!1})},Cp=e=>Ei(e)&&Ep in e,Ep=Symbol("isExecaError"),Ei=e=>Object.prototype.toString.call(e)==="[object Error]",ur=class extends Error{};Ap(ur,ur.name);var lr=class extends Error{};Ap(lr,lr.name);import{constants as mr}from"os";import{constants as Ng}from"os";var Pp=()=>{let e=Rp-Tp+1;return Array.from({length:e},Fg)},Fg=(e,t)=>({name:`SIGRT${t+1}`,number:Tp+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Tp=34,Rp=64;import{constants as Bg}from"os";var Ip=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var Os=()=>{let e=Pp();return[...Ip,...e].map(Ug)},Ug=({name:e,number:t,description:r,action:i,forced:n=!1,standard:s})=>{let{signals:{[e]:o}}=Bg,a=o!==void 0;return{name:e,number:a?o:t,description:r,supported:a,action:i,forced:n,standard:s}};var Gg=()=>{let e=Os();return Object.fromEntries(e.map(zg))},zg=({name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o})=>[e,{name:e,number:t,description:r,supported:i,action:n,forced:s,standard:o}],Op=Gg(),Vg=()=>{let e=Os(),t=65,r=Array.from({length:t},(i,n)=>Wg(n,e));return Object.assign({},...r)},Wg=(e,t)=>{let r=Hg(e,t);if(r===void 0)return{};let{name:i,description:n,supported:s,action:o,forced:a,standard:c}=r;return{[e]:{name:i,number:e,description:n,supported:s,action:o,forced:a,standard:c}}},Hg=(e,t)=>{let r=t.find(({name:i})=>Ng.signals[i]===e);return r!==void 0?r:t.find(i=>i.number===e)},PC=Vg();var Dp=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return Mp(e,t)},Lp=e=>e===0?e:Mp(e,"`subprocess.kill()`'s argument"),Mp=(e,t)=>{if(Number.isInteger(e))return Kg(e,t);if(typeof e=="string")return Jg(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
109
+ ${js()}`)},Kg=(e,t)=>{if(jp.has(e))return jp.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.
110
+ ${js()}`)},Yg=()=>new Map(Object.entries(mr.signals).reverse().map(([e,t])=>[t,e])),jp=Yg(),Jg=(e,t)=>{if(e in mr.signals)return e;throw e.toUpperCase()in mr.signals?new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):new TypeError(`Invalid ${t} '${e}': this signal name does not exist.
111
+ ${js()}`)},js=()=>`Available signal names: ${Xg()}.
112
+ Available signal numbers: ${Zg()}.`,Xg=()=>Object.keys(mr.signals).sort().map(e=>`'${e}'`).join(", "),Zg=()=>[...new Set(Object.values(mr.signals).sort((e,t)=>e-t))].join(", "),Pi=e=>Op[e].description;var Fp=e=>{if(e===!1)return e;if(e===!0)return e_;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},e_=1e3*5,Bp=({kill:e,options:{forceKillAfterDelay:t,killSignal:r},onInternalError:i,context:n,controller:s},o,a)=>{let{signal:c,error:d}=t_(o,a,r);r_(d,i);let p=e(c);return i_({kill:e,signal:c,forceKillAfterDelay:t,killSignal:r,killResult:p,context:n,controller:s}),p},t_=(e,t,r)=>{let[i=r,n]=Ei(e)?[void 0,e]:[e,t];if(typeof i!="string"&&!Number.isInteger(i))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(i)}`);if(n!==void 0&&!Ei(n))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${n}`);return{signal:Lp(i),error:n}},r_=(e,t)=>{e!==void 0&&t.reject(e)},i_=async({kill:e,signal:t,forceKillAfterDelay:r,killSignal:i,killResult:n,context:s,controller:o})=>{t===i&&n&&Ds({kill:e,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},Ds=async({kill:e,forceKillAfterDelay:t,context:r,controllerSignal:i})=>{if(t!==!1)try{await Qg(t,void 0,{signal:i}),e("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};import{once as n_}from"events";var Ti=async(e,t)=>{e.aborted||await n_(e,"abort",{signal:t})};var Up=({cancelSignal:e})=>{if(e!==void 0&&Object.prototype.toString.call(e)!=="[object AbortSignal]")throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)},Np=({subprocess:e,cancelSignal:t,gracefulCancel:r,context:i,controller:n})=>t===void 0||r?[]:[s_(e,t,i,n)],s_=async(e,t,r,{signal:i})=>{throw await Ti(t,i),r.terminationReason??="cancel",e.kill(),t.reason};import{scheduler as $_}from"timers/promises";import{promisify as v_}from"util";var Lt=({methodName:e,isSubprocess:t,ipc:r,isConnected:i})=>{o_(e,t,r),Ls(e,t,i)},o_=(e,t,r)=>{if(!r)throw new Error(`${$e(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Ls=(e,t,r)=>{if(!r)throw new Error(`${$e(e,t)} cannot be used: the ${nt(t)} has already exited or disconnected.`)},Gp=e=>{throw new Error(`${$e("getOneMessage",e)} could not complete: the ${nt(e)} exited or disconnected.`)},zp=e=>{throw new Error(`${$e("sendMessage",e)} failed: the ${nt(e)} is sending a message too, instead of listening to incoming messages.
113
113
  This can be fixed by both sending a message and listening to incoming messages at the same time:
114
114
 
115
115
  const [receivedMessage] = await Promise.all([
116
- ${qe("getOneMessage",e)},
117
- ${qe("sendMessage",e,"message, {strict: true}")},
118
- ]);`)},$i=(e,t)=>new Error(`${qe("sendMessage",t)} failed when sending an acknowledgment response to the ${nt(t)}.`,{cause:e}),Lp=e=>{throw new Error(`${qe("sendMessage",e)} failed: the ${nt(e)} is not listening to incoming messages.`)},Mp=e=>{throw new Error(`${qe("sendMessage",e)} failed: the ${nt(e)} exited without listening to incoming messages.`)},Fp=()=>new Error(`\`cancelSignal\` aborted: the ${nt(!0)} disconnected.`),Bp=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},Up=({error:e,methodName:t,isSubprocess:r})=>{if(e.code==="EPIPE")throw new Error(`${qe(t,r)} cannot be used: the ${nt(r)} is disconnecting.`,{cause:e})},Np=({error:e,methodName:t,isSubprocess:r,message:i})=>{if(Qg(e))throw new Error(`${qe(t,r)}'s argument type is invalid: the message cannot be serialized: ${String(i)}.`,{cause:e})},Qg=({code:e,message:t})=>e_.has(e)||t_.some(r=>t.includes(r)),e_=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),t_=["could not be cloned","circular structure","call stack size exceeded"],qe=(e,t,r="")=>e==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${r_(t)}${e}(${r})`,r_=e=>e?"":"subprocess.",nt=e=>e?"parent process":"subprocess",Dt=e=>{e.connected&&e.disconnect()};var Ie=()=>{let e={},t=new Promise((r,i)=>{Object.assign(e,{resolve:r,reject:i})});return Object.assign(t,e)};var Ci=(e,t="stdin")=>{let{options:i,fileDescriptors:n}=Oe.get(e),s=Gp(n,t,!0),o=e.stdio[s];if(o===null)throw new TypeError(zp(s,t,i,!0));return o},Lt=(e,t="stdout")=>{let{options:i,fileDescriptors:n}=Oe.get(e),s=Gp(n,t,!1),o=s==="all"?e.all:e.stdio[s];if(o==null)throw new TypeError(zp(s,t,i,!1));return o},Oe=new WeakMap,Gp=(e,t,r)=>{let i=i_(t,r);return n_(i,t,r,e),i},i_=(e,t)=>{let r=ms(e);if(r!==void 0)return r;let{validOptions:i,defaultValue:n}=t?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${ur(t)}" must not be "${e}".
116
+ ${$e("getOneMessage",e)},
117
+ ${$e("sendMessage",e,"message, {strict: true}")},
118
+ ]);`)},Ri=(e,t)=>new Error(`${$e("sendMessage",t)} failed when sending an acknowledgment response to the ${nt(t)}.`,{cause:e}),Vp=e=>{throw new Error(`${$e("sendMessage",e)} failed: the ${nt(e)} is not listening to incoming messages.`)},Wp=e=>{throw new Error(`${$e("sendMessage",e)} failed: the ${nt(e)} exited without listening to incoming messages.`)},Hp=()=>new Error(`\`cancelSignal\` aborted: the ${nt(!0)} disconnected.`),Kp=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},Yp=({error:e,methodName:t,isSubprocess:r})=>{if(e.code==="EPIPE")throw new Error(`${$e(t,r)} cannot be used: the ${nt(r)} is disconnecting.`,{cause:e})},Jp=({error:e,methodName:t,isSubprocess:r,message:i})=>{if(a_(e))throw new Error(`${$e(t,r)}'s argument type is invalid: the message cannot be serialized: ${String(i)}.`,{cause:e})},a_=({code:e,message:t})=>c_.has(e)||p_.some(r=>t.includes(r)),c_=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),p_=["could not be cloned","circular structure","call stack size exceeded"],$e=(e,t,r="")=>e==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${d_(t)}${e}(${r})`,d_=e=>e?"":"subprocess.",nt=e=>e?"parent process":"subprocess",Mt=e=>{e.connected&&e.disconnect()};var Oe=()=>{let e={},t=new Promise((r,i)=>{Object.assign(e,{resolve:r,reject:i})});return Object.assign(t,e)};var Oi=(e,t="stdin")=>{let{options:i,fileDescriptors:n}=je.get(e),s=Xp(n,t,!0),o=e.stdio[s];if(o===null)throw new TypeError(Zp(s,t,i,!0));return o},Ft=(e,t="stdout")=>{let{options:i,fileDescriptors:n}=je.get(e),s=Xp(n,t,!1),o=s==="all"?e.all:e.stdio[s];if(o==null)throw new TypeError(Zp(s,t,i,!1));return o},je=new WeakMap,Xp=(e,t,r)=>{let i=u_(t,r);return l_(i,t,r,e),i},u_=(e,t)=>{let r=ws(e);if(r!==void 0)return r;let{validOptions:i,defaultValue:n}=t?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${hr(t)}" must not be "${e}".
119
119
  It must be ${i} or "fd3", "fd4" (and so on).
120
- It is optional and defaults to "${n}".`)},n_=(e,t,r,i)=>{let n=i[Vp(e)];if(n===void 0)throw new TypeError(`"${ur(r)}" must not be ${t}. That file descriptor does not exist.
121
- Please set the "stdio" option to ensure that file descriptor exists.`);if(n.direction==="input"&&!r)throw new TypeError(`"${ur(r)}" must not be ${t}. It must be a readable stream, not writable.`);if(n.direction!=="input"&&r)throw new TypeError(`"${ur(r)}" must not be ${t}. It must be a writable stream, not readable.`)},zp=(e,t,r,i)=>{if(e==="all"&&!r.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:n,optionValue:s}=s_(e,r);return`The "${n}: ${Ai(s)}" option is incompatible with using "${ur(i)}: ${Ai(t)}".
122
- Please set this option with "pipe" instead.`},s_=(e,{stdin:t,stdout:r,stderr:i,stdio:n})=>{let s=Vp(e);return s===0&&t!==void 0?{optionName:"stdin",optionValue:t}:s===1&&r!==void 0?{optionName:"stdout",optionValue:r}:s===2&&i!==void 0?{optionName:"stderr",optionValue:i}:{optionName:`stdio[${s}]`,optionValue:n[s]}},Vp=e=>e==="all"?1:e,ur=e=>e?"to":"from",Ai=e=>typeof e=="string"?`'${e}'`:typeof e=="number"?`${e}`:"Stream";import{once as u_}from"events";import{addAbortListener as o_}from"events";var gt=(e,t,r)=>{let i=e.getMaxListeners();i===0||i===Number.POSITIVE_INFINITY||(e.setMaxListeners(i+t),o_(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))};import{EventEmitter as p_}from"events";import{once as a_}from"events";import{scheduler as c_}from"timers/promises";var Ei=(e,t)=>{t&&Ts(e)},Ts=e=>{e.refCounted()},Pi=(e,t)=>{t&&Rs(e)},Rs=e=>{e.unrefCounted()},Wp=(e,t)=>{t&&(Rs(e),Rs(e))},Hp=(e,t)=>{t&&(Ts(e),Ts(e))};var Kp=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i},n)=>{if(Xp(n)||Qp(n))return;Ti.has(e)||Ti.set(e,[]);let s=Ti.get(e);if(s.push(n),!(s.length>1))for(;s.length>0;){await Zp(e,i,n),await c_.yield();let o=await Jp({wrappedMessage:s[0],anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i});s.shift(),i.emit("message",o),i.emit("message:done")}},Yp=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:n})=>{Is();let s=Ti.get(e);for(;s?.length>0;)await a_(i,"message:done");e.removeListener("message",n),Hp(t,r),i.connected=!1,i.emit("disconnect")},Ti=new WeakMap;var st=(e,t,r)=>{if(Ri.has(e))return Ri.get(e);let i=new p_;return i.connected=!0,Ri.set(e,i),d_({ipcEmitter:i,anyProcess:e,channel:t,isSubprocess:r}),i},Ri=new WeakMap,d_=({ipcEmitter:e,anyProcess:t,channel:r,isSubprocess:i})=>{let n=Kp.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e});t.on("message",n),t.once("disconnect",Yp.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e,boundOnMessage:n})),Wp(r,i)},Ii=e=>{let t=Ri.get(e);return t===void 0?e.channel!==null:t.connected};var ed=({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:n})=>{if(!n)return i;let s=st(e,t,r),o=Di(e,s);return{id:l_++,type:ji,message:i,hasListeners:o}},l_=0n,td=(e,t)=>{if(!(t?.type!==ji||t.hasListeners))for(let{id:r}of e)r!==void 0&&Oi[r].resolve({isDeadlock:!0,hasListeners:!1})},Jp=async({wrappedMessage:e,anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:n})=>{if(e?.type!==ji||!t.connected)return e;let{id:s,message:o}=e,a={id:s,type:id,message:Di(t,n)};try{await Li({anyProcess:t,channel:r,isSubprocess:i,ipc:!0},a)}catch(c){n.emit("strict:error",c)}return o},Xp=e=>{if(e?.type!==id)return!1;let{id:t,message:r}=e;return Oi[t]?.resolve({isDeadlock:!1,hasListeners:r}),!0},rd=async(e,t,r)=>{if(e?.type!==ji)return;let i=Ie();Oi[e.id]=i;let n=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([i,m_(t,r,n)]);s&&Dp(r),o||Lp(r)}finally{n.abort(),delete Oi[e.id]}},Oi={},m_=async(e,t,{signal:r})=>{gt(e,1,r),await u_(e,"disconnect",{signal:r}),Mp(t)},ji="execa:ipc:request",id="execa:ipc:response";var nd=(e,t,r)=>{lr.has(e)||lr.set(e,new Set);let i=lr.get(e),n=Ie(),s=r?t.id:void 0,o={onMessageSent:n,id:s};return i.add(o),{outgoingMessages:i,outgoingMessage:o}},sd=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},Zp=async(e,t,r)=>{for(;!Di(e,t)&&lr.get(e)?.size>0;){let i=[...lr.get(e)];td(i,r),await Promise.all(i.map(({onMessageSent:n})=>n))}},lr=new WeakMap,Di=(e,t)=>t.listenerCount("message")>h_(e),h_=e=>Oe.has(e)&&!Je(Oe.get(e).options.buffer,"ipc")?1:0;var Li=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},n,{strict:s=!1}={})=>{let o="sendMessage";return jt({methodName:o,isSubprocess:r,ipc:i,isConnected:e.connected}),f_({anyProcess:e,channel:t,methodName:o,isSubprocess:r,message:n,strict:s})},f_=async({anyProcess:e,channel:t,methodName:r,isSubprocess:i,message:n,strict:s})=>{let o=ed({anyProcess:e,channel:t,isSubprocess:i,message:n,strict:s}),a=nd(e,o,s);try{await js({anyProcess:e,methodName:r,isSubprocess:i,wrappedMessage:o,message:n})}catch(c){throw Dt(e),c}finally{sd(a)}},js=async({anyProcess:e,methodName:t,isSubprocess:r,wrappedMessage:i,message:n})=>{let s=g_(e);try{await Promise.all([rd(i,e,r),s(i)])}catch(o){throw Up({error:o,methodName:t,isSubprocess:r}),Np({error:o,methodName:t,isSubprocess:r,message:n}),o}},g_=e=>{if(Os.has(e))return Os.get(e);let t=y_(e.send.bind(e));return Os.set(e,t),t},Os=new WeakMap;var ad=(e,t)=>{let r="cancelSignal";return Ps(r,!1,e.connected),js({anyProcess:e,methodName:r,isSubprocess:!1,wrappedMessage:{type:pd,message:t},message:t})},cd=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>(await b_({anyProcess:e,channel:t,isSubprocess:r,ipc:i}),Ds.signal),b_=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>{if(!od){if(od=!0,!i){Bp();return}if(t===null){Is();return}st(e,t,r),await __.yield()}},od=!1,Qp=e=>e?.type!==pd?!1:(Ds.abort(e.message),!0),pd="execa:ipc:cancel",Is=()=>{Ds.abort(Fp())},Ds=new AbortController;var dd=({gracefulCancel:e,cancelSignal:t,ipc:r,serialization:i})=>{if(e){if(t===void 0)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!r)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(i==="json")throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}},ud=({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:i,context:n,controller:s})=>r?[w_({subprocess:e,cancelSignal:t,forceKillAfterDelay:i,context:n,controller:s})]:[],w_=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:{signal:n}})=>{await qi(t,n);let s=x_(t);throw await ad(e,s),Es({kill:e.kill,forceKillAfterDelay:r,context:i,controllerSignal:n}),i.terminationReason??="gracefulCancel",t.reason},x_=({reason:e})=>{if(!(e instanceof DOMException))return e;let t=new Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t};import{setTimeout as k_}from"timers/promises";var ld=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},md=(e,t,r,i)=>t===0||t===void 0?[]:[v_(e,t,r,i)],v_=async(e,t,r,{signal:i})=>{throw await k_(t,void 0,{signal:i}),r.terminationReason??="timeout",e.kill(),new Se};import{execPath as S_,execArgv as q_}from"process";import hd from"path";var yd=({options:e})=>{if(e.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},fd=(e,t,{node:r=!1,nodePath:i=S_,nodeOptions:n=q_.filter(c=>!c.startsWith("--inspect")),cwd:s,execPath:o,...a})=>{if(o!==void 0)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let c=Pt(i,'The "nodePath" option'),d=hd.resolve(s,c),p={...a,nodePath:d,node:r,cwd:s};if(!r)return[e,t,p];if(hd.basename(e,".exe")==="node")throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[d,[...n,e,...t],{ipc:!0,...p,shell:!1}]};import{serialize as $_}from"v8";var gd=({ipcInput:e,ipc:t,serialization:r})=>{if(e!==void 0){if(!t)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");E_[r](e)}},A_=e=>{try{$_(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:t})}},C_=e=>{try{JSON.stringify(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:t})}},E_={advanced:A_,json:C_},_d=async(e,t)=>{t!==void 0&&await e.sendMessage(t)};var wd=({encoding:e})=>{if(Ls.has(e))return;let t=T_(e);if(t!==void 0)throw new TypeError(`Invalid option \`encoding: ${Mi(e)}\`.
123
- Please rename it to ${Mi(t)}.`);let r=[...Ls].map(i=>Mi(i)).join(", ");throw new TypeError(`Invalid option \`encoding: ${Mi(e)}\`.
124
- Please rename it to one of: ${r}.`)},P_=new Set(["utf8","utf16le"]),ye=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),Ls=new Set([...P_,...ye]),T_=e=>{if(e===null)return"buffer";if(typeof e!="string")return;let t=e.toLowerCase();if(t in bd)return bd[t];if(Ls.has(t))return t},bd={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},Mi=e=>typeof e=="string"?`"${e}"`:String(e);import{statSync as R_}from"fs";import I_ from"path";import O_ from"process";var xd=(e=kd())=>{let t=Pt(e,'The "cwd" option');return I_.resolve(t)},kd=()=>{try{return O_.cwd()}catch(e){throw e.message=`The current directory does not exist.
125
- ${e.message}`,e}},vd=(e,t)=>{if(t===kd())return e;let r;try{r=R_(t)}catch(i){return`The "cwd" option is invalid: ${t}.
120
+ It is optional and defaults to "${n}".`)},l_=(e,t,r,i)=>{let n=i[Qp(e)];if(n===void 0)throw new TypeError(`"${hr(r)}" must not be ${t}. That file descriptor does not exist.
121
+ Please set the "stdio" option to ensure that file descriptor exists.`);if(n.direction==="input"&&!r)throw new TypeError(`"${hr(r)}" must not be ${t}. It must be a readable stream, not writable.`);if(n.direction!=="input"&&r)throw new TypeError(`"${hr(r)}" must not be ${t}. It must be a writable stream, not readable.`)},Zp=(e,t,r,i)=>{if(e==="all"&&!r.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:n,optionValue:s}=m_(e,r);return`The "${n}: ${Ii(s)}" option is incompatible with using "${hr(i)}: ${Ii(t)}".
122
+ Please set this option with "pipe" instead.`},m_=(e,{stdin:t,stdout:r,stderr:i,stdio:n})=>{let s=Qp(e);return s===0&&t!==void 0?{optionName:"stdin",optionValue:t}:s===1&&r!==void 0?{optionName:"stdout",optionValue:r}:s===2&&i!==void 0?{optionName:"stderr",optionValue:i}:{optionName:`stdio[${s}]`,optionValue:n[s]}},Qp=e=>e==="all"?1:e,hr=e=>e?"to":"from",Ii=e=>typeof e=="string"?`'${e}'`:typeof e=="number"?`${e}`:"Stream";import{once as b_}from"events";import{addAbortListener as h_}from"events";var gt=(e,t,r)=>{let i=e.getMaxListeners();i===0||i===Number.POSITIVE_INFINITY||(e.setMaxListeners(i+t),h_(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))};import{EventEmitter as g_}from"events";import{once as y_}from"events";import{scheduler as f_}from"timers/promises";var ji=(e,t)=>{t&&Ms(e)},Ms=e=>{e.refCounted()},Di=(e,t)=>{t&&Fs(e)},Fs=e=>{e.unrefCounted()},ed=(e,t)=>{t&&(Fs(e),Fs(e))},td=(e,t)=>{t&&(Ms(e),Ms(e))};var rd=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i},n)=>{if(sd(n)||ad(n))return;Li.has(e)||Li.set(e,[]);let s=Li.get(e);if(s.push(n),!(s.length>1))for(;s.length>0;){await od(e,i,n),await f_.yield();let o=await nd({wrappedMessage:s[0],anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i});s.shift(),i.emit("message",o),i.emit("message:done")}},id=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:n})=>{Bs();let s=Li.get(e);for(;s?.length>0;)await y_(i,"message:done");e.removeListener("message",n),td(t,r),i.connected=!1,i.emit("disconnect")},Li=new WeakMap;var st=(e,t,r)=>{if(Mi.has(e))return Mi.get(e);let i=new g_;return i.connected=!0,Mi.set(e,i),__({ipcEmitter:i,anyProcess:e,channel:t,isSubprocess:r}),i},Mi=new WeakMap,__=({ipcEmitter:e,anyProcess:t,channel:r,isSubprocess:i})=>{let n=rd.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e});t.on("message",n),t.once("disconnect",id.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e,boundOnMessage:n})),ed(r,i)},Fi=e=>{let t=Mi.get(e);return t===void 0?e.channel!==null:t.connected};var cd=({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:n})=>{if(!n)return i;let s=st(e,t,r),o=Ni(e,s);return{id:w_++,type:Ui,message:i,hasListeners:o}},w_=0n,pd=(e,t)=>{if(!(t?.type!==Ui||t.hasListeners))for(let{id:r}of e)r!==void 0&&Bi[r].resolve({isDeadlock:!0,hasListeners:!1})},nd=async({wrappedMessage:e,anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:n})=>{if(e?.type!==Ui||!t.connected)return e;let{id:s,message:o}=e,a={id:s,type:ud,message:Ni(t,n)};try{await Gi({anyProcess:t,channel:r,isSubprocess:i,ipc:!0},a)}catch(c){n.emit("strict:error",c)}return o},sd=e=>{if(e?.type!==ud)return!1;let{id:t,message:r}=e;return Bi[t]?.resolve({isDeadlock:!1,hasListeners:r}),!0},dd=async(e,t,r)=>{if(e?.type!==Ui)return;let i=Oe();Bi[e.id]=i;let n=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([i,x_(t,r,n)]);s&&zp(r),o||Vp(r)}finally{n.abort(),delete Bi[e.id]}},Bi={},x_=async(e,t,{signal:r})=>{gt(e,1,r),await b_(e,"disconnect",{signal:r}),Wp(t)},Ui="execa:ipc:request",ud="execa:ipc:response";var ld=(e,t,r)=>{yr.has(e)||yr.set(e,new Set);let i=yr.get(e),n=Oe(),s=r?t.id:void 0,o={onMessageSent:n,id:s};return i.add(o),{outgoingMessages:i,outgoingMessage:o}},md=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},od=async(e,t,r)=>{for(;!Ni(e,t)&&yr.get(e)?.size>0;){let i=[...yr.get(e)];pd(i,r),await Promise.all(i.map(({onMessageSent:n})=>n))}},yr=new WeakMap,Ni=(e,t)=>t.listenerCount("message")>k_(e),k_=e=>je.has(e)&&!Je(je.get(e).options.buffer,"ipc")?1:0;var Gi=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},n,{strict:s=!1}={})=>{let o="sendMessage";return Lt({methodName:o,isSubprocess:r,ipc:i,isConnected:e.connected}),S_({anyProcess:e,channel:t,methodName:o,isSubprocess:r,message:n,strict:s})},S_=async({anyProcess:e,channel:t,methodName:r,isSubprocess:i,message:n,strict:s})=>{let o=cd({anyProcess:e,channel:t,isSubprocess:i,message:n,strict:s}),a=ld(e,o,s);try{await Ns({anyProcess:e,methodName:r,isSubprocess:i,wrappedMessage:o,message:n})}catch(c){throw Mt(e),c}finally{md(a)}},Ns=async({anyProcess:e,methodName:t,isSubprocess:r,wrappedMessage:i,message:n})=>{let s=q_(e);try{await Promise.all([dd(i,e,r),s(i)])}catch(o){throw Yp({error:o,methodName:t,isSubprocess:r}),Jp({error:o,methodName:t,isSubprocess:r,message:n}),o}},q_=e=>{if(Us.has(e))return Us.get(e);let t=v_(e.send.bind(e));return Us.set(e,t),t},Us=new WeakMap;var yd=(e,t)=>{let r="cancelSignal";return Ls(r,!1,e.connected),Ns({anyProcess:e,methodName:r,isSubprocess:!1,wrappedMessage:{type:gd,message:t},message:t})},fd=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>(await A_({anyProcess:e,channel:t,isSubprocess:r,ipc:i}),Gs.signal),A_=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>{if(!hd){if(hd=!0,!i){Kp();return}if(t===null){Bs();return}st(e,t,r),await $_.yield()}},hd=!1,ad=e=>e?.type!==gd?!1:(Gs.abort(e.message),!0),gd="execa:ipc:cancel",Bs=()=>{Gs.abort(Hp())},Gs=new AbortController;var _d=({gracefulCancel:e,cancelSignal:t,ipc:r,serialization:i})=>{if(e){if(t===void 0)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!r)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(i==="json")throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}},bd=({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:i,context:n,controller:s})=>r?[C_({subprocess:e,cancelSignal:t,forceKillAfterDelay:i,context:n,controller:s})]:[],C_=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:{signal:n}})=>{await Ti(t,n);let s=E_(t);throw await yd(e,s),Ds({kill:e.kill,forceKillAfterDelay:r,context:i,controllerSignal:n}),i.terminationReason??="gracefulCancel",t.reason},E_=({reason:e})=>{if(!(e instanceof DOMException))return e;let t=new Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t};import{setTimeout as P_}from"timers/promises";var wd=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},xd=(e,t,r,i)=>t===0||t===void 0?[]:[T_(e,t,r,i)],T_=async(e,t,r,{signal:i})=>{throw await P_(t,void 0,{signal:i}),r.terminationReason??="timeout",e.kill(),new qe};import{execPath as R_,execArgv as I_}from"process";import kd from"path";var vd=({options:e})=>{if(e.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},Sd=(e,t,{node:r=!1,nodePath:i=R_,nodeOptions:n=I_.filter(c=>!c.startsWith("--inspect")),cwd:s,execPath:o,...a})=>{if(o!==void 0)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let c=Rt(i,'The "nodePath" option'),d=kd.resolve(s,c),p={...a,nodePath:d,node:r,cwd:s};if(!r)return[e,t,p];if(kd.basename(e,".exe")==="node")throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[d,[...n,e,...t],{ipc:!0,...p,shell:!1}]};import{serialize as O_}from"v8";var qd=({ipcInput:e,ipc:t,serialization:r})=>{if(e!==void 0){if(!t)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");L_[r](e)}},j_=e=>{try{O_(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:t})}},D_=e=>{try{JSON.stringify(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:t})}},L_={advanced:j_,json:D_},$d=async(e,t)=>{t!==void 0&&await e.sendMessage(t)};var Cd=({encoding:e})=>{if(zs.has(e))return;let t=F_(e);if(t!==void 0)throw new TypeError(`Invalid option \`encoding: ${zi(e)}\`.
123
+ Please rename it to ${zi(t)}.`);let r=[...zs].map(i=>zi(i)).join(", ");throw new TypeError(`Invalid option \`encoding: ${zi(e)}\`.
124
+ Please rename it to one of: ${r}.`)},M_=new Set(["utf8","utf16le"]),fe=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),zs=new Set([...M_,...fe]),F_=e=>{if(e===null)return"buffer";if(typeof e!="string")return;let t=e.toLowerCase();if(t in Ad)return Ad[t];if(zs.has(t))return t},Ad={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},zi=e=>typeof e=="string"?`"${e}"`:String(e);import{statSync as B_}from"fs";import U_ from"path";import N_ from"process";var Ed=(e=Pd())=>{let t=Rt(e,'The "cwd" option');return U_.resolve(t)},Pd=()=>{try{return N_.cwd()}catch(e){throw e.message=`The current directory does not exist.
125
+ ${e.message}`,e}},Td=(e,t)=>{if(t===Pd())return e;let r;try{r=B_(t)}catch(i){return`The "cwd" option is invalid: ${t}.
126
126
  ${i.message}
127
127
  ${e}`}return r.isDirectory()?e:`The "cwd" option is not a directory: ${t}.
128
- ${e}`};var Fi=(e,t,r)=>{r.cwd=xd(r.cwd);let[i,n,s]=fd(e,t,r),{command:o,args:a,options:c}=qd.default._parse(i,n,s),d=dc(c),p=D_(d);return ld(p),wd(p),gd(p),Ip(p),dd(p),p.shell=ps(p.shell),p.env=L_(p),p.killSignal=Cp(p.killSignal),p.forceKillAfterDelay=Tp(p.forceKillAfterDelay),p.lines=p.lines.map((u,l)=>u&&!ye.has(p.encoding)&&p.buffer[l]),Sd.platform==="win32"&&j_.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:p}},D_=({extendEnv:e=!0,preferLocal:t=!1,cwd:r,localDir:i=r,encoding:n="utf8",reject:s=!0,cleanup:o=!0,all:a=!1,windowsHide:c=!0,killSignal:d="SIGTERM",forceKillAfterDelay:p=!0,gracefulCancel:u=!1,ipcInput:l,ipc:m=l!==void 0||u,serialization:h="advanced",...f})=>({...f,extendEnv:e,preferLocal:t,cwd:r,localDirectory:i,encoding:n,reject:s,cleanup:o,all:a,windowsHide:c,killSignal:d,forceKillAfterDelay:p,gracefulCancel:u,ipcInput:l,ipc:m,serialization:h}),L_=({env:e,extendEnv:t,preferLocal:r,node:i,localDirectory:n,nodePath:s})=>{let o=t?{...Sd.env,...e}:e;return r||i?gp({env:o,cwd:n,execPath:s,preferLocal:r,addExecPath:i}):o};var Bi=(e,t,r)=>r.shell&&t.length>0?[[e,...t].join(" "),[],r]:[e,t,r];import{inspect as gb}from"util";function Mt(e){if(typeof e=="string")return M_(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return F_(e)}var M_=e=>e.at(-1)===$d?e.slice(0,e.at(-2)===Ad?-2:-1):e,F_=e=>e.at(-1)===B_?e.subarray(0,e.at(-2)===U_?-2:-1):e,$d=`
129
- `,B_=$d.codePointAt(0),Ad="\r",U_=Ad.codePointAt(0);import{on as mb}from"events";import{finished as hb}from"stream/promises";function $e(e,{checkOpen:t=!0}={}){return e!==null&&typeof e=="object"&&(e.writable||e.readable||!t||e.writable===void 0&&e.readable===void 0)&&typeof e.pipe=="function"}function Ms(e,{checkOpen:t=!0}={}){return $e(e,{checkOpen:t})&&(e.writable||!t)&&typeof e.write=="function"&&typeof e.end=="function"&&typeof e.writable=="boolean"&&typeof e.writableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function _t(e,{checkOpen:t=!0}={}){return $e(e,{checkOpen:t})&&(e.readable||!t)&&typeof e.read=="function"&&typeof e.readable=="boolean"&&typeof e.readableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function Fs(e,t){return Ms(e,t)&&_t(e,t)}var N_=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Bs=class{#t;#r;#e=!1;#i=void 0;constructor(t,r){this.#t=t,this.#r=r}next(){let t=()=>this.#s();return this.#i=this.#i?this.#i.then(t,t):t(),this.#i}return(t){let r=()=>this.#n(t);return this.#i?this.#i.then(r,r):r()}async#s(){if(this.#e)return{done:!0,value:void 0};let t;try{t=await this.#t.read()}catch(r){throw this.#i=void 0,this.#e=!0,this.#t.releaseLock(),r}return t.done&&(this.#i=void 0,this.#e=!0,this.#t.releaseLock()),t}async#n(t){if(this.#e)return{done:!0,value:t};if(this.#e=!0,!this.#r){let r=this.#t.cancel(t);return this.#t.releaseLock(),await r,{done:!0,value:t}}return this.#t.releaseLock(),{done:!0,value:t}}},Us=Symbol();function Cd(){return this[Us].next()}Object.defineProperty(Cd,"name",{value:"next"});function Ed(e){return this[Us].return(e)}Object.defineProperty(Ed,"name",{value:"return"});var G_=Object.create(N_,{next:{enumerable:!0,configurable:!0,writable:!0,value:Cd},return:{enumerable:!0,configurable:!0,writable:!0,value:Ed}});function Ns({preventCancel:e=!1}={}){let t=this.getReader(),r=new Bs(t,e),i=Object.create(G_);return i[Us]=r,i}var Pd=e=>{if(_t(e,{checkOpen:!1})&&mr.on!==void 0)return V_(e);if(typeof e?.[Symbol.asyncIterator]=="function")return e;if(z_.call(e)==="[object ReadableStream]")return Ns.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:z_}=Object.prototype,V_=async function*(e){let t=new AbortController,r={};W_(e,t,r);try{for await(let[i]of mr.on(e,"data",{signal:t.signal}))yield i}catch(i){if(r.error!==void 0)throw r.error;if(!t.signal.aborted)throw i}finally{e.destroy()}},W_=async(e,t,r)=>{try{await mr.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(i){r.error=i}finally{t.abort()}},mr={};var Ft=async(e,{init:t,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{let d=Pd(e),p=t();p.length=0;try{for await(let u of d){let l=K_(u),m=r[l](u,p);Id({convertedChunk:m,state:p,getSize:i,truncateChunk:n,addChunk:s,maxBuffer:c})}return H_({state:p,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,maxBuffer:c}),a(p)}catch(u){let l=typeof u=="object"&&u!==null?u:new Error(u);throw l.bufferedData=a(p),l}},H_=({state:e,getSize:t,truncateChunk:r,addChunk:i,getFinalChunk:n,maxBuffer:s})=>{let o=n(e);o!==void 0&&Id({convertedChunk:o,state:e,getSize:t,truncateChunk:r,addChunk:i,maxBuffer:s})},Id=({convertedChunk:e,state:t,getSize:r,truncateChunk:i,addChunk:n,maxBuffer:s})=>{let o=r(e),a=t.length+o;if(a<=s){Td(e,t,n,a);return}let c=i(e,s-t.length);throw c!==void 0&&Td(c,t,n,s),new je},Td=(e,t,r,i)=>{t.contents=r(e,t,i),t.length=i},K_=e=>{let t=typeof e;if(t==="string")return"string";if(t!=="object"||e===null)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";let r=Rd.call(e);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Rd.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Rd}=Object.prototype,je=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Xe=e=>e,hr=()=>{},Ui=({contents:e})=>e,Ni=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Gi=e=>e.length;async function zi(e,t){return Ft(e,Z_,t)}var Y_=()=>({contents:[]}),J_=()=>1,X_=(e,{contents:t})=>(t.push(e),t),Z_={init:Y_,convertChunk:{string:Xe,buffer:Xe,arrayBuffer:Xe,dataView:Xe,typedArray:Xe,others:Xe},getSize:J_,truncateChunk:hr,addChunk:X_,getFinalChunk:hr,finalize:Ui};async function Vi(e,t){return Ft(e,ab,t)}var Q_=()=>({contents:new ArrayBuffer(0)}),eb=e=>tb.encode(e),tb=new TextEncoder,Od=e=>new Uint8Array(e),jd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),rb=(e,t)=>e.slice(0,t),ib=(e,{contents:t,length:r},i)=>{let n=Md()?sb(t,i):nb(t,i);return new Uint8Array(n).set(e,r),n},nb=(e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(Ld(t));return new Uint8Array(r).set(new Uint8Array(e),0),r},sb=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:Ld(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r},Ld=e=>Dd**Math.ceil(Math.log(e)/Math.log(Dd)),Dd=2,ob=({contents:e,length:t})=>Md()?e:e.slice(0,t),Md=()=>"resize"in ArrayBuffer.prototype,ab={init:Q_,convertChunk:{string:eb,buffer:Od,arrayBuffer:Od,dataView:jd,typedArray:jd,others:Ni},getSize:Gi,truncateChunk:rb,addChunk:ib,getFinalChunk:hr,finalize:ob};async function Hi(e,t){return Ft(e,lb,t)}var cb=()=>({contents:"",textDecoder:new TextDecoder}),Wi=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),pb=(e,{contents:t})=>t+e,db=(e,t)=>e.slice(0,t),ub=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},lb={init:cb,convertChunk:{string:Xe,buffer:Wi,arrayBuffer:Wi,dataView:Wi,typedArray:Wi,others:Ni},getSize:Gi,truncateChunk:db,addChunk:pb,getFinalChunk:ub,finalize:Ui};Object.assign(mr,{on:mb,finished:hb});var Fd=({error:e,stream:t,readableObjectMode:r,lines:i,encoding:n,fdNumber:s})=>{if(!(e instanceof je))throw e;if(s==="all")return e;let o=yb(r,i,n);throw e.maxBufferInfo={fdNumber:s,unit:o},t.destroy(),e},yb=(e,t,r)=>e?"objects":t?"lines":r==="buffer"?"bytes":"characters",Bd=(e,t,r)=>{if(t.length!==r)return;let i=new je;throw i.maxBufferInfo={fdNumber:"ipc"},i},Ud=(e,t)=>{let{streamName:r,threshold:i,unit:n}=fb(e,t);return`Command's ${r} was larger than ${i} ${n}`},fb=(e,t)=>{if(e?.maxBufferInfo===void 0)return{streamName:"output",threshold:t[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:r,unit:i}}=e;delete e.maxBufferInfo;let n=Je(t,r);return r==="ipc"?{streamName:"IPC output",threshold:n,unit:"messages"}:{streamName:di(r),threshold:n,unit:i}},Nd=(e,t,r)=>e?.code==="ENOBUFS"&&t!==null&&t.some(i=>i!==null&&i.length>Ki(r)),Gd=(e,t,r)=>{if(!t)return e;let i=Ki(r);return e.length>i?e.slice(0,i):e},Ki=([,e])=>e;var Vd=({stdio:e,all:t,ipcOutput:r,originalError:i,signal:n,signalDescription:s,exitCode:o,escapedCommand:a,timedOut:c,isCanceled:d,isGracefullyCanceled:p,isMaxBuffer:u,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h,maxBuffer:f,timeout:x,cwd:w})=>{let S=i?.code,g=_b({originalError:i,timedOut:c,timeout:x,isMaxBuffer:u,maxBuffer:f,errorCode:S,signal:n,signalDescription:s,exitCode:o,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h}),R=wb(i,w),v=R===void 0?"":`
130
- ${R}`,B=`${g}: ${a}${v}`,j=t===void 0?[e[2],e[1]]:[t],L=[B,...j,...e.slice(3),r.map(G=>xb(G)).join(`
131
- `)].map(G=>ar(Mt(kb(G)))).filter(Boolean).join(`
132
-
133
- `);return{originalMessage:R,shortMessage:B,message:L}},_b=({originalError:e,timedOut:t,timeout:r,isMaxBuffer:i,maxBuffer:n,errorCode:s,signal:o,signalDescription:a,exitCode:c,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:u,forceKillAfterDelay:l,killSignal:m})=>{let h=bb(u,l);return t?`Command timed out after ${r} milliseconds${h}`:p?o===void 0?`Command was gracefully canceled with exit code ${c}`:u?`Command was gracefully canceled${h}`:`Command was gracefully canceled with ${o} (${a})`:d?`Command was canceled${h}`:i?`${Ud(e,n)}${h}`:s!==void 0?`Command failed with ${s}${h}`:u?`Command was killed with ${m} (${Si(m)})${h}`:o!==void 0?`Command was killed with ${o} (${a})`:c!==void 0?`Command failed with exit code ${c}`:"Command failed"},bb=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",wb=(e,t)=>{if(e instanceof Se)return;let r=wp(e)?e.originalMessage:String(e?.message??e),i=ar(vd(r,t));return i===""?void 0:i},xb=e=>typeof e=="string"?e:gb(e),kb=e=>Array.isArray(e)?e.map(t=>Mt(zd(t))).filter(Boolean).join(`
134
- `):zd(e),zd=e=>typeof e=="string"?e:Q(e)?ci(e):"";var Yi=({command:e,escapedCommand:t,stdio:r,all:i,ipcOutput:n,options:{cwd:s},startTime:o})=>Wd({command:e,escapedCommand:t,cwd:s,durationMs:gs(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:r[1],stderr:r[2],all:i,stdio:r,ipcOutput:n,pipedFrom:[]}),Bt=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:o})=>yr({error:e,command:t,escapedCommand:r,startTime:s,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:i.length}),ipcOutput:[],options:n,isSync:o}),yr=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,stdio:u,all:l,ipcOutput:m,options:{timeoutDuration:h,timeout:f=h,forceKillAfterDelay:x,killSignal:w,cwd:S,maxBuffer:g},isSync:R})=>{let{exitCode:v,signal:B,signalDescription:j}=Sb(d,p),{originalMessage:L,shortMessage:G,message:H}=Vd({stdio:u,all:l,ipcOutput:m,originalError:e,signal:B,signalDescription:j,exitCode:v,escapedCommand:r,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,forceKillAfterDelay:x,killSignal:w,maxBuffer:g,timeout:f,cwd:S}),$=_p(e,H,R);return Object.assign($,vb({error:$,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:v,signal:B,signalDescription:j,stdio:u,all:l,ipcOutput:m,cwd:S,originalMessage:L,shortMessage:G})),$},vb=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,stdio:l,all:m,ipcOutput:h,cwd:f,originalMessage:x,shortMessage:w})=>Wd({shortMessage:w,originalMessage:x,command:t,escapedCommand:r,cwd:f,durationMs:gs(i),failed:!0,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isTerminated:p!==void 0,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,code:e.cause?.code,stdout:l[1],stderr:l[2],all:m,stdio:l,ipcOutput:h,pipedFrom:[]}),Wd=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),Sb=(e,t)=>{let r=e===null?void 0:e,i=t===null?void 0:t,n=i===void 0?void 0:Si(t);return{exitCode:r,signal:i,signalDescription:n}};var Hd=e=>Number.isFinite(e)?e:0;function qb(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(Hd(e*1e3)%1e3),nanoseconds:Math.trunc(Hd(e*1e6)%1e3)}}function $b(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function Gs(e){switch(typeof e){case"number":{if(Number.isFinite(e))return qb(e);break}case"bigint":return $b(e)}throw new TypeError("Expected a finite number or bigint")}var Ab=e=>e===0||e===0n,Cb=(e,t)=>t===1||t===1n?e:`${e}s`,Eb=1e-7,Pb=24n*60n*60n*1000n;function zs(e,t){let r=typeof e=="bigint";if(!r&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};let i=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let n=[],s=(p,u)=>{let l=Math.floor(p*10**u+Eb);return(Math.round(l)/10**u).toFixed(u)},o=(p,u,l,m)=>{if(!((n.length===0||!t.colonNotation)&&Ab(p)&&!(t.colonNotation&&l==="m"))){if(m??=String(p),t.colonNotation){let h=m.includes(".")?m.split(".")[0].length:m.length,f=n.length>0?2:1;m="0".repeat(Math.max(0,f-h))+m}else m+=t.verbose?" "+Cb(u,p):l;n.push(m)}},a=Gs(e),c=BigInt(a.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(a.hours),"hour","h"):(t.hideYear?o(c,"day","d"):(o(c/365n,"year","y"),o(c%365n,"day","d")),o(Number(a.hours),"hour","h")),o(Number(a.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let p=Number(a.seconds),u=Number(a.milliseconds),l=Number(a.microseconds),m=Number(a.nanoseconds);if(o(p,"second","s"),t.formatSubMilliseconds)o(u,"millisecond","ms"),o(l,"microsecond","\xB5s"),o(m,"nanosecond","ns");else{let h=u+l/1e3+m/1e6,f=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,x=h>=1?Math.round(h):Math.ceil(h),w=f?h.toFixed(f):x;o(Number.parseFloat(w),"millisecond","ms",w)}}else{let p=(r?Number(e%Pb):e)/1e3%60,u=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,l=s(p,u),m=t.keepDecimalsOnWholeSeconds?l:l.replace(/\.0+$/,"");o(Number.parseFloat(m),"second","s",m)}if(n.length===0)return i+"0"+(t.verbose?" milliseconds":"ms");let d=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(n=n.slice(0,Math.max(t.unitCount,1))),i+n.join(d)}var Kd=(e,t)=>{e.failed&&Re({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var Yd=(e,t)=>{Tt(t)&&(Kd(e,t),Tb(e,t))},Tb=(e,t)=>{let r=`(done in ${zs(e.durationMs)})`;Re({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var Ut=(e,t,{reject:r})=>{if(Yd(e,t),e.failed&&r)throw e;return e};import{readFileSync as ku}from"fs";var Zd=(e,t)=>bt(e)?"asyncGenerator":tu(e)?"generator":Ji(e)?"fileUrl":Db(e)?"filePath":Fb(e)?"webStream":$e(e,{checkOpen:!1})?"native":Q(e)?"uint8Array":Bb(e)?"asyncIterable":Ub(e)?"iterable":Hs(e)?Qd({transform:e},t):jb(e)?Rb(e,t):"native",Rb=(e,t)=>Fs(e.transform,{checkOpen:!1})?Ib(e,t):Hs(e.transform)?Qd(e,t):Ob(e,t),Ib=(e,t)=>(eu(e,t,"Duplex stream"),"duplex"),Qd=(e,t)=>(eu(e,t,"web TransformStream"),"webTransform"),eu=({final:e,binary:t,objectMode:r},i,n)=>{Jd(e,`${i}.final`,n),Jd(t,`${i}.binary`,n),Vs(r,`${i}.objectMode`)},Jd=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},Ob=({transform:e,final:t,binary:r,objectMode:i},n)=>{if(e!==void 0&&!Xd(e))throw new TypeError(`The \`${n}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(Fs(t,{checkOpen:!1}))throw new TypeError(`The \`${n}.final\` option must not be a Duplex stream.`);if(Hs(t))throw new TypeError(`The \`${n}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!Xd(t))throw new TypeError(`The \`${n}.final\` option must be a generator.`);return Vs(r,`${n}.binary`),Vs(i,`${n}.objectMode`),bt(e)||bt(t)?"asyncGenerator":"generator"},Vs=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},Xd=e=>bt(e)||tu(e),bt=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",tu=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",jb=e=>K(e)&&(e.transform!==void 0||e.final!==void 0),Ji=e=>Object.prototype.toString.call(e)==="[object URL]",ru=e=>Ji(e)&&e.protocol!=="file:",Db=e=>K(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>Lb.has(t))&&Ws(e.file),Lb=new Set(["file","append"]),Ws=e=>typeof e=="string",iu=(e,t)=>e==="native"&&typeof t=="string"&&!Mb.has(t),Mb=new Set(["ipc","ignore","inherit","overlapped","pipe"]),nu=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",Xi=e=>Object.prototype.toString.call(e)==="[object WritableStream]",Fb=e=>nu(e)||Xi(e),Hs=e=>nu(e?.readable)&&Xi(e?.writable),Bb=e=>su(e)&&typeof e[Symbol.asyncIterator]=="function",Ub=e=>su(e)&&typeof e[Symbol.iterator]=="function",su=e=>typeof e=="object"&&e!==null,xe=new Set(["generator","asyncGenerator","duplex","webTransform"]),Zi=new Set(["fileUrl","filePath","fileNumber"]),Ks=new Set(["fileUrl","filePath"]),ou=new Set([...Ks,"webStream","nodeStream"]),au=new Set(["webTransform","duplex"]),ot={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"};var Ys=(e,t,r,i)=>i==="output"?Nb(e,t,r):Gb(e,t,r),Nb=(e,t,r)=>{let i=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:i,readableObjectMode:e??i}},Gb=(e,t,r)=>{let i=t===0?e===!0:r[t-1].value.readableObjectMode,n=t!==r.length-1&&(e??i);return{writableObjectMode:i,readableObjectMode:n}},cu=(e,t)=>{let r=e.findLast(({type:i})=>xe.has(i));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var pu=(e,t,r,i)=>[...e.filter(({type:n})=>!xe.has(n)),...zb(e,t,r,i)],zb=(e,t,r,{encoding:i})=>{let n=e.filter(({type:o})=>xe.has(o)),s=Array.from({length:n.length});for(let[o,a]of Object.entries(n))s[o]=Vb({stdioItem:a,index:Number(o),newTransforms:s,optionName:t,direction:r,encoding:i});return Yb(s,r)},Vb=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:i,optionName:n,direction:s,encoding:o})=>t==="duplex"?Wb({stdioItem:e,optionName:n}):t==="webTransform"?Hb({stdioItem:e,index:r,newTransforms:i,direction:s}):Kb({stdioItem:e,index:r,newTransforms:i,direction:s,encoding:o}),Wb=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:r,readableObjectMode:i},objectMode:n=i}},optionName:s})=>{if(n&&!i)throw new TypeError(`The \`${s}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!n&&i)throw new TypeError(`The \`${s}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:r,readableObjectMode:i}}},Hb=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n})=>{let{transform:s,objectMode:o}=K(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:c}=Ys(o,r,i,n);return{...e,value:{transform:s,writableObjectMode:a,readableObjectMode:c}}},Kb=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n,encoding:s})=>{let{transform:o,final:a,binary:c=!1,preserveNewlines:d=!1,objectMode:p}=K(t)?t:{transform:t},u=c||ye.has(s),{writableObjectMode:l,readableObjectMode:m}=Ys(p,r,i,n);return{...e,value:{transform:o,final:a,binary:u,preserveNewlines:d,writableObjectMode:l,readableObjectMode:m}}},Yb=(e,t)=>t==="input"?e.reverse():e;import Js from"process";var du=(e,t,r)=>{let i=e.map(n=>Jb(n,t));if(i.includes("input")&&i.includes("output"))throw new TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return i.find(Boolean)??Qb},Jb=({type:e,value:t},r)=>Xb[r]??uu[e](t),Xb=["input","output","output"],Nt=()=>{},Xs=()=>"input",uu={generator:Nt,asyncGenerator:Nt,fileUrl:Nt,filePath:Nt,iterable:Xs,asyncIterable:Xs,uint8Array:Xs,webStream:e=>Xi(e)?"output":"input",nodeStream(e){return _t(e,{checkOpen:!1})?Ms(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:Nt,duplex:Nt,native(e){let t=Zb(e);if(t!==void 0)return t;if($e(e,{checkOpen:!1}))return uu.nodeStream(e)}},Zb=e=>{if([0,Js.stdin].includes(e))return"input";if([1,2,Js.stdout,Js.stderr].includes(e))return"output"},Qb="output";var lu=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var mu=({stdio:e,ipc:t,buffer:r,...i},n,s)=>{let o=ew(e,i).map((a,c)=>hu(a,c));return s?rw(o,r,n):lu(o,t)},ew=(e,t)=>{if(e===void 0)return we.map(i=>t[i]);if(tw(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${we.map(i=>`\`${i}\``).join(", ")}`);if(typeof e=="string")return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,we.length);return Array.from({length:r},(i,n)=>e[n])},tw=e=>we.some(t=>e[t]!==void 0),hu=(e,t)=>Array.isArray(e)?e.map(r=>hu(r,t)):e??(t>=we.length?"ignore":"pipe"),rw=(e,t,r)=>e.map((i,n)=>!t[n]&&n!==0&&!Rt(r,n)&&iw(i)?"ignore":i),iw=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as nw}from"fs";import sw from"tty";var fu=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:i,direction:n,isSync:s})=>!r||t!=="native"?e:s?ow({stdioItem:e,fdNumber:i,direction:n}):pw({stdioItem:e,fdNumber:i}),ow=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i,direction:n})=>{let s=aw({value:t,optionName:r,fdNumber:i,direction:n});if(s!==void 0)return s;if($e(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},aw=({value:e,optionName:t,fdNumber:r,direction:i})=>{let n=cw(e,r);if(n!==void 0){if(i==="output")return{type:"fileNumber",value:n,optionName:t};if(sw.isatty(n))throw new TypeError(`The \`${t}: ${Ai(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Ye(nw(n)),optionName:t}}},cw=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=pi.indexOf(e);if(r!==-1)return r},pw=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i})=>t==="inherit"?{type:"nodeStream",value:yu(i,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:yu(t,t,r),optionName:r}:$e(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,yu=(e,t,r)=>{let i=pi[e];if(i===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return i};var gu=({input:e,inputFile:t},r)=>r===0?[...dw(e),...lw(t)]:[],dw=e=>e===void 0?[]:[{type:uw(e),value:e,optionName:"input"}],uw=e=>{if(_t(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(Q(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},lw=e=>e===void 0?[]:[{...mw(e),optionName:"inputFile"}],mw=e=>{if(Ji(e))return{type:"fileUrl",value:e};if(Ws(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var _u=e=>e.filter((t,r)=>e.every((i,n)=>t.value!==i.value||r>=n||t.type==="generator"||t.type==="asyncGenerator")),bu=({stdioItem:{type:e,value:t,optionName:r},direction:i,fileDescriptors:n,isSync:s})=>{let o=hw(n,e);if(o.length!==0){if(s){yw({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});return}if(ou.has(e))return wu({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});au.has(e)&&gw({otherStdioItems:o,type:e,value:t,optionName:r})}},hw=(e,t)=>e.flatMap(({direction:r,stdioItems:i})=>i.filter(n=>n.type===t).map((n=>({...n,direction:r})))),yw=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{Ks.has(t)&&wu({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})},wu=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{let s=e.filter(a=>fw(a,r));if(s.length===0)return;let o=s.find(a=>a.direction!==n);return xu(o,i,t),n==="output"?s[0].stream:void 0},fw=({type:e,value:t},r)=>e==="filePath"?t.file===r.file:e==="fileUrl"?t.href===r.href:t===r,gw=({otherStdioItems:e,type:t,value:r,optionName:i})=>{let n=e.find(({value:{transform:s}})=>s===r.transform);xu(n,i,t)},xu=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${ot[r]} that is the same.`)};var Qi=(e,t,r,i)=>{let s=mu(t,r,i).map((a,c)=>_w({stdioOption:a,fdNumber:c,options:t,isSync:i})),o=$w({initialFileDescriptors:s,addProperties:e,options:t,isSync:i});return t.stdio=o.map(({stdioItems:a})=>Ew(a)),o},_w=({stdioOption:e,fdNumber:t,options:r,isSync:i})=>{let n=di(t),{stdioItems:s,isStdioArray:o}=bw({stdioOption:e,fdNumber:t,options:r,optionName:n}),a=du(s,t,n),c=s.map(u=>fu({stdioItem:u,isStdioArray:o,fdNumber:t,direction:a,isSync:i})),d=pu(c,n,a,r),p=cu(d,a);return qw(d,p),{direction:a,objectMode:p,stdioItems:d}},bw=({stdioOption:e,fdNumber:t,options:r,optionName:i})=>{let s=[...(Array.isArray(e)?e:[e]).map(c=>ww(c,i)),...gu(r,t)],o=_u(s),a=o.length>1;return xw(o,a,i),vw(o),{stdioItems:o,isStdioArray:a}},ww=(e,t)=>({type:Zd(e,t),value:e,optionName:t}),xw=(e,t,r)=>{if(e.length===0)throw new TypeError(`The \`${r}\` option must not be an empty array.`);if(t){for(let{value:i,optionName:n}of e)if(kw.has(i))throw new Error(`The \`${n}\` option must not include \`${i}\`.`)}},kw=new Set(["ignore","ipc"]),vw=e=>{for(let t of e)Sw(t)},Sw=({type:e,value:t,optionName:r})=>{if(ru(t))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
135
- For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(iu(e,t))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},qw=(e,t)=>{if(!t)return;let r=e.find(({type:i})=>Zi.has(i));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},$w=({initialFileDescriptors:e,addProperties:t,options:r,isSync:i})=>{let n=[];try{for(let s of e)n.push(Aw({fileDescriptor:s,fileDescriptors:n,addProperties:t,options:r,isSync:i}));return n}catch(s){throw Zs(n),s}},Aw=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:i,addProperties:n,options:s,isSync:o})=>{let a=r.map(c=>Cw({stdioItem:c,addProperties:n,direction:e,options:s,fileDescriptors:i,isSync:o}));return{direction:e,objectMode:t,stdioItems:a}},Cw=({stdioItem:e,addProperties:t,direction:r,options:i,fileDescriptors:n,isSync:s})=>{let o=bu({stdioItem:e,direction:r,fileDescriptors:n,isSync:s});return o!==void 0?{...e,stream:o}:{...e,...t[r][e.type](e,i)}},Zs=e=>{for(let{stdioItems:t}of e)for(let{stream:r}of t)r!==void 0&&!ve(r)&&r.destroy()},Ew=e=>{if(e.length>1)return e.some(({value:i})=>i==="overlapped")?"overlapped":"pipe";let[{type:t,value:r}]=e;return t==="native"?r:"pipe"};var Su=(e,t)=>Qi(Tw,e,t,!0),De=({type:e,optionName:t})=>{qu(t,ot[e])},Pw=({optionName:e,value:t})=>((t==="ipc"||t==="overlapped")&&qu(e,`"${t}"`),{}),qu=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},vu={generator(){},asyncGenerator:De,webStream:De,nodeStream:De,webTransform:De,duplex:De,asyncIterable:De,native:Pw},Tw={input:{...vu,fileUrl:({value:e})=>({contents:[Ye(ku(e))]}),filePath:({value:{file:e}})=>({contents:[Ye(ku(e))]}),fileNumber:De,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...vu,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:De,string:De,uint8Array:De}};var Ze=(e,{stripFinalNewline:t},r)=>Qs(t,r)&&e!==void 0&&!Array.isArray(e)?Mt(e):e,Qs=(e,t)=>t==="all"?e[1]||e[2]:e[t];import{Transform as Zw,getDefaultHighWaterMark as Du}from"stream";var en=(e,t,r,i)=>e||r?void 0:Au(t,i),to=(e,t,r)=>r?e.flatMap(i=>$u(i,t)):$u(e,t),$u=(e,t)=>{let{transform:r,final:i}=Au(t,{});return[...r(e),...i()]},Au=(e,t)=>(t.previousChunks="",{transform:Rw.bind(void 0,t,e),final:Ow.bind(void 0,t)}),Rw=function*(e,t,r){if(typeof r!="string"){yield r;return}let{previousChunks:i}=e,n=-1;for(let s=0;s<r.length;s+=1)if(r[s]===`
136
- `){let o=Iw(r,s,t,e),a=r.slice(n+1,s+1-o);i.length>0&&(a=eo(i,a),i=""),yield a,n=s}n!==r.length-1&&(i=eo(i,r.slice(n+1))),e.previousChunks=i},Iw=(e,t,r,i)=>r?0:(i.isWindowsNewline=t!==0&&e[t-1]==="\r",i.isWindowsNewline?2:1),Ow=function*({previousChunks:e}){e.length>0&&(yield e)},Cu=({binary:e,preserveNewlines:t,readableObjectMode:r,state:i})=>e||t||r?void 0:{transform:jw.bind(void 0,i)},jw=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:i,LF:n,concatBytes:s}=typeof t=="string"?Dw:Mw;if(t.at(-1)===n){yield t;return}yield s(t,e?i:r)},eo=(e,t)=>`${e}${t}`,Dw={windowsNewline:`\r
128
+ ${e}`};var Vi=(e,t,r)=>{r.cwd=Ed(r.cwd);let[i,n,s]=Sd(e,t,r),{command:o,args:a,options:c}=Id.default._parse(i,n,s),d=_c(c),p=z_(d);return wd(p),Cd(p),qd(p),Up(p),_d(p),p.shell=fs(p.shell),p.env=V_(p),p.killSignal=Dp(p.killSignal),p.forceKillAfterDelay=Fp(p.forceKillAfterDelay),p.lines=p.lines.map((u,l)=>u&&!fe.has(p.encoding)&&p.buffer[l]),Rd.platform==="win32"&&G_.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:p}},z_=({extendEnv:e=!0,preferLocal:t=!1,cwd:r,localDir:i=r,encoding:n="utf8",reject:s=!0,cleanup:o=!0,all:a=!1,windowsHide:c=!0,killSignal:d="SIGTERM",forceKillAfterDelay:p=!0,gracefulCancel:u=!1,ipcInput:l,ipc:m=l!==void 0||u,serialization:h="advanced",...f})=>({...f,extendEnv:e,preferLocal:t,cwd:r,localDirectory:i,encoding:n,reject:s,cleanup:o,all:a,windowsHide:c,killSignal:d,forceKillAfterDelay:p,gracefulCancel:u,ipcInput:l,ipc:m,serialization:h}),V_=({env:e,extendEnv:t,preferLocal:r,node:i,localDirectory:n,nodePath:s})=>{let o=t?{...Rd.env,...e}:e;return r||i?qp({env:o,cwd:n,execPath:s,preferLocal:r,addExecPath:i}):o};var Wi=(e,t,r)=>r.shell&&t.length>0?[[e,...t].join(" "),[],r]:[e,t,r];import{inspect as qb}from"util";function Bt(e){if(typeof e=="string")return W_(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return H_(e)}var W_=e=>e.at(-1)===Od?e.slice(0,e.at(-2)===jd?-2:-1):e,H_=e=>e.at(-1)===K_?e.subarray(0,e.at(-2)===Y_?-2:-1):e,Od=`
129
+ `,K_=Od.codePointAt(0),jd="\r",Y_=jd.codePointAt(0);import{on as xb}from"events";import{finished as kb}from"stream/promises";function Ae(e,{checkOpen:t=!0}={}){return e!==null&&typeof e=="object"&&(e.writable||e.readable||!t||e.writable===void 0&&e.readable===void 0)&&typeof e.pipe=="function"}function Vs(e,{checkOpen:t=!0}={}){return Ae(e,{checkOpen:t})&&(e.writable||!t)&&typeof e.write=="function"&&typeof e.end=="function"&&typeof e.writable=="boolean"&&typeof e.writableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function _t(e,{checkOpen:t=!0}={}){return Ae(e,{checkOpen:t})&&(e.readable||!t)&&typeof e.read=="function"&&typeof e.readable=="boolean"&&typeof e.readableObjectMode=="boolean"&&typeof e.destroy=="function"&&typeof e.destroyed=="boolean"}function Ws(e,t){return Vs(e,t)&&_t(e,t)}var J_=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Hs=class{#t;#r;#e=!1;#i=void 0;constructor(t,r){this.#t=t,this.#r=r}next(){let t=()=>this.#s();return this.#i=this.#i?this.#i.then(t,t):t(),this.#i}return(t){let r=()=>this.#n(t);return this.#i?this.#i.then(r,r):r()}async#s(){if(this.#e)return{done:!0,value:void 0};let t;try{t=await this.#t.read()}catch(r){throw this.#i=void 0,this.#e=!0,this.#t.releaseLock(),r}return t.done&&(this.#i=void 0,this.#e=!0,this.#t.releaseLock()),t}async#n(t){if(this.#e)return{done:!0,value:t};if(this.#e=!0,!this.#r){let r=this.#t.cancel(t);return this.#t.releaseLock(),await r,{done:!0,value:t}}return this.#t.releaseLock(),{done:!0,value:t}}},Ks=Symbol();function Dd(){return this[Ks].next()}Object.defineProperty(Dd,"name",{value:"next"});function Ld(e){return this[Ks].return(e)}Object.defineProperty(Ld,"name",{value:"return"});var X_=Object.create(J_,{next:{enumerable:!0,configurable:!0,writable:!0,value:Dd},return:{enumerable:!0,configurable:!0,writable:!0,value:Ld}});function Ys({preventCancel:e=!1}={}){let t=this.getReader(),r=new Hs(t,e),i=Object.create(X_);return i[Ks]=r,i}var Md=e=>{if(_t(e,{checkOpen:!1})&&fr.on!==void 0)return Q_(e);if(typeof e?.[Symbol.asyncIterator]=="function")return e;if(Z_.call(e)==="[object ReadableStream]")return Ys.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:Z_}=Object.prototype,Q_=async function*(e){let t=new AbortController,r={};eb(e,t,r);try{for await(let[i]of fr.on(e,"data",{signal:t.signal}))yield i}catch(i){if(r.error!==void 0)throw r.error;if(!t.signal.aborted)throw i}finally{e.destroy()}},eb=async(e,t,r)=>{try{await fr.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(i){r.error=i}finally{t.abort()}},fr={};var Ut=async(e,{init:t,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{let d=Md(e),p=t();p.length=0;try{for await(let u of d){let l=rb(u),m=r[l](u,p);Ud({convertedChunk:m,state:p,getSize:i,truncateChunk:n,addChunk:s,maxBuffer:c})}return tb({state:p,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,maxBuffer:c}),a(p)}catch(u){let l=typeof u=="object"&&u!==null?u:new Error(u);throw l.bufferedData=a(p),l}},tb=({state:e,getSize:t,truncateChunk:r,addChunk:i,getFinalChunk:n,maxBuffer:s})=>{let o=n(e);o!==void 0&&Ud({convertedChunk:o,state:e,getSize:t,truncateChunk:r,addChunk:i,maxBuffer:s})},Ud=({convertedChunk:e,state:t,getSize:r,truncateChunk:i,addChunk:n,maxBuffer:s})=>{let o=r(e),a=t.length+o;if(a<=s){Fd(e,t,n,a);return}let c=i(e,s-t.length);throw c!==void 0&&Fd(c,t,n,s),new De},Fd=(e,t,r,i)=>{t.contents=r(e,t,i),t.length=i},rb=e=>{let t=typeof e;if(t==="string")return"string";if(t!=="object"||e===null)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";let r=Bd.call(e);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Bd.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Bd}=Object.prototype,De=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Xe=e=>e,gr=()=>{},Hi=({contents:e})=>e,Ki=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Yi=e=>e.length;async function Ji(e,t){return Ut(e,ob,t)}var ib=()=>({contents:[]}),nb=()=>1,sb=(e,{contents:t})=>(t.push(e),t),ob={init:ib,convertChunk:{string:Xe,buffer:Xe,arrayBuffer:Xe,dataView:Xe,typedArray:Xe,others:Xe},getSize:nb,truncateChunk:gr,addChunk:sb,getFinalChunk:gr,finalize:Hi};async function Xi(e,t){return Ut(e,yb,t)}var ab=()=>({contents:new ArrayBuffer(0)}),cb=e=>pb.encode(e),pb=new TextEncoder,Nd=e=>new Uint8Array(e),Gd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),db=(e,t)=>e.slice(0,t),ub=(e,{contents:t,length:r},i)=>{let n=Wd()?mb(t,i):lb(t,i);return new Uint8Array(n).set(e,r),n},lb=(e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(Vd(t));return new Uint8Array(r).set(new Uint8Array(e),0),r},mb=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:Vd(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r},Vd=e=>zd**Math.ceil(Math.log(e)/Math.log(zd)),zd=2,hb=({contents:e,length:t})=>Wd()?e:e.slice(0,t),Wd=()=>"resize"in ArrayBuffer.prototype,yb={init:ab,convertChunk:{string:cb,buffer:Nd,arrayBuffer:Nd,dataView:Gd,typedArray:Gd,others:Ki},getSize:Yi,truncateChunk:db,addChunk:ub,getFinalChunk:gr,finalize:hb};async function Qi(e,t){return Ut(e,wb,t)}var fb=()=>({contents:"",textDecoder:new TextDecoder}),Zi=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),gb=(e,{contents:t})=>t+e,_b=(e,t)=>e.slice(0,t),bb=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},wb={init:fb,convertChunk:{string:Xe,buffer:Zi,arrayBuffer:Zi,dataView:Zi,typedArray:Zi,others:Ki},getSize:Yi,truncateChunk:_b,addChunk:gb,getFinalChunk:bb,finalize:Hi};Object.assign(fr,{on:xb,finished:kb});var Hd=({error:e,stream:t,readableObjectMode:r,lines:i,encoding:n,fdNumber:s})=>{if(!(e instanceof De))throw e;if(s==="all")return e;let o=vb(r,i,n);throw e.maxBufferInfo={fdNumber:s,unit:o},t.destroy(),e},vb=(e,t,r)=>e?"objects":t?"lines":r==="buffer"?"bytes":"characters",Kd=(e,t,r)=>{if(t.length!==r)return;let i=new De;throw i.maxBufferInfo={fdNumber:"ipc"},i},Yd=(e,t)=>{let{streamName:r,threshold:i,unit:n}=Sb(e,t);return`Command's ${r} was larger than ${i} ${n}`},Sb=(e,t)=>{if(e?.maxBufferInfo===void 0)return{streamName:"output",threshold:t[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:r,unit:i}}=e;delete e.maxBufferInfo;let n=Je(t,r);return r==="ipc"?{streamName:"IPC output",threshold:n,unit:"messages"}:{streamName:fi(r),threshold:n,unit:i}},Jd=(e,t,r)=>e?.code==="ENOBUFS"&&t!==null&&t.some(i=>i!==null&&i.length>en(r)),Xd=(e,t,r)=>{if(!t)return e;let i=en(r);return e.length>i?e.slice(0,i):e},en=([,e])=>e;var Qd=({stdio:e,all:t,ipcOutput:r,originalError:i,signal:n,signalDescription:s,exitCode:o,escapedCommand:a,timedOut:c,isCanceled:d,isGracefullyCanceled:p,isMaxBuffer:u,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h,maxBuffer:f,timeout:x,cwd:w})=>{let v=i?.code,g=$b({originalError:i,timedOut:c,timeout:x,isMaxBuffer:u,maxBuffer:f,errorCode:v,signal:n,signalDescription:s,exitCode:o,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h}),R=Cb(i,w),S=R===void 0?"":`
130
+ ${R}`,U=`${g}: ${a}${S}`,j=t===void 0?[e[2],e[1]]:[t],L=[U,...j,...e.slice(3),r.map(G=>Eb(G)).join(`
131
+ `)].map(G=>dr(Bt(Pb(G)))).filter(Boolean).join(`
132
+
133
+ `);return{originalMessage:R,shortMessage:U,message:L}},$b=({originalError:e,timedOut:t,timeout:r,isMaxBuffer:i,maxBuffer:n,errorCode:s,signal:o,signalDescription:a,exitCode:c,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:u,forceKillAfterDelay:l,killSignal:m})=>{let h=Ab(u,l);return t?`Command timed out after ${r} milliseconds${h}`:p?o===void 0?`Command was gracefully canceled with exit code ${c}`:u?`Command was gracefully canceled${h}`:`Command was gracefully canceled with ${o} (${a})`:d?`Command was canceled${h}`:i?`${Yd(e,n)}${h}`:s!==void 0?`Command failed with ${s}${h}`:u?`Command was killed with ${m} (${Pi(m)})${h}`:o!==void 0?`Command was killed with ${o} (${a})`:c!==void 0?`Command failed with exit code ${c}`:"Command failed"},Ab=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",Cb=(e,t)=>{if(e instanceof qe)return;let r=Cp(e)?e.originalMessage:String(e?.message??e),i=dr(Td(r,t));return i===""?void 0:i},Eb=e=>typeof e=="string"?e:qb(e),Pb=e=>Array.isArray(e)?e.map(t=>Bt(Zd(t))).filter(Boolean).join(`
134
+ `):Zd(e),Zd=e=>typeof e=="string"?e:ee(e)?hi(e):"";var tn=({command:e,escapedCommand:t,stdio:r,all:i,ipcOutput:n,options:{cwd:s},startTime:o})=>eu({command:e,escapedCommand:t,cwd:s,durationMs:Ss(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:r[1],stderr:r[2],all:i,stdio:r,ipcOutput:n,pipedFrom:[]}),Nt=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:o})=>_r({error:e,command:t,escapedCommand:r,startTime:s,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:i.length}),ipcOutput:[],options:n,isSync:o}),_r=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,stdio:u,all:l,ipcOutput:m,options:{timeoutDuration:h,timeout:f=h,forceKillAfterDelay:x,killSignal:w,cwd:v,maxBuffer:g},isSync:R})=>{let{exitCode:S,signal:U,signalDescription:j}=Rb(d,p),{originalMessage:L,shortMessage:G,message:H}=Qd({stdio:u,all:l,ipcOutput:m,originalError:e,signal:U,signalDescription:j,exitCode:S,escapedCommand:r,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,forceKillAfterDelay:x,killSignal:w,maxBuffer:g,timeout:f,cwd:v}),$=$p(e,H,R);return Object.assign($,Tb({error:$,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:S,signal:U,signalDescription:j,stdio:u,all:l,ipcOutput:m,cwd:v,originalMessage:L,shortMessage:G})),$},Tb=({error:e,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,stdio:l,all:m,ipcOutput:h,cwd:f,originalMessage:x,shortMessage:w})=>eu({shortMessage:w,originalMessage:x,command:t,escapedCommand:r,cwd:f,durationMs:Ss(i),failed:!0,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isTerminated:p!==void 0,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:d,signal:p,signalDescription:u,code:e.cause?.code,stdout:l[1],stderr:l[2],all:m,stdio:l,ipcOutput:h,pipedFrom:[]}),eu=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),Rb=(e,t)=>{let r=e===null?void 0:e,i=t===null?void 0:t,n=i===void 0?void 0:Pi(t);return{exitCode:r,signal:i,signalDescription:n}};var tu=e=>Number.isFinite(e)?e:0;function Ib(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(tu(e*1e3)%1e3),nanoseconds:Math.trunc(tu(e*1e6)%1e3)}}function Ob(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function Js(e){switch(typeof e){case"number":{if(Number.isFinite(e))return Ib(e);break}case"bigint":return Ob(e)}throw new TypeError("Expected a finite number or bigint")}var jb=e=>e===0||e===0n,Db=(e,t)=>t===1||t===1n?e:`${e}s`,Lb=1e-7,Mb=24n*60n*60n*1000n;function Xs(e,t){let r=typeof e=="bigint";if(!r&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};let i=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let n=[],s=(p,u)=>{let l=Math.floor(p*10**u+Lb);return(Math.round(l)/10**u).toFixed(u)},o=(p,u,l,m)=>{if(!((n.length===0||!t.colonNotation)&&jb(p)&&!(t.colonNotation&&l==="m"))){if(m??=String(p),t.colonNotation){let h=m.includes(".")?m.split(".")[0].length:m.length,f=n.length>0?2:1;m="0".repeat(Math.max(0,f-h))+m}else m+=t.verbose?" "+Db(u,p):l;n.push(m)}},a=Js(e),c=BigInt(a.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(a.hours),"hour","h"):(t.hideYear?o(c,"day","d"):(o(c/365n,"year","y"),o(c%365n,"day","d")),o(Number(a.hours),"hour","h")),o(Number(a.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let p=Number(a.seconds),u=Number(a.milliseconds),l=Number(a.microseconds),m=Number(a.nanoseconds);if(o(p,"second","s"),t.formatSubMilliseconds)o(u,"millisecond","ms"),o(l,"microsecond","\xB5s"),o(m,"nanosecond","ns");else{let h=u+l/1e3+m/1e6,f=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,x=h>=1?Math.round(h):Math.ceil(h),w=f?h.toFixed(f):x;o(Number.parseFloat(w),"millisecond","ms",w)}}else{let p=(r?Number(e%Mb):e)/1e3%60,u=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,l=s(p,u),m=t.keepDecimalsOnWholeSeconds?l:l.replace(/\.0+$/,"");o(Number.parseFloat(m),"second","s",m)}if(n.length===0)return i+"0"+(t.verbose?" milliseconds":"ms");let d=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(n=n.slice(0,Math.max(t.unitCount,1))),i+n.join(d)}var ru=(e,t)=>{e.failed&&Ie({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var iu=(e,t)=>{It(t)&&(ru(e,t),Fb(e,t))},Fb=(e,t)=>{let r=`(done in ${Xs(e.durationMs)})`;Ie({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var Gt=(e,t,{reject:r})=>{if(iu(e,t),e.failed&&r)throw e;return e};import{readFileSync as Pu}from"fs";var ou=(e,t)=>bt(e)?"asyncGenerator":pu(e)?"generator":rn(e)?"fileUrl":zb(e)?"filePath":Hb(e)?"webStream":Ae(e,{checkOpen:!1})?"native":ee(e)?"uint8Array":Kb(e)?"asyncIterable":Yb(e)?"iterable":eo(e)?au({transform:e},t):Gb(e)?Bb(e,t):"native",Bb=(e,t)=>Ws(e.transform,{checkOpen:!1})?Ub(e,t):eo(e.transform)?au(e,t):Nb(e,t),Ub=(e,t)=>(cu(e,t,"Duplex stream"),"duplex"),au=(e,t)=>(cu(e,t,"web TransformStream"),"webTransform"),cu=({final:e,binary:t,objectMode:r},i,n)=>{nu(e,`${i}.final`,n),nu(t,`${i}.binary`,n),Zs(r,`${i}.objectMode`)},nu=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},Nb=({transform:e,final:t,binary:r,objectMode:i},n)=>{if(e!==void 0&&!su(e))throw new TypeError(`The \`${n}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(Ws(t,{checkOpen:!1}))throw new TypeError(`The \`${n}.final\` option must not be a Duplex stream.`);if(eo(t))throw new TypeError(`The \`${n}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!su(t))throw new TypeError(`The \`${n}.final\` option must be a generator.`);return Zs(r,`${n}.binary`),Zs(i,`${n}.objectMode`),bt(e)||bt(t)?"asyncGenerator":"generator"},Zs=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},su=e=>bt(e)||pu(e),bt=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",pu=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",Gb=e=>Y(e)&&(e.transform!==void 0||e.final!==void 0),rn=e=>Object.prototype.toString.call(e)==="[object URL]",du=e=>rn(e)&&e.protocol!=="file:",zb=e=>Y(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>Vb.has(t))&&Qs(e.file),Vb=new Set(["file","append"]),Qs=e=>typeof e=="string",uu=(e,t)=>e==="native"&&typeof t=="string"&&!Wb.has(t),Wb=new Set(["ipc","ignore","inherit","overlapped","pipe"]),lu=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",nn=e=>Object.prototype.toString.call(e)==="[object WritableStream]",Hb=e=>lu(e)||nn(e),eo=e=>lu(e?.readable)&&nn(e?.writable),Kb=e=>mu(e)&&typeof e[Symbol.asyncIterator]=="function",Yb=e=>mu(e)&&typeof e[Symbol.iterator]=="function",mu=e=>typeof e=="object"&&e!==null,ke=new Set(["generator","asyncGenerator","duplex","webTransform"]),sn=new Set(["fileUrl","filePath","fileNumber"]),to=new Set(["fileUrl","filePath"]),hu=new Set([...to,"webStream","nodeStream"]),yu=new Set(["webTransform","duplex"]),ot={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"};var ro=(e,t,r,i)=>i==="output"?Jb(e,t,r):Xb(e,t,r),Jb=(e,t,r)=>{let i=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:i,readableObjectMode:e??i}},Xb=(e,t,r)=>{let i=t===0?e===!0:r[t-1].value.readableObjectMode,n=t!==r.length-1&&(e??i);return{writableObjectMode:i,readableObjectMode:n}},fu=(e,t)=>{let r=e.findLast(({type:i})=>ke.has(i));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var gu=(e,t,r,i)=>[...e.filter(({type:n})=>!ke.has(n)),...Zb(e,t,r,i)],Zb=(e,t,r,{encoding:i})=>{let n=e.filter(({type:o})=>ke.has(o)),s=Array.from({length:n.length});for(let[o,a]of Object.entries(n))s[o]=Qb({stdioItem:a,index:Number(o),newTransforms:s,optionName:t,direction:r,encoding:i});return iw(s,r)},Qb=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:i,optionName:n,direction:s,encoding:o})=>t==="duplex"?ew({stdioItem:e,optionName:n}):t==="webTransform"?tw({stdioItem:e,index:r,newTransforms:i,direction:s}):rw({stdioItem:e,index:r,newTransforms:i,direction:s,encoding:o}),ew=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:r,readableObjectMode:i},objectMode:n=i}},optionName:s})=>{if(n&&!i)throw new TypeError(`The \`${s}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!n&&i)throw new TypeError(`The \`${s}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:r,readableObjectMode:i}}},tw=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n})=>{let{transform:s,objectMode:o}=Y(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:c}=ro(o,r,i,n);return{...e,value:{transform:s,writableObjectMode:a,readableObjectMode:c}}},rw=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n,encoding:s})=>{let{transform:o,final:a,binary:c=!1,preserveNewlines:d=!1,objectMode:p}=Y(t)?t:{transform:t},u=c||fe.has(s),{writableObjectMode:l,readableObjectMode:m}=ro(p,r,i,n);return{...e,value:{transform:o,final:a,binary:u,preserveNewlines:d,writableObjectMode:l,readableObjectMode:m}}},iw=(e,t)=>t==="input"?e.reverse():e;import io from"process";var _u=(e,t,r)=>{let i=e.map(n=>nw(n,t));if(i.includes("input")&&i.includes("output"))throw new TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return i.find(Boolean)??aw},nw=({type:e,value:t},r)=>sw[r]??bu[e](t),sw=["input","output","output"],zt=()=>{},no=()=>"input",bu={generator:zt,asyncGenerator:zt,fileUrl:zt,filePath:zt,iterable:no,asyncIterable:no,uint8Array:no,webStream:e=>nn(e)?"output":"input",nodeStream(e){return _t(e,{checkOpen:!1})?Vs(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:zt,duplex:zt,native(e){let t=ow(e);if(t!==void 0)return t;if(Ae(e,{checkOpen:!1}))return bu.nodeStream(e)}},ow=e=>{if([0,io.stdin].includes(e))return"input";if([1,2,io.stdout,io.stderr].includes(e))return"output"},aw="output";var wu=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var xu=({stdio:e,ipc:t,buffer:r,...i},n,s)=>{let o=cw(e,i).map((a,c)=>ku(a,c));return s?dw(o,r,n):wu(o,t)},cw=(e,t)=>{if(e===void 0)return xe.map(i=>t[i]);if(pw(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${xe.map(i=>`\`${i}\``).join(", ")}`);if(typeof e=="string")return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,xe.length);return Array.from({length:r},(i,n)=>e[n])},pw=e=>xe.some(t=>e[t]!==void 0),ku=(e,t)=>Array.isArray(e)?e.map(r=>ku(r,t)):e??(t>=xe.length?"ignore":"pipe"),dw=(e,t,r)=>e.map((i,n)=>!t[n]&&n!==0&&!Ot(r,n)&&uw(i)?"ignore":i),uw=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as lw}from"fs";import mw from"tty";var Su=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:i,direction:n,isSync:s})=>!r||t!=="native"?e:s?hw({stdioItem:e,fdNumber:i,direction:n}):gw({stdioItem:e,fdNumber:i}),hw=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i,direction:n})=>{let s=yw({value:t,optionName:r,fdNumber:i,direction:n});if(s!==void 0)return s;if(Ae(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},yw=({value:e,optionName:t,fdNumber:r,direction:i})=>{let n=fw(e,r);if(n!==void 0){if(i==="output")return{type:"fileNumber",value:n,optionName:t};if(mw.isatty(n))throw new TypeError(`The \`${t}: ${Ii(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Ye(lw(n)),optionName:t}}},fw=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=yi.indexOf(e);if(r!==-1)return r},gw=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i})=>t==="inherit"?{type:"nodeStream",value:vu(i,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:vu(t,t,r),optionName:r}:Ae(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,vu=(e,t,r)=>{let i=yi[e];if(i===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return i};var qu=({input:e,inputFile:t},r)=>r===0?[..._w(e),...ww(t)]:[],_w=e=>e===void 0?[]:[{type:bw(e),value:e,optionName:"input"}],bw=e=>{if(_t(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(ee(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},ww=e=>e===void 0?[]:[{...xw(e),optionName:"inputFile"}],xw=e=>{if(rn(e))return{type:"fileUrl",value:e};if(Qs(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var $u=e=>e.filter((t,r)=>e.every((i,n)=>t.value!==i.value||r>=n||t.type==="generator"||t.type==="asyncGenerator")),Au=({stdioItem:{type:e,value:t,optionName:r},direction:i,fileDescriptors:n,isSync:s})=>{let o=kw(n,e);if(o.length!==0){if(s){vw({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});return}if(hu.has(e))return Cu({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});yu.has(e)&&qw({otherStdioItems:o,type:e,value:t,optionName:r})}},kw=(e,t)=>e.flatMap(({direction:r,stdioItems:i})=>i.filter(n=>n.type===t).map((n=>({...n,direction:r})))),vw=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{to.has(t)&&Cu({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})},Cu=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{let s=e.filter(a=>Sw(a,r));if(s.length===0)return;let o=s.find(a=>a.direction!==n);return Eu(o,i,t),n==="output"?s[0].stream:void 0},Sw=({type:e,value:t},r)=>e==="filePath"?t.file===r.file:e==="fileUrl"?t.href===r.href:t===r,qw=({otherStdioItems:e,type:t,value:r,optionName:i})=>{let n=e.find(({value:{transform:s}})=>s===r.transform);Eu(n,i,t)},Eu=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${ot[r]} that is the same.`)};var on=(e,t,r,i)=>{let s=xu(t,r,i).map((a,c)=>$w({stdioOption:a,fdNumber:c,options:t,isSync:i})),o=Ow({initialFileDescriptors:s,addProperties:e,options:t,isSync:i});return t.stdio=o.map(({stdioItems:a})=>Lw(a)),o},$w=({stdioOption:e,fdNumber:t,options:r,isSync:i})=>{let n=fi(t),{stdioItems:s,isStdioArray:o}=Aw({stdioOption:e,fdNumber:t,options:r,optionName:n}),a=_u(s,t,n),c=s.map(u=>Su({stdioItem:u,isStdioArray:o,fdNumber:t,direction:a,isSync:i})),d=gu(c,n,a,r),p=fu(d,a);return Iw(d,p),{direction:a,objectMode:p,stdioItems:d}},Aw=({stdioOption:e,fdNumber:t,options:r,optionName:i})=>{let s=[...(Array.isArray(e)?e:[e]).map(c=>Cw(c,i)),...qu(r,t)],o=$u(s),a=o.length>1;return Ew(o,a,i),Tw(o),{stdioItems:o,isStdioArray:a}},Cw=(e,t)=>({type:ou(e,t),value:e,optionName:t}),Ew=(e,t,r)=>{if(e.length===0)throw new TypeError(`The \`${r}\` option must not be an empty array.`);if(t){for(let{value:i,optionName:n}of e)if(Pw.has(i))throw new Error(`The \`${n}\` option must not include \`${i}\`.`)}},Pw=new Set(["ignore","ipc"]),Tw=e=>{for(let t of e)Rw(t)},Rw=({type:e,value:t,optionName:r})=>{if(du(t))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
135
+ For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(uu(e,t))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},Iw=(e,t)=>{if(!t)return;let r=e.find(({type:i})=>sn.has(i));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},Ow=({initialFileDescriptors:e,addProperties:t,options:r,isSync:i})=>{let n=[];try{for(let s of e)n.push(jw({fileDescriptor:s,fileDescriptors:n,addProperties:t,options:r,isSync:i}));return n}catch(s){throw so(n),s}},jw=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:i,addProperties:n,options:s,isSync:o})=>{let a=r.map(c=>Dw({stdioItem:c,addProperties:n,direction:e,options:s,fileDescriptors:i,isSync:o}));return{direction:e,objectMode:t,stdioItems:a}},Dw=({stdioItem:e,addProperties:t,direction:r,options:i,fileDescriptors:n,isSync:s})=>{let o=Au({stdioItem:e,direction:r,fileDescriptors:n,isSync:s});return o!==void 0?{...e,stream:o}:{...e,...t[r][e.type](e,i)}},so=e=>{for(let{stdioItems:t}of e)for(let{stream:r}of t)r!==void 0&&!Se(r)&&r.destroy()},Lw=e=>{if(e.length>1)return e.some(({value:i})=>i==="overlapped")?"overlapped":"pipe";let[{type:t,value:r}]=e;return t==="native"?r:"pipe"};var Ru=(e,t)=>on(Fw,e,t,!0),Le=({type:e,optionName:t})=>{Iu(t,ot[e])},Mw=({optionName:e,value:t})=>((t==="ipc"||t==="overlapped")&&Iu(e,`"${t}"`),{}),Iu=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},Tu={generator(){},asyncGenerator:Le,webStream:Le,nodeStream:Le,webTransform:Le,duplex:Le,asyncIterable:Le,native:Mw},Fw={input:{...Tu,fileUrl:({value:e})=>({contents:[Ye(Pu(e))]}),filePath:({value:{file:e}})=>({contents:[Ye(Pu(e))]}),fileNumber:Le,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...Tu,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:Le,string:Le,uint8Array:Le}};var Ze=(e,{stripFinalNewline:t},r)=>oo(t,r)&&e!==void 0&&!Array.isArray(e)?Bt(e):e,oo=(e,t)=>t==="all"?e[1]||e[2]:e[t];import{Transform as ox,getDefaultHighWaterMark as zu}from"stream";var an=(e,t,r,i)=>e||r?void 0:ju(t,i),co=(e,t,r)=>r?e.flatMap(i=>Ou(i,t)):Ou(e,t),Ou=(e,t)=>{let{transform:r,final:i}=ju(t,{});return[...r(e),...i()]},ju=(e,t)=>(t.previousChunks="",{transform:Bw.bind(void 0,t,e),final:Nw.bind(void 0,t)}),Bw=function*(e,t,r){if(typeof r!="string"){yield r;return}let{previousChunks:i}=e,n=-1;for(let s=0;s<r.length;s+=1)if(r[s]===`
136
+ `){let o=Uw(r,s,t,e),a=r.slice(n+1,s+1-o);i.length>0&&(a=ao(i,a),i=""),yield a,n=s}n!==r.length-1&&(i=ao(i,r.slice(n+1))),e.previousChunks=i},Uw=(e,t,r,i)=>r?0:(i.isWindowsNewline=t!==0&&e[t-1]==="\r",i.isWindowsNewline?2:1),Nw=function*({previousChunks:e}){e.length>0&&(yield e)},Du=({binary:e,preserveNewlines:t,readableObjectMode:r,state:i})=>e||t||r?void 0:{transform:Gw.bind(void 0,i)},Gw=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:i,LF:n,concatBytes:s}=typeof t=="string"?zw:Ww;if(t.at(-1)===n){yield t;return}yield s(t,e?i:r)},ao=(e,t)=>`${e}${t}`,zw={windowsNewline:`\r
137
137
  `,unixNewline:`
138
138
  `,LF:`
139
- `,concatBytes:eo},Lw=(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},Mw={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Lw};import{Buffer as Fw}from"buffer";var Eu=(e,t)=>e?void 0:Bw.bind(void 0,t),Bw=function*(e,t){if(typeof t!="string"&&!Q(t)&&!Fw.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},Pu=(e,t)=>e?Uw.bind(void 0,t):Nw.bind(void 0,t),Uw=function*(e,t){Tu(e,t),yield t},Nw=function*(e,t){if(Tu(e,t),typeof t!="string"&&!Q(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},Tu=(e,t)=>{if(t==null)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
139
+ `,concatBytes:ao},Vw=(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},Ww={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Vw};import{Buffer as Hw}from"buffer";var Lu=(e,t)=>e?void 0:Kw.bind(void 0,t),Kw=function*(e,t){if(typeof t!="string"&&!ee(t)&&!Hw.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},Mu=(e,t)=>e?Yw.bind(void 0,t):Jw.bind(void 0,t),Yw=function*(e,t){Fu(e,t),yield t},Jw=function*(e,t){if(Fu(e,t),typeof t!="string"&&!ee(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},Fu=(e,t)=>{if(t==null)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
140
140
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
141
- if (condition) { yield value; }`)};import{Buffer as Gw}from"buffer";import{StringDecoder as zw}from"string_decoder";var tn=(e,t,r)=>{if(r)return;if(e)return{transform:Vw.bind(void 0,new TextEncoder)};let i=new zw(t);return{transform:Ww.bind(void 0,i),final:Hw.bind(void 0,i)}},Vw=function*(e,t){Gw.isBuffer(t)?yield Ye(t):typeof t=="string"?yield e.encode(t):yield t},Ww=function*(e,t){yield Q(t)?e.write(t):t},Hw=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as Ru}from"util";var ro=Ru(async(e,t,r,i)=>{t.currentIterable=e(...r);try{for await(let n of t.currentIterable)i.push(n)}finally{delete t.currentIterable}}),rn=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Yw}=t[r];for await(let n of i(e))yield*rn(n,t,r+1)},Iu=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Kw(r,Number(t),e)},Kw=async function*(e,t,r){if(e!==void 0)for await(let i of e())yield*rn(i,r,t+1)},Ou=Ru(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Yw=function*(e){yield e};var io=(e,t,r,i)=>{try{for(let n of e(...t))r.push(n);i()}catch(n){i(n)}},ju=(e,t)=>[...t.flatMap(r=>[...wt(r,e,0)]),...fr(e)],wt=function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Xw}=t[r];for(let n of i(e))yield*wt(n,t,r+1)},fr=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Jw(r,Number(t),e)},Jw=function*(e,t,r){if(e!==void 0)for(let i of e())yield*wt(i,r,t+1)},Xw=function*(e){yield e};var no=({value:e,value:{transform:t,final:r,writableObjectMode:i,readableObjectMode:n},optionName:s},{encoding:o})=>{let a={},c=Lu(e,o,s),d=bt(t),p=bt(r),u=d?ro.bind(void 0,rn,a):io.bind(void 0,wt),l=d||p?ro.bind(void 0,Iu,a):io.bind(void 0,fr),m=d||p?Ou.bind(void 0,a):void 0;return{stream:new Zw({writableObjectMode:i,writableHighWaterMark:Du(i),readableObjectMode:n,readableHighWaterMark:Du(n),transform(f,x,w){u([f,c,0],this,w)},flush(f){l([c],this,f)},destroy:m})}},nn=(e,t,r,i)=>{let n=t.filter(({type:o})=>o==="generator"),s=i?n.reverse():n;for(let{value:o,optionName:a}of s){let c=Lu(o,r,a);e=ju(c,e)}return e},Lu=({transform:e,final:t,binary:r,writableObjectMode:i,readableObjectMode:n,preserveNewlines:s},o,a)=>{let c={};return[{transform:Eu(i,a)},tn(r,o,i),en(r,s,i,c),{transform:e,final:t},{transform:Pu(n,a)},Cu({binary:r,preserveNewlines:s,readableObjectMode:n,state:c})].filter(Boolean)};var Mu=(e,t)=>{for(let r of Qw(e))ex(e,r,t)},Qw=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),ex=(e,t,r)=>{let{stdioItems:i}=e[t],n=i.filter(({contents:a})=>a!==void 0);if(n.length===0)return;if(t!==0){let[{type:a,optionName:c}]=n;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ot[a]} with synchronous methods.`)}let o=n.map(({contents:a})=>a).map(a=>tx(a,i));r.input=or(o)},tx=(e,t)=>{let r=nn(e,t,"utf8",!0);return rx(r),or(r)},rx=e=>{let t=e.find(r=>typeof r!="string"&&!Q(r));if(t!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)};import{writeFileSync as ox,appendFileSync as ax}from"fs";var sn=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:i})=>i!=="all"&&Rt(r,i)&&!ye.has(t)&&ix(i)&&(e.some(({type:n,value:s})=>n==="native"&&nx.has(s))||e.every(({type:n})=>xe.has(n))),ix=e=>e===1||e===2,nx=new Set(["pipe","overlapped"]),Fu=async(e,t,r,i)=>{for await(let n of e)sx(t)||Uu(n,r,i)},Bu=(e,t,r)=>{for(let i of e)Uu(i,t,r)},sx=e=>e._readableState.pipes.length>0,Uu=(e,t,r)=>{let i=fi(e);Re({type:"output",verboseMessage:i,fdNumber:t,verboseInfo:r})};var Nu=({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:i,verboseInfo:n})=>{if(t===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:t.map((c,d)=>cx({result:c,fileDescriptors:e,fdNumber:d,state:s,outputFiles:o,isMaxBuffer:i,verboseInfo:n},r)),...s}},cx=({result:e,fileDescriptors:t,fdNumber:r,state:i,outputFiles:n,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:d,stripFinalNewline:p,maxBuffer:u})=>{if(e===null)return;let l=Gd(e,s,u),m=Ye(l),{stdioItems:h,objectMode:f}=t[r],x=px([m],h,c,i),{serializedResult:w,finalResult:S=w}=dx({chunks:x,objectMode:f,encoding:c,lines:d,stripFinalNewline:p,fdNumber:r});ux({serializedResult:w,fdNumber:r,state:i,verboseInfo:o,encoding:c,stdioItems:h,objectMode:f});let g=a[r]?S:void 0;try{return i.error===void 0&&lx(w,h,n),g}catch(R){return i.error=R,g}},px=(e,t,r,i)=>{try{return nn(e,t,r,!1)}catch(n){return i.error=n,e}},dx=({chunks:e,objectMode:t,encoding:r,lines:i,stripFinalNewline:n,fdNumber:s})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:or(e)};let o=ic(e,r);return i[s]?{serializedResult:o,finalResult:to(o,!n[s],t)}:{serializedResult:o}},ux=({serializedResult:e,fdNumber:t,state:r,verboseInfo:i,encoding:n,stdioItems:s,objectMode:o})=>{if(!sn({stdioItems:s,encoding:n,verboseInfo:i,fdNumber:t}))return;let a=to(e,!1,o);try{Bu(a,t,i)}catch(c){r.error??=c}},lx=(e,t,r)=>{for(let{path:i,append:n}of t.filter(({type:s})=>Zi.has(s))){let s=typeof i=="string"?i:i.toString();n||r.has(s)?ax(i,e):(r.add(s),ox(i,e))}};var Gu=([,e,t],r)=>{if(r.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Ze(t,r,"all")]:Array.isArray(t)?[Ze(e,r,"all"),...t]:Q(e)&&Q(t)?ds([e,t]):`${e}${t}`};import{once as so}from"events";var zu=async(e,t)=>{let[r,i]=await mx(e);return t.isForcefullyTerminated??=!1,[r,i]},mx=async e=>{let[t,r]=await Promise.allSettled([so(e,"spawn"),so(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?Vu(e):r.value},Vu=async e=>{try{return await so(e,"exit")}catch{return Vu(e)}},Wu=async e=>{let[t,r]=await e;if(!hx(t,r)&&oo(t,r))throw new Se;return[t,r]},hx=(e,t)=>e===void 0&&t===void 0,oo=(e,t)=>e!==0||t!==null;var Hu=({error:e,status:t,signal:r,output:i},{maxBuffer:n})=>{let s=yx(e,t,r),o=s?.code==="ETIMEDOUT",a=Nd(s,i,n);return{resultError:s,exitCode:t,signal:r,timedOut:o,isMaxBuffer:a}},yx=(e,t,r)=>e!==void 0?e:oo(t,r)?new Se:void 0;var Ku=(e,t,r)=>{let{file:i,commandArguments:n,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:d,fileDescriptors:p}=gx(e,t,r),u=wx({file:i,commandArguments:n,options:d,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:p,startTime:a});return Ut(u,c,d)},gx=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=_i(e,t,r),a=_x(r),{file:c,commandArguments:d,options:p}=Fi(e,t,a);bx(p);let u=Su(p,o);return{file:c,commandArguments:d,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},_x=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,bx=({ipc:e,ipcInput:t,detached:r,cancelSignal:i})=>{t&&on("ipcInput"),e&&on("ipc: true"),r&&on("detached: true"),i&&on("cancelSignal")},on=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},wx=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=xx({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:d,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m}=Hu(c,r),{output:h,error:f=d}=Nu({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:m,verboseInfo:s}),x=h.map((S,g)=>Ze(S,r,g)),w=Ze(Gu(h,r),r,"all");return vx({error:f,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m,stdio:x,all:w,options:r,command:i,escapedCommand:n,startTime:a})},xx=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:s,startTime:o})=>{try{Mu(s,r);let a=kx(r);return fx(...Bi(e,t,a))}catch(a){return Bt({error:a,command:i,escapedCommand:n,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},kx=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:Ki(t)}),vx=({error:e,exitCode:t,signal:r,timedOut:i,isMaxBuffer:n,stdio:s,all:o,options:a,command:c,escapedCommand:d,startTime:p})=>e===void 0?Yi({command:c,escapedCommand:d,stdio:s,all:o,ipcOutput:[],options:a,startTime:p}):yr({error:e,command:c,escapedCommand:d,timedOut:i,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:n,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:p,isSync:!0});import{setMaxListeners as dk}from"events";import{spawn as uk}from"child_process";import Qu from"process";import{once as ao,on as Sx}from"events";var Yu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0,filter:s}={})=>(jt({methodName:"getOneMessage",isSubprocess:r,ipc:i,isConnected:Ii(e)}),qx({anyProcess:e,channel:t,isSubprocess:r,filter:s,reference:n})),qx=async({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:n})=>{Ei(t,n);let s=st(e,t,r),o=new AbortController;try{return await Promise.race([$x(s,i,o),Ax(s,r,o),Cx(s,r,o)])}catch(a){throw Dt(e),a}finally{o.abort(),Pi(t,n)}},$x=async(e,t,{signal:r})=>{if(t===void 0){let[i]=await ao(e,"message",{signal:r});return i}for await(let[i]of Sx(e,"message",{signal:r}))if(t(i))return i},Ax=async(e,t,{signal:r})=>{await ao(e,"disconnect",{signal:r}),jp(t)},Cx=async(e,t,{signal:r})=>{let[i]=await ao(e,"strict:error",{signal:r});throw $i(i,t)};import{once as Xu,on as Ex}from"events";var Zu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0}={})=>co({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:!r,reference:n}),co=({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:n,reference:s})=>{jt({methodName:"getEachMessage",isSubprocess:r,ipc:i,isConnected:Ii(e)}),Ei(t,s);let o=st(e,t,r),a=new AbortController,c={};return Px(e,o,a),Tx({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Rx({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:r,shouldAwait:n,controller:a,state:c,reference:s})},Px=async(e,t,r)=>{try{await Xu(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},Tx=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{let[n]=await Xu(e,"strict:error",{signal:r.signal});i.error=$i(n,t),r.abort()}catch{}},Rx=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:i,shouldAwait:n,controller:s,state:o,reference:a}){try{for await(let[c]of Ex(r,"message",{signal:s.signal}))Ju(o),yield c}catch{Ju(o)}finally{s.abort(),Pi(t,a),i||Dt(e),n&&await e}},Ju=({error:e})=>{if(e)throw e};var el=(e,{ipc:t})=>{Object.assign(e,rl(e,!1,t))},tl=()=>{let e=Qu,t=!0,r=Qu.channel!==void 0;return{...rl(e,t,r),getCancelSignal:cd.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},rl=(e,t,r)=>({sendMessage:Li.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:Yu.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:Zu.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})});import{ChildProcess as Ix}from"child_process";import{PassThrough as Ox,Readable as jx,Writable as Dx,Duplex as Lx}from"stream";var il=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,verboseInfo:o})=>{Zs(i);let a=new Ix;Mx(a,i),Object.assign(a,{readable:Fx,writable:Bx,duplex:Ux});let c=Bt({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:!1}),d=Nx(c,o,n);return{subprocess:a,promise:d}},Mx=(e,t)=>{let r=gr(),i=gr(),n=gr(),s=Array.from({length:t.length-3},gr),o=gr(),a=[r,i,n,...s];Object.assign(e,{stdin:r,stdout:i,stderr:n,all:o,stdio:a})},gr=()=>{let e=new Ox;return e.end(),e},Fx=()=>new jx({read(){}}),Bx=()=>new Dx({write(){}}),Ux=()=>new Lx({read(){},write(){}}),Nx=async(e,t,r)=>Ut(e,t,r);import{createReadStream as nl,createWriteStream as sl}from"fs";import{Buffer as Gx}from"buffer";import{Readable as _r,Writable as zx,Duplex as Vx}from"stream";var al=(e,t)=>Qi(Wx,e,t,!1),br=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${ot[e]}.`)},ol={fileNumber:br,generator:no,asyncGenerator:no,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let i=t||r;return{stream:Vx.fromWeb(e,{objectMode:i})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},Wx={input:{...ol,fileUrl:({value:e})=>({stream:nl(e)}),filePath:({value:{file:e}})=>({stream:nl(e)}),webStream:({value:e})=>({stream:_r.fromWeb(e)}),iterable:({value:e})=>({stream:_r.from(e)}),asyncIterable:({value:e})=>({stream:_r.from(e)}),string:({value:e})=>({stream:_r.from(e)}),uint8Array:({value:e})=>({stream:_r.from(Gx.from(e))})},output:{...ol,fileUrl:({value:e})=>({stream:sl(e)}),filePath:({value:{file:e,append:t}})=>({stream:sl(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:zx.fromWeb(e)}),iterable:br,asyncIterable:br,string:br,uint8Array:br}};import{on as Hx,once as cl}from"events";import{PassThrough as Kx,getDefaultHighWaterMark as Yx}from"stream";import{finished as ul}from"stream/promises";function xt(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let n of e)uo(n);let t=e.some(({readableObjectMode:n})=>n),r=Jx(e,t),i=new po({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let n of e)i.add(n);return i}var Jx=(e,t)=>{if(e.length===0)return Yx(t);let r=e.filter(({readableObjectMode:i})=>i===t).map(({readableHighWaterMark:i})=>i);return Math.max(...r)},po=class extends Kx{#t=new Set([]);#r=new Set([]);#e=new Set([]);#i;#s=Symbol("unpipe");#n=new WeakMap;add(t){if(uo(t),this.#t.has(t))return;this.#t.add(t),this.#i??=Xx(this,this.#t,this.#s);let r=e0({passThroughStream:this,stream:t,streams:this.#t,ended:this.#r,aborted:this.#e,onFinished:this.#i,unpipeEvent:this.#s});this.#n.set(t,r),t.pipe(this,{end:!1})}async remove(t){if(uo(t),!this.#t.has(t))return!1;let r=this.#n.get(t);return r===void 0?!1:(this.#n.delete(t),t.unpipe(this),await r,!0)}},Xx=async(e,t,r)=>{an(e,pl);let i=new AbortController;try{await Promise.race([Zx(e,i),Qx(e,t,r,i)])}finally{i.abort(),an(e,-pl)}},Zx=async(e,{signal:t})=>{try{await ul(e,{signal:t,cleanup:!0})}catch(r){throw ll(e,r),r}},Qx=async(e,t,r,{signal:i})=>{for await(let[n]of Hx(e,"unpipe",{signal:i}))t.has(n)&&n.emit(r)},uo=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},e0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,onFinished:s,unpipeEvent:o})=>{an(e,dl);let a=new AbortController;try{await Promise.race([t0(s,t,a),r0({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:a}),i0({stream:t,streams:r,ended:i,aborted:n,unpipeEvent:o,controller:a})])}finally{a.abort(),an(e,-dl)}r.size>0&&r.size===i.size+n.size&&(i.size===0&&n.size>0?lo(e):n0(e))},t0=async(e,t,{signal:r})=>{try{await e,r.aborted||lo(t)}catch(i){r.aborted||ll(t,i)}},r0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:{signal:s}})=>{try{await ul(t,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&i.add(t)}catch(o){if(s.aborted||!r.has(t))return;ml(o)?n.add(t):hl(e,o)}},i0=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:n,controller:{signal:s}})=>{if(await cl(e,n,{signal:s}),!e.readable)return cl(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},n0=e=>{e.writable&&e.end()},ll=(e,t)=>{ml(t)?lo(e):hl(e,t)},ml=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",lo=e=>{(e.readable||e.writable)&&e.destroy()},hl=(e,t)=>{e.destroyed||(e.once("error",s0),e.destroy(t))},s0=()=>{},an=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},pl=2,dl=1;import{finished as yl}from"stream/promises";var Gt=(e,t)=>{e.pipe(t),o0(e,t),a0(e,t)},o0=async(e,t)=>{if(!(ve(e)||ve(t))){try{await yl(e,{cleanup:!0,readable:!0,writable:!1})}catch{}mo(t)}},mo=e=>{e.writable&&e.end()},a0=async(e,t)=>{if(!(ve(e)||ve(t))){try{await yl(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ho(e)}},ho=e=>{e.readable&&e.destroy()};var fl=(e,t,r)=>{let i=new Map;for(let[n,{stdioItems:s,direction:o}]of Object.entries(t)){for(let{stream:a}of s.filter(({type:c})=>xe.has(c)))c0(e,a,o,n);for(let{stream:a}of s.filter(({type:c})=>!xe.has(c)))d0({subprocess:e,stream:a,direction:o,fdNumber:n,pipeGroups:i,controller:r})}for(let[n,s]of i.entries()){let o=s.length===1?s[0]:xt(s);Gt(o,n)}},c0=(e,t,r,i)=>{r==="output"?Gt(e.stdio[i],t):Gt(t,e.stdio[i]);let n=p0[i];n!==void 0&&(e[n]=t),e.stdio[i]=t},p0=["stdin","stdout","stderr"],d0=({subprocess:e,stream:t,direction:r,fdNumber:i,pipeGroups:n,controller:s})=>{if(t===void 0)return;u0(t,s);let[o,a]=r==="output"?[t,e.stdio[i]]:[e.stdio[i],t],c=n.get(o)??[];n.set(o,[...c,a])},u0=(e,{signal:t})=>{ve(e)&&gt(e,l0,t)},l0=2;import{addAbortListener as y0}from"events";var kt=[];kt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&kt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&kt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cn=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",yo=Symbol.for("signal-exit emitter"),fo=globalThis,m0=Object.defineProperty.bind(Object),go=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(fo[yo])return fo[yo];m0(fo,yo,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let i=this.listeners[t],n=i.indexOf(r);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(t,r,i){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(let s of this.listeners[t])n=s(r,i)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,i)||n),n}},pn=class{},h0=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),_o=class extends pn{onExit(){return()=>{}}load(){}unload(){}},bo=class extends pn{#t=wo.platform==="win32"?"SIGINT":"SIGHUP";#r=new go;#e;#i;#s;#n={};#o=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of kt)this.#n[r]=()=>{let i=this.#e.listeners(r),{count:n}=this.#r,s=t;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(n+=s.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#t:r;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#i=t.emit}onExit(t,r){if(!cn(this.#e))return()=>{};this.#o===!1&&this.load();let i=r?.alwaysLast?"afterExit":"exit";return this.#r.on(i,t),()=>{this.#r.removeListener(i,t),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let t of kt)try{let r=this.#n[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#c(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,kt.forEach(t=>{let r=this.#n[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#s,this.#r.count-=1)}#a(t){return cn(this.#e)?(this.#e.exitCode=t||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#c(t,...r){let i=this.#i;if(t==="exit"&&cn(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let n=i.call(this.#e,t,...r);return this.#r.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,t,...r)}},wo=globalThis.process,{onExit:gl,load:iO,unload:nO}=h0(cn(wo)?new bo(wo):new _o);var _l=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let n=gl(()=>{e.kill()});y0(i,()=>{n()})};var wl=({source:e,sourcePromise:t,boundOptions:r,createNested:i},...n)=>{let s=gi(),{destination:o,destinationStream:a,destinationError:c,from:d,unpipeSignal:p}=f0(r,i,n),{sourceStream:u,sourceError:l}=_0(e,d),{options:m,fileDescriptors:h}=Oe.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:l,destination:o,destinationStream:a,destinationError:c,unpipeSignal:p,fileDescriptors:h,startTime:s}},f0=(e,t,r)=>{try{let{destination:i,pipeOptions:{from:n,to:s,unpipeSignal:o}={}}=g0(e,t,...r),a=Ci(i,s);return{destination:i,destinationStream:a,from:n,unpipeSignal:o}}catch(i){return{destinationError:i}}},g0=(e,t,r,...i)=>{if(Array.isArray(r))return{destination:t(bl,e)(r,...i),pipeOptions:e};if(typeof r=="string"||r instanceof URL||cs(r)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[n,s,o]=ai(r,...i);return{destination:t(bl)(n,s,o),pipeOptions:o}}if(Oe.has(r)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:i[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},bl=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),_0=(e,t)=>{try{return{sourceStream:Lt(e,t)}}catch(r){return{sourceError:r}}};var kl=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i,fileDescriptors:n,sourceOptions:s,startTime:o})=>{let a=b0({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i});if(a!==void 0)throw xo({error:a,fileDescriptors:n,sourceOptions:s,startTime:o})},b0=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i})=>{if(t!==void 0&&i!==void 0)return i;if(i!==void 0)return ho(e),i;if(t!==void 0)return mo(r),t},xo=({error:e,fileDescriptors:t,sourceOptions:r,startTime:i})=>Bt({error:e,command:xl,escapedCommand:xl,fileDescriptors:t,options:r,startTime:i,isSync:!1}),xl="source.pipe(destination)";var vl=async e=>{let[{status:t,reason:r,value:i=r},{status:n,reason:s,value:o=s}]=await e;if(o.pipedFrom.includes(i)||o.pipedFrom.push(i),n==="rejected")throw o;if(t==="rejected")throw i;return o};import{finished as w0}from"stream/promises";var Sl=(e,t,r)=>{let i=dn.has(t)?k0(e,t):x0(e,t);return gt(e,S0,r.signal),gt(t,q0,r.signal),v0(t),i},x0=(e,t)=>{let r=xt([e]);return Gt(r,t),dn.set(t,r),r},k0=(e,t)=>{let r=dn.get(t);return r.add(e),r},v0=async e=>{try{await w0(e,{cleanup:!0,readable:!1,writable:!0})}catch{}dn.delete(e)},dn=new WeakMap,S0=2,q0=1;import{aborted as $0}from"util";var ql=(e,t)=>e===void 0?[]:[A0(e,t)],A0=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:i,sourceOptions:n,startTime:s})=>{await $0(e,t),await r.remove(t);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw xo({error:o,fileDescriptors:i,sourceOptions:n,startTime:s})};var un=(e,...t)=>{if(K(t[0]))return un.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...i}=wl(e,...t),n=C0({...i,destination:r});return n.pipe=un.bind(void 0,{...e,source:r,sourcePromise:n,boundOptions:{}}),n},C0=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:i,destination:n,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:d})=>{let p=E0(e,n);kl({sourceStream:t,sourceError:i,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:d});let u=new AbortController;try{let l=Sl(t,s,u);return await Promise.race([vl(p),...ql(a,{sourceStream:t,mergedStream:l,sourceOptions:r,fileDescriptors:c,startTime:d})])}finally{u.abort()}},E0=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as D0}from"timers/promises";import{on as P0}from"events";import{getDefaultHighWaterMark as T0}from"stream";var ln=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:i,encoding:n,preserveNewlines:s})=>{let o=new AbortController;return R0(t,o),Al({stream:e,controller:o,binary:r,shouldEncode:!e.readableObjectMode&&i,encoding:n,shouldSplit:!e.readableObjectMode,preserveNewlines:s})},R0=async(e,t)=>{try{await e}catch{}finally{t.abort()}},ko=({stream:e,onStreamEnd:t,lines:r,encoding:i,stripFinalNewline:n,allMixed:s})=>{let o=new AbortController;I0(t,o,e);let a=e.readableObjectMode&&!s;return Al({stream:e,controller:o,binary:i==="buffer",shouldEncode:!a,encoding:i,shouldSplit:!a&&r,preserveNewlines:!n})},I0=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},Al=({stream:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})=>{let a=P0(e,"data",{signal:t.signal,highWaterMark:$l,highWatermark:$l});return O0({onStdoutChunk:a,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})},vo=T0(!0),$l=vo,O0=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o}){let a=j0({binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of e)yield*wt(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*fr(a)}},j0=({binary:e,shouldEncode:t,encoding:r,shouldSplit:i,preserveNewlines:n})=>[tn(e,r,!t),en(e,n,!i,{})].filter(Boolean);var Cl=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,buffer:n,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:d,streamInfo:p})=>{let u=L0({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:a,verboseInfo:d,streamInfo:p});if(!n){await Promise.all([M0(e),u]);return}let l=Qs(c,r),m=ko({stream:e,onStreamEnd:t,lines:o,encoding:i,stripFinalNewline:l,allMixed:a}),[h]=await Promise.all([F0({stream:e,iterable:m,fdNumber:r,encoding:i,maxBuffer:s,lines:o}),u]);return h},L0=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:n,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!sn({stdioItems:o[r]?.stdioItems,encoding:i,verboseInfo:s,fdNumber:r}))return;let a=ko({stream:e,onStreamEnd:t,lines:!0,encoding:i,stripFinalNewline:!0,allMixed:n});await Fu(a,e,r,s)},M0=async e=>{await D0(),e.readableFlowing===null&&e.resume()},F0=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:i,encoding:n,maxBuffer:s,lines:o})=>{try{return t||o?await zi(r,{maxBuffer:s}):n==="buffer"?new Uint8Array(await Vi(r,{maxBuffer:s})):await Hi(r,{maxBuffer:s})}catch(a){return El(Fd({error:a,stream:e,readableObjectMode:t,lines:o,encoding:n,fdNumber:i}))}},So=async e=>{try{return await e}catch(t){return El(t)}},El=({bufferedData:e})=>tc(e)?new Uint8Array(e):e;import{finished as B0}from"stream/promises";var wr=async(e,t,r,{isSameDirection:i,stopOnExit:n=!1}={})=>{let s=U0(e,r),o=new AbortController;try{await Promise.race([...n?[r.exitPromise]:[],B0(e,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||z0(a,t,r,i)}finally{o.abort()}},U0=(e,{originalStreams:[t],subprocess:r})=>{let i={stdinCleanedUp:!1};return e===t&&N0(e,r,i),i},N0=(e,t,r)=>{let{_destroy:i}=e;e._destroy=(...n)=>{G0(t,r),i.call(e,...n)}},G0=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},z0=(e,t,r,i)=>{if(!V0(e,t,r,i))throw e},V0=(e,t,r,i=!0)=>r.propagating?Pl(e)||mn(e):(r.propagating=!0,qo(r,t)===i?Pl(e):mn(e)),qo=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",mn=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",Pl=e=>e?.code==="EPIPE";var Tl=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>e.stdio.map((c,d)=>$o({stream:c,fdNumber:d,encoding:t,buffer:r[d],maxBuffer:i[d],lines:n[d],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),$o=async({stream:e,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d})=>{if(!e)return;let p=wr(e,t,d);if(qo(d,t)){await p;return}let[u]=await Promise.all([Cl({stream:e,onStreamEnd:p,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d}),p]);return u};var Rl=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?xt([e,t].filter(Boolean)):void 0,Il=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>$o({...W0(e,r),fdNumber:"all",encoding:t,maxBuffer:i[1]+i[2],lines:n[1]||n[2],allMixed:H0(e),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),W0=({stdout:e,stderr:t,all:r},[,i,n])=>{let s=i||n;return s?i?n?{stream:r,buffer:s}:{stream:e,buffer:s}:{stream:t,buffer:s}:{stream:r,buffer:s}},H0=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as K0}from"events";var Ol=e=>Rt(e,"ipc"),jl=(e,t)=>{let r=fi(e);Re({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var Dl=async({subprocess:e,buffer:t,maxBuffer:r,ipc:i,ipcOutput:n,verboseInfo:s})=>{if(!i)return n;let o=Ol(s),a=Je(t,"ipc"),c=Je(r,"ipc");for await(let d of co({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:i,shouldAwait:!1,reference:!0}))a&&(Bd(e,n,c),n.push(d)),o&&jl(d,s);return n},Ll=async(e,t)=>(await Promise.allSettled([e]),t);var Ml=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:i,lines:n,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:d,ipc:p,ipcInput:u},context:l,verboseInfo:m,fileDescriptors:h,originalStreams:f,onInternalError:x,controller:w})=>{let S=zu(e,l),g={originalStreams:f,fileDescriptors:h,subprocess:e,exitPromise:S,propagating:!1},R=Tl({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),v=Il({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),B=[],j=Dl({subprocess:e,buffer:r,maxBuffer:i,ipc:p,ipcOutput:B,verboseInfo:m}),L=Y0(f,e,g),G=J0(h,g);try{return await Promise.race([Promise.all([{},Wu(S),Promise.all(R),v,j,_d(e,u),...L,...G]),x,X0(e,w),...md(e,s,l,w),...Op({subprocess:e,cancelSignal:o,gracefulCancel:a,context:l,controller:w}),...ud({subprocess:e,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:l,controller:w})])}catch(H){return l.terminationReason??="other",Promise.all([{error:H},S,Promise.all(R.map($=>So($))),So(v),Ll(j,B),Promise.allSettled(L),Promise.allSettled(G)])}},Y0=(e,t,r)=>e.map((i,n)=>i===t.stdio[n]?void 0:wr(i,n,r)),J0=(e,t)=>e.flatMap(({stdioItems:r},i)=>r.filter(({value:n,stream:s=n})=>$e(s,{checkOpen:!1})&&!ve(s)).map(({type:n,value:s,stream:o=s})=>wr(o,i,t,{isSameDirection:xe.has(n),stopOnExit:n==="native"}))),X0=async(e,{signal:t})=>{let[r]=await K0(e,"error",{signal:t});throw r};var Fl=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),xr=(e,t,r)=>{let i=e[r];i.has(t)||i.set(t,[]);let n=i.get(t),s=Ie();return n.push(s),{resolve:s.resolve.bind(s),promises:n}},zt=async({resolve:e,promises:t},r)=>{e();let[i]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!i};import{Readable as Z0}from"stream";import{callbackify as Q0}from"util";import{finished as Bl}from"stream/promises";var Ao=async e=>{if(e!==void 0)try{await Co(e)}catch{}},Ul=async e=>{if(e!==void 0)try{await Eo(e)}catch{}},Co=async e=>{await Bl(e,{cleanup:!0,readable:!1,writable:!0})},Eo=async e=>{await Bl(e,{cleanup:!0,readable:!0,writable:!1})},hn=async(e,t)=>{if(await e,t)throw t},yn=(e,t,r)=>{r&&!mn(r)?e.destroy(r):t&&e.destroy()};var Nl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,binary:n=!0,preserveNewlines:s=!0}={})=>{let o=n||ye.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Po(e,i,t),{readableEncoding:d,readableObjectMode:p,readableHighWaterMark:u}=To(a,o),{read:l,onStdoutDataDone:m}=Ro({subprocessStdout:a,subprocess:e,binary:o,encoding:r,preserveNewlines:s}),h=new Z0({read:l,destroy:Q0(Oo.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:u,objectMode:p,encoding:d});return Io({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},Po=(e,t,r)=>{let i=Lt(e,t),n=xr(r,i,"readableDestroy");return{subprocessStdout:i,waitReadableDestroy:n}},To=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},i)=>i?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:vo},Ro=({subprocessStdout:e,subprocess:t,binary:r,encoding:i,preserveNewlines:n})=>{let s=Ie(),o=ln({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:i,preserveNewlines:n});return{read(){ek(this,o,s)},onStdoutDataDone:s}},ek=async(e,t,r)=>{try{let{value:i,done:n}=await t.next();n?r.resolve():e.push(i)}catch{}},Io=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:i,subprocessStdin:n})=>{try{await Eo(e),await i,await Ao(n),await t,r.readable&&r.push(null)}catch(s){await Ao(n),Gl(r,s)}},Oo=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},i)=>{await zt(r,t)&&(Gl(e,i),await hn(t,i))},Gl=(e,t)=>{yn(e,e.readable,t)};import{Writable as tk}from"stream";import{callbackify as zl}from"util";var Vl=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}=jo(e,r,t),o=new tk({...Do(i,e,n),destroy:zl(Mo.bind(void 0,{subprocessStdin:i,subprocess:e,waitWritableFinal:n,waitWritableDestroy:s})),highWaterMark:i.writableHighWaterMark,objectMode:i.writableObjectMode});return Lo(i,o),o},jo=(e,t,r)=>{let i=Ci(e,t),n=xr(r,i,"writableFinal"),s=xr(r,i,"writableDestroy");return{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}},Do=(e,t,r)=>({write:rk.bind(void 0,e),final:zl(ik.bind(void 0,e,t,r))}),rk=(e,t,r,i)=>{e.write(t,r)?i():e.once("drain",i)},ik=async(e,t,r)=>{await zt(r,t)&&(e.writable&&e.end(),await t)},Lo=async(e,t,r)=>{try{await Co(e),t.writable&&t.end()}catch(i){await Ul(r),Wl(t,i)}},Mo=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:i},n)=>{await zt(r,t),await zt(i,t)&&(Wl(e,n),await hn(t,n))},Wl=(e,t)=>{yn(e,e.writable,t)};import{Duplex as nk}from"stream";import{callbackify as sk}from"util";var Hl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,to:n,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ye.has(r),{subprocessStdout:c,waitReadableDestroy:d}=Po(e,i,t),{subprocessStdin:p,waitWritableFinal:u,waitWritableDestroy:l}=jo(e,n,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=To(c,a),{read:x,onStdoutDataDone:w}=Ro({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:o}),S=new nk({read:x,...Do(p,e,u),destroy:sk(ok.bind(void 0,{subprocessStdout:c,subprocessStdin:p,subprocess:e,waitReadableDestroy:d,waitWritableFinal:u,waitWritableDestroy:l})),readableHighWaterMark:f,writableHighWaterMark:p.writableHighWaterMark,readableObjectMode:h,writableObjectMode:p.writableObjectMode,encoding:m});return Io({subprocessStdout:c,onStdoutDataDone:w,readable:S,subprocess:e,subprocessStdin:p}),Lo(p,S,c),S},ok=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:i,waitWritableFinal:n,waitWritableDestroy:s},o)=>{await Promise.all([Oo({subprocessStdout:e,subprocess:r,waitReadableDestroy:i},o),Mo({subprocessStdin:t,subprocess:r,waitWritableFinal:n,waitWritableDestroy:s},o)])};var Fo=(e,t,{from:r,binary:i=!1,preserveNewlines:n=!1}={})=>{let s=i||ye.has(t),o=Lt(e,r),a=ln({subprocessStdout:o,subprocess:e,binary:s,shouldEncode:!0,encoding:t,preserveNewlines:n});return ak(a,o,e)},ak=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var Kl=(e,{encoding:t})=>{let r=Fl();e.readable=Nl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=Vl.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=Hl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=Fo.bind(void 0,e,t),e[Symbol.asyncIterator]=Fo.bind(void 0,e,t,{})};var Yl=(e,t)=>{for(let[r,i]of pk){let n=i.value.bind(t);Reflect.defineProperty(e,r,{...i,value:n})}},ck=(async()=>{})().constructor.prototype,pk=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(ck,e)]);var Jl=(e,t,r,i)=>{let{file:n,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:d,options:p,fileDescriptors:u}=lk(e,t,r),{subprocess:l,promise:m}=hk({file:n,commandArguments:s,options:p,startTime:c,verboseInfo:d,command:o,escapedCommand:a,fileDescriptors:u});return l.pipe=un.bind(void 0,{source:l,sourcePromise:m,boundOptions:{},createNested:i}),Yl(l,m),Oe.set(l,{options:p,fileDescriptors:u}),l},lk=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=_i(e,t,r),{file:a,commandArguments:c,options:d}=Fi(e,t,r),p=mk(d),u=al(p,o);return{file:a,commandArguments:c,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},mk=({timeout:e,signal:t,...r})=>{if(t!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},hk=({file:e,commandArguments:t,options:r,startTime:i,verboseInfo:n,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uk(...Bi(e,t,r))}catch(h){return il({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:i,verboseInfo:n})}let d=new AbortController;dk(Number.POSITIVE_INFINITY,d.signal);let p=[...c.stdio];fl(c,a,d),_l(c,r,d);let u={},l=Ie();c.kill=Rp.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:l,context:u,controller:d}),c.all=Rl(c,r),Kl(c,r),el(c,r);let m=yk({subprocess:c,options:r,startTime:i,verboseInfo:n,fileDescriptors:a,originalStreams:p,command:s,escapedCommand:o,context:u,onInternalError:l,controller:d});return{subprocess:c,promise:m}},yk=async({subprocess:e,options:t,startTime:r,verboseInfo:i,fileDescriptors:n,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:d,controller:p})=>{let[u,[l,m],h,f,x]=await Ml({subprocess:e,options:t,context:c,verboseInfo:i,fileDescriptors:n,originalStreams:s,onInternalError:d,controller:p});p.abort(),d.resolve();let w=h.map((R,v)=>Ze(R,t,v)),S=Ze(f,t,"all"),g=fk({errorInfo:u,exitCode:l,signal:m,stdio:w,all:S,ipcOutput:x,context:c,options:t,command:o,escapedCommand:a,startTime:r});return Ut(g,i,t)},fk=({errorInfo:e,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,context:o,options:a,command:c,escapedCommand:d,startTime:p})=>"error"in e?yr({error:e.error,command:c,escapedCommand:d,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:e.error instanceof je,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,options:a,startTime:p,isSync:!1}):Yi({command:c,escapedCommand:d,stdio:i,all:n,ipcOutput:s,options:a,startTime:p});var fn=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,gk(i,e[i],n)]));return{...e,...r}},gk=(e,t,r)=>_k.has(e)&&K(t)&&K(r)?{...t,...r}:r,_k=new Set(["env",...hs]);var at=(e,t,r,i)=>{let n=(o,a,c)=>at(o,a,r,c),s=(...o)=>bk({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:i,createNested:n},...o);return i!==void 0&&i(s,n,t),s},bk=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:i,createNested:n},s,...o)=>{if(K(s))return n(e,fn(r,s),i);let{file:a,commandArguments:c,options:d,isSync:p}=wk({mapArguments:e,firstArgument:s,nextArguments:o,deepOptions:t,boundOptions:r});return p?Ku(a,c,d):Jl(a,c,d,n)},wk=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:i,boundOptions:n})=>{let s=ac(t)?cc(t,r):[t,...r],[o,a,c]=ai(...s),d=fn(fn(i,n),c),{file:p=o,commandArguments:u=a,options:l=d,isSync:m=!1}=e({file:o,commandArguments:a,options:d});return{file:p,commandArguments:u,options:l,isSync:m}};var Xl=({file:e,commandArguments:t})=>Ql(e,t),Zl=({file:e,commandArguments:t})=>({...Ql(e,t),isSync:!0}),Ql=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...i]=xk(e);return{file:r,commandArguments:i}},xk=e=>{if(typeof e!="string")throw new TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(t==="")return[];let r=[];for(let i of t.split(kk)){let n=r.at(-1);n&&n.endsWith("\\")?r[r.length-1]=`${n.slice(0,-1)} ${i}`:r.push(i)}return r},kk=/ +/g;var em=(e,t,r)=>{e.sync=t(vk,r),e.s=e.sync},tm=({options:e})=>rm(e),vk=({options:e})=>({...rm(e),isSync:!0}),rm=e=>({options:{...Sk(e),...e}}),Sk=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},im={preferLocal:!0};var J=at(()=>({})),HD=at(()=>({isSync:!0})),ct=at(Xl),KD=at(Zl),YD=at(yd),JD=at(tm,{},im,em),{sendMessage:XD,getOneMessage:ZD,getEachMessage:QD,getCancelSignal:e1}=tl();var pe=U(Y(),1);var vr=U(Y(),1);import Ae from"fs";import Ak from"os";import Fe from"path";var gn="spree@example.com",_n="spree123";import Le from"fs";import pt from"path";function _(e=process.cwd()){let t=qk(e),r=pt.join(t,"docker-compose.yml");if(!Le.existsSync(r))throw new Error(`Not a Spree project directory. No docker-compose.yml found.
142
- Run this command from a directory created with create-spree-app.`);let i=$k(t);return{mode:"docker",projectDir:t,port:i}}function qk(e){if(pt.basename(e)!=="backend")return e;let t=pt.dirname(e);for(let r of["docker-compose.yml","docker-compose.dev.yml"]){let i=pt.join(t,r);if(Le.existsSync(i))try{if(/\.\/backend:\/rails(:\w+)?(\s|$)/m.test(Le.readFileSync(i,"utf-8")))return t}catch{}}return e}function Me(e){let t=pt.join(e,".env");if(!Le.existsSync(t))return!1;try{let r=Le.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function kr(e){let t=pt.join(e,"docker-compose.yml");if(!Le.existsSync(t))return!1;try{return/^\s*build\s*:/m.test(Le.readFileSync(t,"utf-8"))}catch{return!1}}function wn(e){try{let r=Le.readFileSync(pt.join(e,".env"),"utf-8").match(/^SPREE_SAMPLE_DATA=(true|false)\b/m);return r?r[1]==="true":void 0}catch{return}}function $k(e){let t=pt.join(e,".env");if(!Le.existsSync(t))return 3e3;let i=Le.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return i?Number(i[1]):3e3}var nm=U(Y(),1);async function X(e,t,r){return J("docker",["compose",...e],{cwd:t,...r})}async function dt(e,t){try{await X(["up","-d","--no-deps","web"],e,{stdio:t?.stdio??"inherit"})}catch{}}async function ne(e,t,r){let i=["compose","exec","-T"];if(r)for(let[s,o]of Object.entries(r))i.push("-e",`${s}=${o}`);i.push("web","bin/rails",e);let{stdout:n}=await J("docker",i,{cwd:t});return n.split(`
141
+ if (condition) { yield value; }`)};import{Buffer as Xw}from"buffer";import{StringDecoder as Zw}from"string_decoder";var cn=(e,t,r)=>{if(r)return;if(e)return{transform:Qw.bind(void 0,new TextEncoder)};let i=new Zw(t);return{transform:ex.bind(void 0,i),final:tx.bind(void 0,i)}},Qw=function*(e,t){Xw.isBuffer(t)?yield Ye(t):typeof t=="string"?yield e.encode(t):yield t},ex=function*(e,t){yield ee(t)?e.write(t):t},tx=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as Bu}from"util";var po=Bu(async(e,t,r,i)=>{t.currentIterable=e(...r);try{for await(let n of t.currentIterable)i.push(n)}finally{delete t.currentIterable}}),pn=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=ix}=t[r];for await(let n of i(e))yield*pn(n,t,r+1)},Uu=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*rx(r,Number(t),e)},rx=async function*(e,t,r){if(e!==void 0)for await(let i of e())yield*pn(i,r,t+1)},Nu=Bu(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),ix=function*(e){yield e};var uo=(e,t,r,i)=>{try{for(let n of e(...t))r.push(n);i()}catch(n){i(n)}},Gu=(e,t)=>[...t.flatMap(r=>[...wt(r,e,0)]),...br(e)],wt=function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=sx}=t[r];for(let n of i(e))yield*wt(n,t,r+1)},br=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*nx(r,Number(t),e)},nx=function*(e,t,r){if(e!==void 0)for(let i of e())yield*wt(i,r,t+1)},sx=function*(e){yield e};var lo=({value:e,value:{transform:t,final:r,writableObjectMode:i,readableObjectMode:n},optionName:s},{encoding:o})=>{let a={},c=Vu(e,o,s),d=bt(t),p=bt(r),u=d?po.bind(void 0,pn,a):uo.bind(void 0,wt),l=d||p?po.bind(void 0,Uu,a):uo.bind(void 0,br),m=d||p?Nu.bind(void 0,a):void 0;return{stream:new ox({writableObjectMode:i,writableHighWaterMark:zu(i),readableObjectMode:n,readableHighWaterMark:zu(n),transform(f,x,w){u([f,c,0],this,w)},flush(f){l([c],this,f)},destroy:m})}},dn=(e,t,r,i)=>{let n=t.filter(({type:o})=>o==="generator"),s=i?n.reverse():n;for(let{value:o,optionName:a}of s){let c=Vu(o,r,a);e=Gu(c,e)}return e},Vu=({transform:e,final:t,binary:r,writableObjectMode:i,readableObjectMode:n,preserveNewlines:s},o,a)=>{let c={};return[{transform:Lu(i,a)},cn(r,o,i),an(r,s,i,c),{transform:e,final:t},{transform:Mu(n,a)},Du({binary:r,preserveNewlines:s,readableObjectMode:n,state:c})].filter(Boolean)};var Wu=(e,t)=>{for(let r of ax(e))cx(e,r,t)},ax=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),cx=(e,t,r)=>{let{stdioItems:i}=e[t],n=i.filter(({contents:a})=>a!==void 0);if(n.length===0)return;if(t!==0){let[{type:a,optionName:c}]=n;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ot[a]} with synchronous methods.`)}let o=n.map(({contents:a})=>a).map(a=>px(a,i));r.input=pr(o)},px=(e,t)=>{let r=dn(e,t,"utf8",!0);return dx(r),pr(r)},dx=e=>{let t=e.find(r=>typeof r!="string"&&!ee(r));if(t!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)};import{writeFileSync as hx,appendFileSync as yx}from"fs";var un=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:i})=>i!=="all"&&Ot(r,i)&&!fe.has(t)&&ux(i)&&(e.some(({type:n,value:s})=>n==="native"&&lx.has(s))||e.every(({type:n})=>ke.has(n))),ux=e=>e===1||e===2,lx=new Set(["pipe","overlapped"]),Hu=async(e,t,r,i)=>{for await(let n of e)mx(t)||Yu(n,r,i)},Ku=(e,t,r)=>{for(let i of e)Yu(i,t,r)},mx=e=>e._readableState.pipes.length>0,Yu=(e,t,r)=>{let i=ki(e);Ie({type:"output",verboseMessage:i,fdNumber:t,verboseInfo:r})};var Ju=({fileDescriptors:e,syncResult:{output:t},options:r,isMaxBuffer:i,verboseInfo:n})=>{if(t===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:t.map((c,d)=>fx({result:c,fileDescriptors:e,fdNumber:d,state:s,outputFiles:o,isMaxBuffer:i,verboseInfo:n},r)),...s}},fx=({result:e,fileDescriptors:t,fdNumber:r,state:i,outputFiles:n,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:d,stripFinalNewline:p,maxBuffer:u})=>{if(e===null)return;let l=Xd(e,s,u),m=Ye(l),{stdioItems:h,objectMode:f}=t[r],x=gx([m],h,c,i),{serializedResult:w,finalResult:v=w}=_x({chunks:x,objectMode:f,encoding:c,lines:d,stripFinalNewline:p,fdNumber:r});bx({serializedResult:w,fdNumber:r,state:i,verboseInfo:o,encoding:c,stdioItems:h,objectMode:f});let g=a[r]?v:void 0;try{return i.error===void 0&&wx(w,h,n),g}catch(R){return i.error=R,g}},gx=(e,t,r,i)=>{try{return dn(e,t,r,!1)}catch(n){return i.error=n,e}},_x=({chunks:e,objectMode:t,encoding:r,lines:i,stripFinalNewline:n,fdNumber:s})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:pr(e)};let o=uc(e,r);return i[s]?{serializedResult:o,finalResult:co(o,!n[s],t)}:{serializedResult:o}},bx=({serializedResult:e,fdNumber:t,state:r,verboseInfo:i,encoding:n,stdioItems:s,objectMode:o})=>{if(!un({stdioItems:s,encoding:n,verboseInfo:i,fdNumber:t}))return;let a=co(e,!1,o);try{Ku(a,t,i)}catch(c){r.error??=c}},wx=(e,t,r)=>{for(let{path:i,append:n}of t.filter(({type:s})=>sn.has(s))){let s=typeof i=="string"?i:i.toString();n||r.has(s)?yx(i,e):(r.add(s),hx(i,e))}};var Xu=([,e,t],r)=>{if(r.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Ze(t,r,"all")]:Array.isArray(t)?[Ze(e,r,"all"),...t]:ee(e)&&ee(t)?gs([e,t]):`${e}${t}`};import{once as mo}from"events";var Zu=async(e,t)=>{let[r,i]=await xx(e);return t.isForcefullyTerminated??=!1,[r,i]},xx=async e=>{let[t,r]=await Promise.allSettled([mo(e,"spawn"),mo(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?Qu(e):r.value},Qu=async e=>{try{return await mo(e,"exit")}catch{return Qu(e)}},el=async e=>{let[t,r]=await e;if(!kx(t,r)&&ho(t,r))throw new qe;return[t,r]},kx=(e,t)=>e===void 0&&t===void 0,ho=(e,t)=>e!==0||t!==null;var tl=({error:e,status:t,signal:r,output:i},{maxBuffer:n})=>{let s=vx(e,t,r),o=s?.code==="ETIMEDOUT",a=Jd(s,i,n);return{resultError:s,exitCode:t,signal:r,timedOut:o,isMaxBuffer:a}},vx=(e,t,r)=>e!==void 0?e:ho(t,r)?new qe:void 0;var rl=(e,t,r)=>{let{file:i,commandArguments:n,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:d,fileDescriptors:p}=qx(e,t,r),u=Cx({file:i,commandArguments:n,options:d,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:p,startTime:a});return Gt(u,c,d)},qx=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=Si(e,t,r),a=$x(r),{file:c,commandArguments:d,options:p}=Vi(e,t,a);Ax(p);let u=Ru(p,o);return{file:c,commandArguments:d,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},$x=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Ax=({ipc:e,ipcInput:t,detached:r,cancelSignal:i})=>{t&&ln("ipcInput"),e&&ln("ipc: true"),r&&ln("detached: true"),i&&ln("cancelSignal")},ln=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Cx=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ex({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:d,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m}=tl(c,r),{output:h,error:f=d}=Ju({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:m,verboseInfo:s}),x=h.map((v,g)=>Ze(v,r,g)),w=Ze(Xu(h,r),r,"all");return Tx({error:f,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m,stdio:x,all:w,options:r,command:i,escapedCommand:n,startTime:a})},Ex=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:s,startTime:o})=>{try{Wu(s,r);let a=Px(r);return Sx(...Wi(e,t,a))}catch(a){return Nt({error:a,command:i,escapedCommand:n,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Px=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:en(t)}),Tx=({error:e,exitCode:t,signal:r,timedOut:i,isMaxBuffer:n,stdio:s,all:o,options:a,command:c,escapedCommand:d,startTime:p})=>e===void 0?tn({command:c,escapedCommand:d,stdio:s,all:o,ipcOutput:[],options:a,startTime:p}):_r({error:e,command:c,escapedCommand:d,timedOut:i,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:n,isForcefullyTerminated:!1,exitCode:t,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:p,isSync:!0});import{setMaxListeners as _k}from"events";import{spawn as bk}from"child_process";import al from"process";import{once as yo,on as Rx}from"events";var il=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0,filter:s}={})=>(Lt({methodName:"getOneMessage",isSubprocess:r,ipc:i,isConnected:Fi(e)}),Ix({anyProcess:e,channel:t,isSubprocess:r,filter:s,reference:n})),Ix=async({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:n})=>{ji(t,n);let s=st(e,t,r),o=new AbortController;try{return await Promise.race([Ox(s,i,o),jx(s,r,o),Dx(s,r,o)])}catch(a){throw Mt(e),a}finally{o.abort(),Di(t,n)}},Ox=async(e,t,{signal:r})=>{if(t===void 0){let[i]=await yo(e,"message",{signal:r});return i}for await(let[i]of Rx(e,"message",{signal:r}))if(t(i))return i},jx=async(e,t,{signal:r})=>{await yo(e,"disconnect",{signal:r}),Gp(t)},Dx=async(e,t,{signal:r})=>{let[i]=await yo(e,"strict:error",{signal:r});throw Ri(i,t)};import{once as sl,on as Lx}from"events";var ol=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0}={})=>fo({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:!r,reference:n}),fo=({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:n,reference:s})=>{Lt({methodName:"getEachMessage",isSubprocess:r,ipc:i,isConnected:Fi(e)}),ji(t,s);let o=st(e,t,r),a=new AbortController,c={};return Mx(e,o,a),Fx({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Bx({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:r,shouldAwait:n,controller:a,state:c,reference:s})},Mx=async(e,t,r)=>{try{await sl(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},Fx=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{let[n]=await sl(e,"strict:error",{signal:r.signal});i.error=Ri(n,t),r.abort()}catch{}},Bx=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:i,shouldAwait:n,controller:s,state:o,reference:a}){try{for await(let[c]of Lx(r,"message",{signal:s.signal}))nl(o),yield c}catch{nl(o)}finally{s.abort(),Di(t,a),i||Mt(e),n&&await e}},nl=({error:e})=>{if(e)throw e};var cl=(e,{ipc:t})=>{Object.assign(e,dl(e,!1,t))},pl=()=>{let e=al,t=!0,r=al.channel!==void 0;return{...dl(e,t,r),getCancelSignal:fd.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},dl=(e,t,r)=>({sendMessage:Gi.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:il.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:ol.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})});import{ChildProcess as Ux}from"child_process";import{PassThrough as Nx,Readable as Gx,Writable as zx,Duplex as Vx}from"stream";var ul=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,verboseInfo:o})=>{so(i);let a=new Ux;Wx(a,i),Object.assign(a,{readable:Hx,writable:Kx,duplex:Yx});let c=Nt({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:!1}),d=Jx(c,o,n);return{subprocess:a,promise:d}},Wx=(e,t)=>{let r=wr(),i=wr(),n=wr(),s=Array.from({length:t.length-3},wr),o=wr(),a=[r,i,n,...s];Object.assign(e,{stdin:r,stdout:i,stderr:n,all:o,stdio:a})},wr=()=>{let e=new Nx;return e.end(),e},Hx=()=>new Gx({read(){}}),Kx=()=>new zx({write(){}}),Yx=()=>new Vx({read(){},write(){}}),Jx=async(e,t,r)=>Gt(e,t,r);import{createReadStream as ll,createWriteStream as ml}from"fs";import{Buffer as Xx}from"buffer";import{Readable as xr,Writable as Zx,Duplex as Qx}from"stream";var yl=(e,t)=>on(e0,e,t,!1),kr=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${ot[e]}.`)},hl={fileNumber:kr,generator:lo,asyncGenerator:lo,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let i=t||r;return{stream:Qx.fromWeb(e,{objectMode:i})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},e0={input:{...hl,fileUrl:({value:e})=>({stream:ll(e)}),filePath:({value:{file:e}})=>({stream:ll(e)}),webStream:({value:e})=>({stream:xr.fromWeb(e)}),iterable:({value:e})=>({stream:xr.from(e)}),asyncIterable:({value:e})=>({stream:xr.from(e)}),string:({value:e})=>({stream:xr.from(e)}),uint8Array:({value:e})=>({stream:xr.from(Xx.from(e))})},output:{...hl,fileUrl:({value:e})=>({stream:ml(e)}),filePath:({value:{file:e,append:t}})=>({stream:ml(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:Zx.fromWeb(e)}),iterable:kr,asyncIterable:kr,string:kr,uint8Array:kr}};import{on as t0,once as fl}from"events";import{PassThrough as r0,getDefaultHighWaterMark as i0}from"stream";import{finished as bl}from"stream/promises";function xt(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let n of e)_o(n);let t=e.some(({readableObjectMode:n})=>n),r=n0(e,t),i=new go({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let n of e)i.add(n);return i}var n0=(e,t)=>{if(e.length===0)return i0(t);let r=e.filter(({readableObjectMode:i})=>i===t).map(({readableHighWaterMark:i})=>i);return Math.max(...r)},go=class extends r0{#t=new Set([]);#r=new Set([]);#e=new Set([]);#i;#s=Symbol("unpipe");#n=new WeakMap;add(t){if(_o(t),this.#t.has(t))return;this.#t.add(t),this.#i??=s0(this,this.#t,this.#s);let r=c0({passThroughStream:this,stream:t,streams:this.#t,ended:this.#r,aborted:this.#e,onFinished:this.#i,unpipeEvent:this.#s});this.#n.set(t,r),t.pipe(this,{end:!1})}async remove(t){if(_o(t),!this.#t.has(t))return!1;let r=this.#n.get(t);return r===void 0?!1:(this.#n.delete(t),t.unpipe(this),await r,!0)}},s0=async(e,t,r)=>{mn(e,gl);let i=new AbortController;try{await Promise.race([o0(e,i),a0(e,t,r,i)])}finally{i.abort(),mn(e,-gl)}},o0=async(e,{signal:t})=>{try{await bl(e,{signal:t,cleanup:!0})}catch(r){throw wl(e,r),r}},a0=async(e,t,r,{signal:i})=>{for await(let[n]of t0(e,"unpipe",{signal:i}))t.has(n)&&n.emit(r)},_o=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},c0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,onFinished:s,unpipeEvent:o})=>{mn(e,_l);let a=new AbortController;try{await Promise.race([p0(s,t,a),d0({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:a}),u0({stream:t,streams:r,ended:i,aborted:n,unpipeEvent:o,controller:a})])}finally{a.abort(),mn(e,-_l)}r.size>0&&r.size===i.size+n.size&&(i.size===0&&n.size>0?bo(e):l0(e))},p0=async(e,t,{signal:r})=>{try{await e,r.aborted||bo(t)}catch(i){r.aborted||wl(t,i)}},d0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:{signal:s}})=>{try{await bl(t,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&i.add(t)}catch(o){if(s.aborted||!r.has(t))return;xl(o)?n.add(t):kl(e,o)}},u0=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:n,controller:{signal:s}})=>{if(await fl(e,n,{signal:s}),!e.readable)return fl(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},l0=e=>{e.writable&&e.end()},wl=(e,t)=>{xl(t)?bo(e):kl(e,t)},xl=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",bo=e=>{(e.readable||e.writable)&&e.destroy()},kl=(e,t)=>{e.destroyed||(e.once("error",m0),e.destroy(t))},m0=()=>{},mn=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},gl=2,_l=1;import{finished as vl}from"stream/promises";var Vt=(e,t)=>{e.pipe(t),h0(e,t),y0(e,t)},h0=async(e,t)=>{if(!(Se(e)||Se(t))){try{await vl(e,{cleanup:!0,readable:!0,writable:!1})}catch{}wo(t)}},wo=e=>{e.writable&&e.end()},y0=async(e,t)=>{if(!(Se(e)||Se(t))){try{await vl(t,{cleanup:!0,readable:!1,writable:!0})}catch{}xo(e)}},xo=e=>{e.readable&&e.destroy()};var Sl=(e,t,r)=>{let i=new Map;for(let[n,{stdioItems:s,direction:o}]of Object.entries(t)){for(let{stream:a}of s.filter(({type:c})=>ke.has(c)))f0(e,a,o,n);for(let{stream:a}of s.filter(({type:c})=>!ke.has(c)))_0({subprocess:e,stream:a,direction:o,fdNumber:n,pipeGroups:i,controller:r})}for(let[n,s]of i.entries()){let o=s.length===1?s[0]:xt(s);Vt(o,n)}},f0=(e,t,r,i)=>{r==="output"?Vt(e.stdio[i],t):Vt(t,e.stdio[i]);let n=g0[i];n!==void 0&&(e[n]=t),e.stdio[i]=t},g0=["stdin","stdout","stderr"],_0=({subprocess:e,stream:t,direction:r,fdNumber:i,pipeGroups:n,controller:s})=>{if(t===void 0)return;b0(t,s);let[o,a]=r==="output"?[t,e.stdio[i]]:[e.stdio[i],t],c=n.get(o)??[];n.set(o,[...c,a])},b0=(e,{signal:t})=>{Se(e)&&gt(e,w0,t)},w0=2;import{addAbortListener as v0}from"events";var kt=[];kt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&kt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&kt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var hn=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",ko=Symbol.for("signal-exit emitter"),vo=globalThis,x0=Object.defineProperty.bind(Object),So=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vo[ko])return vo[ko];x0(vo,ko,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let i=this.listeners[t],n=i.indexOf(r);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(t,r,i){if(this.emitted[t])return!1;this.emitted[t]=!0;let n=!1;for(let s of this.listeners[t])n=s(r,i)===!0||n;return t==="exit"&&(n=this.emit("afterExit",r,i)||n),n}},yn=class{},k0=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),qo=class extends yn{onExit(){return()=>{}}load(){}unload(){}},$o=class extends yn{#t=Ao.platform==="win32"?"SIGINT":"SIGHUP";#r=new So;#e;#i;#s;#n={};#o=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of kt)this.#n[r]=()=>{let i=this.#e.listeners(r),{count:n}=this.#r,s=t;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(n+=s.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#t:r;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#i=t.emit}onExit(t,r){if(!hn(this.#e))return()=>{};this.#o===!1&&this.load();let i=r?.alwaysLast?"afterExit":"exit";return this.#r.on(i,t),()=>{this.#r.removeListener(i,t),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let t of kt)try{let r=this.#n[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#c(t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,kt.forEach(t=>{let r=this.#n[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#s,this.#r.count-=1)}#a(t){return hn(this.#e)?(this.#e.exitCode=t||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#c(t,...r){let i=this.#i;if(t==="exit"&&hn(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let n=i.call(this.#e,t,...r);return this.#r.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,t,...r)}},Ao=globalThis.process,{onExit:ql,load:mO,unload:hO}=k0(hn(Ao)?new $o(Ao):new qo);var $l=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let n=ql(()=>{e.kill()});v0(i,()=>{n()})};var Cl=({source:e,sourcePromise:t,boundOptions:r,createNested:i},...n)=>{let s=vi(),{destination:o,destinationStream:a,destinationError:c,from:d,unpipeSignal:p}=S0(r,i,n),{sourceStream:u,sourceError:l}=$0(e,d),{options:m,fileDescriptors:h}=je.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:l,destination:o,destinationStream:a,destinationError:c,unpipeSignal:p,fileDescriptors:h,startTime:s}},S0=(e,t,r)=>{try{let{destination:i,pipeOptions:{from:n,to:s,unpipeSignal:o}={}}=q0(e,t,...r),a=Oi(i,s);return{destination:i,destinationStream:a,from:n,unpipeSignal:o}}catch(i){return{destinationError:i}}},q0=(e,t,r,...i)=>{if(Array.isArray(r))return{destination:t(Al,e)(r,...i),pipeOptions:e};if(typeof r=="string"||r instanceof URL||ys(r)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[n,s,o]=mi(r,...i);return{destination:t(Al)(n,s,o),pipeOptions:o}}if(je.has(r)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:i[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Al=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),$0=(e,t)=>{try{return{sourceStream:Ft(e,t)}}catch(r){return{sourceError:r}}};var Pl=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i,fileDescriptors:n,sourceOptions:s,startTime:o})=>{let a=A0({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i});if(a!==void 0)throw Co({error:a,fileDescriptors:n,sourceOptions:s,startTime:o})},A0=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i})=>{if(t!==void 0&&i!==void 0)return i;if(i!==void 0)return xo(e),i;if(t!==void 0)return wo(r),t},Co=({error:e,fileDescriptors:t,sourceOptions:r,startTime:i})=>Nt({error:e,command:El,escapedCommand:El,fileDescriptors:t,options:r,startTime:i,isSync:!1}),El="source.pipe(destination)";var Tl=async e=>{let[{status:t,reason:r,value:i=r},{status:n,reason:s,value:o=s}]=await e;if(o.pipedFrom.includes(i)||o.pipedFrom.push(i),n==="rejected")throw o;if(t==="rejected")throw i;return o};import{finished as C0}from"stream/promises";var Rl=(e,t,r)=>{let i=fn.has(t)?P0(e,t):E0(e,t);return gt(e,R0,r.signal),gt(t,I0,r.signal),T0(t),i},E0=(e,t)=>{let r=xt([e]);return Vt(r,t),fn.set(t,r),r},P0=(e,t)=>{let r=fn.get(t);return r.add(e),r},T0=async e=>{try{await C0(e,{cleanup:!0,readable:!1,writable:!0})}catch{}fn.delete(e)},fn=new WeakMap,R0=2,I0=1;import{aborted as O0}from"util";var Il=(e,t)=>e===void 0?[]:[j0(e,t)],j0=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:i,sourceOptions:n,startTime:s})=>{await O0(e,t),await r.remove(t);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw Co({error:o,fileDescriptors:i,sourceOptions:n,startTime:s})};var gn=(e,...t)=>{if(Y(t[0]))return gn.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...i}=Cl(e,...t),n=D0({...i,destination:r});return n.pipe=gn.bind(void 0,{...e,source:r,sourcePromise:n,boundOptions:{}}),n},D0=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:i,destination:n,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:d})=>{let p=L0(e,n);Pl({sourceStream:t,sourceError:i,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:d});let u=new AbortController;try{let l=Rl(t,s,u);return await Promise.race([Tl(p),...Il(a,{sourceStream:t,mergedStream:l,sourceOptions:r,fileDescriptors:c,startTime:d})])}finally{u.abort()}},L0=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as z0}from"timers/promises";import{on as M0}from"events";import{getDefaultHighWaterMark as F0}from"stream";var _n=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:i,encoding:n,preserveNewlines:s})=>{let o=new AbortController;return B0(t,o),jl({stream:e,controller:o,binary:r,shouldEncode:!e.readableObjectMode&&i,encoding:n,shouldSplit:!e.readableObjectMode,preserveNewlines:s})},B0=async(e,t)=>{try{await e}catch{}finally{t.abort()}},Eo=({stream:e,onStreamEnd:t,lines:r,encoding:i,stripFinalNewline:n,allMixed:s})=>{let o=new AbortController;U0(t,o,e);let a=e.readableObjectMode&&!s;return jl({stream:e,controller:o,binary:i==="buffer",shouldEncode:!a,encoding:i,shouldSplit:!a&&r,preserveNewlines:!n})},U0=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},jl=({stream:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})=>{let a=M0(e,"data",{signal:t.signal,highWaterMark:Ol,highWatermark:Ol});return N0({onStdoutChunk:a,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})},Po=F0(!0),Ol=Po,N0=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o}){let a=G0({binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of e)yield*wt(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*br(a)}},G0=({binary:e,shouldEncode:t,encoding:r,shouldSplit:i,preserveNewlines:n})=>[cn(e,r,!t),an(e,n,!i,{})].filter(Boolean);var Dl=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,buffer:n,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:d,streamInfo:p})=>{let u=V0({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:a,verboseInfo:d,streamInfo:p});if(!n){await Promise.all([W0(e),u]);return}let l=oo(c,r),m=Eo({stream:e,onStreamEnd:t,lines:o,encoding:i,stripFinalNewline:l,allMixed:a}),[h]=await Promise.all([H0({stream:e,iterable:m,fdNumber:r,encoding:i,maxBuffer:s,lines:o}),u]);return h},V0=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:n,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!un({stdioItems:o[r]?.stdioItems,encoding:i,verboseInfo:s,fdNumber:r}))return;let a=Eo({stream:e,onStreamEnd:t,lines:!0,encoding:i,stripFinalNewline:!0,allMixed:n});await Hu(a,e,r,s)},W0=async e=>{await z0(),e.readableFlowing===null&&e.resume()},H0=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:i,encoding:n,maxBuffer:s,lines:o})=>{try{return t||o?await Ji(r,{maxBuffer:s}):n==="buffer"?new Uint8Array(await Xi(r,{maxBuffer:s})):await Qi(r,{maxBuffer:s})}catch(a){return Ll(Hd({error:a,stream:e,readableObjectMode:t,lines:o,encoding:n,fdNumber:i}))}},To=async e=>{try{return await e}catch(t){return Ll(t)}},Ll=({bufferedData:e})=>pc(e)?new Uint8Array(e):e;import{finished as K0}from"stream/promises";var vr=async(e,t,r,{isSameDirection:i,stopOnExit:n=!1}={})=>{let s=Y0(e,r),o=new AbortController;try{await Promise.race([...n?[r.exitPromise]:[],K0(e,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Z0(a,t,r,i)}finally{o.abort()}},Y0=(e,{originalStreams:[t],subprocess:r})=>{let i={stdinCleanedUp:!1};return e===t&&J0(e,r,i),i},J0=(e,t,r)=>{let{_destroy:i}=e;e._destroy=(...n)=>{X0(t,r),i.call(e,...n)}},X0=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},Z0=(e,t,r,i)=>{if(!Q0(e,t,r,i))throw e},Q0=(e,t,r,i=!0)=>r.propagating?Ml(e)||bn(e):(r.propagating=!0,Ro(r,t)===i?Ml(e):bn(e)),Ro=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",bn=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",Ml=e=>e?.code==="EPIPE";var Fl=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>e.stdio.map((c,d)=>Io({stream:c,fdNumber:d,encoding:t,buffer:r[d],maxBuffer:i[d],lines:n[d],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Io=async({stream:e,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d})=>{if(!e)return;let p=vr(e,t,d);if(Ro(d,t)){await p;return}let[u]=await Promise.all([Dl({stream:e,onStreamEnd:p,fdNumber:t,encoding:r,buffer:i,maxBuffer:n,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:d}),p]);return u};var Bl=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?xt([e,t].filter(Boolean)):void 0,Ul=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Io({...ek(e,r),fdNumber:"all",encoding:t,maxBuffer:i[1]+i[2],lines:n[1]||n[2],allMixed:tk(e),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),ek=({stdout:e,stderr:t,all:r},[,i,n])=>{let s=i||n;return s?i?n?{stream:r,buffer:s}:{stream:e,buffer:s}:{stream:t,buffer:s}:{stream:r,buffer:s}},tk=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as rk}from"events";var Nl=e=>Ot(e,"ipc"),Gl=(e,t)=>{let r=ki(e);Ie({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var zl=async({subprocess:e,buffer:t,maxBuffer:r,ipc:i,ipcOutput:n,verboseInfo:s})=>{if(!i)return n;let o=Nl(s),a=Je(t,"ipc"),c=Je(r,"ipc");for await(let d of fo({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:i,shouldAwait:!1,reference:!0}))a&&(Kd(e,n,c),n.push(d)),o&&Gl(d,s);return n},Vl=async(e,t)=>(await Promise.allSettled([e]),t);var Wl=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:i,lines:n,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:d,ipc:p,ipcInput:u},context:l,verboseInfo:m,fileDescriptors:h,originalStreams:f,onInternalError:x,controller:w})=>{let v=Zu(e,l),g={originalStreams:f,fileDescriptors:h,subprocess:e,exitPromise:v,propagating:!1},R=Fl({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),S=Ul({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),U=[],j=zl({subprocess:e,buffer:r,maxBuffer:i,ipc:p,ipcOutput:U,verboseInfo:m}),L=ik(f,e,g),G=nk(h,g);try{return await Promise.race([Promise.all([{},el(v),Promise.all(R),S,j,$d(e,u),...L,...G]),x,sk(e,w),...xd(e,s,l,w),...Np({subprocess:e,cancelSignal:o,gracefulCancel:a,context:l,controller:w}),...bd({subprocess:e,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:l,controller:w})])}catch(H){return l.terminationReason??="other",Promise.all([{error:H},v,Promise.all(R.map($=>To($))),To(S),Vl(j,U),Promise.allSettled(L),Promise.allSettled(G)])}},ik=(e,t,r)=>e.map((i,n)=>i===t.stdio[n]?void 0:vr(i,n,r)),nk=(e,t)=>e.flatMap(({stdioItems:r},i)=>r.filter(({value:n,stream:s=n})=>Ae(s,{checkOpen:!1})&&!Se(s)).map(({type:n,value:s,stream:o=s})=>vr(o,i,t,{isSameDirection:ke.has(n),stopOnExit:n==="native"}))),sk=async(e,{signal:t})=>{let[r]=await rk(e,"error",{signal:t});throw r};var Hl=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Sr=(e,t,r)=>{let i=e[r];i.has(t)||i.set(t,[]);let n=i.get(t),s=Oe();return n.push(s),{resolve:s.resolve.bind(s),promises:n}},Wt=async({resolve:e,promises:t},r)=>{e();let[i]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...t])]);return!i};import{Readable as ok}from"stream";import{callbackify as ak}from"util";import{finished as Kl}from"stream/promises";var Oo=async e=>{if(e!==void 0)try{await jo(e)}catch{}},Yl=async e=>{if(e!==void 0)try{await Do(e)}catch{}},jo=async e=>{await Kl(e,{cleanup:!0,readable:!1,writable:!0})},Do=async e=>{await Kl(e,{cleanup:!0,readable:!0,writable:!1})},wn=async(e,t)=>{if(await e,t)throw t},xn=(e,t,r)=>{r&&!bn(r)?e.destroy(r):t&&e.destroy()};var Jl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,binary:n=!0,preserveNewlines:s=!0}={})=>{let o=n||fe.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Lo(e,i,t),{readableEncoding:d,readableObjectMode:p,readableHighWaterMark:u}=Mo(a,o),{read:l,onStdoutDataDone:m}=Fo({subprocessStdout:a,subprocess:e,binary:o,encoding:r,preserveNewlines:s}),h=new ok({read:l,destroy:ak(Uo.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:u,objectMode:p,encoding:d});return Bo({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},Lo=(e,t,r)=>{let i=Ft(e,t),n=Sr(r,i,"readableDestroy");return{subprocessStdout:i,waitReadableDestroy:n}},Mo=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},i)=>i?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:Po},Fo=({subprocessStdout:e,subprocess:t,binary:r,encoding:i,preserveNewlines:n})=>{let s=Oe(),o=_n({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:i,preserveNewlines:n});return{read(){ck(this,o,s)},onStdoutDataDone:s}},ck=async(e,t,r)=>{try{let{value:i,done:n}=await t.next();n?r.resolve():e.push(i)}catch{}},Bo=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:i,subprocessStdin:n})=>{try{await Do(e),await i,await Oo(n),await t,r.readable&&r.push(null)}catch(s){await Oo(n),Xl(r,s)}},Uo=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},i)=>{await Wt(r,t)&&(Xl(e,i),await wn(t,i))},Xl=(e,t)=>{xn(e,e.readable,t)};import{Writable as pk}from"stream";import{callbackify as Zl}from"util";var Ql=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}=No(e,r,t),o=new pk({...Go(i,e,n),destroy:Zl(Vo.bind(void 0,{subprocessStdin:i,subprocess:e,waitWritableFinal:n,waitWritableDestroy:s})),highWaterMark:i.writableHighWaterMark,objectMode:i.writableObjectMode});return zo(i,o),o},No=(e,t,r)=>{let i=Oi(e,t),n=Sr(r,i,"writableFinal"),s=Sr(r,i,"writableDestroy");return{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}},Go=(e,t,r)=>({write:dk.bind(void 0,e),final:Zl(uk.bind(void 0,e,t,r))}),dk=(e,t,r,i)=>{e.write(t,r)?i():e.once("drain",i)},uk=async(e,t,r)=>{await Wt(r,t)&&(e.writable&&e.end(),await t)},zo=async(e,t,r)=>{try{await jo(e),t.writable&&t.end()}catch(i){await Yl(r),em(t,i)}},Vo=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:i},n)=>{await Wt(r,t),await Wt(i,t)&&(em(e,n),await wn(t,n))},em=(e,t)=>{xn(e,e.writable,t)};import{Duplex as lk}from"stream";import{callbackify as mk}from"util";var tm=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,to:n,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||fe.has(r),{subprocessStdout:c,waitReadableDestroy:d}=Lo(e,i,t),{subprocessStdin:p,waitWritableFinal:u,waitWritableDestroy:l}=No(e,n,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=Mo(c,a),{read:x,onStdoutDataDone:w}=Fo({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:o}),v=new lk({read:x,...Go(p,e,u),destroy:mk(hk.bind(void 0,{subprocessStdout:c,subprocessStdin:p,subprocess:e,waitReadableDestroy:d,waitWritableFinal:u,waitWritableDestroy:l})),readableHighWaterMark:f,writableHighWaterMark:p.writableHighWaterMark,readableObjectMode:h,writableObjectMode:p.writableObjectMode,encoding:m});return Bo({subprocessStdout:c,onStdoutDataDone:w,readable:v,subprocess:e,subprocessStdin:p}),zo(p,v,c),v},hk=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:i,waitWritableFinal:n,waitWritableDestroy:s},o)=>{await Promise.all([Uo({subprocessStdout:e,subprocess:r,waitReadableDestroy:i},o),Vo({subprocessStdin:t,subprocess:r,waitWritableFinal:n,waitWritableDestroy:s},o)])};var Wo=(e,t,{from:r,binary:i=!1,preserveNewlines:n=!1}={})=>{let s=i||fe.has(t),o=Ft(e,r),a=_n({subprocessStdout:o,subprocess:e,binary:s,shouldEncode:!0,encoding:t,preserveNewlines:n});return yk(a,o,e)},yk=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var rm=(e,{encoding:t})=>{let r=Hl();e.readable=Jl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=Ql.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=tm.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=Wo.bind(void 0,e,t),e[Symbol.asyncIterator]=Wo.bind(void 0,e,t,{})};var im=(e,t)=>{for(let[r,i]of gk){let n=i.value.bind(t);Reflect.defineProperty(e,r,{...i,value:n})}},fk=(async()=>{})().constructor.prototype,gk=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(fk,e)]);var nm=(e,t,r,i)=>{let{file:n,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:d,options:p,fileDescriptors:u}=wk(e,t,r),{subprocess:l,promise:m}=kk({file:n,commandArguments:s,options:p,startTime:c,verboseInfo:d,command:o,escapedCommand:a,fileDescriptors:u});return l.pipe=gn.bind(void 0,{source:l,sourcePromise:m,boundOptions:{},createNested:i}),im(l,m),je.set(l,{options:p,fileDescriptors:u}),l},wk=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=Si(e,t,r),{file:a,commandArguments:c,options:d}=Vi(e,t,r),p=xk(d),u=yl(p,o);return{file:a,commandArguments:c,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},xk=({timeout:e,signal:t,...r})=>{if(t!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:e}},kk=({file:e,commandArguments:t,options:r,startTime:i,verboseInfo:n,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=bk(...Wi(e,t,r))}catch(h){return ul({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:i,verboseInfo:n})}let d=new AbortController;_k(Number.POSITIVE_INFINITY,d.signal);let p=[...c.stdio];Sl(c,a,d),$l(c,r,d);let u={},l=Oe();c.kill=Bp.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:l,context:u,controller:d}),c.all=Bl(c,r),rm(c,r),cl(c,r);let m=vk({subprocess:c,options:r,startTime:i,verboseInfo:n,fileDescriptors:a,originalStreams:p,command:s,escapedCommand:o,context:u,onInternalError:l,controller:d});return{subprocess:c,promise:m}},vk=async({subprocess:e,options:t,startTime:r,verboseInfo:i,fileDescriptors:n,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:d,controller:p})=>{let[u,[l,m],h,f,x]=await Wl({subprocess:e,options:t,context:c,verboseInfo:i,fileDescriptors:n,originalStreams:s,onInternalError:d,controller:p});p.abort(),d.resolve();let w=h.map((R,S)=>Ze(R,t,S)),v=Ze(f,t,"all"),g=Sk({errorInfo:u,exitCode:l,signal:m,stdio:w,all:v,ipcOutput:x,context:c,options:t,command:o,escapedCommand:a,startTime:r});return Gt(g,i,t)},Sk=({errorInfo:e,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,context:o,options:a,command:c,escapedCommand:d,startTime:p})=>"error"in e?_r({error:e.error,command:c,escapedCommand:d,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:e.error instanceof De,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,options:a,startTime:p,isSync:!1}):tn({command:c,escapedCommand:d,stdio:i,all:n,ipcOutput:s,options:a,startTime:p});var kn=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,qk(i,e[i],n)]));return{...e,...r}},qk=(e,t,r)=>$k.has(e)&&Y(t)&&Y(r)?{...t,...r}:r,$k=new Set(["env",...xs]);var at=(e,t,r,i)=>{let n=(o,a,c)=>at(o,a,r,c),s=(...o)=>Ak({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:i,createNested:n},...o);return i!==void 0&&i(s,n,t),s},Ak=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:i,createNested:n},s,...o)=>{if(Y(s))return n(e,kn(r,s),i);let{file:a,commandArguments:c,options:d,isSync:p}=Ck({mapArguments:e,firstArgument:s,nextArguments:o,deepOptions:t,boundOptions:r});return p?rl(a,c,d):nm(a,c,d,n)},Ck=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:i,boundOptions:n})=>{let s=yc(t)?fc(t,r):[t,...r],[o,a,c]=mi(...s),d=kn(kn(i,n),c),{file:p=o,commandArguments:u=a,options:l=d,isSync:m=!1}=e({file:o,commandArguments:a,options:d});return{file:p,commandArguments:u,options:l,isSync:m}};var sm=({file:e,commandArguments:t})=>am(e,t),om=({file:e,commandArguments:t})=>({...am(e,t),isSync:!0}),am=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[r,...i]=Ek(e);return{file:r,commandArguments:i}},Ek=e=>{if(typeof e!="string")throw new TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(t==="")return[];let r=[];for(let i of t.split(Pk)){let n=r.at(-1);n&&n.endsWith("\\")?r[r.length-1]=`${n.slice(0,-1)} ${i}`:r.push(i)}return r},Pk=/ +/g;var cm=(e,t,r)=>{e.sync=t(Tk,r),e.s=e.sync},pm=({options:e})=>dm(e),Tk=({options:e})=>({...dm(e),isSync:!0}),dm=e=>({options:{...Rk(e),...e}}),Rk=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},um={preferLocal:!0};var J=at(()=>({})),i1=at(()=>({isSync:!0})),ct=at(sm),n1=at(om),s1=at(vd),o1=at(pm,{},um,cm),{sendMessage:a1,getOneMessage:c1,getEachMessage:p1,getCancelSignal:d1}=pl();var se=M(K(),1);var $r=M(K(),1);import Ce from"fs";import jk from"os";import Be from"path";var Ht="spree@example.com",Kt="spree123";import Me from"fs";import pt from"path";function _(e=process.cwd()){let t=Ik(e),r=pt.join(t,"docker-compose.yml");if(!Me.existsSync(r))throw new Error(`Not a Spree project directory. No docker-compose.yml found.
142
+ Run this command from a directory created with create-spree-app.`);let i=Ok(t);return{mode:"docker",projectDir:t,port:i}}function Ik(e){if(pt.basename(e)!=="backend")return e;let t=pt.dirname(e);for(let r of["docker-compose.yml","docker-compose.dev.yml"]){let i=pt.join(t,r);if(Me.existsSync(i))try{if(/\.\/backend:\/rails(:\w+)?(\s|$)/m.test(Me.readFileSync(i,"utf-8")))return t}catch{}}return e}function Fe(e){let t=pt.join(e,".env");if(!Me.existsSync(t))return!1;try{let r=Me.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function qr(e){let t=pt.join(e,"docker-compose.yml");if(!Me.existsSync(t))return!1;try{return/^\s*build\s*:/m.test(Me.readFileSync(t,"utf-8"))}catch{return!1}}function Sn(e){try{let r=Me.readFileSync(pt.join(e,".env"),"utf-8").match(/^SPREE_SAMPLE_DATA=(true|false)\b/m);return r?r[1]==="true":void 0}catch{return}}function Ok(e){let t=pt.join(e,".env");if(!Me.existsSync(t))return 3e3;let i=Me.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return i?Number(i[1]):3e3}var lm=M(K(),1);async function X(e,t,r){return J("docker",["compose",...e],{cwd:t,...r})}async function dt(e,t){try{await X(["up","-d","--no-deps","web"],e,{stdio:t?.stdio??"inherit"})}catch{}}async function ne(e,t,r){let i=["compose","exec","-T"];if(r)for(let[s,o]of Object.entries(r))i.push("-e",`${s}=${o}`);i.push("web","bin/rails",e);let{stdout:n}=await J("docker",i,{cwd:t});return n.split(`
143
143
  `).filter(s=>!s.startsWith("[")).join(`
144
- `).trim()}async function sm(e){let{stdout:t}=await J("docker",["compose","ps","-a","-q"],{cwd:e});return t.trim().length>0}async function vt(e,t){let{stdout:r}=await J("docker",["compose","ps",e,"--format","{{.State}}"],{cwd:t});return r.split(`
145
- `).some(i=>i.trim()==="running")}async function F(e,t,r={}){let{service:i="web",tty:n=!0,detach:s=!1,env:o}=r,a=["compose","exec"];if(s&&a.push("-d"),n||a.push("-T"),o)for(let[c,d]of Object.entries(o))a.push("-e",`${c}=${d}`);a.push(i,...e),await J("docker",a,{cwd:t,stdio:"inherit"})}async function xn(e){await F(["bin/rails","spree:admin:tailwindcss:build"],e,{tty:!1})}async function om(e){await F(["bin/rails","spree:admin:tailwindcss:watch"],e,{detach:!0})}async function Bo(e,t,r={}){let{service:i="web",env:n,captureStderr:s=!1}=r,o=["compose","run","--rm"];if(n)for(let[c,d]of Object.entries(n))o.push("-e",`${c}=${d}`);o.push(i,...e),await J("docker",o,{cwd:t,...s?{stdin:"inherit",stdout:"inherit",stderr:["pipe","inherit"]}:{stdio:"inherit"}})}async function ut(e,t,r={}){let{service:i="web",env:n,edgeHint:s}=r;if(await vt(i,t)){await F(e,t,{service:i,env:n});return}Me(t)&&(O([`The ${i} container is not running, and this is a monorepo edge project.`,`Run ${nm.default.bold("pnpm server:dev")} from the monorepo root${s?` \u2014 ${s}`:""}.`].join(`
146
- `)),process.exit(1)),b.info(`${i} container is not running \u2014 using a one-off container (\`docker compose run\`) instead.`),await Bo(e,t,{service:i,env:n})}async function kn(e,t){await J("docker",["compose","logs","-f",e],{cwd:t,stdio:"inherit"})}var Uo=`http://localhost:${3e3}`,lt=class extends Error{};function am(){return process.env.XDG_CONFIG_HOME?Fe.join(process.env.XDG_CONFIG_HOME,"spree"):Fe.join(Ak.homedir(),".config","spree")}function St(){return Fe.join(am(),"config.json")}function Sr(e){return e?.code==="ENOENT"}function qr(){let e;try{e=Ae.readFileSync(St(),"utf-8")}catch(t){if(Sr(t))return{profiles:{}};throw t}try{let t=JSON.parse(e);return{...t,profiles:t.profiles??{}}}catch{let t=`${St()}.bak`;try{Ae.renameSync(St(),t)}catch{}return process.stderr.write(`${vr.default.yellow(`warning: ${St()} was not valid JSON; moved it to ${t} and starting fresh.`)}
147
- `),{profiles:{}}}}function No(e){Ae.mkdirSync(am(),{recursive:!0,mode:448}),cm(St(),`${JSON.stringify(e,null,2)}
148
- `)}function cm(e,t){Ae.writeFileSync(e,t,{mode:384}),Ae.chmodSync(e,384)}function Vt(e){return Fe.join(e,".spree","credentials.json")}function Go(e){return Fe.join(e,".spree","setup-complete")}function pm(e){let t=Go(e);Ae.mkdirSync(Fe.dirname(t),{recursive:!0,mode:448}),dm(Fe.join(Fe.dirname(t),".gitignore")),Ae.writeFileSync(t,`${new Date().toISOString()}
149
- `)}function Ck(e){let t;try{t=Ae.readFileSync(Vt(e),"utf-8")}catch(r){if(Sr(r))return null;throw r}try{return JSON.parse(t)}catch{return null}}function Ek(e,t){let r=Vt(e),i=Fe.dirname(r);Ae.mkdirSync(i,{recursive:!0,mode:448}),dm(Fe.join(i,".gitignore")),cm(r,`${JSON.stringify(t,null,2)}
150
- `)}function dm(e){let t="";try{t=Ae.readFileSync(e,"utf-8")}catch(i){if(!Sr(i))throw i}t.split(`
151
- `).some(i=>i.trim()==="*")||Ae.writeFileSync(e,t&&!t.endsWith(`
144
+ `).trim()}async function mm(e){let{stdout:t}=await J("docker",["compose","ps","-a","-q"],{cwd:e});return t.trim().length>0}async function vt(e,t){let{stdout:r}=await J("docker",["compose","ps",e,"--format","{{.State}}"],{cwd:t});return r.split(`
145
+ `).some(i=>i.trim()==="running")}async function B(e,t,r={}){let{service:i="web",tty:n=!0,detach:s=!1,env:o}=r,a=["compose","exec"];if(s&&a.push("-d"),n||a.push("-T"),o)for(let[c,d]of Object.entries(o))a.push("-e",`${c}=${d}`);a.push(i,...e),await J("docker",a,{cwd:t,stdio:"inherit"})}async function qn(e){await B(["bin/rails","spree:admin:tailwindcss:build"],e,{tty:!1})}async function hm(e){await B(["bin/rails","spree:admin:tailwindcss:watch"],e,{detach:!0})}async function Ho(e,t,r={}){let{service:i="web",env:n,captureStderr:s=!1}=r,o=["compose","run","--rm"];if(n)for(let[c,d]of Object.entries(n))o.push("-e",`${c}=${d}`);o.push(i,...e),await J("docker",o,{cwd:t,...s?{stdin:"inherit",stdout:"inherit",stderr:["pipe","inherit"]}:{stdio:"inherit"}})}async function ut(e,t,r={}){let{service:i="web",env:n,edgeHint:s}=r;if(await vt(i,t)){await B(e,t,{service:i,env:n});return}Fe(t)&&(O([`The ${i} container is not running, and this is a monorepo edge project.`,`Run ${lm.default.bold("pnpm server:dev")} from the monorepo root${s?` \u2014 ${s}`:""}.`].join(`
146
+ `)),process.exit(1)),b.info(`${i} container is not running \u2014 using a one-off container (\`docker compose run\`) instead.`),await Ho(e,t,{service:i,env:n})}async function $n(e,t){await J("docker",["compose","logs","-f",e],{cwd:t,stdio:"inherit"})}var Ko=`http://localhost:${3e3}`,lt=class extends Error{};function ym(){return process.env.XDG_CONFIG_HOME?Be.join(process.env.XDG_CONFIG_HOME,"spree"):Be.join(jk.homedir(),".config","spree")}function St(){return Be.join(ym(),"config.json")}function Ar(e){return e?.code==="ENOENT"}function Cr(){let e;try{e=Ce.readFileSync(St(),"utf-8")}catch(t){if(Ar(t))return{profiles:{}};throw t}try{let t=JSON.parse(e);return{...t,profiles:t.profiles??{}}}catch{let t=`${St()}.bak`;try{Ce.renameSync(St(),t)}catch{}return process.stderr.write(`${$r.default.yellow(`warning: ${St()} was not valid JSON; moved it to ${t} and starting fresh.`)}
147
+ `),{profiles:{}}}}function Yo(e){Ce.mkdirSync(ym(),{recursive:!0,mode:448}),fm(St(),`${JSON.stringify(e,null,2)}
148
+ `)}function fm(e,t){Ce.writeFileSync(e,t,{mode:384}),Ce.chmodSync(e,384)}function Yt(e){return Be.join(e,".spree","credentials.json")}function Jo(e){return Be.join(e,".spree","setup-complete")}function gm(e){let t=Jo(e);Ce.mkdirSync(Be.dirname(t),{recursive:!0,mode:448}),_m(Be.join(Be.dirname(t),".gitignore")),Ce.writeFileSync(t,`${new Date().toISOString()}
149
+ `)}function Dk(e){let t;try{t=Ce.readFileSync(Yt(e),"utf-8")}catch(r){if(Ar(r))return null;throw r}try{return JSON.parse(t)}catch{return null}}function Lk(e,t){let r=Yt(e),i=Be.dirname(r);Ce.mkdirSync(i,{recursive:!0,mode:448}),_m(Be.join(i,".gitignore")),fm(r,`${JSON.stringify(t,null,2)}
150
+ `)}function _m(e){let t="";try{t=Ce.readFileSync(e,"utf-8")}catch(i){if(!Ar(i))throw i}t.split(`
151
+ `).some(i=>i.trim()==="*")||Ce.writeFileSync(e,t&&!t.endsWith(`
152
152
  `)?`${t}
153
153
  *
154
154
  `:`${t}*
155
- `)}function vn(e){return e.slice(0,12)}async function zo(e,t,r=!1){r||process.stderr.write(`${vr.default.dim("No credentials found \u2014 minting a read-only API key via the dev stack...")}
155
+ `)}function An(e){return e.slice(0,12)}async function Xo(e,t,r=!1){r||process.stderr.write(`${$r.default.dim("No credentials found \u2014 minting a read-only API key via the dev stack...")}
156
156
  `);let i;try{i=await ne("spree:cli:create_api_key",e,{NAME:"@spree/cli (auto)",KEY_TYPE:"secret",SCOPES:"read_all"})}catch(o){let a=o instanceof Error?o.message.split(`
157
157
  `)[0]:String(o);throw new lt(`Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.
158
- ${vr.default.dim(a)}`)}let n=i.match(/sk_[A-Za-z0-9_-]+/);if(!n)throw new lt("Could not mint an API key via the dev stack. Is it running? Start it with `spree dev`.");let s={baseUrl:`http://localhost:${t}`,token:n[0],scopes:["read_all"],mintedAt:new Date().toISOString()};return Ek(e,s),r||process.stderr.write(`${vr.default.dim("Saved to .spree/credentials.json (scopes: read_all)")}
159
- `),s}async function $r(e,t={}){let{allowMint:r=!0,cwd:i=process.cwd()}=t,n=qr(),s=e.baseUrl,o=e.apiKey,a;if(o&&(a={apiKey:o,source:"flags"}),!a&&e.profile){let p=n.profiles[e.profile];if(!p)throw new lt(`Unknown profile "${e.profile}". Run \`spree auth login --profile ${e.profile}\` to create it.`);a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:e.profile}}if(!a&&process.env.SPREE_API_KEY&&(a={baseUrl:process.env.SPREE_BASE_URL,apiKey:process.env.SPREE_API_KEY,source:"env"}),!a){let p,u=0;try{let l=_(i);p=l.projectDir,u=l.port}catch{}if(p){let l=`http://localhost:${u}`,m=!s||s.replace(/\/$/,"")===l,h=Ck(p);!h&&r&&m&&(h=await zo(p,u)),h&&(a={baseUrl:h.baseUrl,apiKey:h.token,source:"project",scopes:h.scopes})}}if(!a&&n.defaultProfile){let p=n.profiles[n.defaultProfile];p&&(a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:n.defaultProfile})}let c=s??a?.baseUrl,d=a?.apiKey;if(!c&&(a?.source==="flags"||a?.source==="env")&&(c=Uo),!c||!d)throw new lt(["No Admin API credentials found. Provide them via one of (host and key resolve together per source):"," - flags: --api-key <sk_...> (host defaults to "+Uo+"; pass --base-url for a remote store)"," - env: SPREE_API_KEY (host defaults to "+Uo+"; set SPREE_BASE_URL for a remote store)"," - project: run inside a Spree project with the dev stack up (auto-mints a read-only key)"," - profile: spree auth login --profile <name>"].join(`
160
- `));return{baseUrl:c,apiKey:d,source:a?.source??"flags",profileName:a?.profileName,tokenPrefix:vn(d),scopes:a?.scopes}}function mm(e){e.command("add").description("Add an optional component to your project").argument("<thing>","Component to add (currently: dashboard)").option("--template <src>","Starter template: git URL or local path (default: the template bundled with the CLI; env SPREE_DASHBOARD_TEMPLATE overrides)").option("--no-install","Skip dependency install").action(async(t,r)=>{t!=="dashboard"&&(console.error(`
161
- ${pe.default.red("Error:")} Unknown component: ${t}. Try: dashboard
162
- `),process.exit(2)),ni(pe.default.bgCyan(pe.default.black(" Spree Dashboard ")));let i=_();await Rk(i,{template:r.template??process.env.SPREE_DASHBOARD_TEMPLATE??Ik(),install:r.install}),Et("Done!")})}async function Rk(e,t){let r=se.join(e.projectDir,"apps","dashboard"),i=se.join(r,".env.local");if(re.existsSync(r)){let a=Cr(e.projectDir,e.port);if(a==="untouched"){b.warn(`${pe.default.bold("apps/dashboard/")} already exists. Nothing to do.`);return}um(e.projectDir,Ar(e.projectDir,r)),b.info(`${a==="written"?"Wrote missing":"Repaired"} ${pe.default.bold("apps/dashboard/.env.local")}. Nothing else to do.`);return}let n=E();n.start("Fetching dashboard starter...");try{await jk(t.template,r),Ok(r)}catch(a){n.stop("Fetch failed."),b.error(a instanceof Error?a.message:String(a)),process.exit(1)}n.stop(`Created ${pe.default.cyan("apps/dashboard/")}`),hm(i,e.port);let s=Ar(e.projectDir,r),o=um(e.projectDir,s);if(o==="amended"?b.info(`Amended ${pe.default.bold("render.yaml")}: the backend service now builds the dashboard and serves it at ${pe.default.cyan("/dashboard")} \u2014 same origin, nothing else to configure.`):o==="unrecognized"&&b.warn(`${pe.default.bold("render.yaml")} exists but doesn't match the starter Blueprint \u2014 left untouched. See the dashboard deployment docs to wire it up manually.`),t.install){n.start(`Installing dependencies with ${s}...`);try{await J(s,["install"],{cwd:r}),n.stop("Dependencies installed.")}catch(a){n.stop(pe.default.yellow(`${s} install failed \u2014 run it manually in apps/dashboard/.`)),b.warn(a instanceof Error?a.message:String(a))}}W(["Start it with:",` ${pe.default.cyan(`cd apps/dashboard && ${t.install?"":"pnpm install && "}pnpm dev`)}`,"",`Then open ${pe.default.bold(`http://localhost:${5173}`)} and sign in`,"with your admin email and password."].join(`
163
- `),"Dashboard added!")}function Ik(){let e=se.dirname(Tk(import.meta.url)),t=[se.resolve(e,"../../templates/dashboard-starter"),se.resolve(e,"templates/dashboard-starter")];for(let r of t)if(re.existsSync(se.join(r,"package.json")))return r;console.error(`
164
- ${pe.default.red("Error:")} Bundled dashboard template not found. In the monorepo, run ${pe.default.cyan("pnpm build")} in packages/cli first (it generates the template), or pass --template <path|git-url>.
165
- `),process.exit(1)}function um(e,t){let r=se.join(e,"render.yaml");if(!re.existsSync(r))return"no-blueprint";let i=re.readFileSync(r,"utf-8");if(i.includes("SPREE_DASHBOARD_DIST_PATH"))return"present";let n=t==="pnpm"?"corepack enable pnpm && pnpm install && VITE_BASE_PATH=/dashboard/ pnpm build":t==="yarn"?"yarn install && VITE_BASE_PATH=/dashboard/ yarn build":"npm install && VITE_BASE_PATH=/dashboard/ npm run build",s=/^([ \t]*)buildCommand:.*bundle install.*$/m;if(!s.exec(i))return"unrecognized";let a=i.replace(s,h=>`${h} && (cd ../apps/dashboard && ${n})`),c=/^([ \t]*)envVars:[ \t]*$/m,d=a.slice(a.indexOf("buildCommand:")),p=c.exec(d);if(!p)return"unrecognized";let u=`${p[1]} `,l=`${u}# Serve the dashboard built above at /dashboard (single node \u2014 same
158
+ ${$r.default.dim(a)}`)}let n=i.match(/sk_[A-Za-z0-9_-]+/);if(!n)throw new lt("Could not mint an API key via the dev stack. Is it running? Start it with `spree dev`.");let s={baseUrl:`http://localhost:${t}`,token:n[0],scopes:["read_all"],mintedAt:new Date().toISOString()};return Lk(e,s),r||process.stderr.write(`${$r.default.dim("Saved to .spree/credentials.json (scopes: read_all)")}
159
+ `),s}async function Er(e,t={}){let{allowMint:r=!0,cwd:i=process.cwd()}=t,n=Cr(),s=e.baseUrl,o=e.apiKey,a;if(o&&(a={apiKey:o,source:"flags"}),!a&&e.profile){let p=n.profiles[e.profile];if(!p)throw new lt(`Unknown profile "${e.profile}". Run \`spree auth login --profile ${e.profile}\` to create it.`);a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:e.profile}}if(!a&&process.env.SPREE_API_KEY&&(a={baseUrl:process.env.SPREE_BASE_URL,apiKey:process.env.SPREE_API_KEY,source:"env"}),!a){let p,u=0;try{let l=_(i);p=l.projectDir,u=l.port}catch{}if(p){let l=`http://localhost:${u}`,m=!s||s.replace(/\/$/,"")===l,h=Dk(p);!h&&r&&m&&(h=await Xo(p,u)),h&&(a={baseUrl:h.baseUrl,apiKey:h.token,source:"project",scopes:h.scopes})}}if(!a&&n.defaultProfile){let p=n.profiles[n.defaultProfile];p&&(a={baseUrl:p.baseUrl,apiKey:p.token,source:"profile",profileName:n.defaultProfile})}let c=s??a?.baseUrl,d=a?.apiKey;if(!c&&(a?.source==="flags"||a?.source==="env")&&(c=Ko),!c||!d)throw new lt(["No Admin API credentials found. Provide them via one of (host and key resolve together per source):"," - flags: --api-key <sk_...> (host defaults to "+Ko+"; pass --base-url for a remote store)"," - env: SPREE_API_KEY (host defaults to "+Ko+"; set SPREE_BASE_URL for a remote store)"," - project: run inside a Spree project with the dev stack up (auto-mints a read-only key)"," - profile: spree auth login --profile <name>"].join(`
160
+ `));return{baseUrl:c,apiKey:d,source:a?.source??"flags",profileName:a?.profileName,tokenPrefix:An(d),scopes:a?.scopes}}function xm(e){e.command("add").description("Add an optional component to your project").argument("<thing>","Component to add (currently: dashboard)").option("--template <src>","Starter template: git URL or local path (default: the template bundled with the CLI; env SPREE_DASHBOARD_TEMPLATE overrides)").option("--no-install","Skip dependency install").option("--quiet","Skip the final summary note (for wrapping tools that print their own)").action(async(t,r)=>{t!=="dashboard"&&(console.error(`
161
+ ${se.default.red("Error:")} Unknown component: ${t}. Try: dashboard
162
+ `),process.exit(2)),di(se.default.bgCyan(se.default.black(" Spree Dashboard ")));let i=_();await Fk(i,{template:r.template??process.env.SPREE_DASHBOARD_TEMPLATE??Bk(),install:r.install,quiet:r.quiet}),Tt("Done!")})}async function Fk(e,t){let r=oe.join(e.projectDir,"apps","dashboard"),i=oe.join(r,".env.local");if(re.existsSync(r)){let a=Pr(e.projectDir,e.port);if(a==="untouched"){b.warn(`${se.default.bold("apps/dashboard/")} already exists. Nothing to do.`);return}bm(e.projectDir,qt(e.projectDir,r)),b.info(`${a==="written"?"Wrote missing":"Repaired"} ${se.default.bold("apps/dashboard/.env.local")}. Nothing else to do.`);return}let n=E();n.start("Fetching dashboard starter...");try{await Nk(t.template,r),Uk(r)}catch(a){n.stop("Fetch failed."),b.error(a instanceof Error?a.message:String(a)),process.exit(1)}n.stop(`Created ${se.default.cyan("apps/dashboard/")}`),km(i,e.port);let s=qt(e.projectDir,r),o=bm(e.projectDir,s);if(o==="amended"?b.info(`Amended ${se.default.bold("render.yaml")}: the backend service now builds the dashboard and serves it at ${se.default.cyan("/dashboard")} \u2014 same origin, nothing else to configure.`):o==="unrecognized"&&b.warn(`${se.default.bold("render.yaml")} exists but doesn't match the starter Blueprint \u2014 left untouched. See the dashboard deployment docs to wire it up manually.`),t.install){n.start(`Installing dependencies with ${s}...`);try{await J(s,["install"],{cwd:r}),n.stop("Dependencies installed.")}catch(a){n.stop(se.default.yellow(`${s} install failed \u2014 run it manually in apps/dashboard/.`)),b.warn(a instanceof Error?a.message:String(a))}}t.quiet||W(["Start it with:",` ${se.default.cyan(`${s==="npm"?"npx":s} spree dev`)}`,` ${se.default.dim("# runs the API and the dashboard together")}`,...t.install?[]:[` ${se.default.dim(`# install dependencies first: cd apps/dashboard && ${s} install`)}`],"",`Then open ${se.default.bold(`http://localhost:${5173}`)} and sign in`,"with your admin email and password."].join(`
163
+ `),"Dashboard added!")}function Bk(){let e=oe.dirname(Mk(import.meta.url)),t=[oe.resolve(e,"../../templates/dashboard-starter"),oe.resolve(e,"templates/dashboard-starter")];for(let r of t)if(re.existsSync(oe.join(r,"package.json")))return r;console.error(`
164
+ ${se.default.red("Error:")} Bundled dashboard template not found. In the monorepo, run ${se.default.cyan("pnpm build")} in packages/cli first (it generates the template), or pass --template <path|git-url>.
165
+ `),process.exit(1)}function bm(e,t){let r=oe.join(e,"render.yaml");if(!re.existsSync(r))return"no-blueprint";let i=re.readFileSync(r,"utf-8");if(i.includes("SPREE_DASHBOARD_DIST_PATH"))return"present";let n=t==="pnpm"?"corepack enable pnpm && pnpm install && VITE_BASE_PATH=/dashboard/ pnpm build":t==="yarn"?"yarn install && VITE_BASE_PATH=/dashboard/ yarn build":"npm install && VITE_BASE_PATH=/dashboard/ npm run build",s=/^([ \t]*)buildCommand:.*bundle install.*$/m;if(!s.exec(i))return"unrecognized";let a=i.replace(s,h=>`${h} && (cd ../apps/dashboard && ${n})`),c=/^([ \t]*)envVars:[ \t]*$/m,d=a.slice(a.indexOf("buildCommand:")),p=c.exec(d);if(!p)return"unrecognized";let u=`${p[1]} `,l=`${u}# Serve the dashboard built above at /dashboard (single node \u2014 same
166
166
  ${u}# origin as the API, so no CORS or cookie configuration).
167
167
  ${u}- key: SPREE_DASHBOARD_DIST_PATH
168
168
  ${u} value: ../apps/dashboard/dist
169
169
  `,m=a.indexOf("buildCommand:")+p.index+p[0].length;return a=`${a.slice(0,m)}
170
- ${l.replace(/\n$/,"")}${a.slice(m)}`,re.writeFileSync(r,a),"amended"}function Ok(e){let t=se.join(e,"gitignore.template");re.existsSync(t)&&re.renameSync(t,se.join(e,".gitignore"))}async function jk(e,t){if(re.existsSync(e)&&re.statSync(e).isDirectory()){re.cpSync(e,t,{recursive:!0,filter:r=>{let i=se.basename(r);return i!=="node_modules"&&i!=="dist"&&i!==".git"}});return}await J("git",["clone","--depth","1","--",e,t]),re.rmSync(se.join(t,".git"),{recursive:!0,force:!0})}var lm=/^VITE_SPREE_API_URL=(https?:\/\/localhost\S*)$/m;function Cr(e,t){let r=se.join(e,"apps","dashboard");if(!re.existsSync(se.join(r,"package.json")))return"untouched";let i=se.join(r,".env.local"),n;try{n=re.readFileSync(i,"utf-8")}catch(s){if(!Sr(s))throw s;return hm(i,t),"written"}return lm.test(n)?(re.writeFileSync(i,n.replace(lm,`VITE_API_PROXY_TARGET=http://localhost:${t}`)),"repaired"):"untouched"}function hm(e,t){re.writeFileSync(e,["# Dev-server proxy target \u2014 where Vite forwards /api and /rails (your","# Rails backend). The SPA stays same-origin with the API: the SDK uses","# relative URLs and the proxy bridges the port gap.","#","# Do NOT set VITE_SPREE_API_URL for local dev \u2014 it switches the SDK to","# absolute cross-origin URLs, which breaks on CORS and the SameSite=Lax","# auth cookie. Set it only when building for a deploy where the","# dashboard is hosted on a different origin than the API.","#","# No credentials belong in this file \u2014 every VITE_-prefixed value is","# compiled into the client bundle.",`VITE_API_PROXY_TARGET=http://localhost:${t}`,""].join(`
171
- `))}function Ar(e,t){for(let r of[t,e]){if(re.existsSync(se.join(r,"pnpm-lock.yaml")))return"pnpm";if(re.existsSync(se.join(r,"yarn.lock")))return"yarn";if(re.existsSync(se.join(r,"package-lock.json")))return"npm"}return"pnpm"}function P(e){if(!e)return;let t={};return e.expand?.length&&(t.expand=e.expand.join(",")),e.fields?.length&&(t.fields=e.fields.join(",")),Object.keys(t).length>0?t:void 0}function Dk(e){return e===!1?!1:{maxRetries:e?.maxRetries??2,retryOnStatus:e?.retryOnStatus??[429,500,502,503,504],baseDelay:e?.baseDelay??300,maxDelay:e?.maxDelay??1e4,retryOnNetworkError:e?.retryOnNetworkError??!0}}var Lk=new Set(["page","limit","expand","sort","fields"]);function k(e){let t={};for(let[r,i]of Object.entries(e))if(i!==void 0){if(Lk.has(r)){t[r]=Array.isArray(i)?i.join(","):i;continue}if(r.startsWith("q[")){t[r]=i;continue}if(Array.isArray(i)){let n=r.endsWith("[]")?r.slice(0,-2):r;t[`q[${n}][]`]=i}else t[`q[${r}]`]=i}return t}var $t=class extends Error{code;status;details;constructor(e,t){super(e.error.message),this.name="SpreeError",this.code=e.error.code,this.status=t,this.details=e.error.details}};function ym(e,t){let r=t.baseDelay*2**e,i=Math.random()*t.baseDelay;return Math.min(r+i,t.maxDelay)}function fm(e){return new Promise(t=>setTimeout(t,e))}function Mk(){return`spree-sdk-retry-${crypto.randomUUID()}`}function Fk(e,t,r,i){return e==="GET"||e==="HEAD"||i?r.retryOnStatus.includes(t):t===429}function Bk(e,t,r){return t.retryOnNetworkError?e==="GET"||e==="HEAD"||r:!1}function Uk(e,t,r,i){return async function(s,o,a={}){let{token:c,spreeToken:d,idempotencyKey:p,headers:u={},body:l,params:m}=a,h=a.locale??i?.locale,f=a.currency??i?.currency,x=a.country??i?.country,w=a.channel??i?.channel,S=typeof window<"u"?window.location.origin:void 0,g=e.baseUrl||S;if(!g)throw new TypeError("sdk-core: baseUrl is required in non-browser environments (no window.location to resolve relative URLs against)");let R=new URL(`${e.baseUrl}${t}${o}`,g);m&&Object.entries(m).forEach(([H,$])=>{if($!==void 0)if(Array.isArray($))for(let Ge of $)R.searchParams.append(H,String(Ge));else R.searchParams.set(H,String($))});let v={"Content-Type":"application/json",...u};r.headerValue&&(v[r.headerName]=r.headerValue),c&&(v.Authorization=`Bearer ${c}`),d&&(v["x-spree-token"]=d),h&&(v["x-spree-locale"]=h),f&&(v["x-spree-currency"]=f),x&&(v["x-spree-country"]=x),w&&(v["x-spree-channel"]=w);let j=p??(s!=="GET"&&s!=="HEAD"&&e.retryConfig?Mk():void 0);j&&(v["Idempotency-Key"]=j);let L=!!j,G=e.retryConfig?e.retryConfig.maxRetries+1:1;for(let H=0;H<G;H++)try{let $=await e.fetchFn(R.toString(),{method:s,headers:v,body:l?JSON.stringify(l):void 0,credentials:e.credentials});if(!$.ok){if(!(H>=G-1)&&e.retryConfig&&Fk(s,$.status,e.retryConfig,L)){let V=$.headers.get("Retry-After"),ue=V?Math.min(parseInt(V,10)*1e3,e.retryConfig.maxDelay):ym(H,e.retryConfig);await fm(ue);continue}let ze=await $.json();throw new $t(ze,$.status)}return $.status===204?void 0:$.status===202?$.headers.get("content-type")?.includes("application/json")?$.json():void 0:$.json()}catch($){if($ instanceof $t)throw $;if(!(H>=G-1)&&e.retryConfig&&Bk(s,e.retryConfig,L)){let ze=ym(H,e.retryConfig);await fm(ze);continue}throw $}throw new Error("Unexpected end of retry loop")}}var qt={"Spree::Product":"/products","Spree::Variant":"/variants","Spree::Order":"/orders","Spree::User":"/customers","Spree::Category":"/categories","Spree::OptionType":"/option_types"},Nk=class{request;constructor(e){this.request=e}parentScopedCustomFields(e){return{list:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields`,{...i,params:r?k(r):void 0}),get:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields/${r}`,i),create:(t,r,i)=>this.request("POST",`${e}/${t}/custom_fields`,{...i,body:r}),update:(t,r,i,n)=>this.request("PATCH",`${e}/${t}/custom_fields/${r}`,{...n,body:i}),delete:(t,r,i)=>this.request("DELETE",`${e}/${t}/custom_fields/${r}`,i)}}parentScopedTranslations(e){return{get:(t,r)=>this.request("GET",`${e}/${t}/translations`,r).then(i=>i.data)}}customFields(e,t){let r=qt[e];if(!r)throw new Error(`Unknown custom-field owner type: ${e}. Add it to CUSTOM_FIELD_OWNER_PATHS.`);let i=this.parentScopedCustomFields(r);return{list:(n,s)=>i.list(t,n,s),get:(n,s)=>i.get(t,n,s),create:(n,s)=>i.create(t,n,s),update:(n,s,o)=>i.update(t,n,s,o),delete:(n,s)=>i.delete(t,n,s)}}customFieldDefinitions={list:(e,t)=>this.request("GET","/custom_field_definitions",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/custom_field_definitions/${e}`,t),create:(e,t)=>this.request("POST","/custom_field_definitions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/custom_field_definitions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/custom_field_definitions/${e}`,t)};auth={login:(e,t)=>this.request("POST","/auth/login",{...t,body:e}),refresh:e=>this.request("POST","/auth/refresh",e),logout:e=>this.request("POST","/auth/logout",e),lookupInvitation:(e,t,r)=>this.request("GET",`/auth/invitations/${e}/lookup`,{...r,params:{token:t}}),acceptInvitation:(e,t,r,i)=>this.request("POST",`/auth/invitations/${e}/accept`,{...i,params:{token:t},body:r}),requestPasswordReset:(e,t)=>this.request("POST","/auth/password_resets",{...t,body:e}),resetPassword:(e,t,r)=>this.request("PATCH",`/auth/password_resets/${encodeURIComponent(e)}`,{...r,body:t})};me={get:e=>this.request("GET","/me",e),update:(e,t)=>this.request("PATCH","/me",{...t,body:e})};dashboard={analytics:(e,t)=>this.request("GET","/dashboard/analytics",{...t,params:e})};store={get:e=>this.request("GET","/store",e),update:(e,t)=>this.request("PATCH","/store",{...t,body:e})};locales={list:e=>this.request("GET","/locales",e).then(t=>t.data)};translatableResources={list:e=>this.request("GET","/translatable_resources",e).then(t=>t.data)};translations={batch:(e,t)=>this.request("POST","/translations/batch",{...t,body:{translations:e}}).then(r=>r.data)};products={list:(e,t)=>this.request("GET","/products",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/products/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/products",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/products/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/products/${e}`,t),clone:(e,t)=>this.request("POST",`/products/${e}/clone`,t),bulkStatusUpdate:(e,t)=>this.request("POST","/products/bulk_status_update",{...t,body:e}),bulkAddToCategories:(e,t)=>this.request("POST","/products/bulk_add_to_categories",{...t,body:e}),bulkRemoveFromCategories:(e,t)=>this.request("POST","/products/bulk_remove_from_categories",{...t,body:e}),bulkAddToChannels:(e,t)=>this.request("POST","/products/bulk_add_to_channels",{...t,body:e}),bulkRemoveFromChannels:(e,t)=>this.request("POST","/products/bulk_remove_from_channels",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/products/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/products/bulk_remove_tags",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/products/bulk_destroy",{...t,body:e}),media:{list:(e,t,r)=>this.request("GET",`/products/${e}/media`,{...r,params:t?k(t):void 0}),create:(e,t,r)=>this.request("POST",`/products/${e}/media`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/media/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/media/${t}`,r)},variants:{list:(e,t,r)=>this.request("GET",`/products/${e}/variants`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/products/${e}/variants`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/variants/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/variants/${t}`,r),media:{list:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}/media`,{...i,params:r?k(r):void 0}),create:(e,t,r,i)=>this.request("POST",`/products/${e}/variants/${t}/media`,{...i,body:r}),update:(e,t,r,i,n)=>this.request("PATCH",`/products/${e}/variants/${t}/media/${r}`,{...n,body:i}),delete:(e,t,r,i)=>this.request("DELETE",`/products/${e}/variants/${t}/media/${r}`,i)}},customFields:this.parentScopedCustomFields(qt["Spree::Product"]),translations:this.parentScopedTranslations("/products")};orders={list:(e,t)=>this.request("GET","/orders",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/orders",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/orders/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/orders/${e}`,t),complete:(e,t,r)=>this.request("PATCH",`/orders/${e}/complete`,{...r,body:t}),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/cancel`,{...r,body:t}),approve:(e,t,r)=>this.request("PATCH",`/orders/${e}/approve`,{...r,body:t}),resume:(e,t)=>this.request("PATCH",`/orders/${e}/resume`,t),resendConfirmation:(e,t)=>this.request("POST",`/orders/${e}/resend_confirmation`,t),giftCards:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/gift_cards`,{...r,body:t}),remove:(e,t,r)=>this.request("DELETE",`/orders/${e}/gift_cards/${t}`,r)},storeCredits:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/store_credits`,{...r,body:t}),remove:(e,t)=>this.request("DELETE",`/orders/${e}/store_credits`,t)},items:{list:(e,t,r)=>this.request("GET",`/orders/${e}/items`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/items/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/items`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/items/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/orders/${e}/items/${t}`,r)},fulfillments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/fulfillments`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/fulfillments/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/fulfillments`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}`,{...i,body:r}),fulfill:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/fulfill`,r),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/cancel`,r),resume:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/resume`,r),split:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/split`,{...i,body:r})},payments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/payments`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/payments/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/payments`,{...r,body:t}),capture:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/capture`,r),void:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/void`,r)},refunds:{list:(e,t,r)=>this.request("GET",`/orders/${e}/refunds`,{...r,params:t?k(t):void 0}),create:(e,t,r)=>this.request("POST",`/orders/${e}/refunds`,{...r,body:t})},adjustments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments/${t}`,r)},customFields:this.parentScopedCustomFields(qt["Spree::Order"])};optionTypes={list:(e,t)=>this.request("GET","/option_types",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/option_types/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/option_types",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/option_types/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/option_types/${e}`,t),customFields:this.parentScopedCustomFields(qt["Spree::OptionType"]),translations:this.parentScopedTranslations("/option_types")};paymentMethods={list:(e,t)=>this.request("GET","/payment_methods",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/payment_methods/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/payment_methods",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/payment_methods/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/payment_methods/${e}`,t),types:e=>this.request("GET","/payment_methods/types",e)};priceLists={list:(e,t)=>this.request("GET","/price_lists",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/price_lists/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/price_lists",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/price_lists/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/price_lists/${e}`,t),activate:(e,t)=>this.request("PATCH",`/price_lists/${e}/activate`,t),deactivate:(e,t)=>this.request("PATCH",`/price_lists/${e}/deactivate`,t),ruleTypes:e=>this.request("GET","/price_lists/price_rule_types",e)};prices={list:(e,t)=>this.request("GET","/prices",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/prices/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/prices",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/prices/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/prices/${e}`,t),bulkUpsert:(e,t)=>this.request("POST","/prices/bulk_upsert",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/prices/bulk_destroy",{...t,body:e})};promotions={list:(e,t)=>this.request("GET","/promotions",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/promotions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/promotions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/promotions/${e}`,t),actions:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_actions`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_actions/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_actions/${t}`,r)},rules:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_rules`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_rules/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_rules/${t}`,r)},couponCodes:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes/${t}`,r)}};promotionActions={types:e=>this.request("GET","/promotion_actions/types",e),calculators:(e,t)=>this.request("GET","/promotion_actions/calculators",{...t,params:{type:e}})};promotionRules={types:e=>this.request("GET","/promotion_rules/types",e)};tags={list:(e,t)=>this.request("GET","/tags",{...t,params:e})};customerGroups={list:(e,t)=>this.request("GET","/customer_groups",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/customer_groups/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/customer_groups",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customer_groups/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customer_groups/${e}`,t)};giftCards={list:(e,t)=>this.request("GET","/gift_cards",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/gift_cards/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/gift_cards",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/gift_cards/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/gift_cards/${e}`,t)};giftCardBatches={list:(e,t)=>this.request("GET","/gift_card_batches",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/gift_card_batches/${e}`,t),create:(e,t)=>this.request("POST","/gift_card_batches",{...t,body:e})};exports={list:(e,t)=>this.request("GET","/exports",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/exports/${e}`,t),create:(e,t)=>this.request("POST","/exports",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/exports/${e}`,t)};imports={list:(e,t)=>this.request("GET","/imports",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/imports/${e}`,t),create:(e,t)=>this.request("POST","/imports",{...t,body:e}),completeMapping:(e,t,r)=>this.request("PATCH",`/imports/${e}/complete_mapping`,{...r,body:t??{}}),retryFailedRows:(e,t)=>this.request("PATCH",`/imports/${e}/retry_failed_rows`,t),delete:(e,t)=>this.request("DELETE",`/imports/${e}`,t),rows:{list:(e,t,r)=>this.request("GET",`/imports/${e}/rows`,{...r,params:t?k(t):void 0})}};customers={list:(e,t)=>this.request("GET","/customers",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/customers/${e}`,{...r,params:P(t)}),creditCards:{list:(e,t,r)=>this.request("GET",`/customers/${e}/credit_cards`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/credit_cards/${t}`,{...i,params:P(r)}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/credit_cards/${t}`,r)},create:(e,t)=>this.request("POST","/customers",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customers/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customers/${e}`,t),bulkAddToGroups:(e,t)=>this.request("POST","/customers/bulk_add_to_groups",{...t,body:e}),bulkRemoveFromGroups:(e,t)=>this.request("POST","/customers/bulk_remove_from_groups",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/customers/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/customers/bulk_remove_tags",{...t,body:e}),addresses:{list:(e,t,r)=>this.request("GET",`/customers/${e}/addresses`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/addresses/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/addresses`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/addresses/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/addresses/${t}`,r)},storeCredits:{list:(e,t,r)=>this.request("GET",`/customers/${e}/store_credits`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/store_credits/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/store_credits`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/store_credits/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/store_credits/${t}`,r)},customFields:this.parentScopedCustomFields(qt["Spree::User"])};categories={list:(e,t)=>this.request("GET","/categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/categories/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/categories",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/categories/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/categories/${e}`,t),reposition:(e,t,r)=>this.request("PATCH",`/categories/${e}/reposition`,{...r,body:t}),products:{list:(e,t,r)=>this.request("GET",`/categories/${e}/products`,{...r,params:t?k(t):void 0}),add:(e,t,r)=>this.request("POST",`/categories/${e}/products`,{...r,body:{product_id:t}}),remove:(e,t,r)=>this.request("DELETE",`/categories/${e}/products/${t}`,r),reposition:(e,t,r,i)=>this.request("PATCH",`/categories/${e}/products/${t}/reposition`,{...i,body:r})},customFields:this.parentScopedCustomFields(qt["Spree::Category"]),translations:this.parentScopedTranslations("/categories")};variants={list:(e,t)=>this.request("GET","/variants",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/variants/${e}`,{...r,params:P(t)}),customFields:this.parentScopedCustomFields(qt["Spree::Variant"])};taxCategories={list:(e,t)=>this.request("GET","/tax_categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/tax_categories/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/tax_categories",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/tax_categories/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/tax_categories/${e}`,t)};channels={list:(e,t)=>this.request("GET","/channels",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/channels/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/channels",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/channels/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/channels/${e}`,t),addProducts:(e,t,r)=>this.request("POST",`/channels/${e}/add_products`,{...r,body:t}),removeProducts:(e,t,r)=>this.request("POST",`/channels/${e}/remove_products`,{...r,body:t})};markets={list:(e,t)=>this.request("GET","/markets",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/markets/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/markets",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/markets/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/markets/${e}`,t)};storeCreditCategories={list:(e,t)=>this.request("GET","/store_credit_categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/store_credit_categories/${e}`,{...r,params:P(t)})};stockLocations={list:(e,t)=>this.request("GET","/stock_locations",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_locations/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/stock_locations",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/stock_locations/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_locations/${e}`,t)};stockItems={list:(e,t)=>this.request("GET","/stock_items",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_items/${e}`,{...r,params:P(t)}),update:(e,t,r)=>this.request("PATCH",`/stock_items/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_items/${e}`,t)};stockTransfers={list:(e,t)=>this.request("GET","/stock_transfers",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_transfers/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/stock_transfers",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/stock_transfers/${e}`,t)};countries={list:(e,t)=>this.request("GET","/countries",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/countries/${e}`,{...r,params:P(t)})};directUploads={create:(e,t)=>this.request("POST","/direct_uploads",{...t,body:e})};adminUsers={list:(e,t)=>this.request("GET","/admin_users",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/admin_users/${e}`,{...r,params:P(t)}),update:(e,t,r)=>this.request("PATCH",`/admin_users/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/admin_users/${e}`,t)};invitations={list:(e,t)=>this.request("GET","/invitations",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/invitations/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/invitations",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/invitations/${e}`,t),resend:(e,t)=>this.request("PATCH",`/invitations/${e}/resend`,t)};apiKeys={list:(e,t)=>this.request("GET","/api_keys",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/api_keys/${e}`,{...r,params:P(t)}),current:e=>this.request("GET","/api_keys/current",e??{}),create:(e,t)=>this.request("POST","/api_keys",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/api_keys/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/api_keys/${e}`,t),revoke:(e,t)=>this.request("PATCH",`/api_keys/${e}/revoke`,t)};allowedOrigins={list:(e,t)=>this.request("GET","/allowed_origins",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/allowed_origins/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/allowed_origins",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/allowed_origins/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/allowed_origins/${e}`,t)};webhookEndpoints={list:(e,t)=>this.request("GET","/webhook_endpoints",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/webhook_endpoints",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/webhook_endpoints/${e}`,t),sendTest:(e,t)=>this.request("POST",`/webhook_endpoints/${e}/send_test`,t),enable:(e,t)=>this.request("PATCH",`/webhook_endpoints/${e}/enable`,t),disable:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}/disable`,{...r,body:t}),deliveries:{list:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries/${t}`,r),redeliver:(e,t,r)=>this.request("POST",`/webhook_endpoints/${e}/deliveries/${t}/redeliver`,r)}};roles={list:(e,t)=>this.request("GET","/roles",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/roles/${e}`,{...r,params:P(t)})}};function Er(e){let t=e.baseUrl.replace(/\/$/,""),r=e.fetch||fetch.bind(globalThis),i=Dk(e.retry),n={baseUrl:t,fetchFn:r,retryConfig:i,credentials:e.credentials??"include"},s=e.jwtToken,o=e.storeId,a=null,c="/api/v3/admin",d=async(l,m,h={})=>{let f={};o&&(f["X-Spree-Store-Id"]=o);let x={...h,headers:{...f,...h.headers}},w=()=>{let S=e.secretKey?{headerName:"X-Spree-Api-Key",headerValue:e.secretKey}:{headerName:"Authorization",headerValue:s?`Bearer ${s}`:""};return Uk(n,c,S)(l,m,x)};try{return await w()}catch(S){if(S instanceof $t&&S.status===401&&a&&!m.includes("/auth/")&&await a())return w();throw S}},p=new Nk(d),u=Object.create(p);return u.setStore=l=>{o=l},u.setToken=l=>{s=l},u.onUnauthorized=l=>{a=l},u}var Km=U(jr(),1),Ee=U(Y(),1);var jm=U(Y(),1);import zv from"fs";var ca=Symbol("no-body");async function Dm(e){if(e===void 0)return ca;let t;if(e==="-")t=await Vv();else if(e.startsWith("@")){let r=e.slice(1);try{t=zv.readFileSync(r,"utf-8")}catch(i){throw i?.code==="ENOENT"?new Error(`Request body file not found: ${r}`):new Error(`Could not read request body file ${r}: ${i.message}`)}}else t=e;try{return JSON.parse(t)}catch{let r=e==="-"?" (from stdin)":e.startsWith("@")?` (${e.slice(1)})`:"";throw new Error(`Request body is not valid JSON${r}`)}}async function Vv(){process.stdin.isTTY&&process.stderr.write(`${jm.default.dim("Reading request body from stdin \u2014 paste JSON and press Ctrl-D...")}
172
- `);let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}var pa=U(jr(),1),fe=U(Y(),1);function Dr(e,t="json"){if(e!=null){if(t==="table"){let r=Kv(e);if(r){(0,pa.printTable)(r.map(Lm));return}let i=Lm(e);(0,pa.printTable)(Object.entries(i).map(([n,s])=>({field:n,value:s})));return}process.stdout.isTTY?process.stdout.write(`${Hv(JSON.stringify(e,null,2))}
170
+ ${l.replace(/\n$/,"")}${a.slice(m)}`,re.writeFileSync(r,a),"amended"}function Uk(e){let t=oe.join(e,"gitignore.template");re.existsSync(t)&&re.renameSync(t,oe.join(e,".gitignore"))}async function Nk(e,t){if(re.existsSync(e)&&re.statSync(e).isDirectory()){re.cpSync(e,t,{recursive:!0,filter:r=>{let i=oe.basename(r);return i!=="node_modules"&&i!=="dist"&&i!==".git"}});return}await J("git",["clone","--depth","1","--",e,t]),re.rmSync(oe.join(t,".git"),{recursive:!0,force:!0})}var wm=/^VITE_SPREE_API_URL=(https?:\/\/localhost\S*)$/m;function Pr(e,t){let r=oe.join(e,"apps","dashboard");if(!re.existsSync(oe.join(r,"package.json")))return"untouched";let i=oe.join(r,".env.local"),n;try{n=re.readFileSync(i,"utf-8")}catch(s){if(!Ar(s))throw s;return km(i,t),"written"}return wm.test(n)?(re.writeFileSync(i,n.replace(wm,`VITE_API_PROXY_TARGET=http://localhost:${t}`)),"repaired"):"untouched"}function km(e,t){re.writeFileSync(e,["# Dev-server proxy target \u2014 where Vite forwards /api and /rails (your","# Rails backend). The SPA stays same-origin with the API: the SDK uses","# relative URLs and the proxy bridges the port gap.","#","# Do NOT set VITE_SPREE_API_URL for local dev \u2014 it switches the SDK to","# absolute cross-origin URLs, which breaks on CORS and the SameSite=Lax","# auth cookie. Set it only when building for a deploy where the","# dashboard is hosted on a different origin than the API.","#","# No credentials belong in this file \u2014 every VITE_-prefixed value is","# compiled into the client bundle.",`VITE_API_PROXY_TARGET=http://localhost:${t}`,""].join(`
171
+ `))}function qt(e,t){for(let r of[t,e]){if(re.existsSync(oe.join(r,"pnpm-lock.yaml")))return"pnpm";if(re.existsSync(oe.join(r,"yarn.lock")))return"yarn";if(re.existsSync(oe.join(r,"package-lock.json")))return"npm"}return"pnpm"}function P(e){if(!e)return;let t={};return e.expand?.length&&(t.expand=e.expand.join(",")),e.fields?.length&&(t.fields=e.fields.join(",")),Object.keys(t).length>0?t:void 0}function Gk(e){return e===!1?!1:{maxRetries:e?.maxRetries??2,retryOnStatus:e?.retryOnStatus??[429,500,502,503,504],baseDelay:e?.baseDelay??300,maxDelay:e?.maxDelay??1e4,retryOnNetworkError:e?.retryOnNetworkError??!0}}var zk=new Set(["page","limit","expand","sort","fields"]);function k(e){let t={};for(let[r,i]of Object.entries(e))if(i!==void 0){if(zk.has(r)){t[r]=Array.isArray(i)?i.join(","):i;continue}if(r.startsWith("q[")){t[r]=i;continue}if(Array.isArray(i)){let n=r.endsWith("[]")?r.slice(0,-2):r;t[`q[${n}][]`]=i}else t[`q[${r}]`]=i}return t}var Ct=class extends Error{code;status;details;constructor(e,t){super(e.error.message),this.name="SpreeError",this.code=e.error.code,this.status=t,this.details=e.error.details}};function vm(e,t){let r=t.baseDelay*2**e,i=Math.random()*t.baseDelay;return Math.min(r+i,t.maxDelay)}function Sm(e){return new Promise(t=>setTimeout(t,e))}function Vk(){return`spree-sdk-retry-${crypto.randomUUID()}`}function Wk(e,t,r,i){return e==="GET"||e==="HEAD"||i?r.retryOnStatus.includes(t):t===429}function Hk(e,t,r){return t.retryOnNetworkError?e==="GET"||e==="HEAD"||r:!1}function Kk(e,t,r,i){return async function(s,o,a={}){let{token:c,spreeToken:d,idempotencyKey:p,headers:u={},body:l,params:m}=a,h=a.locale??i?.locale,f=a.currency??i?.currency,x=a.country??i?.country,w=a.channel??i?.channel,v=typeof window<"u"?window.location.origin:void 0,g=e.baseUrl||v;if(!g)throw new TypeError("sdk-core: baseUrl is required in non-browser environments (no window.location to resolve relative URLs against)");let R=new URL(`${e.baseUrl}${t}${o}`,g);m&&Object.entries(m).forEach(([H,$])=>{if($!==void 0)if(Array.isArray($))for(let Ge of $)R.searchParams.append(H,String(Ge));else R.searchParams.set(H,String($))});let S={"Content-Type":"application/json",...u};r.headerValue&&(S[r.headerName]=r.headerValue),c&&(S.Authorization=`Bearer ${c}`),d&&(S["x-spree-token"]=d),h&&(S["x-spree-locale"]=h),f&&(S["x-spree-currency"]=f),x&&(S["x-spree-country"]=x),w&&(S["x-spree-channel"]=w);let j=p??(s!=="GET"&&s!=="HEAD"&&e.retryConfig?Vk():void 0);j&&(S["Idempotency-Key"]=j);let L=!!j,G=e.retryConfig?e.retryConfig.maxRetries+1:1;for(let H=0;H<G;H++)try{let $=await e.fetchFn(R.toString(),{method:s,headers:S,body:l?JSON.stringify(l):void 0,credentials:e.credentials});if(!$.ok){if(!(H>=G-1)&&e.retryConfig&&Wk(s,$.status,e.retryConfig,L)){let V=$.headers.get("Retry-After"),ue=V?Math.min(parseInt(V,10)*1e3,e.retryConfig.maxDelay):vm(H,e.retryConfig);await Sm(ue);continue}let ze=await $.json();throw new Ct(ze,$.status)}return $.status===204?void 0:$.status===202?$.headers.get("content-type")?.includes("application/json")?$.json():void 0:$.json()}catch($){if($ instanceof Ct)throw $;if(!(H>=G-1)&&e.retryConfig&&Hk(s,e.retryConfig,L)){let ze=vm(H,e.retryConfig);await Sm(ze);continue}throw $}throw new Error("Unexpected end of retry loop")}}var At={"Spree::Product":"/products","Spree::Variant":"/variants","Spree::Order":"/orders","Spree::User":"/customers","Spree::Category":"/categories","Spree::OptionType":"/option_types"},Yk=class{request;constructor(e){this.request=e}parentScopedCustomFields(e){return{list:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields`,{...i,params:r?k(r):void 0}),get:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields/${r}`,i),create:(t,r,i)=>this.request("POST",`${e}/${t}/custom_fields`,{...i,body:r}),update:(t,r,i,n)=>this.request("PATCH",`${e}/${t}/custom_fields/${r}`,{...n,body:i}),delete:(t,r,i)=>this.request("DELETE",`${e}/${t}/custom_fields/${r}`,i)}}parentScopedTranslations(e){return{get:(t,r)=>this.request("GET",`${e}/${t}/translations`,r).then(i=>i.data)}}customFields(e,t){let r=At[e];if(!r)throw new Error(`Unknown custom-field owner type: ${e}. Add it to CUSTOM_FIELD_OWNER_PATHS.`);let i=this.parentScopedCustomFields(r);return{list:(n,s)=>i.list(t,n,s),get:(n,s)=>i.get(t,n,s),create:(n,s)=>i.create(t,n,s),update:(n,s,o)=>i.update(t,n,s,o),delete:(n,s)=>i.delete(t,n,s)}}customFieldDefinitions={list:(e,t)=>this.request("GET","/custom_field_definitions",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/custom_field_definitions/${e}`,t),create:(e,t)=>this.request("POST","/custom_field_definitions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/custom_field_definitions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/custom_field_definitions/${e}`,t)};auth={login:(e,t)=>this.request("POST","/auth/login",{...t,body:e}),refresh:e=>this.request("POST","/auth/refresh",e),logout:e=>this.request("POST","/auth/logout",e),lookupInvitation:(e,t,r)=>this.request("GET",`/auth/invitations/${e}/lookup`,{...r,params:{token:t}}),acceptInvitation:(e,t,r,i)=>this.request("POST",`/auth/invitations/${e}/accept`,{...i,params:{token:t},body:r}),requestPasswordReset:(e,t)=>this.request("POST","/auth/password_resets",{...t,body:e}),resetPassword:(e,t,r)=>this.request("PATCH",`/auth/password_resets/${encodeURIComponent(e)}`,{...r,body:t})};me={get:e=>this.request("GET","/me",e),update:(e,t)=>this.request("PATCH","/me",{...t,body:e})};dashboard={analytics:(e,t)=>this.request("GET","/dashboard/analytics",{...t,params:e})};store={get:e=>this.request("GET","/store",e),update:(e,t)=>this.request("PATCH","/store",{...t,body:e})};locales={list:e=>this.request("GET","/locales",e).then(t=>t.data)};translatableResources={list:e=>this.request("GET","/translatable_resources",e).then(t=>t.data)};translations={batch:(e,t)=>this.request("POST","/translations/batch",{...t,body:{translations:e}}).then(r=>r.data)};products={list:(e,t)=>this.request("GET","/products",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/products/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/products",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/products/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/products/${e}`,t),clone:(e,t)=>this.request("POST",`/products/${e}/clone`,t),bulkStatusUpdate:(e,t)=>this.request("POST","/products/bulk_status_update",{...t,body:e}),bulkAddToCategories:(e,t)=>this.request("POST","/products/bulk_add_to_categories",{...t,body:e}),bulkRemoveFromCategories:(e,t)=>this.request("POST","/products/bulk_remove_from_categories",{...t,body:e}),bulkAddToChannels:(e,t)=>this.request("POST","/products/bulk_add_to_channels",{...t,body:e}),bulkRemoveFromChannels:(e,t)=>this.request("POST","/products/bulk_remove_from_channels",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/products/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/products/bulk_remove_tags",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/products/bulk_destroy",{...t,body:e}),media:{list:(e,t,r)=>this.request("GET",`/products/${e}/media`,{...r,params:t?k(t):void 0}),create:(e,t,r)=>this.request("POST",`/products/${e}/media`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/media/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/media/${t}`,r)},variants:{list:(e,t,r)=>this.request("GET",`/products/${e}/variants`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/products/${e}/variants`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/products/${e}/variants/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/products/${e}/variants/${t}`,r),media:{list:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}/media`,{...i,params:r?k(r):void 0}),create:(e,t,r,i)=>this.request("POST",`/products/${e}/variants/${t}/media`,{...i,body:r}),update:(e,t,r,i,n)=>this.request("PATCH",`/products/${e}/variants/${t}/media/${r}`,{...n,body:i}),delete:(e,t,r,i)=>this.request("DELETE",`/products/${e}/variants/${t}/media/${r}`,i)}},customFields:this.parentScopedCustomFields(At["Spree::Product"]),translations:this.parentScopedTranslations("/products")};orders={list:(e,t)=>this.request("GET","/orders",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/orders",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/orders/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/orders/${e}`,t),complete:(e,t,r)=>this.request("PATCH",`/orders/${e}/complete`,{...r,body:t}),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/cancel`,{...r,body:t}),approve:(e,t,r)=>this.request("PATCH",`/orders/${e}/approve`,{...r,body:t}),resume:(e,t)=>this.request("PATCH",`/orders/${e}/resume`,t),resendConfirmation:(e,t)=>this.request("POST",`/orders/${e}/resend_confirmation`,t),giftCards:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/gift_cards`,{...r,body:t}),remove:(e,t,r)=>this.request("DELETE",`/orders/${e}/gift_cards/${t}`,r)},storeCredits:{apply:(e,t,r)=>this.request("POST",`/orders/${e}/store_credits`,{...r,body:t}),remove:(e,t)=>this.request("DELETE",`/orders/${e}/store_credits`,t)},items:{list:(e,t,r)=>this.request("GET",`/orders/${e}/items`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/items/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/items`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/items/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/orders/${e}/items/${t}`,r)},fulfillments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/fulfillments`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/fulfillments/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/fulfillments`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}`,{...i,body:r}),fulfill:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/fulfill`,r),cancel:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/cancel`,r),resume:(e,t,r)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/resume`,r),split:(e,t,r,i)=>this.request("PATCH",`/orders/${e}/fulfillments/${t}/split`,{...i,body:r})},payments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/payments`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/payments/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/orders/${e}/payments`,{...r,body:t}),capture:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/capture`,r),void:(e,t,r)=>this.request("PATCH",`/orders/${e}/payments/${t}/void`,r)},refunds:{list:(e,t,r)=>this.request("GET",`/orders/${e}/refunds`,{...r,params:t?k(t):void 0}),create:(e,t,r)=>this.request("POST",`/orders/${e}/refunds`,{...r,body:t})},adjustments:{list:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments/${t}`,r)},customFields:this.parentScopedCustomFields(At["Spree::Order"])};optionTypes={list:(e,t)=>this.request("GET","/option_types",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/option_types/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/option_types",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/option_types/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/option_types/${e}`,t),customFields:this.parentScopedCustomFields(At["Spree::OptionType"]),translations:this.parentScopedTranslations("/option_types")};paymentMethods={list:(e,t)=>this.request("GET","/payment_methods",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/payment_methods/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/payment_methods",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/payment_methods/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/payment_methods/${e}`,t),types:e=>this.request("GET","/payment_methods/types",e)};priceLists={list:(e,t)=>this.request("GET","/price_lists",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/price_lists/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/price_lists",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/price_lists/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/price_lists/${e}`,t),activate:(e,t)=>this.request("PATCH",`/price_lists/${e}/activate`,t),deactivate:(e,t)=>this.request("PATCH",`/price_lists/${e}/deactivate`,t),ruleTypes:e=>this.request("GET","/price_lists/price_rule_types",e)};prices={list:(e,t)=>this.request("GET","/prices",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/prices/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/prices",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/prices/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/prices/${e}`,t),bulkUpsert:(e,t)=>this.request("POST","/prices/bulk_upsert",{...t,body:e}),bulkDestroy:(e,t)=>this.request("DELETE","/prices/bulk_destroy",{...t,body:e})};promotions={list:(e,t)=>this.request("GET","/promotions",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/promotions",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/promotions/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/promotions/${e}`,t),actions:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_actions/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_actions`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_actions/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_actions/${t}`,r)},rules:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/promotion_rules/${t}`,r),create:(e,t,r)=>this.request("POST",`/promotions/${e}/promotion_rules`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/promotions/${e}/promotion_rules/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/promotions/${e}/promotion_rules/${t}`,r)},couponCodes:{list:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}/coupon_codes/${t}`,r)}};promotionActions={types:e=>this.request("GET","/promotion_actions/types",e),calculators:(e,t)=>this.request("GET","/promotion_actions/calculators",{...t,params:{type:e}})};promotionRules={types:e=>this.request("GET","/promotion_rules/types",e)};tags={list:(e,t)=>this.request("GET","/tags",{...t,params:e})};customerGroups={list:(e,t)=>this.request("GET","/customer_groups",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/customer_groups/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/customer_groups",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customer_groups/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customer_groups/${e}`,t)};giftCards={list:(e,t)=>this.request("GET","/gift_cards",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/gift_cards/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/gift_cards",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/gift_cards/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/gift_cards/${e}`,t)};giftCardBatches={list:(e,t)=>this.request("GET","/gift_card_batches",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/gift_card_batches/${e}`,t),create:(e,t)=>this.request("POST","/gift_card_batches",{...t,body:e})};exports={list:(e,t)=>this.request("GET","/exports",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/exports/${e}`,t),create:(e,t)=>this.request("POST","/exports",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/exports/${e}`,t)};imports={list:(e,t)=>this.request("GET","/imports",{...t,params:e?k(e):void 0}),get:(e,t)=>this.request("GET",`/imports/${e}`,t),create:(e,t)=>this.request("POST","/imports",{...t,body:e}),completeMapping:(e,t,r)=>this.request("PATCH",`/imports/${e}/complete_mapping`,{...r,body:t??{}}),retryFailedRows:(e,t)=>this.request("PATCH",`/imports/${e}/retry_failed_rows`,t),delete:(e,t)=>this.request("DELETE",`/imports/${e}`,t),rows:{list:(e,t,r)=>this.request("GET",`/imports/${e}/rows`,{...r,params:t?k(t):void 0})}};customers={list:(e,t)=>this.request("GET","/customers",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/customers/${e}`,{...r,params:P(t)}),creditCards:{list:(e,t,r)=>this.request("GET",`/customers/${e}/credit_cards`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/credit_cards/${t}`,{...i,params:P(r)}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/credit_cards/${t}`,r)},create:(e,t)=>this.request("POST","/customers",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/customers/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/customers/${e}`,t),bulkAddToGroups:(e,t)=>this.request("POST","/customers/bulk_add_to_groups",{...t,body:e}),bulkRemoveFromGroups:(e,t)=>this.request("POST","/customers/bulk_remove_from_groups",{...t,body:e}),bulkAddTags:(e,t)=>this.request("POST","/customers/bulk_add_tags",{...t,body:e}),bulkRemoveTags:(e,t)=>this.request("POST","/customers/bulk_remove_tags",{...t,body:e}),addresses:{list:(e,t,r)=>this.request("GET",`/customers/${e}/addresses`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/addresses/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/addresses`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/addresses/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/addresses/${t}`,r)},storeCredits:{list:(e,t,r)=>this.request("GET",`/customers/${e}/store_credits`,{...r,params:t?k(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/store_credits/${t}`,{...i,params:P(r)}),create:(e,t,r)=>this.request("POST",`/customers/${e}/store_credits`,{...r,body:t}),update:(e,t,r,i)=>this.request("PATCH",`/customers/${e}/store_credits/${t}`,{...i,body:r}),delete:(e,t,r)=>this.request("DELETE",`/customers/${e}/store_credits/${t}`,r)},customFields:this.parentScopedCustomFields(At["Spree::User"])};categories={list:(e,t)=>this.request("GET","/categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/categories/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/categories",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/categories/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/categories/${e}`,t),reposition:(e,t,r)=>this.request("PATCH",`/categories/${e}/reposition`,{...r,body:t}),products:{list:(e,t,r)=>this.request("GET",`/categories/${e}/products`,{...r,params:t?k(t):void 0}),add:(e,t,r)=>this.request("POST",`/categories/${e}/products`,{...r,body:{product_id:t}}),remove:(e,t,r)=>this.request("DELETE",`/categories/${e}/products/${t}`,r),reposition:(e,t,r,i)=>this.request("PATCH",`/categories/${e}/products/${t}/reposition`,{...i,body:r})},customFields:this.parentScopedCustomFields(At["Spree::Category"]),translations:this.parentScopedTranslations("/categories")};variants={list:(e,t)=>this.request("GET","/variants",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/variants/${e}`,{...r,params:P(t)}),customFields:this.parentScopedCustomFields(At["Spree::Variant"])};taxCategories={list:(e,t)=>this.request("GET","/tax_categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/tax_categories/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/tax_categories",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/tax_categories/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/tax_categories/${e}`,t)};channels={list:(e,t)=>this.request("GET","/channels",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/channels/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/channels",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/channels/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/channels/${e}`,t),addProducts:(e,t,r)=>this.request("POST",`/channels/${e}/add_products`,{...r,body:t}),removeProducts:(e,t,r)=>this.request("POST",`/channels/${e}/remove_products`,{...r,body:t})};markets={list:(e,t)=>this.request("GET","/markets",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/markets/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/markets",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/markets/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/markets/${e}`,t)};storeCreditCategories={list:(e,t)=>this.request("GET","/store_credit_categories",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/store_credit_categories/${e}`,{...r,params:P(t)})};stockLocations={list:(e,t)=>this.request("GET","/stock_locations",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_locations/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/stock_locations",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/stock_locations/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_locations/${e}`,t)};stockItems={list:(e,t)=>this.request("GET","/stock_items",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_items/${e}`,{...r,params:P(t)}),update:(e,t,r)=>this.request("PATCH",`/stock_items/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/stock_items/${e}`,t)};stockTransfers={list:(e,t)=>this.request("GET","/stock_transfers",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_transfers/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/stock_transfers",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/stock_transfers/${e}`,t)};countries={list:(e,t)=>this.request("GET","/countries",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/countries/${e}`,{...r,params:P(t)})};directUploads={create:(e,t)=>this.request("POST","/direct_uploads",{...t,body:e})};adminUsers={list:(e,t)=>this.request("GET","/admin_users",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/admin_users/${e}`,{...r,params:P(t)}),update:(e,t,r)=>this.request("PATCH",`/admin_users/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/admin_users/${e}`,t)};invitations={list:(e,t)=>this.request("GET","/invitations",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/invitations/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/invitations",{...t,body:e}),delete:(e,t)=>this.request("DELETE",`/invitations/${e}`,t),resend:(e,t)=>this.request("PATCH",`/invitations/${e}/resend`,t)};apiKeys={list:(e,t)=>this.request("GET","/api_keys",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/api_keys/${e}`,{...r,params:P(t)}),current:e=>this.request("GET","/api_keys/current",e??{}),create:(e,t)=>this.request("POST","/api_keys",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/api_keys/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/api_keys/${e}`,t),revoke:(e,t)=>this.request("PATCH",`/api_keys/${e}/revoke`,t)};allowedOrigins={list:(e,t)=>this.request("GET","/allowed_origins",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/allowed_origins/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/allowed_origins",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/allowed_origins/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/allowed_origins/${e}`,t)};webhookEndpoints={list:(e,t)=>this.request("GET","/webhook_endpoints",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}`,{...r,params:P(t)}),create:(e,t)=>this.request("POST","/webhook_endpoints",{...t,body:e}),update:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}`,{...r,body:t}),delete:(e,t)=>this.request("DELETE",`/webhook_endpoints/${e}`,t),sendTest:(e,t)=>this.request("POST",`/webhook_endpoints/${e}/send_test`,t),enable:(e,t)=>this.request("PATCH",`/webhook_endpoints/${e}/enable`,t),disable:(e,t,r)=>this.request("PATCH",`/webhook_endpoints/${e}/disable`,{...r,body:t}),deliveries:{list:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries`,{...r,params:t?k(t):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}/deliveries/${t}`,r),redeliver:(e,t,r)=>this.request("POST",`/webhook_endpoints/${e}/deliveries/${t}/redeliver`,r)}};roles={list:(e,t)=>this.request("GET","/roles",{...t,params:e?k(e):void 0}),get:(e,t,r)=>this.request("GET",`/roles/${e}`,{...r,params:P(t)})}};function Tr(e){let t=e.baseUrl.replace(/\/$/,""),r=e.fetch||fetch.bind(globalThis),i=Gk(e.retry),n={baseUrl:t,fetchFn:r,retryConfig:i,credentials:e.credentials??"include"},s=e.jwtToken,o=e.storeId,a=null,c="/api/v3/admin",d=async(l,m,h={})=>{let f={};o&&(f["X-Spree-Store-Id"]=o);let x={...h,headers:{...f,...h.headers}},w=()=>{let v=e.secretKey?{headerName:"X-Spree-Api-Key",headerValue:e.secretKey}:{headerName:"Authorization",headerValue:s?`Bearer ${s}`:""};return Kk(n,c,v)(l,m,x)};try{return await w()}catch(v){if(v instanceof Ct&&v.status===401&&a&&!m.includes("/auth/")&&await a())return w();throw v}},p=new Yk(d),u=Object.create(p);return u.setStore=l=>{o=l},u.setToken=l=>{s=l},u.onUnauthorized=l=>{a=l},u}var rh=M(Lr(),1),Pe=M(K(),1);var Gm=M(K(),1);import Xv from"fs";var ya=Symbol("no-body");async function zm(e){if(e===void 0)return ya;let t;if(e==="-")t=await Zv();else if(e.startsWith("@")){let r=e.slice(1);try{t=Xv.readFileSync(r,"utf-8")}catch(i){throw i?.code==="ENOENT"?new Error(`Request body file not found: ${r}`):new Error(`Could not read request body file ${r}: ${i.message}`)}}else t=e;try{return JSON.parse(t)}catch{let r=e==="-"?" (from stdin)":e.startsWith("@")?` (${e.slice(1)})`:"";throw new Error(`Request body is not valid JSON${r}`)}}async function Zv(){process.stdin.isTTY&&process.stderr.write(`${Gm.default.dim("Reading request body from stdin \u2014 paste JSON and press Ctrl-D...")}
172
+ `);let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}var fa=M(Lr(),1),ge=M(K(),1);function Mr(e,t="json"){if(e!=null){if(t==="table"){let r=tS(e);if(r){(0,fa.printTable)(r.map(Vm));return}let i=Vm(e);(0,fa.printTable)(Object.entries(i).map(([n,s])=>({field:n,value:s})));return}process.stdout.isTTY?process.stdout.write(`${eS(JSON.stringify(e,null,2))}
173
173
  `):process.stdout.write(`${JSON.stringify(e)}
174
- `)}}var Wv=/("(?:\\.|[^"\\])*"(\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function Hv(e){return e.replace(Wv,(t,r,i,n,s)=>r!==void 0?i?fe.default.cyan(r.slice(0,-i.length))+i:fe.default.green(r):n!==void 0?fe.default.yellow(n):s!==void 0?fe.default.yellow(s):t)}function Kv(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:null}function Lm(e){let t={};for(let[r,i]of Object.entries(e))i===null||["string","number","boolean"].includes(typeof i)?t[r]=i:Array.isArray(i)?t[r]=`[${i.length}]`:t[r]="{\u2026}";return t}function Ct(e,t={}){if(e instanceof $t){let i=e.details?`
175
- ${JSON.stringify({details:e.details},null,2)}`:"";process.stderr.write(`${fe.default.red(`${e.code}:`)} ${e.message}${i}
176
- `);let n=e.details?.required_scope;typeof n=="string"&&process.stderr.write(`${fe.default.dim(`Hint: this key lacks \`${n}\`. Create one that has it and use it:`)}
177
- ${fe.default.dim(` spree api-key create --type secret --scopes ${n}`)}
178
- ${fe.default.dim(" then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>")}
179
- `),process.exit(1)}if(e instanceof lt&&(process.stderr.write(`${fe.default.red("error:")} ${e.message}
180
- `),process.exit(2)),e instanceof TypeError&&/fetch failed/i.test(e.message)){let i=e.cause,n=i instanceof Error?i.message:i?String(i):"",s=t.baseUrl?` (${t.baseUrl})`:"";process.stderr.write(`${fe.default.red("error:")} could not reach the server${s}${n?`: ${n}`:""}
181
- `),process.stderr.write(`${fe.default.dim("Hint: check the URL, or run `spree api status` to diagnose reachability and credentials.")}
182
- `),process.exit(2)}let r=e instanceof Error?e.message:String(e);process.stderr.write(`${fe.default.red("error:")} ${r}
183
- `),process.exit(2)}function Fm(e){let t=new Map;for(let i of e.query??[]){let n=i.indexOf("=");if(n<=0)throw new Error(`Invalid -q expression "${i}" \u2014 expected key=value (e.g. -q status_eq=active)`);let s=i.slice(0,n),o=i.slice(n+1),a=t.get(s);a?a.push(o):t.set(s,[o])}let r={};for(let[i,n]of t)n.length>1?r[`q[${i}][]`]=n:r[`q[${i}]`]=n[0];return e.sort&&(r.sort=e.sort),e.page!==void 0&&(r.page=Mm(e.page,"--page")),e.limit!==void 0&&(r.limit=Mm(e.limit,"--limit")),e.expand&&(r.expand=e.expand),e.fields&&(r.fields=e.fields),r}function Mm(e,t){if(!/^[1-9]\d*$/.test(e))throw new Error(`Invalid ${t} "${e}" \u2014 expected a positive integer`);return Number(e)}function Lr(e){let t=e.startsWith("/")?e:`/${e}`,r="/api/v3/admin";return t===r?"/":t.startsWith(`${r}/`)?t.slice(r.length):t}var Yt=U(Y(),1);async function Mr(e,t){let r=Er({baseUrl:e,secretKey:t,retry:!1});try{return{status:"connected",storeName:(await r.request("GET","/store",{}))?.name}}catch(i){return i instanceof $t?i.status===401?{status:"unauthorized",message:i.message}:i.status===403?{status:"forbidden"}:{status:"unreachable",message:`server responded HTTP ${i.status}: ${i.message}`}:{status:"unreachable",message:i instanceof Error?i.message:String(i)}}}async function Bm(e,t){let r=Er({baseUrl:e,secretKey:t,retry:!1});try{return(await r.apiKeys.current()).scopes??null}catch{return null}}function qn(e){return e.status==="unauthorized"||e.status==="unreachable"}function $n(e){return{connected:Yt.default.green(`connected${e.storeName?` (${e.storeName})`:""}`),forbidden:Yt.default.green("connected")+Yt.default.dim(" (key valid; lacks read_settings for store details)"),unauthorized:Yt.default.red("key rejected (401)"),unreachable:Yt.default.red(`unreachable \u2014 ${e.message}`)}[e.status]}var Um={info:{title:"Admin API",contact:{name:"Spree Commerce",url:"https://spreecommerce.org",email:"hello@spreecommerce.org"},description:`Spree Admin API v3 - Administrative API for managing products, orders, and store settings.
174
+ `)}}var Qv=/("(?:\\.|[^"\\])*"(\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function eS(e){return e.replace(Qv,(t,r,i,n,s)=>r!==void 0?i?ge.default.cyan(r.slice(0,-i.length))+i:ge.default.green(r):n!==void 0?ge.default.yellow(n):s!==void 0?ge.default.yellow(s):t)}function tS(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:null}function Vm(e){let t={};for(let[r,i]of Object.entries(e))i===null||["string","number","boolean"].includes(typeof i)?t[r]=i:Array.isArray(i)?t[r]=`[${i.length}]`:t[r]="{\u2026}";return t}function Pt(e,t={}){if(e instanceof Ct){let i=e.details?`
175
+ ${JSON.stringify({details:e.details},null,2)}`:"";process.stderr.write(`${ge.default.red(`${e.code}:`)} ${e.message}${i}
176
+ `);let n=e.details?.required_scope;typeof n=="string"&&process.stderr.write(`${ge.default.dim(`Hint: this key lacks \`${n}\`. Create one that has it and use it:`)}
177
+ ${ge.default.dim(` spree api-key create --type secret --scopes ${n}`)}
178
+ ${ge.default.dim(" then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>")}
179
+ `),process.exit(1)}if(e instanceof lt&&(process.stderr.write(`${ge.default.red("error:")} ${e.message}
180
+ `),process.exit(2)),e instanceof TypeError&&/fetch failed/i.test(e.message)){let i=e.cause,n=i instanceof Error?i.message:i?String(i):"",s=t.baseUrl?` (${t.baseUrl})`:"";process.stderr.write(`${ge.default.red("error:")} could not reach the server${s}${n?`: ${n}`:""}
181
+ `),process.stderr.write(`${ge.default.dim("Hint: check the URL, or run `spree api status` to diagnose reachability and credentials.")}
182
+ `),process.exit(2)}let r=e instanceof Error?e.message:String(e);process.stderr.write(`${ge.default.red("error:")} ${r}
183
+ `),process.exit(2)}function Hm(e){let t=new Map;for(let i of e.query??[]){let n=i.indexOf("=");if(n<=0)throw new Error(`Invalid -q expression "${i}" \u2014 expected key=value (e.g. -q status_eq=active)`);let s=i.slice(0,n),o=i.slice(n+1),a=t.get(s);a?a.push(o):t.set(s,[o])}let r={};for(let[i,n]of t)n.length>1?r[`q[${i}][]`]=n:r[`q[${i}]`]=n[0];return e.sort&&(r.sort=e.sort),e.page!==void 0&&(r.page=Wm(e.page,"--page")),e.limit!==void 0&&(r.limit=Wm(e.limit,"--limit")),e.expand&&(r.expand=e.expand),e.fields&&(r.fields=e.fields),r}function Wm(e,t){if(!/^[1-9]\d*$/.test(e))throw new Error(`Invalid ${t} "${e}" \u2014 expected a positive integer`);return Number(e)}function Fr(e){let t=e.startsWith("/")?e:`/${e}`,r="/api/v3/admin";return t===r?"/":t.startsWith(`${r}/`)?t.slice(r.length):t}var Qt=M(K(),1);async function Br(e,t){let r=Tr({baseUrl:e,secretKey:t,retry:!1});try{return{status:"connected",storeName:(await r.request("GET","/store",{}))?.name}}catch(i){return i instanceof Ct?i.status===401?{status:"unauthorized",message:i.message}:i.status===403?{status:"forbidden"}:{status:"unreachable",message:`server responded HTTP ${i.status}: ${i.message}`}:{status:"unreachable",message:i instanceof Error?i.message:String(i)}}}async function Km(e,t){let r=Tr({baseUrl:e,secretKey:t,retry:!1});try{return(await r.apiKeys.current()).scopes??null}catch{return null}}function En(e){return e.status==="unauthorized"||e.status==="unreachable"}function Pn(e){return{connected:Qt.default.green(`connected${e.storeName?` (${e.storeName})`:""}`),forbidden:Qt.default.green("connected")+Qt.default.dim(" (key valid; lacks read_settings for store details)"),unauthorized:Qt.default.red("key rejected (401)"),unreachable:Qt.default.red(`unreachable \u2014 ${e.message}`)}[e.status]}var Ym={info:{title:"Admin API",contact:{name:"Spree Commerce",url:"https://spreecommerce.org",email:"hello@spreecommerce.org"},description:`Spree Admin API v3 - Administrative API for managing products, orders, and store settings.
184
184
 
185
185
  ## Authentication
186
186
 
@@ -361,29 +361,29 @@ accepts Spree's payloads.
361
361
  repeated delivery failures), no notification email is sent.
362
362
 
363
363
 
364
- **Required scope:** \`write_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint disabled",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{reason:{type:"string"}}}}}}}},"/api/v3/admin/categories":{get:{summary:"List categories",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of the store's categories (manual hierarchical taxons; rule-based collections are excluded).\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., children, parent, ancestors).",schema:{type:"string"}}],responses:{"200":{description:"categories found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Category"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a category. Nests under the parent when parent_id is given, otherwise creates a top-level category.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"category created",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},parent_id:{type:"string",description:"Prefixed ID of the parent category"},description:{type:"string"},permalink:{type:"string"},meta_title:{type:"string"},meta_description:{type:"string"},meta_keywords:{type:"string"},hide_from_nav:{type:"boolean"}},required:["name"]}}}}}},"/api/v3/admin/categories/{id}":{get:{summary:"Get a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single category by ID.\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., children, parent, ancestors).",schema:{type:"string"}}],responses:{"200":{description:"category found",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}},"404":{description:"category not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a category.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"category updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},parent_id:{type:"string",description:"Prefixed ID of the parent category"},description:{type:"string"},permalink:{type:"string"},meta_title:{type:"string"},meta_description:{type:"string"},meta_keywords:{type:"string"},hide_from_nav:{type:"boolean"}}}}}}},delete:{summary:"Delete a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a category and its descendants.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"204":{description:"category deleted"}}}},"/api/v3/admin/categories/{id}/reposition":{patch:{summary:"Reposition a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Moves a category to a new parent and/or index within the tree.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"category repositioned",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{new_parent_id:{type:"string",description:"Prefixed ID of the new parent (omit for top level)"},new_position:{type:"integer",description:"0-based index among the new parent's children"}},required:["new_position"]}}}}}},"/api/v3/admin/categories/{category_id}/products":{get:{summary:"List category products",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Products classified under the category, ordered by their classification position.\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"products found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Product"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Add a product to a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Classifies a product under the category (appended to the end).\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"201":{description:"product added",content:{"application/json":{schema:{$ref:"#/components/schemas/Product"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{product_id:{type:"string"}},required:["product_id"]}}}}}},"/api/v3/admin/categories/{category_id}/products/{id}/reposition":{patch:{summary:"Reposition a category product",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Moves a product to a new index among the category's products.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}}],responses:{"204":{description:"product repositioned"}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{new_position:{type:"integer",description:"0-based index among the category's products"}},required:["new_position"]}}}}}},"/api/v3/admin/imports":{get:{summary:"List imports",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns CSV imports queued or completed for the current store.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"imports found",content:{"application/json":{}}}}},post:{summary:"Create an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Queues a CSV import. Upload the file first via `POST /api/v3/admin/direct_uploads`\nand pass the returned `signed_id` as `attachment`. On success the import is in the\n`mapping` state and the response carries the mapping payload: `schema_fields`\n(the canonical columns for the type), `csv_headers`, a `sample_row`, and the\nauto-assigned `mappings`.\n\nAdjust mappings if needed, then call `PATCH /admin/imports/{id}/complete_mapping`\nto start processing. Poll `GET /admin/imports/{id}` while `status` is\n`completed_mapping`/`processing`; terminal statuses are `completed` and `failed`.\n\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"import created in mapping state",content:{"application/json":{}}},"422":{description:"unknown import type",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["type","attachment"],properties:{type:{type:"string",enum:["Spree::Imports::Products","Spree::Imports::Customers","Spree::Imports::ProductTranslations"]},attachment:{type:"string",description:"ActiveStorage signed blob id from POST /api/v3/admin/direct_uploads."},preferred_delimiter:{type:"string",enum:[",",";","|"," "],description:"CSV column separator. Defaults to a comma."},results_url:{type:"string",description:"Absolute URL of your admin imports view; the import-done email links back to it with `?import=<id>` appended. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/imports/template":{get:{summary:"Download an import template",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a CSV header row for the given import type, including the custom field columns available for the model.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"type",in:"query",required:!0,description:"Registered import type, e.g. Spree::Imports::Products.",schema:{type:"string"}}],responses:{"200":{description:"CSV template",content:{"application/json":{},"text/csv":{schema:{type:"string",format:"binary"}}}}}}},"/api/v3/admin/imports/{id}":{get:{summary:"Show an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns import status and row counters. The admin dashboard polls this endpoint while `status` is `completed_mapping` or `processing`; `rows_count`, `completed_rows_count` and `failed_rows_count` drive the progress bar. The mapping payload (`csv_headers`, `sample_row`) is only present while `status` is `mapping`.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"import found",content:{"application/json":{}}}}},delete:{summary:"Delete an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the import, its rows and the uploaded file. Returns 422 while the import is being processed.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"import deleted"}}}},"/api/v3/admin/imports/{id}/download":{get:{summary:"Download the originally uploaded file",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Streams the CSV exactly as it was uploaded \u2014 the audit trail for what was imported. JWT/API-key protected; SPA clients fetch it with the Authorization header and trigger the browser download via a Blob URL.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"CSV file",content:{"application/json":{},"text/csv":{schema:{type:"string",format:"binary"}}}}}}},"/api/v3/admin/imports/{id}/complete_mapping":{patch:{summary:"Complete mapping and start processing",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Applies the submitted column mappings, then starts row processing. Omit `mappings`\nto accept the auto-assigned ones from the create response. Returns 422 when a\nrequired schema field is left unmapped (`details.missing_required_fields`) or a\nfile column is assigned twice.\n\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"mapping completed, processing queued",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{mappings:{type:"array",description:"Column assignments to apply before starting. `file_column: null` unmaps a field.",items:{type:"object",required:["schema_field"],properties:{schema_field:{type:"string"},file_column:{type:"string",nullable:!0}}}}}}}}}}},"/api/v3/admin/imports/{id}/retry_failed_rows":{patch:{summary:"Retry failed rows",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Re-processes the rows that failed. The import re-enters `processing`; poll `GET /admin/imports/{id}` until it completes again. Returns 422 when the import is not `completed` or has no failed rows.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"retry queued",content:{"application/json":{}}}}}},"/api/v3/admin/imports/{import_id}/rows":{get:{summary:"List import rows",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Paginated rows of an import \u2014 the failure report. Filter with `q[status_eq]=failed` to list only rows that could not be imported; each row carries the raw CSV `data` and its `validation_errors`.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"import_id",in:"path",required:!0,schema:{type:"string"}},{name:"q[status_eq]",in:"query",required:!1,description:"Filter rows by status: pending, processing, completed, failed.",schema:{type:"string"}}],responses:{"200":{description:"rows found",content:{"application/json":{}}}}}}},components:{schemas:{PaginationMeta:{type:"object",properties:{page:{type:"integer"},limit:{type:"integer"},count:{type:"integer",description:"Total number of records"},pages:{type:"integer",description:"Total number of pages"},from:{type:"integer",description:"Index of first record on this page"},to:{type:"integer",description:"Index of last record on this page"},in:{type:"integer",description:"Number of records on this page"},previous:{type:"integer",nullable:!0,description:"Previous page number"},next:{type:"integer",nullable:!0,description:"Next page number"}},required:["page","limit","count","pages","from","to","in"]},ErrorResponse:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"},details:{type:"object",description:"Field-specific validation errors",nullable:!0}},required:["code","message"]}},required:["error"]},AuthResponse:{type:"object",properties:{token:{type:"string",description:"JWT access token"},user:{$ref:"#/components/schemas/AdminUser"}},required:["token","user"]},PermissionRule:{type:"object",description:"A single permission rule (CanCanCan rule). Rules are applied in order, last-matching-wins.",properties:{allow:{type:"boolean",description:"true for `can`, false for `cannot`"},actions:{type:"array",items:{type:"string"},description:'Action names, e.g. ["read", "update"] or ["manage"]'},subjects:{type:"array",items:{type:"string"},description:'Subject class names, e.g. ["Spree::Product"] or ["all"]'},has_conditions:{type:"boolean",description:"True if the server-side rule has per-record conditions. The SPA shows the action optimistically and handles 403 from the API."}},required:["allow","actions","subjects","has_conditions"]},MeResponse:{type:"object",description:"Current admin user profile and serialized permissions",properties:{user:{$ref:"#/components/schemas/AdminUser"},permissions:{type:"array",items:{$ref:"#/components/schemas/PermissionRule"}}},required:["user","permissions"]},ImportSchemaField:{type:"object",description:"A canonical column of an import type, including per-store custom field columns",properties:{name:{type:"string",description:"Canonical field name used in mappings"},label:{type:"string",description:"Human-readable label"},required:{type:"boolean",description:"Whether the field must be mapped before processing"}},required:["name","label","required"]},CheckoutRequirement:{type:"object",properties:{step:{type:"string",description:"Checkout step this requirement belongs to"},field:{type:"string",description:"Field that needs to be satisfied"},message:{type:"string",description:"Human-readable requirement message"}},required:["step","field","message"]},CartWarning:{type:"object",description:"A warning about a cart issue (e.g., item removed due to stock change)",properties:{code:{type:"string",description:"Machine-readable warning code"},message:{type:"string",description:"Human-readable warning message"},line_item_id:{type:"string",nullable:!0,description:"Prefixed line item ID (when applicable)"},variant_id:{type:"string",nullable:!0,description:"Prefixed variant ID (when applicable)"}},required:["code","message"]},FulfillmentManifestItem:{type:"object",description:"An item within a fulfillment \u2014 which line item and how many units are in this fulfillment",properties:{item_id:{type:"string",description:"Line item ID"},variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer",description:"Quantity in this fulfillment"}},required:["item_id","variant_id","quantity"]},AdminUserRoleAssignment:{type:"object",description:"A role assignment for the current store on a staff member",properties:{id:{type:"string",description:"Prefixed role ID"},name:{type:"string",description:"Role name"}},required:["id","name"]},PreferenceField:{type:"object",description:"A single configurable preference on a payment method, promotion rule/action, or calculator. The frontend uses `type` + `default` to render a sensible input.",properties:{key:{type:"string"},type:{type:"string",description:"string | text | password | integer | decimal | boolean | array | hash"},default:{description:"Default value (any JSON type), null when there is no default",nullable:!0}},required:["key","type"]},PromotionActionCalculator:{type:"object",description:"The action's nested calculator (when the action carries one \u2014 null for actions like `free_shipping`)",properties:{type:{type:"string",description:"Wire shorthand for the calculator subclass"},label:{type:"string"},preferences:{type:"object",additionalProperties:!0},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}}},required:["type","label","preferences","preference_schema"]},PromotionActionLineItem:{type:"object",description:"One row in a `create_line_items` action \u2014 the variant added to the order and how many",properties:{variant_id:{type:"string"},quantity:{type:"integer"}},required:["variant_id","quantity"]},Address:{type:"object",properties:{id:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string"},address1:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},postal_code:{type:"string",nullable:!0},city:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},country_name:{type:"string"},country_iso:{type:"string"},state_text:{type:"string",nullable:!0},state_abbr:{type:"string",nullable:!0},quick_checkout:{type:"boolean"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"},state_name:{type:"string",nullable:!0},label:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0}},required:["id","first_name","last_name","full_name","address1","address2","postal_code","city","phone","company","country_name","country_iso","state_text","state_abbr","quick_checkout","is_default_billing","is_default_shipping","state_name","label","metadata","created_at","updated_at","customer_id"],"x-typelizer":!0},Adjustment:{type:"object",properties:{id:{type:"string"},label:{type:"string"},display_amount:{type:"string"},included:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","label","display_amount","included","created_at","updated_at","amount","order_id"],"x-typelizer":!0},AdminUser:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string",nullable:!0},selected_locale:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},avatar_url:{type:"string",nullable:!0},roles:{type:"array",items:{$ref:"#/components/schemas/AdminUserRoleAssignment"}}},required:["id","email","first_name","last_name","full_name","selected_locale","created_at","updated_at","avatar_url","roles"],"x-typelizer":!0},AllowedOrigin:{type:"object",properties:{id:{type:"string"},origin:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","origin","created_at","updated_at"],"x-typelizer":!0},ApiKey:{type:"object",properties:{id:{type:"string"},name:{type:"string"},key_type:{type:"string"},token_prefix:{type:"string",nullable:!0},scopes:{type:"array",items:{type:"string"}},created_at:{type:"string"},updated_at:{type:"string"},revoked_at:{type:"string",nullable:!0},last_used_at:{type:"string",nullable:!0},plaintext_token:{type:"string",nullable:!0},created_by_email:{type:"string",nullable:!0}},required:["id","name","key_type","token_prefix","scopes","created_at","updated_at","revoked_at","last_used_at","plaintext_token","created_by_email"],"x-typelizer":!0},Category:{type:"object",properties:{id:{type:"string"},name:{type:"string"},permalink:{type:"string"},position:{type:"number"},depth:{type:"number"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},children_count:{type:"number"},parent_id:{type:"string",nullable:!0},description:{type:"string"},description_html:{type:"string"},image_url:{type:"string",nullable:!0},square_image_url:{type:"string",nullable:!0},is_root:{type:"boolean"},is_child:{type:"boolean"},is_leaf:{type:"boolean"},parent:{$ref:"#/components/schemas/Category"},children:{type:"array",items:{$ref:"#/components/schemas/Category"}},ancestors:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},translations:{type:"object"},metadata:{type:"object"},pretty_name:{type:"string"},lft:{type:"number"},rgt:{type:"number"},products_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","permalink","position","depth","meta_title","meta_description","meta_keywords","children_count","parent_id","description","description_html","image_url","square_image_url","is_root","is_child","is_leaf","metadata","pretty_name","lft","rgt","products_count","created_at","updated_at"],"x-typelizer":!0},Channel:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string"},active:{type:"boolean"},default:{type:"boolean"},preferred_order_routing_strategy:{type:"string",nullable:!0},preferred_storefront_access:{type:"string",nullable:!0},preferred_guest_checkout:{type:"boolean",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","active","default","preferred_order_routing_strategy","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at"],"x-typelizer":!0},Country:{type:"object",properties:{iso:{type:"string"},iso3:{type:"string"},name:{type:"string"},states_required:{type:"boolean"},zipcode_required:{type:"boolean"},states:{type:"array",items:{$ref:"#/components/schemas/State"}},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["iso","iso3","name","states_required","zipcode_required","created_at","updated_at"],"x-typelizer":!0},CouponCode:{type:"object",properties:{id:{type:"string"},code:{type:"string"},state:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},promotion_id:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","code","state","created_at","updated_at","promotion_id","order_id"],"x-typelizer":!0},CreditCard:{type:"object",properties:{id:{type:"string"},brand:{type:"string"},last4:{type:"string"},month:{type:"number"},year:{type:"number"},name:{type:"string",nullable:!0},default:{type:"boolean"},gateway_payment_profile_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},payment_method_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","brand","last4","month","year","name","default","gateway_payment_profile_id","customer_id","payment_method_id","metadata","created_at","updated_at"],"x-typelizer":!0},CustomFieldDefinition:{type:"object",properties:{id:{type:"string"},namespace:{type:"string"},key:{type:"string"},label:{type:"string"},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},resource_type:{type:"string"},storefront_visible:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","namespace","key","label","field_type","resource_type","storefront_visible","created_at","updated_at"],"x-typelizer":!0},CustomField:{type:"object",properties:{id:{type:"string"},label:{type:"string"},type:{type:"string",deprecated:!0},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},key:{type:"string"},value:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},storefront_visible:{type:"boolean"},custom_field_definition_id:{type:"string"}},required:["id","label","type","field_type","key","value","created_at","updated_at","storefront_visible","custom_field_definition_id"],"x-typelizer":!0},CustomerGroup:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},customers_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","name","description","customers_count","created_at","updated_at"],"x-typelizer":!0},Customer:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},accepts_email_marketing:{type:"boolean"},full_name:{type:"string"},available_store_credit_total:{type:"string"},display_available_store_credit_total:{type:"string"},addresses:{type:"array",items:{$ref:"#/components/schemas/Address"}},default_billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},default_shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},login:{type:"string",nullable:!0},metadata:{type:"object"},last_sign_in_at:{type:"string",nullable:!0},current_sign_in_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},sign_in_count:{type:"number"},failed_attempts:{type:"number"},last_sign_in_ip:{type:"string",nullable:!0},current_sign_in_ip:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note_html:{type:"string",nullable:!0},default_billing_address_id:{type:"string",nullable:!0},default_shipping_address_id:{type:"string",nullable:!0},orders_count:{type:"number"},total_spent:{type:"string"},display_total_spent:{type:"string"},last_order_completed_at:{type:"string",nullable:!0},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}},store_credits:{type:"array",items:{$ref:"#/components/schemas/StoreCredit"}},customer_group_ids:{type:"array",items:{type:"string"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}}},required:["id","email","first_name","last_name","phone","accepts_email_marketing","full_name","available_store_credit_total","display_available_store_credit_total","login","metadata","last_sign_in_at","current_sign_in_at","created_at","updated_at","sign_in_count","failed_attempts","last_sign_in_ip","current_sign_in_ip","tags","internal_note_html","default_billing_address_id","default_shipping_address_id","orders_count","total_spent","display_total_spent","last_order_completed_at","customer_group_ids"],"x-typelizer":!0},DeliveryMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","created_at","updated_at"],"x-typelizer":!0},DeliveryRate:{type:"object",properties:{id:{type:"string"},delivery_method_id:{type:"string"},name:{type:"string"},selected:{type:"boolean"},cost:{type:"string"},total:{type:"string"},additional_tax_total:{type:"string"},included_tax_total:{type:"string"},tax_total:{type:"string"},display_cost:{type:"string"},display_total:{type:"string"},display_additional_tax_total:{type:"string"},display_included_tax_total:{type:"string"},display_tax_total:{type:"string"},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","delivery_method_id","name","selected","cost","total","additional_tax_total","included_tax_total","tax_total","display_cost","display_total","display_additional_tax_total","display_included_tax_total","display_tax_total","created_at","updated_at"],"x-typelizer":!0},DigitalLink:{type:"object",properties:{id:{type:"string"},access_counter:{type:"number"},filename:{type:"string"},content_type:{type:"string"},download_url:{type:"string"},authorizable:{type:"boolean"},expired:{type:"boolean"},access_limit_exceeded:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","access_counter","filename","content_type","download_url","authorizable","expired","access_limit_exceeded","created_at","updated_at"],"x-typelizer":!0},Discount:{type:"object",properties:{id:{type:"string"},promotion_id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},amount:{type:"string"},display_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","promotion_id","name","description","code","amount","display_amount","created_at","updated_at"],"x-typelizer":!0},Export:{type:"object",properties:{id:{type:"string"},number:{type:"string"},type:{type:"string",nullable:!0},format:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},user_id:{type:"string",nullable:!0},done:{type:"boolean"},filename:{type:"string",nullable:!0},byte_size:{type:"number",nullable:!0},download_url:{type:"string",nullable:!0}},required:["id","number","type","format","created_at","updated_at","user_id","done","filename","byte_size","download_url"],"x-typelizer":!0},Fulfillment:{type:"object",properties:{id:{type:"string"},number:{type:"string"},tracking:{type:"string",nullable:!0},tracking_url:{type:"string",nullable:!0},cost:{type:"string"},display_cost:{type:"string"},total:{type:"string"},display_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},status:{type:"string"},fulfillment_type:{type:"string"},fulfilled_at:{type:"string",nullable:!0},items:{type:"array",items:{$ref:"#/components/schemas/FulfillmentManifestItem"}},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},stock_location:{$ref:"#/components/schemas/StockLocation"},delivery_rates:{type:"array",items:{$ref:"#/components/schemas/DeliveryRate"}},metadata:{type:"object"},adjustment_total:{type:"string"},pre_tax_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","number","tracking","tracking_url","cost","display_cost","total","display_total","discount_total","display_discount_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","tax_total","display_tax_total","status","fulfillment_type","fulfilled_at","items","metadata","adjustment_total","pre_tax_amount","created_at","updated_at","order_id","stock_location_id"],"x-typelizer":!0},GiftCardBatch:{type:"object",properties:{id:{type:"string"},codes_count:{type:"number"},currency:{type:"string",nullable:!0},prefix:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0}},required:["id","codes_count","currency","prefix","created_at","updated_at","amount","expires_at","created_by_id"],"x-typelizer":!0},GiftCard:{type:"object",properties:{id:{type:"string"},code:{type:"string"},status:{type:"string"},currency:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_authorized:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},expires_at:{type:"string",nullable:!0},redeemed_at:{type:"string",nullable:!0},expired:{type:"boolean"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/AdminUser"},gift_card_batch:{$ref:"#/components/schemas/GiftCardBatch"},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}}},required:["id","code","status","currency","amount","amount_used","amount_authorized","amount_remaining","display_amount","display_amount_used","display_amount_remaining","expires_at","redeemed_at","expired","active","created_at","updated_at","customer_id","created_by_id"],"x-typelizer":!0},ImportMapping:{type:"object",properties:{id:{type:"string"},schema_field:{type:"string"},file_column:{type:"string",nullable:!0},required:{type:"boolean"}},required:["id","schema_field","file_column","required"],"x-typelizer":!0},ImportRow:{type:"object",properties:{id:{type:"string"},row_number:{type:"number"},status:{type:"string"},validation_errors:{type:"string",nullable:!0},item_type:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},import_id:{type:"string",nullable:!0},item_id:{type:"string",nullable:!0},data:{type:"object"}},required:["id","row_number","status","validation_errors","item_type","created_at","updated_at","import_id","item_id","data"],"x-typelizer":!0},Import:{type:"object",properties:{id:{type:"string"},number:{type:"string"},type:{type:"string",nullable:!0},rows_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},status:{type:"string"},owner_type:{type:"string",nullable:!0},owner_id:{type:"string",nullable:!0},user_id:{type:"string",nullable:!0},processing_errors:{type:"string",nullable:!0},preferred_delimiter:{type:"string"},original_filename:{type:"string",nullable:!0},original_byte_size:{type:"number",nullable:!0},original_file_url:{type:"string",nullable:!0},completed_rows_count:{type:"number"},failed_rows_count:{type:"number"},schema_fields:{type:"array",items:{$ref:"#/components/schemas/ImportSchemaField"}},csv_headers:{type:"array",items:{type:"string"}},sample_row:{type:"object"},mappings:{type:"array",items:{$ref:"#/components/schemas/ImportMapping"}}},required:["id","number","type","rows_count","created_at","updated_at","status","owner_type","owner_id","user_id","processing_errors","preferred_delimiter","original_filename","original_byte_size","original_file_url","completed_rows_count","failed_rows_count","schema_fields","csv_headers","sample_row","mappings"],"x-typelizer":!0},Invitation:{type:"object",properties:{id:{type:"string"},email:{type:"string"},status:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},expires_at:{type:"string"},role_id:{type:"string"},role_name:{type:"string"},inviter_email:{type:"string"},acceptance_url:{type:"string"},invitee_exists:{type:"boolean"},store:{type:"object"}},required:["id","email","status","created_at","updated_at","expires_at","role_id","role_name","inviter_email","acceptance_url","invitee_exists","store"],"x-typelizer":!0},LineItem:{type:"object",properties:{id:{type:"string"},variant_id:{type:"string"},preorder:{type:"boolean"},preorder_ships_at:{type:"string",nullable:!0},quantity:{type:"number"},currency:{type:"string"},name:{type:"string"},slug:{type:"string"},options_text:{type:"string"},price:{type:"string"},display_price:{type:"string"},total:{type:"string"},display_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},pre_tax_amount:{type:"string"},display_pre_tax_amount:{type:"string"},discounted_amount:{type:"string"},display_discounted_amount:{type:"string"},display_compare_at_amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0},thumbnail_url:{type:"string",nullable:!0},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},digital_links:{type:"array",items:{$ref:"#/components/schemas/DigitalLink"}},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},cost_price:{type:"string",nullable:!0},tax_category_id:{type:"string",nullable:!0},variant:{$ref:"#/components/schemas/Variant"},tax_category:{$ref:"#/components/schemas/TaxCategory"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","variant_id","preorder","preorder_ships_at","quantity","currency","name","slug","options_text","price","display_price","total","display_total","adjustment_total","display_adjustment_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","discount_total","display_discount_total","pre_tax_amount","display_pre_tax_amount","discounted_amount","display_discounted_amount","display_compare_at_amount","compare_at_amount","thumbnail_url","option_values","digital_links","metadata","created_at","updated_at","cost_price","tax_category_id"],"x-typelizer":!0},Market:{type:"object",properties:{id:{type:"string"},name:{type:"string"},currency:{type:"string"},default_locale:{type:"string"},tax_inclusive:{type:"boolean"},default:{type:"boolean"},country_isos:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","currency","default_locale","tax_inclusive","default","country_isos","supported_locales","created_at","updated_at"],"x-typelizer":!0},Media:{type:"object",properties:{id:{type:"string"},product_id:{type:"string",nullable:!0},variant_ids:{type:"array",items:{type:"string"}},position:{type:"number"},alt:{type:"string",nullable:!0},media_type:{type:"string"},focal_point_x:{type:"number",nullable:!0},focal_point_y:{type:"number",nullable:!0},external_video_url:{type:"string",nullable:!0},original_url:{type:"string",nullable:!0},mini_url:{type:"string",nullable:!0},small_url:{type:"string",nullable:!0},medium_url:{type:"string",nullable:!0},large_url:{type:"string",nullable:!0},xlarge_url:{type:"string",nullable:!0},og_image_url:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},viewable_id:{type:"string"},download_url:{type:"string",nullable:!0},metadata:{type:"object"},viewable_type:{type:"string"}},required:["id","product_id","variant_ids","position","alt","media_type","focal_point_x","focal_point_y","external_video_url","original_url","mini_url","small_url","medium_url","large_url","xlarge_url","og_image_url","created_at","updated_at","viewable_id","download_url","metadata","viewable_type"],"x-typelizer":!0},OptionType:{type:"object",properties:{id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},kind:{type:"string"},translations:{type:"object"},metadata:{type:"object"},filterable:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}}},required:["id","name","label","position","kind","metadata","filterable","created_at","updated_at"],"x-typelizer":!0},OptionValue:{type:"object",properties:{id:{type:"string"},option_type_id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},color_code:{type:"string",nullable:!0},option_type_name:{type:"string"},option_type_label:{type:"string"},image_url:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},option_type:{$ref:"#/components/schemas/OptionType"}},required:["id","option_type_id","name","label","position","color_code","option_type_name","option_type_label","image_url","metadata","created_at","updated_at"],"x-typelizer":!0},Order:{type:"object",properties:{id:{type:"string"},market_id:{type:"string",nullable:!0},channel_id:{type:"string",nullable:!0},number:{type:"string"},email:{type:"string"},customer_note:{type:"string",nullable:!0},currency:{type:"string"},locale:{type:"string",nullable:!0},total_quantity:{type:"number"},fulfillment_status:{type:"string",nullable:!0},payment_status:{type:"string",nullable:!0},completed_at:{type:"string",nullable:!0},item_total:{type:"string"},display_item_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},total:{type:"string"},display_total:{type:"string"},gift_card_total:{type:"string"},display_gift_card_total:{type:"string"},amount_due:{type:"string"},display_amount_due:{type:"string"},delivery_total:{type:"string"},display_delivery_total:{type:"string"},store_credit_total:{type:"string"},display_store_credit_total:{type:"string"},covered_by_store_credit:{type:"boolean"},discounts:{type:"array",items:{$ref:"#/components/schemas/Discount"}},items:{type:"array",items:{$ref:"#/components/schemas/LineItem"}},fulfillments:{type:"array",items:{$ref:"#/components/schemas/Fulfillment"}},payments:{type:"array",items:{$ref:"#/components/schemas/Payment"}},billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},gift_card:{allOf:[{$ref:"#/components/schemas/GiftCard"}],nullable:!0},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},status:{type:"string"},last_ip_address:{type:"string",nullable:!0},considered_risky:{type:"boolean"},confirmation_delivered:{type:"boolean"},store_owner_notification_delivered:{type:"boolean"},payment_total:{type:"string"},display_payment_total:{type:"string"},metadata:{type:"object"},canceled_at:{type:"string",nullable:!0},approved_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},preferred_stock_location_id:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note:{type:"string",nullable:!0},approver_id:{type:"string",nullable:!0},canceler_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},channel:{$ref:"#/components/schemas/Channel"},preferred_stock_location:{$ref:"#/components/schemas/StockLocation"},payment_methods:{type:"array",items:{$ref:"#/components/schemas/PaymentMethod"}},customer:{$ref:"#/components/schemas/Customer"},approver:{$ref:"#/components/schemas/Customer"},canceler:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/Customer"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}},return_authorizations:{type:"array",items:{$ref:"#/components/schemas/ReturnAuthorization"}},reimbursements:{type:"array",items:{$ref:"#/components/schemas/Reimbursement"}}},required:["id","market_id","channel_id","number","email","customer_note","currency","locale","total_quantity","fulfillment_status","payment_status","completed_at","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","gift_card","market","status","last_ip_address","considered_risky","confirmation_delivered","store_owner_notification_delivered","payment_total","display_payment_total","metadata","canceled_at","approved_at","created_at","updated_at","preferred_stock_location_id","tags","internal_note","approver_id","canceler_id","created_by_id","customer_id"],"x-typelizer":!0},PaymentMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},type:{type:"string"},session_required:{type:"boolean"},source_required:{type:"boolean"},metadata:{type:"object"},active:{type:"boolean"},auto_capture:{type:"boolean",nullable:!0},storefront_visible:{type:"boolean"},position:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},preferences:{type:"object"},preference_schema:{type:"object"}},required:["id","name","description","type","session_required","source_required","metadata","active","auto_capture","storefront_visible","position","created_at","updated_at","preferences","preference_schema"],"x-typelizer":!0},Payment:{type:"object",properties:{id:{type:"string"},payment_method_id:{type:"string"},response_code:{type:"string",nullable:!0},number:{type:"string"},amount:{type:"string"},display_amount:{type:"string"},status:{type:"string"},source_type:{type:"string",nullable:!0,enum:["credit_card","store_credit","payment_source"]},source_id:{type:"string",nullable:!0},source:{anyOf:[{$ref:"#/components/schemas/CreditCard"},{$ref:"#/components/schemas/StoreCredit"},{$ref:"#/components/schemas/PaymentSource"}],nullable:!0},payment_method:{$ref:"#/components/schemas/PaymentMethod"},metadata:{type:"object"},avs_response:{type:"string",nullable:!0},cvv_response_code:{type:"string",nullable:!0},cvv_response_message:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},captured_amount:{type:"string"},order_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},refunds:{type:"array",items:{$ref:"#/components/schemas/Refund"}}},required:["id","payment_method_id","response_code","number","amount","display_amount","status","source_type","source_id","source","metadata","avs_response","cvv_response_code","cvv_response_message","created_at","updated_at","captured_amount","order_id"],"x-typelizer":!0},PaymentSource:{type:"object",properties:{id:{type:"string"},gateway_payment_profile_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","gateway_payment_profile_id","metadata","created_at","updated_at"],"x-typelizer":!0},PriceHistory:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_in_cents:{type:"number"},currency:{type:"string"},display_amount:{type:"string"},recorded_at:{type:"string"},variant_id:{type:"string"},price_id:{type:"string"},compare_at_amount:{type:"string",nullable:!0},created_at:{type:"string"}},required:["id","amount","amount_in_cents","currency","display_amount","recorded_at","variant_id","price_id","compare_at_amount","created_at"],"x-typelizer":!0},PriceList:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},status:{type:"string"},position:{type:"number"},match_policy:{type:"string"},starts_at:{type:"string",nullable:!0},ends_at:{type:"string",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},currently_active:{type:"boolean"},products_count:{type:"number"},prices_count:{type:"number"},product_ids:{type:"array",items:{type:"string"}},price_rules:{type:"array",items:{$ref:"#/components/schemas/PriceRule"}}},required:["id","name","description","status","position","match_policy","starts_at","ends_at","deleted_at","created_at","updated_at","currently_active","products_count","prices_count","product_ids"],"x-typelizer":!0},PriceRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},price_list_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},description:{type:"string",nullable:!0},markets:{type:"array",items:{$ref:"#/components/schemas/Market"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","created_at","updated_at","type","price_list_id","preferences","preference_schema","label","description"],"x-typelizer":!0},Price:{type:"object",properties:{id:{type:"string"},amount:{type:"string",nullable:!0},amount_in_cents:{type:"number",nullable:!0},compare_at_amount:{type:"string",nullable:!0},compare_at_amount_in_cents:{type:"number",nullable:!0},currency:{type:"string",nullable:!0},display_amount:{type:"string",nullable:!0},display_compare_at_amount:{type:"string",nullable:!0},price_list_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","amount","amount_in_cents","compare_at_amount","compare_at_amount_in_cents","currency","display_amount","display_compare_at_amount","price_list_id","variant_id","created_at","updated_at"],"x-typelizer":!0},ProductPublication:{type:"object",properties:{id:{type:"string"},published_at:{type:"string",nullable:!0},unpublished_at:{type:"string",nullable:!0},product_id:{type:"string"},channel_id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","published_at","unpublished_at","product_id","channel_id","created_at","updated_at"],"x-typelizer":!0},Product:{type:"object",properties:{id:{type:"string"},name:{type:"string"},slug:{type:"string"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},variant_count:{type:"number"},available_on:{type:"string",nullable:!0},preorder_ships_at:{type:"string",nullable:!0},purchasable:{type:"boolean"},preorder:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},available:{type:"boolean"},description:{type:"string",nullable:!0},description_html:{type:"string",nullable:!0},default_variant_id:{type:"string"},thumbnail_url:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},variants:{type:"array",items:{$ref:"#/components/schemas/Variant"}},default_variant:{$ref:"#/components/schemas/Variant"},option_types:{type:"array",items:{$ref:"#/components/schemas/OptionType"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},translations:{type:"object"},status:{type:"string"},metadata:{type:"object"},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},tax_category_id:{type:"string",nullable:!0},product_publications:{type:"array",items:{$ref:"#/components/schemas/ProductPublication"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}}},required:["id","name","slug","meta_title","meta_description","meta_keywords","variant_count","available_on","preorder_ships_at","purchasable","preorder","in_stock","backorderable","available","description","description_html","default_variant_id","thumbnail_url","tags","price","original_price","status","metadata","deleted_at","created_at","updated_at","tax_category_id"],"x-typelizer":!0},PromotionAction:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},calculator:{allOf:[{$ref:"#/components/schemas/PromotionActionCalculator"}],nullable:!0},line_items:{type:"array",items:{$ref:"#/components/schemas/PromotionActionLineItem"},nullable:!0}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","calculator","line_items"],"x-typelizer":!0},PromotionRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},product_ids:{type:"array",items:{type:"string"},nullable:!0},category_ids:{type:"array",items:{type:"string"},nullable:!0},customer_ids:{type:"array",items:{type:"string"},nullable:!0},products:{type:"array",items:{$ref:"#/components/schemas/Product"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}},markets:{type:"array",items:{$ref:"#/components/schemas/Market"}}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","product_ids","category_ids","customer_ids"],"x-typelizer":!0},Promotion:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},starts_at:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},usage_limit:{type:"number",nullable:!0},match_policy:{type:"string",enum:["all","any"]},path:{type:"string",nullable:!0},kind:{type:"string",enum:["coupon_code","automatic"]},multi_codes:{type:"boolean"},number_of_codes:{type:"number",nullable:!0},code_prefix:{type:"string",nullable:!0},promotion_category_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},action_ids:{type:"array",items:{type:"string"}},rule_ids:{type:"array",items:{type:"string"}}},required:["id","name","description","code","starts_at","expires_at","usage_limit","match_policy","path","kind","multi_codes","number_of_codes","code_prefix","promotion_category_id","metadata","created_at","updated_at","action_ids","rule_ids"],"x-typelizer":!0},Refund:{type:"object",properties:{id:{type:"string"},transaction_id:{type:"string",nullable:!0},amount:{type:"string",nullable:!0},payment_id:{type:"string",nullable:!0},refund_reason_id:{type:"string",nullable:!0},reimbursement_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},payment:{$ref:"#/components/schemas/Payment"},reimbursement:{$ref:"#/components/schemas/Reimbursement"}},required:["id","transaction_id","amount","payment_id","refund_reason_id","reimbursement_id","metadata","created_at","updated_at"],"x-typelizer":!0},Reimbursement:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reimbursement_status:{type:"string",nullable:!0},total:{type:"string",nullable:!0},order_id:{type:"string",nullable:!0},customer_return_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"}},required:["id","number","reimbursement_status","total","order_id","customer_return_id","created_at","updated_at"],"x-typelizer":!0},ReturnAuthorization:{type:"object",properties:{id:{type:"string"},number:{type:"string"},status:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},return_authorization_reason_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"},stock_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","status","order_id","stock_location_id","return_authorization_reason_id","created_at","updated_at"],"x-typelizer":!0},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","created_at","updated_at"],"x-typelizer":!0},SetupTask:{type:"object",properties:{name:{type:"string"},done:{type:"boolean"}},required:["name","done"],"x-typelizer":!0},State:{type:"object",properties:{abbr:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["abbr","name","created_at","updated_at"],"x-typelizer":!0},StockItem:{type:"object",properties:{id:{type:"string"},count_on_hand:{type:"number"},backorderable:{type:"boolean"},stock_location_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},allocated_count:{type:"number"},available_count:{type:"number"},stock_location:{$ref:"#/components/schemas/StockLocation"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","count_on_hand","backorderable","stock_location_id","variant_id","metadata","created_at","updated_at","allocated_count","available_count"],"x-typelizer":!0},StockLocation:{type:"object",properties:{id:{type:"string"},state_abbr:{type:"string",nullable:!0},name:{type:"string"},address1:{type:"string",nullable:!0},city:{type:"string",nullable:!0},zipcode:{type:"string",nullable:!0},country_iso:{type:"string",nullable:!0},country_name:{type:"string",nullable:!0},state_text:{type:"string",nullable:!0},admin_name:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},state_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},active:{type:"boolean"},default:{type:"boolean"},backorderable_default:{type:"boolean"},propagate_all_variants:{type:"boolean"},kind:{type:"string"},pickup_enabled:{type:"boolean"},pickup_stock_policy:{type:"string"},pickup_ready_in_minutes:{type:"number",nullable:!0},pickup_instructions:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","state_abbr","name","address1","city","zipcode","country_iso","country_name","state_text","admin_name","address2","state_name","phone","company","active","default","backorderable_default","propagate_all_variants","kind","pickup_enabled","pickup_stock_policy","pickup_ready_in_minutes","pickup_instructions","created_at","updated_at"],"x-typelizer":!0},StockReservation:{type:"object",properties:{id:{type:"string"},stock_item_id:{type:"string"},line_item_id:{type:"string"},order_id:{type:"string"},variant_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},quantity:{type:"number"},expires_at:{type:"string"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","stock_item_id","line_item_id","order_id","variant_id","stock_location_id","quantity","expires_at","active","created_at","updated_at"],"x-typelizer":!0},StockTransfer:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reference:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},source_location_id:{type:"string",nullable:!0},destination_location_id:{type:"string",nullable:!0},source_location:{$ref:"#/components/schemas/StockLocation"},destination_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","reference","metadata","created_at","updated_at","source_location_id","destination_location_id"],"x-typelizer":!0},StoreCreditCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},non_expiring:{type:"boolean"}},required:["id","name","created_at","updated_at","non_expiring"],"x-typelizer":!0},StoreCredit:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},currency:{type:"string"},memo:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},category_id:{type:"string",nullable:!0},category_name:{type:"string",nullable:!0}},required:["id","amount","amount_used","amount_remaining","display_amount","display_amount_used","display_amount_remaining","currency","memo","metadata","created_at","updated_at","customer_id","created_by_id","category_id","category_name"],"x-typelizer":!0},Store:{type:"object",properties:{id:{type:"string"},metadata:{type:"object"},name:{type:"string"},code:{type:"string"},preferred_storefront_url:{type:"string",nullable:!0},default_currency:{type:"string"},default_locale:{type:"string"},mail_from_address:{type:"string",nullable:!0},customer_support_email:{type:"string",nullable:!0},new_order_notifications_email:{type:"string",nullable:!0},preferred_send_consumer_transactional_emails:{type:"boolean"},preferred_admin_locale:{type:"string",nullable:!0},preferred_timezone:{type:"string"},preferred_weight_unit:{type:"string"},preferred_unit_system:{type:"string"},preferred_storefront_access:{type:"string"},preferred_guest_checkout:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},url:{type:"string"},api_url:{type:"string"},setup_tasks:{type:"array",items:{$ref:"#/components/schemas/SetupTask"}},supported_currencies:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},available_locales:{type:"array",items:{type:"string"}},logo_url:{type:"string",nullable:!0},mailer_logo_url:{type:"string",nullable:!0}},required:["id","metadata","name","code","preferred_storefront_url","default_currency","default_locale","mail_from_address","customer_support_email","new_order_notifications_email","preferred_send_consumer_transactional_emails","preferred_admin_locale","preferred_timezone","preferred_weight_unit","preferred_unit_system","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at","url","api_url","setup_tasks","supported_currencies","supported_locales","available_locales","logo_url","mailer_logo_url"],"x-typelizer":!0},TaxCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},tax_code:{type:"string",nullable:!0},description:{type:"string",nullable:!0},is_default:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","tax_code","description","is_default","created_at","updated_at"],"x-typelizer":!0},Variant:{type:"object",properties:{id:{type:"string"},product_id:{type:"string"},sku:{type:"string",nullable:!0},options_text:{type:"string"},track_inventory:{type:"boolean"},media_count:{type:"number"},preorder_ships_at:{type:"string",nullable:!0},thumbnail_url:{type:"string",nullable:!0},purchasable:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},preorder:{type:"boolean"},weight:{type:"number",nullable:!0},height:{type:"number",nullable:!0},width:{type:"number",nullable:!0},depth:{type:"number",nullable:!0},price:{$ref:"#/components/schemas/Price"},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},metadata:{type:"object"},position:{type:"number"},cost_price:{type:"string",nullable:!0},cost_currency:{type:"string",nullable:!0},barcode:{type:"string",nullable:!0},weight_unit:{type:"string",nullable:!0},dimensions_unit:{type:"string",nullable:!0},backorder_limit:{type:"number",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},preorderable:{type:"boolean"},tax_category_id:{type:"string",nullable:!0},available_stock:{type:"number",nullable:!0},reserved_quantity:{type:"number"},total_on_hand:{type:"number",nullable:!0},product_name:{type:"string"},prices:{type:"array",items:{$ref:"#/components/schemas/Price"}},stock_items:{type:"array",items:{$ref:"#/components/schemas/StockItem"}}},required:["id","product_id","sku","options_text","track_inventory","media_count","preorder_ships_at","thumbnail_url","purchasable","in_stock","backorderable","preorder","weight","height","width","depth","price","original_price","option_values","metadata","position","cost_price","cost_currency","barcode","weight_unit","dimensions_unit","backorder_limit","deleted_at","created_at","updated_at","preorderable","tax_category_id","available_stock","reserved_quantity","total_on_hand","product_name"],"x-typelizer":!0},WebhookDelivery:{type:"object",properties:{id:{type:"string"},event_name:{type:"string"},event_id:{type:"string",nullable:!0},response_code:{type:"number",nullable:!0},execution_time:{type:"number",nullable:!0},error_type:{type:"string",nullable:!0},request_errors:{type:"string",nullable:!0},response_body:{type:"string",nullable:!0},success:{type:"boolean",nullable:!0},payload:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},delivered_at:{type:"string",nullable:!0},webhook_endpoint_id:{type:"string"},webhook_endpoint_url:{type:"string"}},required:["id","event_name","event_id","response_code","execution_time","error_type","request_errors","response_body","success","payload","created_at","updated_at","delivered_at","webhook_endpoint_id","webhook_endpoint_url"],"x-typelizer":!0},WebhookEndpoint:{type:"object",properties:{id:{type:"string"},name:{type:"string",nullable:!0},url:{type:"string"},active:{type:"boolean"},subscriptions:{type:"array",items:{type:"string"}},disabled_reason:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},disabled_at:{type:"string",nullable:!0},secret_key:{type:"string",nullable:!0},last_delivery_at:{type:"string",nullable:!0},recent_delivery_count:{type:"number"},recent_failure_count:{type:"number"},total_delivery_count:{type:"number"},successful_delivery_count:{type:"number"},failed_delivery_count:{type:"number"}},required:["id","name","url","active","subscriptions","disabled_reason","created_at","updated_at","disabled_at","secret_key","last_delivery_at","recent_delivery_count","recent_failure_count","total_delivery_count","successful_delivery_count","failed_delivery_count"],"x-typelizer":!0}}}};var Gm=new Set(["get","post","put","patch","delete"]);function An(){return Um}function Jv(e){let t=e.description?.match(/\*\*Required scope:\*\* (.+?) \(for API-key authentication\)\./);return t?t[1].replaceAll("`",""):"\u2014"}function zm(e,t={}){let r=[];for(let[i,n]of Object.entries(e.paths)){let s=i.replace("/api/v3/admin","")||"/";for(let[o,a]of Object.entries(n)){if(!Gm.has(o))continue;if(t.resource){let d=s.split("/")[1]??"";if(d!==t.resource&&!d.startsWith(t.resource))continue}let c=a.summary??"";t.search&&!`${o} ${s} ${c}`.toLowerCase().includes(t.search.toLowerCase())||r.push({method:o.toUpperCase(),path:s,scope:Jv(a),summary:c})}}return r}function Vm(e,t){let r=t.trim().split(/\s+/),i=r.length>1?r[0].toLowerCase():void 0,n=r.length>1?r[1]:r[0],s=Lr(n),o=Nm(e,i,a=>a===s);return o.length>0?o:Nm(e,i,a=>Xv(a,s))}function Nm(e,t,r){let i=[];for(let[n,s]of Object.entries(e.paths)){let o=n.replace("/api/v3/admin","")||"/";if(r(o))for(let[a,c]of Object.entries(s))Gm.has(a)&&(t&&a!==t||i.push({method:a.toUpperCase(),path:o,summary:c.summary,description:c.description,parameters:Jt(c.parameters,e),requestBody:Jt(c.requestBody,e),responses:Jt(c.responses,e)}))}return i}function Xv(e,t){if(e===t)return!0;let r=e.split("/"),i=t.split("/");return r.length!==i.length?!1:r.every((n,s)=>n.startsWith("{")&&n.endsWith("}")?i[s].length>0:n===i[s])}var Zv=8;function Jt(e,t,r=[]){if(Array.isArray(e))return e.map(o=>Jt(o,t,r));if(!e||typeof e!="object")return e;let i=e,n=i.$ref;if(typeof n=="string"){let o=n.replace("#/components/schemas/","");return r.includes(o)||r.length>=Zv||!(o in t.components.schemas)?{$ref:n}:Jt(t.components.schemas[o],t,[...r,o])}let s={};for(let[o,a]of Object.entries(i))s[o]=Jt(a,t,r);return s}function Qv(e,t){return[...t,e]}function Ym(e){return e.option("--profile <name>","use a saved profile (see `spree auth`)").option("--base-url <url>","store URL (overrides profile/env/project)").option("--api-key <key>","secret API key (prefer SPREE_API_KEY \u2014 flags leak into shell history)").option("--store-id <id>","X-Spree-Store-Id for hosts serving multiple stores")}function Jm(){return new Pa("--format <format>","output format").choices(["json","table"]).default("json")}function Wm(e){return Ym(e).addOption(Jm())}async function Hm(e){let t=await $r({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile});return{client:Er({baseUrl:t.baseUrl,secretKey:t.apiKey,...e.storeId?{storeId:e.storeId}:{}}),credentials:t}}function Xm(e){let t=e.command("api").description("Call the Admin API directly (generic get/post/patch/delete)");t.addHelpText("after",["","Examples:"," spree api get /products -q status_eq=active --limit 10",` spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'`," spree api get /orders/ord_x8k2J9aQ --expand items,payments","","Discover the surface (offline, no server needed):"," spree api endpoints --search <term> # find endpoints + required scopes",' spree api schema "POST /orders" # request/response schema for one operation'," spree completion zsh # tab-completion for paths, filters, scopes"].join(`
365
- `)),Wm(t.command("get <path>").description("GET an Admin API path, e.g. `spree api get /products -q status_eq=active`").option("-q, --query <expr>","Ransack predicate key=value (repeatable)",Qv,[]).option("--sort <fields>","sort, e.g. -created_at").option("--page <n>","page number").option("--limit <n>","page size (max 100)").option("--expand <relations>","expand relations, e.g. variants,variants.prices").option("--fields <fields>","sparse fields, e.g. id,name")).action(async(r,i)=>{let n;try{let s=Fm(i),{client:o,credentials:a}=await Hm(i);n=a.baseUrl;let c=await o.request("GET",Lr(r),{params:s});Dr(c,i.format)}catch(s){Ct(s,{baseUrl:n})}});for(let r of["post","patch","delete"])Wm(t.command(`${r} <path>`).description(`${r.toUpperCase()} an Admin API path`).option("-d, --data <json>","request body: inline JSON, @file, or '-' for stdin")).action(async(i,n)=>{let s;try{let o=await Dm(n.data),{client:a,credentials:c}=await Hm(n);s=c.baseUrl;let d=await a.request(r.toUpperCase(),Lr(i),{...o===ca?{}:{body:o}});Dr(d,n.format)}catch(o){Ct(o,{baseUrl:s})}});t.command("endpoints").description("List Admin API endpoints with their required scopes").option("--resource <name>","filter by first path segment, e.g. orders").option("--search <term>","filter by method, path, or summary").addOption(Jm()).action(r=>{let i=zm(An(),{resource:r.resource,search:r.search});if(i.length===0){process.stderr.write(`No endpoints match.
366
- `),process.exitCode=1;return}if(r.format==="table"){(0,Km.printTable)(i.map(n=>({Method:n.method,Path:n.path,Scope:n.scope,Summary:n.summary})));return}Dr(i,"json")}),t.command("schema <operation>").description('Show the request/response schema for an operation, e.g. `spree api schema "POST /products"`').action(r=>{let i=Vm(An(),r);if(i.length===0){process.stderr.write(`No operation matches "${r}". Try \`spree api endpoints --search ${r.split(/\s+/).pop()}\`.
367
- `),process.exitCode=1;return}let n=/\s/.test(r.trim());Dr(n&&i.length===1?i[0]:i,"json")}),Ym(t.command("status").description("Show resolved credentials, server reachability, and the bundled spec version")).action(async r=>{try{let i=await $r({baseUrl:r.baseUrl,apiKey:r.apiKey,profile:r.profile},{allowMint:!1}),n=await Mr(i.baseUrl,i.apiKey),s=An(),o=$n(n),a=[`${Ee.default.bold("Base URL:")} ${i.baseUrl}`,`${Ee.default.bold("Credentials:")} ${i.source}${i.profileName?` (${i.profileName})`:""}, key ${i.tokenPrefix}${Ee.default.dim("\u2026")}`],c=n.status==="unreachable"||n.status==="unauthorized"?null:await Bm(i.baseUrl,i.apiKey);c!==null?a.push(`${Ee.default.bold("Scopes:")} ${c.length?c.join(", "):Ee.default.dim("(none)")}`):i.scopes?.length&&a.push(`${Ee.default.bold("Scopes:")} ${i.scopes.join(", ")} ${Ee.default.dim("(local snapshot from mint time \u2014 may be stale)")}`),a.push(`${Ee.default.bold("Server:")} ${o}`),a.push(`${Ee.default.bold("Bundled spec:")} ${s.info?.version??"unknown"} ${Ee.default.dim("(spree api endpoints/schema reflect this snapshot, not the live server)")}`),process.stdout.write(`${a.join(`
364
+ **Required scope:** \`write_webhooks\` (for API-key authentication).`,parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"200":{description:"webhook endpoint disabled",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{reason:{type:"string"}}}}}}}},"/api/v3/admin/categories":{get:{summary:"List categories",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of the store's categories (manual hierarchical taxons; rule-based collections are excluded).\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"page",in:"query",required:!1,description:"Page number",schema:{type:"integer"}},{name:"limit",in:"query",required:!1,description:"Number of records per page",schema:{type:"integer"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., children, parent, ancestors).",schema:{type:"string"}}],responses:{"200":{description:"categories found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Category"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a category. Nests under the parent when parent_id is given, otherwise creates a top-level category.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}}],responses:{"201":{description:"category created",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},parent_id:{type:"string",description:"Prefixed ID of the parent category"},description:{type:"string"},permalink:{type:"string"},meta_title:{type:"string"},meta_description:{type:"string"},meta_keywords:{type:"string"},hide_from_nav:{type:"boolean"}},required:["name"]}}}}}},"/api/v3/admin/categories/{id}":{get:{summary:"Get a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single category by ID.\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., children, parent, ancestors).",schema:{type:"string"}}],responses:{"200":{description:"category found",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}},"404":{description:"category not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a category.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"category updated",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},parent_id:{type:"string",description:"Prefixed ID of the parent category"},description:{type:"string"},permalink:{type:"string"},meta_title:{type:"string"},meta_description:{type:"string"},meta_keywords:{type:"string"},hide_from_nav:{type:"boolean"}}}}}}},delete:{summary:"Delete a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a category and its descendants.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"204":{description:"category deleted"}}}},"/api/v3/admin/categories/{id}/reposition":{patch:{summary:"Reposition a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Moves a category to a new parent and/or index within the tree.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"category repositioned",content:{"application/json":{schema:{$ref:"#/components/schemas/Category"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{new_parent_id:{type:"string",description:"Prefixed ID of the new parent (omit for top level)"},new_position:{type:"integer",description:"0-based index among the new parent's children"}},required:["new_position"]}}}}}},"/api/v3/admin/categories/{category_id}/products":{get:{summary:"List category products",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Products classified under the category, ordered by their classification position.\n\n**Required scope:** `read_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"200":{description:"products found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/Product"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Add a product to a category",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Classifies a product under the category (appended to the end).\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}}],responses:{"201":{description:"product added",content:{"application/json":{schema:{$ref:"#/components/schemas/Product"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{product_id:{type:"string"}},required:["product_id"]}}}}}},"/api/v3/admin/categories/{category_id}/products/{id}/reposition":{patch:{summary:"Reposition a category product",tags:["Categories"],security:[{api_key:[],bearer_auth:[]}],description:"Moves a product to a new index among the category's products.\n\n**Required scope:** `write_categories` (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,description:"Bearer token for admin authentication",schema:{type:"string"}},{name:"category_id",in:"path",required:!0,description:"Category ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Product ID",schema:{type:"string"}}],responses:{"204":{description:"product repositioned"}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{new_position:{type:"integer",description:"0-based index among the category's products"}},required:["new_position"]}}}}}},"/api/v3/admin/imports":{get:{summary:"List imports",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns CSV imports queued or completed for the current store.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"200":{description:"imports found",content:{"application/json":{}}}}},post:{summary:"Create an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Queues a CSV import. Upload the file first via `POST /api/v3/admin/direct_uploads`\nand pass the returned `signed_id` as `attachment`. On success the import is in the\n`mapping` state and the response carries the mapping payload: `schema_fields`\n(the canonical columns for the type), `csv_headers`, a `sample_row`, and the\nauto-assigned `mappings`.\n\nAdjust mappings if needed, then call `PATCH /admin/imports/{id}/complete_mapping`\nto start processing. Poll `GET /admin/imports/{id}` while `status` is\n`completed_mapping`/`processing`; terminal statuses are `completed` and `failed`.\n\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}}],responses:{"201":{description:"import created in mapping state",content:{"application/json":{}}},"422":{description:"unknown import type",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["type","attachment"],properties:{type:{type:"string",enum:["Spree::Imports::Products","Spree::Imports::Customers","Spree::Imports::ProductTranslations"]},attachment:{type:"string",description:"ActiveStorage signed blob id from POST /api/v3/admin/direct_uploads."},preferred_delimiter:{type:"string",enum:[",",";","|"," "],description:"CSV column separator. Defaults to a comma."},results_url:{type:"string",description:"Absolute URL of your admin imports view; the import-done email links back to it with `?import=<id>` appended. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/imports/template":{get:{summary:"Download an import template",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a CSV header row for the given import type, including the custom field columns available for the model.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"type",in:"query",required:!0,description:"Registered import type, e.g. Spree::Imports::Products.",schema:{type:"string"}}],responses:{"200":{description:"CSV template",content:{"application/json":{},"text/csv":{schema:{type:"string",format:"binary"}}}}}}},"/api/v3/admin/imports/{id}":{get:{summary:"Show an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns import status and row counters. The admin dashboard polls this endpoint while `status` is `completed_mapping` or `processing`; `rows_count`, `completed_rows_count` and `failed_rows_count` drive the progress bar. The mapping payload (`csv_headers`, `sample_row`) is only present while `status` is `mapping`.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"import found",content:{"application/json":{}}}}},delete:{summary:"Delete an import",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the import, its rows and the uploaded file. Returns 422 while the import is being processed.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"import deleted"}}}},"/api/v3/admin/imports/{id}/download":{get:{summary:"Download the originally uploaded file",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Streams the CSV exactly as it was uploaded \u2014 the audit trail for what was imported. JWT/API-key protected; SPA clients fetch it with the Authorization header and trigger the browser download via a Blob URL.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"CSV file",content:{"application/json":{},"text/csv":{schema:{type:"string",format:"binary"}}}}}}},"/api/v3/admin/imports/{id}/complete_mapping":{patch:{summary:"Complete mapping and start processing",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Applies the submitted column mappings, then starts row processing. Omit `mappings`\nto accept the auto-assigned ones from the create response. Returns 422 when a\nrequired schema field is left unmapped (`details.missing_required_fields`) or a\nfile column is assigned twice.\n\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"mapping completed, processing queued",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{mappings:{type:"array",description:"Column assignments to apply before starting. `file_column: null` unmaps a field.",items:{type:"object",required:["schema_field"],properties:{schema_field:{type:"string"},file_column:{type:"string",nullable:!0}}}}}}}}}}},"/api/v3/admin/imports/{id}/retry_failed_rows":{patch:{summary:"Retry failed rows",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Re-processes the rows that failed. The import re-enters `processing`; poll `GET /admin/imports/{id}` until it completes again. Returns 422 when the import is not `completed` or has no failed rows.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"retry queued",content:{"application/json":{}}}}}},"/api/v3/admin/imports/{import_id}/rows":{get:{summary:"List import rows",tags:["Imports"],security:[{api_key:[],bearer_auth:[]}],description:"Paginated rows of an import \u2014 the failure report. Filter with `q[status_eq]=failed` to list only rows that could not be imported; each row carries the raw CSV `data` and its `validation_errors`.\n\n**Required scope:** the write scope of the imported resource \u2014 `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).",parameters:[{name:"x-spree-api-key",in:"header",required:!0,schema:{type:"string"}},{name:"Authorization",in:"header",required:!0,schema:{type:"string"}},{name:"import_id",in:"path",required:!0,schema:{type:"string"}},{name:"q[status_eq]",in:"query",required:!1,description:"Filter rows by status: pending, processing, completed, failed.",schema:{type:"string"}}],responses:{"200":{description:"rows found",content:{"application/json":{}}}}}}},components:{schemas:{PaginationMeta:{type:"object",properties:{page:{type:"integer"},limit:{type:"integer"},count:{type:"integer",description:"Total number of records"},pages:{type:"integer",description:"Total number of pages"},from:{type:"integer",description:"Index of first record on this page"},to:{type:"integer",description:"Index of last record on this page"},in:{type:"integer",description:"Number of records on this page"},previous:{type:"integer",nullable:!0,description:"Previous page number"},next:{type:"integer",nullable:!0,description:"Next page number"}},required:["page","limit","count","pages","from","to","in"]},ErrorResponse:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"},details:{type:"object",description:"Field-specific validation errors",nullable:!0}},required:["code","message"]}},required:["error"]},AuthResponse:{type:"object",properties:{token:{type:"string",description:"JWT access token"},user:{$ref:"#/components/schemas/AdminUser"}},required:["token","user"]},PermissionRule:{type:"object",description:"A single permission rule (CanCanCan rule). Rules are applied in order, last-matching-wins.",properties:{allow:{type:"boolean",description:"true for `can`, false for `cannot`"},actions:{type:"array",items:{type:"string"},description:'Action names, e.g. ["read", "update"] or ["manage"]'},subjects:{type:"array",items:{type:"string"},description:'Subject class names, e.g. ["Spree::Product"] or ["all"]'},has_conditions:{type:"boolean",description:"True if the server-side rule has per-record conditions. The SPA shows the action optimistically and handles 403 from the API."}},required:["allow","actions","subjects","has_conditions"]},MeResponse:{type:"object",description:"Current admin user profile and serialized permissions",properties:{user:{$ref:"#/components/schemas/AdminUser"},permissions:{type:"array",items:{$ref:"#/components/schemas/PermissionRule"}}},required:["user","permissions"]},ImportSchemaField:{type:"object",description:"A canonical column of an import type, including per-store custom field columns",properties:{name:{type:"string",description:"Canonical field name used in mappings"},label:{type:"string",description:"Human-readable label"},required:{type:"boolean",description:"Whether the field must be mapped before processing"}},required:["name","label","required"]},CheckoutRequirement:{type:"object",properties:{step:{type:"string",description:"Checkout step this requirement belongs to"},field:{type:"string",description:"Field that needs to be satisfied"},message:{type:"string",description:"Human-readable requirement message"}},required:["step","field","message"]},CartWarning:{type:"object",description:"A warning about a cart issue (e.g., item removed due to stock change)",properties:{code:{type:"string",description:"Machine-readable warning code"},message:{type:"string",description:"Human-readable warning message"},line_item_id:{type:"string",nullable:!0,description:"Prefixed line item ID (when applicable)"},variant_id:{type:"string",nullable:!0,description:"Prefixed variant ID (when applicable)"}},required:["code","message"]},FulfillmentManifestItem:{type:"object",description:"An item within a fulfillment \u2014 which line item and how many units are in this fulfillment",properties:{item_id:{type:"string",description:"Line item ID"},variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer",description:"Quantity in this fulfillment"}},required:["item_id","variant_id","quantity"]},AdminUserRoleAssignment:{type:"object",description:"A role assignment for the current store on a staff member",properties:{id:{type:"string",description:"Prefixed role ID"},name:{type:"string",description:"Role name"}},required:["id","name"]},PreferenceField:{type:"object",description:"A single configurable preference on a payment method, promotion rule/action, or calculator. The frontend uses `type` + `default` to render a sensible input.",properties:{key:{type:"string"},type:{type:"string",description:"string | text | password | integer | decimal | boolean | array | hash"},default:{description:"Default value (any JSON type), null when there is no default",nullable:!0}},required:["key","type"]},PromotionActionCalculator:{type:"object",description:"The action's nested calculator (when the action carries one \u2014 null for actions like `free_shipping`)",properties:{type:{type:"string",description:"Wire shorthand for the calculator subclass"},label:{type:"string"},preferences:{type:"object",additionalProperties:!0},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}}},required:["type","label","preferences","preference_schema"]},PromotionActionLineItem:{type:"object",description:"One row in a `create_line_items` action \u2014 the variant added to the order and how many",properties:{variant_id:{type:"string"},quantity:{type:"integer"}},required:["variant_id","quantity"]},Address:{type:"object",properties:{id:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string"},address1:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},postal_code:{type:"string",nullable:!0},city:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},country_name:{type:"string"},country_iso:{type:"string"},state_text:{type:"string",nullable:!0},state_abbr:{type:"string",nullable:!0},quick_checkout:{type:"boolean"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"},state_name:{type:"string",nullable:!0},label:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0}},required:["id","first_name","last_name","full_name","address1","address2","postal_code","city","phone","company","country_name","country_iso","state_text","state_abbr","quick_checkout","is_default_billing","is_default_shipping","state_name","label","metadata","created_at","updated_at","customer_id"],"x-typelizer":!0},Adjustment:{type:"object",properties:{id:{type:"string"},label:{type:"string"},display_amount:{type:"string"},included:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","label","display_amount","included","created_at","updated_at","amount","order_id"],"x-typelizer":!0},AdminUser:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},full_name:{type:"string",nullable:!0},selected_locale:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},avatar_url:{type:"string",nullable:!0},roles:{type:"array",items:{$ref:"#/components/schemas/AdminUserRoleAssignment"}}},required:["id","email","first_name","last_name","full_name","selected_locale","created_at","updated_at","avatar_url","roles"],"x-typelizer":!0},AllowedOrigin:{type:"object",properties:{id:{type:"string"},origin:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","origin","created_at","updated_at"],"x-typelizer":!0},ApiKey:{type:"object",properties:{id:{type:"string"},name:{type:"string"},key_type:{type:"string"},token_prefix:{type:"string",nullable:!0},scopes:{type:"array",items:{type:"string"}},created_at:{type:"string"},updated_at:{type:"string"},revoked_at:{type:"string",nullable:!0},last_used_at:{type:"string",nullable:!0},plaintext_token:{type:"string",nullable:!0},created_by_email:{type:"string",nullable:!0}},required:["id","name","key_type","token_prefix","scopes","created_at","updated_at","revoked_at","last_used_at","plaintext_token","created_by_email"],"x-typelizer":!0},Category:{type:"object",properties:{id:{type:"string"},name:{type:"string"},permalink:{type:"string"},position:{type:"number"},depth:{type:"number"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},children_count:{type:"number"},parent_id:{type:"string",nullable:!0},description:{type:"string"},description_html:{type:"string"},image_url:{type:"string",nullable:!0},square_image_url:{type:"string",nullable:!0},is_root:{type:"boolean"},is_child:{type:"boolean"},is_leaf:{type:"boolean"},parent:{$ref:"#/components/schemas/Category"},children:{type:"array",items:{$ref:"#/components/schemas/Category"}},ancestors:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},translations:{type:"object"},metadata:{type:"object"},pretty_name:{type:"string"},lft:{type:"number"},rgt:{type:"number"},products_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","permalink","position","depth","meta_title","meta_description","meta_keywords","children_count","parent_id","description","description_html","image_url","square_image_url","is_root","is_child","is_leaf","metadata","pretty_name","lft","rgt","products_count","created_at","updated_at"],"x-typelizer":!0},Channel:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string"},active:{type:"boolean"},default:{type:"boolean"},preferred_order_routing_strategy:{type:"string",nullable:!0},preferred_storefront_access:{type:"string",nullable:!0},preferred_guest_checkout:{type:"boolean",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","active","default","preferred_order_routing_strategy","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at"],"x-typelizer":!0},Country:{type:"object",properties:{iso:{type:"string"},iso3:{type:"string"},name:{type:"string"},states_required:{type:"boolean"},zipcode_required:{type:"boolean"},states:{type:"array",items:{$ref:"#/components/schemas/State"}},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["iso","iso3","name","states_required","zipcode_required","created_at","updated_at"],"x-typelizer":!0},CouponCode:{type:"object",properties:{id:{type:"string"},code:{type:"string"},state:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},promotion_id:{type:"string"},order_id:{type:"string",nullable:!0}},required:["id","code","state","created_at","updated_at","promotion_id","order_id"],"x-typelizer":!0},CreditCard:{type:"object",properties:{id:{type:"string"},brand:{type:"string"},last4:{type:"string"},month:{type:"number"},year:{type:"number"},name:{type:"string",nullable:!0},default:{type:"boolean"},gateway_payment_profile_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},payment_method_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","brand","last4","month","year","name","default","gateway_payment_profile_id","customer_id","payment_method_id","metadata","created_at","updated_at"],"x-typelizer":!0},CustomFieldDefinition:{type:"object",properties:{id:{type:"string"},namespace:{type:"string"},key:{type:"string"},label:{type:"string"},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},resource_type:{type:"string"},storefront_visible:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","namespace","key","label","field_type","resource_type","storefront_visible","created_at","updated_at"],"x-typelizer":!0},CustomField:{type:"object",properties:{id:{type:"string"},label:{type:"string"},type:{type:"string",deprecated:!0},field_type:{type:"string",enum:["short_text","long_text","rich_text","number","boolean","json"]},key:{type:"string"},value:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},storefront_visible:{type:"boolean"},custom_field_definition_id:{type:"string"}},required:["id","label","type","field_type","key","value","created_at","updated_at","storefront_visible","custom_field_definition_id"],"x-typelizer":!0},CustomerGroup:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},customers_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","name","description","customers_count","created_at","updated_at"],"x-typelizer":!0},Customer:{type:"object",properties:{id:{type:"string"},email:{type:"string"},first_name:{type:"string",nullable:!0},last_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},accepts_email_marketing:{type:"boolean"},full_name:{type:"string"},available_store_credit_total:{type:"string"},display_available_store_credit_total:{type:"string"},addresses:{type:"array",items:{$ref:"#/components/schemas/Address"}},default_billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},default_shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},login:{type:"string",nullable:!0},metadata:{type:"object"},last_sign_in_at:{type:"string",nullable:!0},current_sign_in_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},sign_in_count:{type:"number"},failed_attempts:{type:"number"},last_sign_in_ip:{type:"string",nullable:!0},current_sign_in_ip:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note_html:{type:"string",nullable:!0},default_billing_address_id:{type:"string",nullable:!0},default_shipping_address_id:{type:"string",nullable:!0},orders_count:{type:"number"},total_spent:{type:"string"},display_total_spent:{type:"string"},last_order_completed_at:{type:"string",nullable:!0},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}},store_credits:{type:"array",items:{$ref:"#/components/schemas/StoreCredit"}},customer_group_ids:{type:"array",items:{type:"string"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}}},required:["id","email","first_name","last_name","phone","accepts_email_marketing","full_name","available_store_credit_total","display_available_store_credit_total","login","metadata","last_sign_in_at","current_sign_in_at","created_at","updated_at","sign_in_count","failed_attempts","last_sign_in_ip","current_sign_in_ip","tags","internal_note_html","default_billing_address_id","default_shipping_address_id","orders_count","total_spent","display_total_spent","last_order_completed_at","customer_group_ids"],"x-typelizer":!0},DeliveryMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},code:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","code","created_at","updated_at"],"x-typelizer":!0},DeliveryRate:{type:"object",properties:{id:{type:"string"},delivery_method_id:{type:"string"},name:{type:"string"},selected:{type:"boolean"},cost:{type:"string"},total:{type:"string"},additional_tax_total:{type:"string"},included_tax_total:{type:"string"},tax_total:{type:"string"},display_cost:{type:"string"},display_total:{type:"string"},display_additional_tax_total:{type:"string"},display_included_tax_total:{type:"string"},display_tax_total:{type:"string"},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","delivery_method_id","name","selected","cost","total","additional_tax_total","included_tax_total","tax_total","display_cost","display_total","display_additional_tax_total","display_included_tax_total","display_tax_total","created_at","updated_at"],"x-typelizer":!0},DigitalLink:{type:"object",properties:{id:{type:"string"},access_counter:{type:"number"},filename:{type:"string"},content_type:{type:"string"},download_url:{type:"string"},authorizable:{type:"boolean"},expired:{type:"boolean"},access_limit_exceeded:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","access_counter","filename","content_type","download_url","authorizable","expired","access_limit_exceeded","created_at","updated_at"],"x-typelizer":!0},Discount:{type:"object",properties:{id:{type:"string"},promotion_id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},amount:{type:"string"},display_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","promotion_id","name","description","code","amount","display_amount","created_at","updated_at"],"x-typelizer":!0},Export:{type:"object",properties:{id:{type:"string"},number:{type:"string"},type:{type:"string",nullable:!0},format:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},user_id:{type:"string",nullable:!0},done:{type:"boolean"},filename:{type:"string",nullable:!0},byte_size:{type:"number",nullable:!0},download_url:{type:"string",nullable:!0}},required:["id","number","type","format","created_at","updated_at","user_id","done","filename","byte_size","download_url"],"x-typelizer":!0},Fulfillment:{type:"object",properties:{id:{type:"string"},number:{type:"string"},tracking:{type:"string",nullable:!0},tracking_url:{type:"string",nullable:!0},cost:{type:"string"},display_cost:{type:"string"},total:{type:"string"},display_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},status:{type:"string"},fulfillment_type:{type:"string"},fulfilled_at:{type:"string",nullable:!0},items:{type:"array",items:{$ref:"#/components/schemas/FulfillmentManifestItem"}},delivery_method:{$ref:"#/components/schemas/DeliveryMethod"},stock_location:{$ref:"#/components/schemas/StockLocation"},delivery_rates:{type:"array",items:{$ref:"#/components/schemas/DeliveryRate"}},metadata:{type:"object"},adjustment_total:{type:"string"},pre_tax_amount:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","number","tracking","tracking_url","cost","display_cost","total","display_total","discount_total","display_discount_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","tax_total","display_tax_total","status","fulfillment_type","fulfilled_at","items","metadata","adjustment_total","pre_tax_amount","created_at","updated_at","order_id","stock_location_id"],"x-typelizer":!0},GiftCardBatch:{type:"object",properties:{id:{type:"string"},codes_count:{type:"number"},currency:{type:"string",nullable:!0},prefix:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},amount:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0}},required:["id","codes_count","currency","prefix","created_at","updated_at","amount","expires_at","created_by_id"],"x-typelizer":!0},GiftCard:{type:"object",properties:{id:{type:"string"},code:{type:"string"},status:{type:"string"},currency:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_authorized:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},expires_at:{type:"string",nullable:!0},redeemed_at:{type:"string",nullable:!0},expired:{type:"boolean"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/AdminUser"},gift_card_batch:{$ref:"#/components/schemas/GiftCardBatch"},orders:{type:"array",items:{$ref:"#/components/schemas/Order"}}},required:["id","code","status","currency","amount","amount_used","amount_authorized","amount_remaining","display_amount","display_amount_used","display_amount_remaining","expires_at","redeemed_at","expired","active","created_at","updated_at","customer_id","created_by_id"],"x-typelizer":!0},ImportMapping:{type:"object",properties:{id:{type:"string"},schema_field:{type:"string"},file_column:{type:"string",nullable:!0},required:{type:"boolean"}},required:["id","schema_field","file_column","required"],"x-typelizer":!0},ImportRow:{type:"object",properties:{id:{type:"string"},row_number:{type:"number"},status:{type:"string"},validation_errors:{type:"string",nullable:!0},item_type:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},import_id:{type:"string",nullable:!0},item_id:{type:"string",nullable:!0},data:{type:"object"}},required:["id","row_number","status","validation_errors","item_type","created_at","updated_at","import_id","item_id","data"],"x-typelizer":!0},Import:{type:"object",properties:{id:{type:"string"},number:{type:"string"},type:{type:"string",nullable:!0},rows_count:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},status:{type:"string"},owner_type:{type:"string",nullable:!0},owner_id:{type:"string",nullable:!0},user_id:{type:"string",nullable:!0},processing_errors:{type:"string",nullable:!0},preferred_delimiter:{type:"string"},original_filename:{type:"string",nullable:!0},original_byte_size:{type:"number",nullable:!0},original_file_url:{type:"string",nullable:!0},completed_rows_count:{type:"number"},failed_rows_count:{type:"number"},schema_fields:{type:"array",items:{$ref:"#/components/schemas/ImportSchemaField"}},csv_headers:{type:"array",items:{type:"string"}},sample_row:{type:"object"},mappings:{type:"array",items:{$ref:"#/components/schemas/ImportMapping"}}},required:["id","number","type","rows_count","created_at","updated_at","status","owner_type","owner_id","user_id","processing_errors","preferred_delimiter","original_filename","original_byte_size","original_file_url","completed_rows_count","failed_rows_count","schema_fields","csv_headers","sample_row","mappings"],"x-typelizer":!0},Invitation:{type:"object",properties:{id:{type:"string"},email:{type:"string"},status:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},expires_at:{type:"string"},role_id:{type:"string"},role_name:{type:"string"},inviter_email:{type:"string"},acceptance_url:{type:"string"},invitee_exists:{type:"boolean"},store:{type:"object"}},required:["id","email","status","created_at","updated_at","expires_at","role_id","role_name","inviter_email","acceptance_url","invitee_exists","store"],"x-typelizer":!0},LineItem:{type:"object",properties:{id:{type:"string"},variant_id:{type:"string"},preorder:{type:"boolean"},preorder_ships_at:{type:"string",nullable:!0},quantity:{type:"number"},currency:{type:"string"},name:{type:"string"},slug:{type:"string"},options_text:{type:"string"},price:{type:"string"},display_price:{type:"string"},total:{type:"string"},display_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},pre_tax_amount:{type:"string"},display_pre_tax_amount:{type:"string"},discounted_amount:{type:"string"},display_discounted_amount:{type:"string"},display_compare_at_amount:{type:"string",nullable:!0},compare_at_amount:{type:"string",nullable:!0},thumbnail_url:{type:"string",nullable:!0},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},digital_links:{type:"array",items:{$ref:"#/components/schemas/DigitalLink"}},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},cost_price:{type:"string",nullable:!0},tax_category_id:{type:"string",nullable:!0},variant:{$ref:"#/components/schemas/Variant"},tax_category:{$ref:"#/components/schemas/TaxCategory"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}}},required:["id","variant_id","preorder","preorder_ships_at","quantity","currency","name","slug","options_text","price","display_price","total","display_total","adjustment_total","display_adjustment_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","discount_total","display_discount_total","pre_tax_amount","display_pre_tax_amount","discounted_amount","display_discounted_amount","display_compare_at_amount","compare_at_amount","thumbnail_url","option_values","digital_links","metadata","created_at","updated_at","cost_price","tax_category_id"],"x-typelizer":!0},Market:{type:"object",properties:{id:{type:"string"},name:{type:"string"},currency:{type:"string"},default_locale:{type:"string"},tax_inclusive:{type:"boolean"},default:{type:"boolean"},country_isos:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","currency","default_locale","tax_inclusive","default","country_isos","supported_locales","created_at","updated_at"],"x-typelizer":!0},Media:{type:"object",properties:{id:{type:"string"},product_id:{type:"string",nullable:!0},variant_ids:{type:"array",items:{type:"string"}},position:{type:"number"},alt:{type:"string",nullable:!0},media_type:{type:"string"},focal_point_x:{type:"number",nullable:!0},focal_point_y:{type:"number",nullable:!0},external_video_url:{type:"string",nullable:!0},original_url:{type:"string",nullable:!0},mini_url:{type:"string",nullable:!0},small_url:{type:"string",nullable:!0},medium_url:{type:"string",nullable:!0},large_url:{type:"string",nullable:!0},xlarge_url:{type:"string",nullable:!0},og_image_url:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},viewable_id:{type:"string"},download_url:{type:"string",nullable:!0},metadata:{type:"object"},viewable_type:{type:"string"}},required:["id","product_id","variant_ids","position","alt","media_type","focal_point_x","focal_point_y","external_video_url","original_url","mini_url","small_url","medium_url","large_url","xlarge_url","og_image_url","created_at","updated_at","viewable_id","download_url","metadata","viewable_type"],"x-typelizer":!0},OptionType:{type:"object",properties:{id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},kind:{type:"string"},translations:{type:"object"},metadata:{type:"object"},filterable:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}}},required:["id","name","label","position","kind","metadata","filterable","created_at","updated_at"],"x-typelizer":!0},OptionValue:{type:"object",properties:{id:{type:"string"},option_type_id:{type:"string"},name:{type:"string"},label:{type:"string"},position:{type:"number"},color_code:{type:"string",nullable:!0},option_type_name:{type:"string"},option_type_label:{type:"string"},image_url:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},option_type:{$ref:"#/components/schemas/OptionType"}},required:["id","option_type_id","name","label","position","color_code","option_type_name","option_type_label","image_url","metadata","created_at","updated_at"],"x-typelizer":!0},Order:{type:"object",properties:{id:{type:"string"},market_id:{type:"string",nullable:!0},channel_id:{type:"string",nullable:!0},number:{type:"string"},email:{type:"string"},customer_note:{type:"string",nullable:!0},currency:{type:"string"},locale:{type:"string",nullable:!0},total_quantity:{type:"number"},fulfillment_status:{type:"string",nullable:!0},payment_status:{type:"string",nullable:!0},completed_at:{type:"string",nullable:!0},item_total:{type:"string"},display_item_total:{type:"string"},adjustment_total:{type:"string"},display_adjustment_total:{type:"string"},discount_total:{type:"string"},display_discount_total:{type:"string"},tax_total:{type:"string"},display_tax_total:{type:"string"},included_tax_total:{type:"string"},display_included_tax_total:{type:"string"},additional_tax_total:{type:"string"},display_additional_tax_total:{type:"string"},total:{type:"string"},display_total:{type:"string"},gift_card_total:{type:"string"},display_gift_card_total:{type:"string"},amount_due:{type:"string"},display_amount_due:{type:"string"},delivery_total:{type:"string"},display_delivery_total:{type:"string"},store_credit_total:{type:"string"},display_store_credit_total:{type:"string"},covered_by_store_credit:{type:"boolean"},discounts:{type:"array",items:{$ref:"#/components/schemas/Discount"}},items:{type:"array",items:{$ref:"#/components/schemas/LineItem"}},fulfillments:{type:"array",items:{$ref:"#/components/schemas/Fulfillment"}},payments:{type:"array",items:{$ref:"#/components/schemas/Payment"}},billing_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},shipping_address:{allOf:[{$ref:"#/components/schemas/Address"}],nullable:!0},gift_card:{allOf:[{$ref:"#/components/schemas/GiftCard"}],nullable:!0},market:{allOf:[{$ref:"#/components/schemas/Market"}],nullable:!0},status:{type:"string"},last_ip_address:{type:"string",nullable:!0},considered_risky:{type:"boolean"},confirmation_delivered:{type:"boolean"},store_owner_notification_delivered:{type:"boolean"},payment_total:{type:"string"},display_payment_total:{type:"string"},metadata:{type:"object"},canceled_at:{type:"string",nullable:!0},approved_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},preferred_stock_location_id:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},internal_note:{type:"string",nullable:!0},approver_id:{type:"string",nullable:!0},canceler_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},customer_id:{type:"string",nullable:!0},channel:{$ref:"#/components/schemas/Channel"},preferred_stock_location:{$ref:"#/components/schemas/StockLocation"},payment_methods:{type:"array",items:{$ref:"#/components/schemas/PaymentMethod"}},customer:{$ref:"#/components/schemas/Customer"},approver:{$ref:"#/components/schemas/Customer"},canceler:{$ref:"#/components/schemas/Customer"},created_by:{$ref:"#/components/schemas/Customer"},adjustments:{type:"array",items:{$ref:"#/components/schemas/Adjustment"}},return_authorizations:{type:"array",items:{$ref:"#/components/schemas/ReturnAuthorization"}},reimbursements:{type:"array",items:{$ref:"#/components/schemas/Reimbursement"}}},required:["id","market_id","channel_id","number","email","customer_note","currency","locale","total_quantity","fulfillment_status","payment_status","completed_at","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","gift_card","market","status","last_ip_address","considered_risky","confirmation_delivered","store_owner_notification_delivered","payment_total","display_payment_total","metadata","canceled_at","approved_at","created_at","updated_at","preferred_stock_location_id","tags","internal_note","approver_id","canceler_id","created_by_id","customer_id"],"x-typelizer":!0},PaymentMethod:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},type:{type:"string"},session_required:{type:"boolean"},source_required:{type:"boolean"},metadata:{type:"object"},active:{type:"boolean"},auto_capture:{type:"boolean",nullable:!0},storefront_visible:{type:"boolean"},position:{type:"number"},created_at:{type:"string"},updated_at:{type:"string"},preferences:{type:"object"},preference_schema:{type:"object"}},required:["id","name","description","type","session_required","source_required","metadata","active","auto_capture","storefront_visible","position","created_at","updated_at","preferences","preference_schema"],"x-typelizer":!0},Payment:{type:"object",properties:{id:{type:"string"},payment_method_id:{type:"string"},response_code:{type:"string",nullable:!0},number:{type:"string"},amount:{type:"string"},display_amount:{type:"string"},status:{type:"string"},source_type:{type:"string",nullable:!0,enum:["credit_card","store_credit","payment_source"]},source_id:{type:"string",nullable:!0},source:{anyOf:[{$ref:"#/components/schemas/CreditCard"},{$ref:"#/components/schemas/StoreCredit"},{$ref:"#/components/schemas/PaymentSource"}],nullable:!0},payment_method:{$ref:"#/components/schemas/PaymentMethod"},metadata:{type:"object"},avs_response:{type:"string",nullable:!0},cvv_response_code:{type:"string",nullable:!0},cvv_response_message:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},captured_amount:{type:"string"},order_id:{type:"string",nullable:!0},order:{$ref:"#/components/schemas/Order"},refunds:{type:"array",items:{$ref:"#/components/schemas/Refund"}}},required:["id","payment_method_id","response_code","number","amount","display_amount","status","source_type","source_id","source","metadata","avs_response","cvv_response_code","cvv_response_message","created_at","updated_at","captured_amount","order_id"],"x-typelizer":!0},PaymentSource:{type:"object",properties:{id:{type:"string"},gateway_payment_profile_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","gateway_payment_profile_id","metadata","created_at","updated_at"],"x-typelizer":!0},PriceHistory:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_in_cents:{type:"number"},currency:{type:"string"},display_amount:{type:"string"},recorded_at:{type:"string"},variant_id:{type:"string"},price_id:{type:"string"},compare_at_amount:{type:"string",nullable:!0},created_at:{type:"string"}},required:["id","amount","amount_in_cents","currency","display_amount","recorded_at","variant_id","price_id","compare_at_amount","created_at"],"x-typelizer":!0},PriceList:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},status:{type:"string"},position:{type:"number"},match_policy:{type:"string"},starts_at:{type:"string",nullable:!0},ends_at:{type:"string",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},currently_active:{type:"boolean"},products_count:{type:"number"},prices_count:{type:"number"},product_ids:{type:"array",items:{type:"string"}},price_rules:{type:"array",items:{$ref:"#/components/schemas/PriceRule"}}},required:["id","name","description","status","position","match_policy","starts_at","ends_at","deleted_at","created_at","updated_at","currently_active","products_count","prices_count","product_ids"],"x-typelizer":!0},PriceRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},price_list_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},description:{type:"string",nullable:!0},markets:{type:"array",items:{$ref:"#/components/schemas/Market"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}}},required:["id","created_at","updated_at","type","price_list_id","preferences","preference_schema","label","description"],"x-typelizer":!0},Price:{type:"object",properties:{id:{type:"string"},amount:{type:"string",nullable:!0},amount_in_cents:{type:"number",nullable:!0},compare_at_amount:{type:"string",nullable:!0},compare_at_amount_in_cents:{type:"number",nullable:!0},currency:{type:"string",nullable:!0},display_amount:{type:"string",nullable:!0},display_compare_at_amount:{type:"string",nullable:!0},price_list_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","amount","amount_in_cents","compare_at_amount","compare_at_amount_in_cents","currency","display_amount","display_compare_at_amount","price_list_id","variant_id","created_at","updated_at"],"x-typelizer":!0},ProductPublication:{type:"object",properties:{id:{type:"string"},published_at:{type:"string",nullable:!0},unpublished_at:{type:"string",nullable:!0},product_id:{type:"string"},channel_id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","published_at","unpublished_at","product_id","channel_id","created_at","updated_at"],"x-typelizer":!0},Product:{type:"object",properties:{id:{type:"string"},name:{type:"string"},slug:{type:"string"},meta_title:{type:"string",nullable:!0},meta_description:{type:"string",nullable:!0},meta_keywords:{type:"string",nullable:!0},variant_count:{type:"number"},available_on:{type:"string",nullable:!0},preorder_ships_at:{type:"string",nullable:!0},purchasable:{type:"boolean"},preorder:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},available:{type:"boolean"},description:{type:"string",nullable:!0},description_html:{type:"string",nullable:!0},default_variant_id:{type:"string"},thumbnail_url:{type:"string",nullable:!0},tags:{type:"array",items:{type:"string"}},price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},variants:{type:"array",items:{$ref:"#/components/schemas/Variant"}},default_variant:{$ref:"#/components/schemas/Variant"},option_types:{type:"array",items:{$ref:"#/components/schemas/OptionType"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},translations:{type:"object"},status:{type:"string"},metadata:{type:"object"},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},tax_category_id:{type:"string",nullable:!0},product_publications:{type:"array",items:{$ref:"#/components/schemas/ProductPublication"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}}},required:["id","name","slug","meta_title","meta_description","meta_keywords","variant_count","available_on","preorder_ships_at","purchasable","preorder","in_stock","backorderable","available","description","description_html","default_variant_id","thumbnail_url","tags","price","original_price","status","metadata","deleted_at","created_at","updated_at","tax_category_id"],"x-typelizer":!0},PromotionAction:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},calculator:{allOf:[{$ref:"#/components/schemas/PromotionActionCalculator"}],nullable:!0},line_items:{type:"array",items:{$ref:"#/components/schemas/PromotionActionLineItem"},nullable:!0}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","calculator","line_items"],"x-typelizer":!0},PromotionRule:{type:"object",properties:{id:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},type:{type:"string"},promotion_id:{type:"string"},preferences:{type:"object"},preference_schema:{type:"array",items:{$ref:"#/components/schemas/PreferenceField"}},label:{type:"string"},product_ids:{type:"array",items:{type:"string"},nullable:!0},category_ids:{type:"array",items:{type:"string"},nullable:!0},customer_ids:{type:"array",items:{type:"string"},nullable:!0},products:{type:"array",items:{$ref:"#/components/schemas/Product"}},categories:{type:"array",items:{$ref:"#/components/schemas/Category"}},customers:{type:"array",items:{$ref:"#/components/schemas/Customer"}},customer_groups:{type:"array",items:{$ref:"#/components/schemas/CustomerGroup"}},countries:{type:"array",items:{$ref:"#/components/schemas/Country"}},channels:{type:"array",items:{$ref:"#/components/schemas/Channel"}},markets:{type:"array",items:{$ref:"#/components/schemas/Market"}}},required:["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","product_ids","category_ids","customer_ids"],"x-typelizer":!0},Promotion:{type:"object",properties:{id:{type:"string"},name:{type:"string"},description:{type:"string",nullable:!0},code:{type:"string",nullable:!0},starts_at:{type:"string",nullable:!0},expires_at:{type:"string",nullable:!0},usage_limit:{type:"number",nullable:!0},match_policy:{type:"string",enum:["all","any"]},path:{type:"string",nullable:!0},kind:{type:"string",enum:["coupon_code","automatic"]},multi_codes:{type:"boolean"},number_of_codes:{type:"number",nullable:!0},code_prefix:{type:"string",nullable:!0},promotion_category_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},action_ids:{type:"array",items:{type:"string"}},rule_ids:{type:"array",items:{type:"string"}}},required:["id","name","description","code","starts_at","expires_at","usage_limit","match_policy","path","kind","multi_codes","number_of_codes","code_prefix","promotion_category_id","metadata","created_at","updated_at","action_ids","rule_ids"],"x-typelizer":!0},Refund:{type:"object",properties:{id:{type:"string"},transaction_id:{type:"string",nullable:!0},amount:{type:"string",nullable:!0},payment_id:{type:"string",nullable:!0},refund_reason_id:{type:"string",nullable:!0},reimbursement_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},payment:{$ref:"#/components/schemas/Payment"},reimbursement:{$ref:"#/components/schemas/Reimbursement"}},required:["id","transaction_id","amount","payment_id","refund_reason_id","reimbursement_id","metadata","created_at","updated_at"],"x-typelizer":!0},Reimbursement:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reimbursement_status:{type:"string",nullable:!0},total:{type:"string",nullable:!0},order_id:{type:"string",nullable:!0},customer_return_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"}},required:["id","number","reimbursement_status","total","order_id","customer_return_id","created_at","updated_at"],"x-typelizer":!0},ReturnAuthorization:{type:"object",properties:{id:{type:"string"},number:{type:"string"},status:{type:"string"},order_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},return_authorization_reason_id:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},order:{$ref:"#/components/schemas/Order"},stock_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","status","order_id","stock_location_id","return_authorization_reason_id","created_at","updated_at"],"x-typelizer":!0},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","created_at","updated_at"],"x-typelizer":!0},SetupTask:{type:"object",properties:{name:{type:"string"},done:{type:"boolean"}},required:["name","done"],"x-typelizer":!0},State:{type:"object",properties:{abbr:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"}},required:["abbr","name","created_at","updated_at"],"x-typelizer":!0},StockItem:{type:"object",properties:{id:{type:"string"},count_on_hand:{type:"number"},backorderable:{type:"boolean"},stock_location_id:{type:"string",nullable:!0},variant_id:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},allocated_count:{type:"number"},available_count:{type:"number"},stock_location:{$ref:"#/components/schemas/StockLocation"},variant:{$ref:"#/components/schemas/Variant"}},required:["id","count_on_hand","backorderable","stock_location_id","variant_id","metadata","created_at","updated_at","allocated_count","available_count"],"x-typelizer":!0},StockLocation:{type:"object",properties:{id:{type:"string"},state_abbr:{type:"string",nullable:!0},name:{type:"string"},address1:{type:"string",nullable:!0},city:{type:"string",nullable:!0},zipcode:{type:"string",nullable:!0},country_iso:{type:"string",nullable:!0},country_name:{type:"string",nullable:!0},state_text:{type:"string",nullable:!0},admin_name:{type:"string",nullable:!0},address2:{type:"string",nullable:!0},state_name:{type:"string",nullable:!0},phone:{type:"string",nullable:!0},company:{type:"string",nullable:!0},active:{type:"boolean"},default:{type:"boolean"},backorderable_default:{type:"boolean"},propagate_all_variants:{type:"boolean"},kind:{type:"string"},pickup_enabled:{type:"boolean"},pickup_stock_policy:{type:"string"},pickup_ready_in_minutes:{type:"number",nullable:!0},pickup_instructions:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","state_abbr","name","address1","city","zipcode","country_iso","country_name","state_text","admin_name","address2","state_name","phone","company","active","default","backorderable_default","propagate_all_variants","kind","pickup_enabled","pickup_stock_policy","pickup_ready_in_minutes","pickup_instructions","created_at","updated_at"],"x-typelizer":!0},StockReservation:{type:"object",properties:{id:{type:"string"},stock_item_id:{type:"string"},line_item_id:{type:"string"},order_id:{type:"string"},variant_id:{type:"string",nullable:!0},stock_location_id:{type:"string",nullable:!0},quantity:{type:"number"},expires_at:{type:"string"},active:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","stock_item_id","line_item_id","order_id","variant_id","stock_location_id","quantity","expires_at","active","created_at","updated_at"],"x-typelizer":!0},StockTransfer:{type:"object",properties:{id:{type:"string"},number:{type:"string"},reference:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},source_location_id:{type:"string",nullable:!0},destination_location_id:{type:"string",nullable:!0},source_location:{$ref:"#/components/schemas/StockLocation"},destination_location:{$ref:"#/components/schemas/StockLocation"}},required:["id","number","reference","metadata","created_at","updated_at","source_location_id","destination_location_id"],"x-typelizer":!0},StoreCreditCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},created_at:{type:"string"},updated_at:{type:"string"},non_expiring:{type:"boolean"}},required:["id","name","created_at","updated_at","non_expiring"],"x-typelizer":!0},StoreCredit:{type:"object",properties:{id:{type:"string"},amount:{type:"string"},amount_used:{type:"string"},amount_remaining:{type:"string"},display_amount:{type:"string"},display_amount_used:{type:"string"},display_amount_remaining:{type:"string"},currency:{type:"string"},memo:{type:"string",nullable:!0},metadata:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},customer_id:{type:"string",nullable:!0},created_by_id:{type:"string",nullable:!0},category_id:{type:"string",nullable:!0},category_name:{type:"string",nullable:!0}},required:["id","amount","amount_used","amount_remaining","display_amount","display_amount_used","display_amount_remaining","currency","memo","metadata","created_at","updated_at","customer_id","created_by_id","category_id","category_name"],"x-typelizer":!0},Store:{type:"object",properties:{id:{type:"string"},metadata:{type:"object"},name:{type:"string"},code:{type:"string"},preferred_storefront_url:{type:"string",nullable:!0},default_currency:{type:"string"},default_locale:{type:"string"},mail_from_address:{type:"string",nullable:!0},customer_support_email:{type:"string",nullable:!0},new_order_notifications_email:{type:"string",nullable:!0},preferred_send_consumer_transactional_emails:{type:"boolean"},preferred_admin_locale:{type:"string",nullable:!0},preferred_timezone:{type:"string"},preferred_weight_unit:{type:"string"},preferred_unit_system:{type:"string"},preferred_storefront_access:{type:"string"},preferred_guest_checkout:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"},url:{type:"string"},api_url:{type:"string"},setup_tasks:{type:"array",items:{$ref:"#/components/schemas/SetupTask"}},supported_currencies:{type:"array",items:{type:"string"}},supported_locales:{type:"array",items:{type:"string"}},available_locales:{type:"array",items:{type:"string"}},logo_url:{type:"string",nullable:!0},mailer_logo_url:{type:"string",nullable:!0}},required:["id","metadata","name","code","preferred_storefront_url","default_currency","default_locale","mail_from_address","customer_support_email","new_order_notifications_email","preferred_send_consumer_transactional_emails","preferred_admin_locale","preferred_timezone","preferred_weight_unit","preferred_unit_system","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at","url","api_url","setup_tasks","supported_currencies","supported_locales","available_locales","logo_url","mailer_logo_url"],"x-typelizer":!0},TaxCategory:{type:"object",properties:{id:{type:"string"},name:{type:"string"},tax_code:{type:"string",nullable:!0},description:{type:"string",nullable:!0},is_default:{type:"boolean"},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","name","tax_code","description","is_default","created_at","updated_at"],"x-typelizer":!0},Variant:{type:"object",properties:{id:{type:"string"},product_id:{type:"string"},sku:{type:"string",nullable:!0},options_text:{type:"string"},track_inventory:{type:"boolean"},media_count:{type:"number"},preorder_ships_at:{type:"string",nullable:!0},thumbnail_url:{type:"string",nullable:!0},purchasable:{type:"boolean"},in_stock:{type:"boolean"},backorderable:{type:"boolean"},preorder:{type:"boolean"},weight:{type:"number",nullable:!0},height:{type:"number",nullable:!0},width:{type:"number",nullable:!0},depth:{type:"number",nullable:!0},price:{$ref:"#/components/schemas/Price"},original_price:{allOf:[{$ref:"#/components/schemas/Price"}],nullable:!0},primary_media:{$ref:"#/components/schemas/Media"},media:{type:"array",items:{$ref:"#/components/schemas/Media"}},option_values:{type:"array",items:{$ref:"#/components/schemas/OptionValue"}},custom_fields:{type:"array",items:{$ref:"#/components/schemas/CustomField"}},prior_price:{allOf:[{$ref:"#/components/schemas/PriceHistory"}],nullable:!0},metadata:{type:"object"},position:{type:"number"},cost_price:{type:"string",nullable:!0},cost_currency:{type:"string",nullable:!0},barcode:{type:"string",nullable:!0},weight_unit:{type:"string",nullable:!0},dimensions_unit:{type:"string",nullable:!0},backorder_limit:{type:"number",nullable:!0},deleted_at:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},preorderable:{type:"boolean"},tax_category_id:{type:"string",nullable:!0},available_stock:{type:"number",nullable:!0},reserved_quantity:{type:"number"},total_on_hand:{type:"number",nullable:!0},product_name:{type:"string"},prices:{type:"array",items:{$ref:"#/components/schemas/Price"}},stock_items:{type:"array",items:{$ref:"#/components/schemas/StockItem"}}},required:["id","product_id","sku","options_text","track_inventory","media_count","preorder_ships_at","thumbnail_url","purchasable","in_stock","backorderable","preorder","weight","height","width","depth","price","original_price","option_values","metadata","position","cost_price","cost_currency","barcode","weight_unit","dimensions_unit","backorder_limit","deleted_at","created_at","updated_at","preorderable","tax_category_id","available_stock","reserved_quantity","total_on_hand","product_name"],"x-typelizer":!0},WebhookDelivery:{type:"object",properties:{id:{type:"string"},event_name:{type:"string"},event_id:{type:"string",nullable:!0},response_code:{type:"number",nullable:!0},execution_time:{type:"number",nullable:!0},error_type:{type:"string",nullable:!0},request_errors:{type:"string",nullable:!0},response_body:{type:"string",nullable:!0},success:{type:"boolean",nullable:!0},payload:{type:"object"},created_at:{type:"string"},updated_at:{type:"string"},delivered_at:{type:"string",nullable:!0},webhook_endpoint_id:{type:"string"},webhook_endpoint_url:{type:"string"}},required:["id","event_name","event_id","response_code","execution_time","error_type","request_errors","response_body","success","payload","created_at","updated_at","delivered_at","webhook_endpoint_id","webhook_endpoint_url"],"x-typelizer":!0},WebhookEndpoint:{type:"object",properties:{id:{type:"string"},name:{type:"string",nullable:!0},url:{type:"string"},active:{type:"boolean"},subscriptions:{type:"array",items:{type:"string"}},disabled_reason:{type:"string",nullable:!0},created_at:{type:"string"},updated_at:{type:"string"},disabled_at:{type:"string",nullable:!0},secret_key:{type:"string",nullable:!0},last_delivery_at:{type:"string",nullable:!0},recent_delivery_count:{type:"number"},recent_failure_count:{type:"number"},total_delivery_count:{type:"number"},successful_delivery_count:{type:"number"},failed_delivery_count:{type:"number"}},required:["id","name","url","active","subscriptions","disabled_reason","created_at","updated_at","disabled_at","secret_key","last_delivery_at","recent_delivery_count","recent_failure_count","total_delivery_count","successful_delivery_count","failed_delivery_count"],"x-typelizer":!0}}}};var Xm=new Set(["get","post","put","patch","delete"]);function Tn(){return Ym}function iS(e){let t=e.description?.match(/\*\*Required scope:\*\* (.+?) \(for API-key authentication\)\./);return t?t[1].replaceAll("`",""):"\u2014"}function Zm(e,t={}){let r=[];for(let[i,n]of Object.entries(e.paths)){let s=i.replace("/api/v3/admin","")||"/";for(let[o,a]of Object.entries(n)){if(!Xm.has(o))continue;if(t.resource){let d=s.split("/")[1]??"";if(d!==t.resource&&!d.startsWith(t.resource))continue}let c=a.summary??"";t.search&&!`${o} ${s} ${c}`.toLowerCase().includes(t.search.toLowerCase())||r.push({method:o.toUpperCase(),path:s,scope:iS(a),summary:c})}}return r}function Qm(e,t){let r=t.trim().split(/\s+/),i=r.length>1?r[0].toLowerCase():void 0,n=r.length>1?r[1]:r[0],s=Fr(n),o=Jm(e,i,a=>a===s);return o.length>0?o:Jm(e,i,a=>nS(a,s))}function Jm(e,t,r){let i=[];for(let[n,s]of Object.entries(e.paths)){let o=n.replace("/api/v3/admin","")||"/";if(r(o))for(let[a,c]of Object.entries(s))Xm.has(a)&&(t&&a!==t||i.push({method:a.toUpperCase(),path:o,summary:c.summary,description:c.description,parameters:er(c.parameters,e),requestBody:er(c.requestBody,e),responses:er(c.responses,e)}))}return i}function nS(e,t){if(e===t)return!0;let r=e.split("/"),i=t.split("/");return r.length!==i.length?!1:r.every((n,s)=>n.startsWith("{")&&n.endsWith("}")?i[s].length>0:n===i[s])}var sS=8;function er(e,t,r=[]){if(Array.isArray(e))return e.map(o=>er(o,t,r));if(!e||typeof e!="object")return e;let i=e,n=i.$ref;if(typeof n=="string"){let o=n.replace("#/components/schemas/","");return r.includes(o)||r.length>=sS||!(o in t.components.schemas)?{$ref:n}:er(t.components.schemas[o],t,[...r,o])}let s={};for(let[o,a]of Object.entries(i))s[o]=er(a,t,r);return s}function oS(e,t){return[...t,e]}function ih(e){return e.option("--profile <name>","use a saved profile (see `spree auth`)").option("--base-url <url>","store URL (overrides profile/env/project)").option("--api-key <key>","secret API key (prefer SPREE_API_KEY \u2014 flags leak into shell history)").option("--store-id <id>","X-Spree-Store-Id for hosts serving multiple stores")}function nh(){return new Ma("--format <format>","output format").choices(["json","table"]).default("json")}function eh(e){return ih(e).addOption(nh())}async function th(e){let t=await Er({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile});return{client:Tr({baseUrl:t.baseUrl,secretKey:t.apiKey,...e.storeId?{storeId:e.storeId}:{}}),credentials:t}}function sh(e){let t=e.command("api").description("Call the Admin API directly (generic get/post/patch/delete)");t.addHelpText("after",["","Examples:"," spree api get /products -q status_eq=active --limit 10",` spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'`," spree api get /orders/ord_x8k2J9aQ --expand items,payments","","Discover the surface (offline, no server needed):"," spree api endpoints --search <term> # find endpoints + required scopes",' spree api schema "POST /orders" # request/response schema for one operation'," spree completion zsh # tab-completion for paths, filters, scopes"].join(`
365
+ `)),eh(t.command("get <path>").description("GET an Admin API path, e.g. `spree api get /products -q status_eq=active`").option("-q, --query <expr>","Ransack predicate key=value (repeatable)",oS,[]).option("--sort <fields>","sort, e.g. -created_at").option("--page <n>","page number").option("--limit <n>","page size (max 100)").option("--expand <relations>","expand relations, e.g. variants,variants.prices").option("--fields <fields>","sparse fields, e.g. id,name")).action(async(r,i)=>{let n;try{let s=Hm(i),{client:o,credentials:a}=await th(i);n=a.baseUrl;let c=await o.request("GET",Fr(r),{params:s});Mr(c,i.format)}catch(s){Pt(s,{baseUrl:n})}});for(let r of["post","patch","delete"])eh(t.command(`${r} <path>`).description(`${r.toUpperCase()} an Admin API path`).option("-d, --data <json>","request body: inline JSON, @file, or '-' for stdin")).action(async(i,n)=>{let s;try{let o=await zm(n.data),{client:a,credentials:c}=await th(n);s=c.baseUrl;let d=await a.request(r.toUpperCase(),Fr(i),{...o===ya?{}:{body:o}});Mr(d,n.format)}catch(o){Pt(o,{baseUrl:s})}});t.command("endpoints").description("List Admin API endpoints with their required scopes").option("--resource <name>","filter by first path segment, e.g. orders").option("--search <term>","filter by method, path, or summary").addOption(nh()).action(r=>{let i=Zm(Tn(),{resource:r.resource,search:r.search});if(i.length===0){process.stderr.write(`No endpoints match.
366
+ `),process.exitCode=1;return}if(r.format==="table"){(0,rh.printTable)(i.map(n=>({Method:n.method,Path:n.path,Scope:n.scope,Summary:n.summary})));return}Mr(i,"json")}),t.command("schema <operation>").description('Show the request/response schema for an operation, e.g. `spree api schema "POST /products"`').action(r=>{let i=Qm(Tn(),r);if(i.length===0){process.stderr.write(`No operation matches "${r}". Try \`spree api endpoints --search ${r.split(/\s+/).pop()}\`.
367
+ `),process.exitCode=1;return}let n=/\s/.test(r.trim());Mr(n&&i.length===1?i[0]:i,"json")}),ih(t.command("status").description("Show resolved credentials, server reachability, and the bundled spec version")).action(async r=>{try{let i=await Er({baseUrl:r.baseUrl,apiKey:r.apiKey,profile:r.profile},{allowMint:!1}),n=await Br(i.baseUrl,i.apiKey),s=Tn(),o=Pn(n),a=[`${Pe.default.bold("Base URL:")} ${i.baseUrl}`,`${Pe.default.bold("Credentials:")} ${i.source}${i.profileName?` (${i.profileName})`:""}, key ${i.tokenPrefix}${Pe.default.dim("\u2026")}`],c=n.status==="unreachable"||n.status==="unauthorized"?null:await Km(i.baseUrl,i.apiKey);c!==null?a.push(`${Pe.default.bold("Scopes:")} ${c.length?c.join(", "):Pe.default.dim("(none)")}`):i.scopes?.length&&a.push(`${Pe.default.bold("Scopes:")} ${i.scopes.join(", ")} ${Pe.default.dim("(local snapshot from mint time \u2014 may be stale)")}`),a.push(`${Pe.default.bold("Server:")} ${o}`),a.push(`${Pe.default.bold("Bundled spec:")} ${s.info?.version??"unknown"} ${Pe.default.dim("(spree api endpoints/schema reflect this snapshot, not the live server)")}`),process.stdout.write(`${a.join(`
368
368
  `)}
369
- `),qn(n)&&(process.exitCode=1)}catch(i){Ct(i,{baseUrl:r.baseUrl})}})}var Zm=U(jr(),1),et=U(Y(),1);function Qm(e){let t=e.command("api-key").description("Manage API keys");t.command("create").description("Create an API key").option("--name <name>","key name").option("--type <type>","key type: publishable or secret").option("--scopes <scopes>","comma-separated scopes for secret keys (e.g. read_all or read_orders,write_products)").action(async r=>{let i=_(),n=r.name,s=r.type,o=r.scopes;if(!n){let m=await le({message:"Key name:",placeholder:"My Storefront",validate(h){if(!h)return"Name is required"}});D(m)&&(O("Cancelled."),process.exit(0)),n=m}if(!s){let m=await oi({message:"Key type:",options:[{value:"publishable",label:"Publishable (for storefronts)"},{value:"secret",label:"Secret (for server-to-server)"}]});D(m)&&(O("Cancelled."),process.exit(0)),s=m}if(s!=="publishable"&&s!=="secret")throw new Error('Key type must be "publishable" or "secret".');if(s==="secret"&&!o){let m=await le({message:"Scopes (comma-separated):",placeholder:"read_all",initialValue:"read_all",validate(h){if(!h)return"Secret keys require at least one scope"}});D(m)&&(O("Cancelled."),process.exit(0)),o=m}let a=E();a.start("Creating API key...");let c=await ne("spree:cli:create_api_key",i.projectDir,{NAME:n,KEY_TYPE:s,...s==="secret"&&o?{SCOPES:o}:{}}),d=s==="publishable"?"pk_":"sk_",p=c.match(new RegExp(`${d}[A-Za-z0-9_-]+`)),u=p?p[0]:c.trim();a.stop("API key created.");let l=[`${et.default.bold("Name:")} ${n}`,`${et.default.bold("Type:")} ${s}`,`${et.default.bold("Token:")} ${et.default.cyan(u)}`];s==="secret"&&(l.push(`${et.default.bold("Scopes:")} ${o}`),l.push(""),l.push(et.default.yellow("Save this token now \u2014 secret keys cannot be retrieved later."))),W(l.join(`
369
+ `),En(n)&&(process.exitCode=1)}catch(i){Pt(i,{baseUrl:r.baseUrl})}})}var oh=M(Lr(),1),et=M(K(),1);function ah(e){let t=e.command("api-key").description("Manage API keys");t.command("create").description("Create an API key").option("--name <name>","key name").option("--type <type>","key type: publishable or secret").option("--scopes <scopes>","comma-separated scopes for secret keys (e.g. read_all or read_orders,write_products)").action(async r=>{let i=_(),n=r.name,s=r.type,o=r.scopes;if(!n){let m=await le({message:"Key name:",placeholder:"My Storefront",validate(h){if(!h)return"Name is required"}});D(m)&&(O("Cancelled."),process.exit(0)),n=m}if(!s){let m=await li({message:"Key type:",options:[{value:"publishable",label:"Publishable (for storefronts)"},{value:"secret",label:"Secret (for server-to-server)"}]});D(m)&&(O("Cancelled."),process.exit(0)),s=m}if(s!=="publishable"&&s!=="secret")throw new Error('Key type must be "publishable" or "secret".');if(s==="secret"&&!o){let m=await le({message:"Scopes (comma-separated):",placeholder:"read_all",initialValue:"read_all",validate(h){if(!h)return"Secret keys require at least one scope"}});D(m)&&(O("Cancelled."),process.exit(0)),o=m}let a=E();a.start("Creating API key...");let c=await ne("spree:cli:create_api_key",i.projectDir,{NAME:n,KEY_TYPE:s,...s==="secret"&&o?{SCOPES:o}:{}}),d=s==="publishable"?"pk_":"sk_",p=c.match(new RegExp(`${d}[A-Za-z0-9_-]+`)),u=p?p[0]:c.trim();a.stop("API key created.");let l=[`${et.default.bold("Name:")} ${n}`,`${et.default.bold("Type:")} ${s}`,`${et.default.bold("Token:")} ${et.default.cyan(u)}`];s==="secret"&&(l.push(`${et.default.bold("Scopes:")} ${o}`),l.push(""),l.push(et.default.yellow("Save this token now \u2014 secret keys cannot be retrieved later."))),W(l.join(`
370
370
  `),"API Key")}),t.command("list").description("List API keys").action(async()=>{let r=_(),i=E();i.start("Fetching API keys...");let n=await ne("spree:cli:list_api_keys",r.projectDir);i.stop("");let s=n.trim().split(`
371
- `).filter(Boolean);if(s.length===0){b.info("No API keys found.");return}let o=s.map(a=>{let[c,d,p,u,l,m]=a.split("|");return{ID:c??"",Name:d??"",Type:p??"",Token:u??"",Created:l??"",Status:m==="active"?et.default.green(m):et.default.red(m??"")}});(0,Zm.printTable)(o)}),t.command("revoke").description("Revoke an API key").argument("<id>","ID of the key to revoke (from api-key list)").action(async r=>{let i=_(),n=E();n.start("Revoking API key...");let o=(await ne("spree:cli:revoke_api_key",i.projectDir,{ID:r})).trim();n.stop(`API key "${o}" revoked.`)})}var eh=U(jr(),1),ie=U(Y(),1);function th(e){let t=e.command("auth").description("Manage Admin API credentials (profiles in ~/.config/spree)");t.command("login").description("Save a secret API key as a named profile").option("--profile <name>","profile name","default").option("--base-url <url>","store URL, e.g. https://store.example.com").action(async r=>{process.stdin.isTTY||(process.stderr.write(`${ie.default.red("error:")} \`spree auth login\` is interactive. For non-interactive use, set SPREE_BASE_URL + SPREE_API_KEY (or pass --base-url/--api-key to \`spree api\`).
372
- `),process.exit(2));let i=r.baseUrl;if(!i){let d=await le({message:"Store URL:",placeholder:"https://store.example.com",validate(p){if(!p)return"URL is required";if(!/^https?:\/\//.test(p))return"Must start with http:// or https://"}});D(d)&&(O("Cancelled."),process.exit(130)),i=d}i=i.replace(/\/$/,"");let n=await si({message:"Secret API key (sk_...):",validate(d){if(!d)return"Key is required";if(!d.startsWith("sk_"))return"Admin API keys start with sk_"}});D(n)&&(O("Cancelled."),process.exit(130));let s=n,o=E();o.start("Validating credentials...");let a=await Mr(i,s);a.status==="unauthorized"&&(o.stop(ie.default.red("The server rejected this key (401). Check the key and try again.")),process.exit(2)),a.status==="unreachable"&&(o.stop(ie.default.red(`Could not reach ${i}: ${a.message}`)),process.exit(2)),o.stop(a.storeName?`Connected to ${ie.default.bold(a.storeName)}.`:"Credentials accepted (key lacks read_settings, so the store name is hidden \u2014 that is fine).");let c=qr();c.profiles[r.profile]={baseUrl:i,token:s},c.defaultProfile||=r.profile,No(c),W([`${ie.default.bold("Profile:")} ${r.profile}${c.defaultProfile===r.profile?ie.default.dim(" (default)"):""}`,`${ie.default.bold("Base URL:")} ${i}`,`${ie.default.bold("Key:")} ${vn(s)}${ie.default.dim("\u2026")}`,"",ie.default.dim(`Saved to ${St()}`)].join(`
373
- `),"Logged in")}),t.command("status").description("Show which credentials `spree api` would use, and verify them").option("--profile <name>","check a specific profile").action(async r=>{let i;try{i=await $r({profile:r.profile},{allowMint:!1})}catch(a){Ct(a)}let n=E();n.start("Checking server...");let s=await Mr(i.baseUrl,i.apiKey);n.stop("");let o=$n(s);W([`${ie.default.bold("Source:")} ${i.source}${i.profileName?` (${i.profileName})`:""}`,`${ie.default.bold("Base URL:")} ${i.baseUrl}`,`${ie.default.bold("Key:")} ${i.tokenPrefix}${ie.default.dim("\u2026")}`,...i.scopes?[`${ie.default.bold("Scopes:")} ${i.scopes.join(", ")}`]:[],`${ie.default.bold("Server:")} ${o}`].join(`
374
- `),"Auth status"),qn(s)&&(process.exitCode=1)}),t.command("logout").description("Remove a saved profile (or the project credentials)").option("--profile <name>","profile to remove","default").option("--project","remove .spree/credentials.json from the current project instead").action(async r=>{if(r.project){let n;try{n=_().projectDir}catch(o){Ct(o)}(await import("fs")).rmSync(Vt(n),{force:!0}),b.success("Removed project credentials. The next `spree api` call mints a fresh read-only key.");return}let i=qr();if(!i.profiles[r.profile]){let n=Object.keys(i.profiles),s=n.length?` Saved profiles: ${n.join(", ")}.`:" No profiles are saved.";process.stderr.write(`${ie.default.red("error:")} no profile named "${r.profile}".${s}
375
- `),process.exit(2)}delete i.profiles[r.profile],i.defaultProfile===r.profile&&(i.defaultProfile=Object.keys(i.profiles)[0]),No(i),b.success(`Removed profile "${r.profile}". The key itself stays active \u2014 revoke it with \`spree api-key revoke\` or in the admin.`)}),t.command("list").description("List saved profiles").action(()=>{let r=qr(),i=Object.keys(r.profiles);if(i.length===0){b.info("No profiles saved. Run `spree auth login` to add one.");return}(0,eh.printTable)(i.map(n=>({Profile:r.defaultProfile===n?`${n} *`:n,"Base URL":r.profiles[n].baseUrl,Key:`${vn(r.profiles[n].token)}\u2026`})))})}import Xt from"fs";import eS from"os";import yt from"path";var ae=U(Y(),1);function rh(e){e.command("build").description("Rebuild the dev image (after Dockerfile / .ruby-version changes)").option("--reset-bundle","also wipe the bundle_cache volume to re-seed gems").option("--yes","skip confirmation prompts (for CI)").option("--production","build the production image instead \u2014 includes apps/dashboard when present").option("--tag <tag>","image tag for --production (default: <project>-spree:latest)").action(async t=>{if(t.production){await iS(_().projectDir,t.tag);return}await tS(t)})}async function tS(e){let t=_();if(Me(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${ae.default.bold("pnpm server:build")} from the monorepo root instead of ${ae.default.bold("spree build")}.`,"It builds against the edge compose overlay the running stack was started with."].join(`
376
- `)),process.exit(1)),kr(t.projectDir)||(console.error(`
377
- ${ae.default.red("Error:")} docker-compose.yml has no \`build:\` section. Run ${ae.default.bold("spree eject")} first to switch to a build-from-source stack.
378
- `),process.exit(1)),e.resetBundle){if(!e.yes){let i=await Ke({message:"Wipe the bundle_cache volume? Any gems added via `spree bundle add` since the last image build will be lost.",initialValue:!1});(D(i)||!i)&&(O("Build cancelled."),process.exit(0))}let r=E();r.start("Wiping bundle_cache volume...");try{await X(["down"],t.projectDir,{stdio:"ignore"});let n=`${await nS(t.projectDir)}_bundle_cache`;await sS(n,t.projectDir)?(await J("docker",["volume","rm",n],{cwd:t.projectDir,stdio:"ignore"}),r.stop("bundle_cache volume wiped.")):r.stop(`bundle_cache volume not present (looked for ${n}).`)}catch(i){throw r.stop("Failed to wipe bundle_cache volume."),i}}console.log(`
379
- ${ae.default.bold("Rebuilding dev image...")}
380
- `),await X(["build","web","worker"],t.projectDir,{stdio:"inherit"}),W([`Image rebuilt. Start the stack with ${ae.default.bold("spree dev")}.`,e.resetBundle?`On next boot, gems will re-seed into a fresh ${ae.default.dim("bundle_cache")} volume.`:""].filter(Boolean).join(`
381
- `),"Build complete")}function rS(e,t){let r=yt.join(e,"backend"),i=yt.join(r,"Dockerfile");if(!Xt.existsSync(i))throw new Error("No backend/Dockerfile found. Is this a create-spree-app project?");let n=t??`${yt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}-spree:latest`,s=["build",r,"-f",i,"-t",n],o=yt.join(e,"apps","dashboard");if(!Xt.existsSync(yt.join(o,"package.json")))return{args:s,imageTag:n,dashboard:"stock-or-none"};if(!Xt.readFileSync(i,"utf-8").includes("DASHBOARD_SOURCE"))return{args:s,imageTag:n,dashboard:"unsupported-dockerfile"};let a=Xt.mkdtempSync(yt.join(eS.tmpdir(),"spree-dashboard-src-"));return Xt.cpSync(o,a,{recursive:!0,filter:c=>{let d=yt.basename(c);return d!=="node_modules"&&d!=="dist"&&d!==".tanstack"}}),s.push("--build-arg","DASHBOARD_SOURCE=custom","--build-context",`dashboard-src=${a}`),{args:s,imageTag:n,dashboard:"custom",stagedDashboardDir:a}}async function iS(e,t){let r;try{r=rS(e,t)}catch(i){console.error(`
382
- ${ae.default.red("Error:")} ${i instanceof Error?i.message:String(i)}
383
- `),process.exit(1)}r.dashboard==="custom"?b.info(`Including your dashboard from ${ae.default.bold("apps/dashboard/")} (built in-image).`):r.dashboard==="unsupported-dockerfile"&&b.warn(`${ae.default.bold("apps/dashboard/")} exists, but ${ae.default.bold("backend/Dockerfile")} predates dashboard support (no DASHBOARD_SOURCE build arg) \u2014 the image will NOT include your dashboard. Update the Dockerfile from the spree-starter template to bake it in.`),console.log(`
384
- ${ae.default.bold(`Building production image ${r.imageTag}...`)}
385
- `);try{await J("docker",r.args,{cwd:e,stdio:"inherit"})}finally{r.stagedDashboardDir&&Xt.rmSync(r.stagedDashboardDir,{recursive:!0,force:!0})}W([`Run it: ${ae.default.cyan(`docker run --rm -p 3000:3000 ${r.imageTag}`)}`,`Push it: ${ae.default.cyan(`docker tag ${r.imageTag} <registry>/<repo> && docker push <registry>/<repo>`)}`,r.dashboard!=="unsupported-dockerfile"?`Dashboard: served at ${ae.default.bold("/dashboard")} when the image includes one.`:""].filter(Boolean).join(`
386
- `),"Production image built")}async function nS(e){try{let{stdout:t}=await J("docker",["compose","config","--format","json"],{cwd:e}),r=JSON.parse(t);if(r.name)return r.name}catch{}return yt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}async function sS(e,t){try{return await J("docker",["volume","inspect",e],{cwd:t,stdio:"ignore"}),!0}catch{return!1}}function ih(e){e.command("bundle").description("Run a bundler command (`bundle \u2026`) inside the web container").argument("<args...>","arguments to pass to bundle").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await ut(["bundle",...t],r.projectDir,{edgeHint:"the edge stack heals gem drift on boot"})})}var nh=["/admin_users","/allowed_origins","/api_keys","/auth","/categories","/channels","/custom_field_definitions","/customer_groups","/customers","/exports","/gift_card_batches","/gift_cards","/imports","/invitations","/locales","/markets","/me","/option_types","/orders","/payment_methods","/price_lists","/prices","/products","/promotion_actions","/promotion_rules","/promotions","/roles","/stock_locations","/store","/store_credit_categories","/tags","/translatable_resources","/translations","/webhook_endpoints"];var sh=["bash","zsh","fish"],aS=["eq","not_eq","cont","not_cont","start","end","in","not_in","gt","gteq","lt","lteq","null","not_null","present","blank"],cS=["get","post","patch","delete","endpoints","schema","status"],pS=["read_all","write_all","read_orders","write_orders","read_products","write_products","read_promotions","write_promotions","read_customers","write_customers","read_payments","write_payments","read_fulfillments","write_fulfillments","read_refunds","write_refunds","read_gift_cards","write_gift_cards","read_store_credits","write_store_credits","read_stock","write_stock","read_categories","write_categories","read_settings","write_settings","read_webhooks","write_webhooks","read_api_keys","write_api_keys","read_dashboard"];function dS(e){let[t,r,...i]=e,n=e[e.length-1]??"",s=e[e.length-2]??"";if(e.length<=1)return Cn(["api","auth",...uS],n);if((s==="-q"||s==="--query")&&n.includes("_")&&!n.includes("=")){let o=n.slice(0,n.lastIndexOf("_")+1);return aS.map(a=>`${o}${a}=`)}if(s==="--scopes"){let o=n.includes(",")?n.slice(n.lastIndexOf(",")+1):n,a=n.slice(0,n.length-o.length);return Cn(pS,o).map(c=>a+c)}if(t==="api"){if(e.length===2)return Cn(cS,n);if(["get","post","patch","delete","schema"].includes(r)&&i.length<=1)return Cn(nh,n)}return[]}var uS=["api-key","dev","console","migrate"];function Cn(e,t){return t?e.filter(r=>r.startsWith(t)):e}function lS(e){return e==="fish"?`# spree fish completion \u2014 eval "$(spree completion fish)"
371
+ `).filter(Boolean);if(s.length===0){b.info("No API keys found.");return}let o=s.map(a=>{let[c,d,p,u,l,m]=a.split("|");return{ID:c??"",Name:d??"",Type:p??"",Token:u??"",Created:l??"",Status:m==="active"?et.default.green(m):et.default.red(m??"")}});(0,oh.printTable)(o)}),t.command("revoke").description("Revoke an API key").argument("<id>","ID of the key to revoke (from api-key list)").action(async r=>{let i=_(),n=E();n.start("Revoking API key...");let o=(await ne("spree:cli:revoke_api_key",i.projectDir,{ID:r})).trim();n.stop(`API key "${o}" revoked.`)})}var ch=M(Lr(),1),ie=M(K(),1);function ph(e){let t=e.command("auth").description("Manage Admin API credentials (profiles in ~/.config/spree)");t.command("login").description("Save a secret API key as a named profile").option("--profile <name>","profile name","default").option("--base-url <url>","store URL, e.g. https://store.example.com").action(async r=>{process.stdin.isTTY||(process.stderr.write(`${ie.default.red("error:")} \`spree auth login\` is interactive. For non-interactive use, set SPREE_BASE_URL + SPREE_API_KEY (or pass --base-url/--api-key to \`spree api\`).
372
+ `),process.exit(2));let i=r.baseUrl;if(!i){let d=await le({message:"Store URL:",placeholder:"https://store.example.com",validate(p){if(!p)return"URL is required";if(!/^https?:\/\//.test(p))return"Must start with http:// or https://"}});D(d)&&(O("Cancelled."),process.exit(130)),i=d}i=i.replace(/\/$/,"");let n=await ui({message:"Secret API key (sk_...):",validate(d){if(!d)return"Key is required";if(!d.startsWith("sk_"))return"Admin API keys start with sk_"}});D(n)&&(O("Cancelled."),process.exit(130));let s=n,o=E();o.start("Validating credentials...");let a=await Br(i,s);a.status==="unauthorized"&&(o.stop(ie.default.red("The server rejected this key (401). Check the key and try again.")),process.exit(2)),a.status==="unreachable"&&(o.stop(ie.default.red(`Could not reach ${i}: ${a.message}`)),process.exit(2)),o.stop(a.storeName?`Connected to ${ie.default.bold(a.storeName)}.`:"Credentials accepted (key lacks read_settings, so the store name is hidden \u2014 that is fine).");let c=Cr();c.profiles[r.profile]={baseUrl:i,token:s},c.defaultProfile||=r.profile,Yo(c),W([`${ie.default.bold("Profile:")} ${r.profile}${c.defaultProfile===r.profile?ie.default.dim(" (default)"):""}`,`${ie.default.bold("Base URL:")} ${i}`,`${ie.default.bold("Key:")} ${An(s)}${ie.default.dim("\u2026")}`,"",ie.default.dim(`Saved to ${St()}`)].join(`
373
+ `),"Logged in")}),t.command("status").description("Show which credentials `spree api` would use, and verify them").option("--profile <name>","check a specific profile").action(async r=>{let i;try{i=await Er({profile:r.profile},{allowMint:!1})}catch(a){Pt(a)}let n=E();n.start("Checking server...");let s=await Br(i.baseUrl,i.apiKey);n.stop("");let o=Pn(s);W([`${ie.default.bold("Source:")} ${i.source}${i.profileName?` (${i.profileName})`:""}`,`${ie.default.bold("Base URL:")} ${i.baseUrl}`,`${ie.default.bold("Key:")} ${i.tokenPrefix}${ie.default.dim("\u2026")}`,...i.scopes?[`${ie.default.bold("Scopes:")} ${i.scopes.join(", ")}`]:[],`${ie.default.bold("Server:")} ${o}`].join(`
374
+ `),"Auth status"),En(s)&&(process.exitCode=1)}),t.command("logout").description("Remove a saved profile (or the project credentials)").option("--profile <name>","profile to remove","default").option("--project","remove .spree/credentials.json from the current project instead").action(async r=>{if(r.project){let n;try{n=_().projectDir}catch(o){Pt(o)}(await import("fs")).rmSync(Yt(n),{force:!0}),b.success("Removed project credentials. The next `spree api` call mints a fresh read-only key.");return}let i=Cr();if(!i.profiles[r.profile]){let n=Object.keys(i.profiles),s=n.length?` Saved profiles: ${n.join(", ")}.`:" No profiles are saved.";process.stderr.write(`${ie.default.red("error:")} no profile named "${r.profile}".${s}
375
+ `),process.exit(2)}delete i.profiles[r.profile],i.defaultProfile===r.profile&&(i.defaultProfile=Object.keys(i.profiles)[0]),Yo(i),b.success(`Removed profile "${r.profile}". The key itself stays active \u2014 revoke it with \`spree api-key revoke\` or in the admin.`)}),t.command("list").description("List saved profiles").action(()=>{let r=Cr(),i=Object.keys(r.profiles);if(i.length===0){b.info("No profiles saved. Run `spree auth login` to add one.");return}(0,ch.printTable)(i.map(n=>({Profile:r.defaultProfile===n?`${n} *`:n,"Base URL":r.profiles[n].baseUrl,Key:`${An(r.profiles[n].token)}\u2026`})))})}import tr from"fs";import aS from"os";import yt from"path";var ce=M(K(),1);function dh(e){e.command("build").description("Rebuild the dev image (after Dockerfile / .ruby-version changes)").option("--reset-bundle","also wipe the bundle_cache volume to re-seed gems").option("--yes","skip confirmation prompts (for CI)").option("--production","build the production image instead \u2014 includes apps/dashboard when present").option("--tag <tag>","image tag for --production (default: <project>-spree:latest)").action(async t=>{if(t.production){await dS(_().projectDir,t.tag);return}await cS(t)})}async function cS(e){let t=_();if(Fe(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${ce.default.bold("pnpm server:build")} from the monorepo root instead of ${ce.default.bold("spree build")}.`,"It builds against the edge compose overlay the running stack was started with."].join(`
376
+ `)),process.exit(1)),qr(t.projectDir)||(console.error(`
377
+ ${ce.default.red("Error:")} docker-compose.yml has no \`build:\` section. Run ${ce.default.bold("spree eject")} first to switch to a build-from-source stack.
378
+ `),process.exit(1)),e.resetBundle){if(!e.yes){let i=await Ke({message:"Wipe the bundle_cache volume? Any gems added via `spree bundle add` since the last image build will be lost.",initialValue:!1});(D(i)||!i)&&(O("Build cancelled."),process.exit(0))}let r=E();r.start("Wiping bundle_cache volume...");try{await X(["down"],t.projectDir,{stdio:"ignore"});let n=`${await uS(t.projectDir)}_bundle_cache`;await lS(n,t.projectDir)?(await J("docker",["volume","rm",n],{cwd:t.projectDir,stdio:"ignore"}),r.stop("bundle_cache volume wiped.")):r.stop(`bundle_cache volume not present (looked for ${n}).`)}catch(i){throw r.stop("Failed to wipe bundle_cache volume."),i}}console.log(`
379
+ ${ce.default.bold("Rebuilding dev image...")}
380
+ `),await X(["build","web","worker"],t.projectDir,{stdio:"inherit"}),W([`Image rebuilt. Start the stack with ${ce.default.bold("spree dev")}.`,e.resetBundle?`On next boot, gems will re-seed into a fresh ${ce.default.dim("bundle_cache")} volume.`:""].filter(Boolean).join(`
381
+ `),"Build complete")}function pS(e,t){let r=yt.join(e,"backend"),i=yt.join(r,"Dockerfile");if(!tr.existsSync(i))throw new Error("No backend/Dockerfile found. Is this a create-spree-app project?");let n=t??`${yt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}-spree:latest`,s=["build",r,"-f",i,"-t",n],o=yt.join(e,"apps","dashboard");if(!tr.existsSync(yt.join(o,"package.json")))return{args:s,imageTag:n,dashboard:"stock-or-none"};if(!tr.readFileSync(i,"utf-8").includes("DASHBOARD_SOURCE"))return{args:s,imageTag:n,dashboard:"unsupported-dockerfile"};let a=tr.mkdtempSync(yt.join(aS.tmpdir(),"spree-dashboard-src-"));return tr.cpSync(o,a,{recursive:!0,filter:c=>{let d=yt.basename(c);return d!=="node_modules"&&d!=="dist"&&d!==".tanstack"}}),s.push("--build-arg","DASHBOARD_SOURCE=custom","--build-context",`dashboard-src=${a}`),{args:s,imageTag:n,dashboard:"custom",stagedDashboardDir:a}}async function dS(e,t){let r;try{r=pS(e,t)}catch(i){console.error(`
382
+ ${ce.default.red("Error:")} ${i instanceof Error?i.message:String(i)}
383
+ `),process.exit(1)}r.dashboard==="custom"?b.info(`Including your dashboard from ${ce.default.bold("apps/dashboard/")} (built in-image).`):r.dashboard==="unsupported-dockerfile"&&b.warn(`${ce.default.bold("apps/dashboard/")} exists, but ${ce.default.bold("backend/Dockerfile")} predates dashboard support (no DASHBOARD_SOURCE build arg) \u2014 the image will NOT include your dashboard. Update the Dockerfile from the spree-starter template to bake it in.`),console.log(`
384
+ ${ce.default.bold(`Building production image ${r.imageTag}...`)}
385
+ `);try{await J("docker",r.args,{cwd:e,stdio:"inherit"})}finally{r.stagedDashboardDir&&tr.rmSync(r.stagedDashboardDir,{recursive:!0,force:!0})}W([`Run it: ${ce.default.cyan(`docker run --rm -p 3000:3000 ${r.imageTag}`)}`,`Push it: ${ce.default.cyan(`docker tag ${r.imageTag} <registry>/<repo> && docker push <registry>/<repo>`)}`,r.dashboard!=="unsupported-dockerfile"?`Dashboard: served at ${ce.default.bold("/dashboard")} when the image includes one.`:""].filter(Boolean).join(`
386
+ `),"Production image built")}async function uS(e){try{let{stdout:t}=await J("docker",["compose","config","--format","json"],{cwd:e}),r=JSON.parse(t);if(r.name)return r.name}catch{}return yt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}async function lS(e,t){try{return await J("docker",["volume","inspect",e],{cwd:t,stdio:"ignore"}),!0}catch{return!1}}function uh(e){e.command("bundle").description("Run a bundler command (`bundle \u2026`) inside the web container").argument("<args...>","arguments to pass to bundle").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await ut(["bundle",...t],r.projectDir,{edgeHint:"the edge stack heals gem drift on boot"})})}var lh=["/admin_users","/allowed_origins","/api_keys","/auth","/categories","/channels","/custom_field_definitions","/customer_groups","/customers","/exports","/gift_card_batches","/gift_cards","/imports","/invitations","/locales","/markets","/me","/option_types","/orders","/payment_methods","/price_lists","/prices","/products","/promotion_actions","/promotion_rules","/promotions","/roles","/stock_locations","/store","/store_credit_categories","/tags","/translatable_resources","/translations","/webhook_endpoints"];var mh=["bash","zsh","fish"],hS=["eq","not_eq","cont","not_cont","start","end","in","not_in","gt","gteq","lt","lteq","null","not_null","present","blank"],yS=["get","post","patch","delete","endpoints","schema","status"],fS=["read_all","write_all","read_orders","write_orders","read_products","write_products","read_promotions","write_promotions","read_customers","write_customers","read_payments","write_payments","read_fulfillments","write_fulfillments","read_refunds","write_refunds","read_gift_cards","write_gift_cards","read_store_credits","write_store_credits","read_stock","write_stock","read_categories","write_categories","read_settings","write_settings","read_webhooks","write_webhooks","read_api_keys","write_api_keys","read_dashboard"];function gS(e){let[t,r,...i]=e,n=e[e.length-1]??"",s=e[e.length-2]??"";if(e.length<=1)return Rn(["api","auth",..._S],n);if((s==="-q"||s==="--query")&&n.includes("_")&&!n.includes("=")){let o=n.slice(0,n.lastIndexOf("_")+1);return hS.map(a=>`${o}${a}=`)}if(s==="--scopes"){let o=n.includes(",")?n.slice(n.lastIndexOf(",")+1):n,a=n.slice(0,n.length-o.length);return Rn(fS,o).map(c=>a+c)}if(t==="api"){if(e.length===2)return Rn(yS,n);if(["get","post","patch","delete","schema"].includes(r)&&i.length<=1)return Rn(lh,n)}return[]}var _S=["api-key","dev","console","migrate"];function Rn(e,t){return t?e.filter(r=>r.startsWith(t)):e}function bS(e){return e==="fish"?`# spree fish completion \u2014 eval "$(spree completion fish)"
387
387
  function __spree_complete
388
388
  set -l tokens (commandline -opc) (commandline -ct)
389
389
  spree __complete $tokens[2..-1]
@@ -402,42 +402,44 @@ _spree() {
402
402
  COMPREPLY=( $(spree __complete "\${words[@]}") )
403
403
  }
404
404
  complete -F _spree spree
405
- `}function oh(e){e.command("completion <shell>").description("Output a shell completion script (bash, zsh, or fish)").action(t=>{if(!sh.includes(t)){process.stderr.write(`Unsupported shell "${t}". Choose one of: ${sh.join(", ")}.
406
- `),process.exitCode=2;return}process.stdout.write(lS(t))}),e.command("__complete",{hidden:!0}).allowUnknownOption().argument("[words...]").action(t=>{for(let r of dS(t??[]))process.stdout.write(`${r}
407
- `)})}function ah(e){e.command("console").description("Open Rails console").action(async()=>{let t=_();await ut(["bin/rails","console"],t.projectDir,{edgeHint:"then open the console"})})}var Pe=U(Y(),1);var mS=["bin/rails","db:drop","db:create","spree:install:migrations","db:migrate","db:seed"];function ch(e){e.command("db:reset").description("Drop, create, migrate, and seed the dev database (destructive; self-heals a running stack)").option("--yes","skip the confirmation prompt (for CI)").action(async t=>{let r=_(),i=s=>{O(s.join(`
408
- `)),process.exit(1)};if(Me(r.projectDir)&&i(["This is a monorepo edge project (SPREE_PATH set in .env).",`Reset the dev database from the monorepo root with ${Pe.default.bold("pnpm server:setup")}`,"(or the relevant `pnpm server:*` script) \u2014 the project-local compose is not the","running config here."]),!t.yes){let s=await Ke({message:"This will drop the spree_development database. Continue?",initialValue:!1});(D(s)||!s)&&(O("Cancelled."),process.exit(0))}let n;try{let[s,o]=await Promise.all([vt("web",r.projectDir),vt("worker",r.projectDir)]);n=s||o}catch(s){return i(["Could not inspect the Docker stack from this directory.",` ${Pe.default.dim(String(s.message).split(`
409
- `)[0])}`,"",`Run ${Pe.default.bold("spree db:reset")} from your project root (the directory holding the`,".env with SECRET_KEY_BASE), and make sure Docker is running."])}if(n){let s=E();s.start("Stopping web + worker to release database connections..."),await X(["stop","web","worker"],r.projectDir),s.stop("Stopped web + worker.")}try{await Bo(mS,r.projectDir,{captureStderr:!0})}catch(s){let o=String(s.stderr??s.message??"");throw/being accessed by other users|55006/.test(o)&&i(["Could not drop spree_development \u2014 another client is still connected.",`A database client (TablePlus, DataGrip, psql) may be connected on port ${Pe.default.bold("5433")}.`,"Disconnect it, then re-run `spree db:reset`.",...n?["",`Bring the stack back up with ${Pe.default.bold("spree dev")}.`]:[]]),s}b.success("Database reset."),n&&W(`Bring the stack back up with ${Pe.default.bold("spree dev")}.`,"Done")}),e.command("db:console").description("Open a psql session against the dev database").action(async()=>{let t=_(),r;try{r=await vt("postgres",t.projectDir)}catch(i){O(["Could not inspect the Docker stack from this directory.",` ${Pe.default.dim(String(i.message).split(`
410
- `)[0])}`,"",`Run ${Pe.default.bold("spree db:console")} from your project root, and make sure Docker is running.`].join(`
411
- `)),process.exit(1)}r||(O(["Postgres is not running.",`Start the stack with ${Pe.default.bold("spree dev")}, then re-run ${Pe.default.bold("spree db:console")}.`].join(`
412
- `)),process.exit(1)),await F(["psql","-U","postgres","spree_development"],t.projectDir,{service:"postgres"})})}import ua from"fs";import xS from"path";var Ne=U(Y(),1);import Zt from"fs";import{platform as hS}from"os";import Qt from"path";var ge=U(Y(),1);var yS=3e3,ph=12e4;function uh(e){e.command("init").description("First-run setup: start services, configure API key, load sample data").option("--no-sample-data","skip loading sample data").option("--no-open","skip opening browser").action(async t=>{await da(t)})}async function da(e){let t=_(),r=e.sampleData&&(wn(t.projectDir)??!0);b.step("Pulling latest images..."),await X(["pull"],t.projectDir,{stdio:"inherit"});let i=E();i.start("Starting Docker services..."),await dt(t.projectDir,{stdio:"ignore"}),await X(["up","-d"],t.projectDir),i.stop("Docker services started."),i.start("Waiting for Spree to be ready..."),await fS(t.port),i.stop("Spree is ready."),i.start("Seeding database..."),await ne("db:seed",t.projectDir),i.stop("Database seeded."),i.start("Configuring API keys...");let n=await gS(t.projectDir);bS(t.projectDir,n);let s=await _S(t.projectDir,t.port);i.stop("API keys configured."),await dh(t.projectDir,"storefront"),await dh(t.projectDir,"dashboard"),Cr(t.projectDir,t.port),r&&(i.start("Loading sample data..."),await ne("spree:load_sample_data",t.projectDir),i.stop("Sample data loaded.")),i.start("Indexing products for search..."),await ne("spree:search:reindex",t.projectDir),i.stop("Search index ready."),pm(t.projectDir);let o=Qt.join(t.projectDir,"apps","dashboard"),a=Ar(t.projectDir,o);W(["",ge.default.bold("Admin Dashboard"),` ${ge.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${gn}`,` Password: ${_n}`,"",ge.default.bold("Store API"),` ${ge.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,` Publishable key: ${ge.default.cyan(n)}`,"",ge.default.bold("Admin API"),` ${ge.default.cyan(`http://localhost:${t.port}/api/v3/admin`)}`,` Secret key: ${ge.default.cyan(s)}`,` ${ge.default.dim("Saved to .spree/credentials.json")}`,"",...Zt.existsSync(Qt.join(o,"package.json"))?[ge.default.bold("React Dashboard (Developer Preview)"),` ${ge.default.cyan(`cd apps/dashboard && ${a} run dev`)}`,""]:[]].join(`
413
- `),"Your Spree store is ready!"),e.open&&await wS(`http://localhost:${t.port}/admin`),b.info(`Streaming logs (Ctrl+C to stop)...
414
- `),await kn("web",t.projectDir)}async function dh(e,t){let r=Qt.join(e,"apps",t);if(!Zt.existsSync(Qt.join(r,"package.json"))||Zt.existsSync(Qt.join(r,"node_modules")))return;let i=Ar(e,r),n=E();n.start(`Installing ${t} dependencies with ${i}...`);try{await J(i,["install"],{cwd:r}),n.stop(`${t==="dashboard"?"Dashboard":"Storefront"} dependencies installed.`)}catch(s){n.stop(ge.default.yellow(`${i} install failed \u2014 run it manually in apps/${t}/.`)),b.warn(s instanceof Error?s.message:String(s))}}async function fS(e){let t=`http://localhost:${e}/up`,r=Date.now();for(;Date.now()-r<ph;){try{if((await fetch(t)).ok)return}catch{}await new Promise(i=>setTimeout(i,yS))}throw new Error(`Spree did not become healthy within ${ph/1e3}s`)}async function gS(e){let t=await ne("spree:cli:ensure_api_key",e),r=t.match(/pk_[A-Za-z0-9_-]+/);if(!r)throw new Error(`Could not extract API key from Rails output: ${t}`);return r[0]}async function _S(e,t){let{token:r}=await zo(e,t,!0);return r}function bS(e,t){let r=Qt.join(e,"apps","storefront",".env.local");if(!Zt.existsSync(r))return;let i=Zt.readFileSync(r,"utf-8");Zt.writeFileSync(r,i.replace(/SPREE_PUBLISHABLE_KEY=.*/,`SPREE_PUBLISHABLE_KEY=${t}`))}async function wS(e){let t=hS(),r=t==="darwin"?"open":t==="win32"?"start":"xdg-open";try{await ct(`${r} ${e}`,{stdio:"ignore"})}catch{}}function lh(e){e.command("dev").description("Run the app in the foreground \u2014 streams web + worker logs; Ctrl+C stops them").action(async()=>{let t=_();if(Me(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${Ne.default.bold("pnpm server:dev")} from the monorepo root instead of ${Ne.default.bold("spree dev")}.`,"It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source."].join(`
415
- `)),process.exit(1)),Cr(t.projectDir,t.port),!kr(t.projectDir)&&!ua.existsSync(Go(t.projectDir))&&!ua.existsSync(Vt(t.projectDir))){let s=wn(t.projectDir)!==void 0;if(!s)try{s=!await sm(t.projectDir)}catch{}if(s){b.info("First run detected \u2014 completing setup automatically."),await da({sampleData:!0,open:!0});return}}W(["",Ne.default.bold("Admin Dashboard"),` ${Ne.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${gn}`,` Password: ${_n}`,"",Ne.default.bold("Store API"),` ${Ne.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,""].join(`
416
- `),"Spree Commerce"),b.info(`Starting services \u2014 web + worker logs stream below. ${Ne.default.bold("Ctrl+C")} stops them (databases keep running; ${Ne.default.bold("spree stop")} shuts everything down).
417
- `);let r=()=>{};process.on("SIGINT",r);let i;try{if(await dt(t.projectDir),kr(t.projectDir)){let s=xS.join(t.projectDir,"backend/app/assets/builds/spree/admin/application.css");if(!ua.existsSync(s)){let o=E();o.start("Compiling admin dashboard stylesheets...");try{await xn(t.projectDir),o.stop("Admin dashboard stylesheets compiled.")}catch{o.stop("Could not compile admin dashboard stylesheets \u2014 admin pages may 500.")}}try{await om(t.projectDir),b.info("Watching admin dashboard stylesheets \u2014 edits recompile live.")}catch{}}i=await X(["up","web","worker"],t.projectDir,{stdio:"inherit",reject:!1})}finally{process.off("SIGINT",r)}let n=i.exitCode??0;n!==0&&n!==130&&(O(`docker compose exited with code ${n} \u2014 see the output above.`),process.exit(n)),Et(`Web + worker stopped. Databases keep running \u2014 ${Ne.default.bold("spree stop")} shuts everything down.`)})}import Fr from"fs";import la from"path";var me=U(Y(),1);function mh(e){e.command("eject").description("Switch to the dev compose: bind-mount ./backend with hot reload").action(async()=>{let t=_(),r=la.join(t.projectDir,"backend");Fr.existsSync(r)||(console.error(`
418
- ${me.default.red("Error:")} No backend/ directory found.
419
- `),process.exit(1));let i=la.join(t.projectDir,"docker-compose.dev.yml");Fr.existsSync(i)||(console.error(`
420
- ${me.default.red("Error:")} No docker-compose.dev.yml found.
421
- `),process.exit(1));let n=Fr.readFileSync(i,"utf-8");n.includes("- .:/rails")&&(n=n.replace("- .:/rails","- ./backend:/rails"),Fr.writeFileSync(i,n)),Fr.writeFileSync(la.join(t.projectDir,"docker-compose.yml"),n),console.log(`
422
- ${me.default.bold("Switching to dev compose (bind-mounts ./backend)...")}
405
+ `}function hh(e){e.command("completion <shell>").description("Output a shell completion script (bash, zsh, or fish)").action(t=>{if(!mh.includes(t)){process.stderr.write(`Unsupported shell "${t}". Choose one of: ${mh.join(", ")}.
406
+ `),process.exitCode=2;return}process.stdout.write(bS(t))}),e.command("__complete",{hidden:!0}).allowUnknownOption().argument("[words...]").action(t=>{for(let r of gS(t??[]))process.stdout.write(`${r}
407
+ `)})}function yh(e){e.command("console").description("Open Rails console").action(async()=>{let t=_();await ut(["bin/rails","console"],t.projectDir,{edgeHint:"then open the console"})})}var Te=M(K(),1);var wS=["bin/rails","db:drop","db:create","spree:install:migrations","db:migrate","db:seed"];function fh(e){e.command("db:reset").description("Drop, create, migrate, and seed the dev database (destructive; self-heals a running stack)").option("--yes","skip the confirmation prompt (for CI)").action(async t=>{let r=_(),i=s=>{O(s.join(`
408
+ `)),process.exit(1)};if(Fe(r.projectDir)&&i(["This is a monorepo edge project (SPREE_PATH set in .env).",`Reset the dev database from the monorepo root with ${Te.default.bold("pnpm server:setup")}`,"(or the relevant `pnpm server:*` script) \u2014 the project-local compose is not the","running config here."]),!t.yes){let s=await Ke({message:"This will drop the spree_development database. Continue?",initialValue:!1});(D(s)||!s)&&(O("Cancelled."),process.exit(0))}let n;try{let[s,o]=await Promise.all([vt("web",r.projectDir),vt("worker",r.projectDir)]);n=s||o}catch(s){return i(["Could not inspect the Docker stack from this directory.",` ${Te.default.dim(String(s.message).split(`
409
+ `)[0])}`,"",`Run ${Te.default.bold("spree db:reset")} from your project root (the directory holding the`,".env with SECRET_KEY_BASE), and make sure Docker is running."])}if(n){let s=E();s.start("Stopping web + worker to release database connections..."),await X(["stop","web","worker"],r.projectDir),s.stop("Stopped web + worker.")}try{await Ho(wS,r.projectDir,{captureStderr:!0})}catch(s){let o=String(s.stderr??s.message??"");throw/being accessed by other users|55006/.test(o)&&i(["Could not drop spree_development \u2014 another client is still connected.",`A database client (TablePlus, DataGrip, psql) may be connected on port ${Te.default.bold("5433")}.`,"Disconnect it, then re-run `spree db:reset`.",...n?["",`Bring the stack back up with ${Te.default.bold("spree dev")}.`]:[]]),s}b.success("Database reset."),n&&W(`Bring the stack back up with ${Te.default.bold("spree dev")}.`,"Done")}),e.command("db:console").description("Open a psql session against the dev database").action(async()=>{let t=_(),r;try{r=await vt("postgres",t.projectDir)}catch(i){O(["Could not inspect the Docker stack from this directory.",` ${Te.default.dim(String(i.message).split(`
410
+ `)[0])}`,"",`Run ${Te.default.bold("spree db:console")} from your project root, and make sure Docker is running.`].join(`
411
+ `)),process.exit(1)}r||(O(["Postgres is not running.",`Start the stack with ${Te.default.bold("spree dev")}, then re-run ${Te.default.bold("spree db:console")}.`].join(`
412
+ `)),process.exit(1)),await B(["psql","-U","postgres","spree_development"],t.projectDir,{service:"postgres"})})}import ba from"fs";import TS from"path";var _e=M(K(),1);import{spawn as xS}from"child_process";import ga from"fs";import rr from"path";var Ur=M(K(),1);function Nr(e){return ga.existsSync(rr.join(e,"apps","dashboard","package.json"))}function Gr(e){let t=rr.join(e,"apps","dashboard");return ga.existsSync(rr.join(t,"package.json"))&&ga.existsSync(rr.join(t,"node_modules"))}function In(e){let t=rr.join(e,"apps","dashboard");b.warn(`${Ur.default.bold("apps/dashboard/")} has no dependencies installed \u2014 skipping its dev server. Install them (cd apps/dashboard && ${qt(e,t)} install) and rerun.`)}var kS=Ur.default.dim("dashboard | "),vS=new RegExp("\x1B\\[[0-9;]*m","g");function On(e){if(!Gr(e))return null;let t=rr.join(e,"apps","dashboard"),r=qt(e,t),i=process.platform==="win32",n=xS(r,["run","dev"],{cwd:t,stdio:["ignore","pipe","pipe"],detached:!i,shell:i}),s=`http://localhost:${5173}`,o=!1,a=()=>{},c=new Promise(m=>{a=m}),d=m=>{o=!0,clearTimeout(p),a(m)},p=setTimeout(()=>d(s),3e4);p.unref();let u=(m,h)=>{let f="";m.on("data",x=>{f+=x.toString();let w=f.split(`
413
+ `);f=w.pop()??"";for(let v of w)if(h.write(`${kS}${v}
414
+ `),!o){let g=v.replace(vS,"").match(/Local:\s+(http:\/\/\S+?)\/?\s*$/);g&&d(g[1])}})};n.stdout&&u(n.stdout,process.stdout),n.stderr&&u(n.stderr,process.stderr);let l=!1;return n.on("error",m=>{d(s),b.warn(`Could not start the dashboard dev server (${m.message}) \u2014 start it manually with ${Ur.default.bold(`cd apps/dashboard && ${r} run dev`)}. The API keeps running.`)}),n.on("exit",(m,h)=>{d(s),!l&&h===null&&m!==null&&m!==0&&m!==130&&b.warn(`The dashboard dev server exited (code ${m}) \u2014 restart it with ${Ur.default.bold(`cd apps/dashboard && ${r} run dev`)}. The API keeps running.`)}),{url:c,stop:()=>{if(l=!0,d(s),!(n.exitCode!==null||n.killed)){if(!i&&n.pid)try{process.kill(-n.pid,"SIGTERM");return}catch{}n.kill("SIGTERM")}}}}import zr from"fs";import{platform as SS}from"os";import jn from"path";var me=M(K(),1);var qS=3e3,gh=12e4;function bh(e){e.command("init").description("First-run setup: start services, configure API key, load sample data").option("--no-sample-data","skip loading sample data").option("--no-open","skip opening browser").action(async t=>{await _a(t)})}async function _a(e){let t=_(),r=e.sampleData&&(Sn(t.projectDir)??!0);b.step("Pulling latest images..."),await X(["pull"],t.projectDir,{stdio:"inherit"});let i=E();i.start("Starting Docker services..."),await dt(t.projectDir,{stdio:"ignore"}),await X(["up","-d"],t.projectDir),i.stop("Docker services started."),i.start("Waiting for Spree to be ready..."),await $S(t.port),i.stop("Spree is ready."),i.start("Seeding database..."),await ne("db:seed",t.projectDir),i.stop("Database seeded."),i.start("Configuring API keys...");let n=await AS(t.projectDir);ES(t.projectDir,n);let s=await CS(t.projectDir,t.port);i.stop("API keys configured."),await _h(t.projectDir,"storefront"),await _h(t.projectDir,"dashboard"),Pr(t.projectDir,t.port),r&&(i.start("Loading sample data..."),await ne("spree:load_sample_data",t.projectDir),i.stop("Sample data loaded.")),i.start("Indexing products for search..."),await ne("spree:search:reindex",t.projectDir),i.stop("Search index ready."),gm(t.projectDir);let o=Gr(t.projectDir);Nr(t.projectDir)&&!o&&In(t.projectDir);let a=o?[me.default.bold("Admin Dashboard (React, Developer Preview)"),` ${me.default.cyan(`http://localhost:${5173}`)}`,` Email: ${Ht}`,` Password: ${Kt}`,` ${me.default.dim(`Live-reloading from apps/dashboard/ \u2014 classic admin: http://localhost:${t.port}/admin`)}`]:[me.default.bold("Admin Dashboard"),` ${me.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${Ht}`,` Password: ${Kt}`];W(["",...a,"",me.default.bold("Store API"),` ${me.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,` Publishable key: ${me.default.cyan(n)}`,"",me.default.bold("Admin API"),` ${me.default.cyan(`http://localhost:${t.port}/api/v3/admin`)}`,` Secret key: ${me.default.cyan(s)}`,` ${me.default.dim("Saved to .spree/credentials.json")}`,""].join(`
415
+ `),"Your Spree store is ready!");let c=o?On(t.projectDir):null,d=()=>{c?.stop(),process.exit(130)};process.once("SIGINT",d);try{e.open&&await PS(c?await c.url:`http://localhost:${t.port}/admin`),b.info(`Streaming logs (Ctrl+C to stop)...
416
+ `),await $n("web",t.projectDir)}finally{process.removeListener("SIGINT",d),c?.stop()}}async function _h(e,t){let r=jn.join(e,"apps",t);if(!zr.existsSync(jn.join(r,"package.json"))||zr.existsSync(jn.join(r,"node_modules")))return;let i=qt(e,r),n=E();n.start(`Installing ${t} dependencies with ${i}...`);try{await J(i,["install"],{cwd:r}),n.stop(`${t==="dashboard"?"Dashboard":"Storefront"} dependencies installed.`)}catch(s){n.stop(me.default.yellow(`${i} install failed \u2014 run it manually in apps/${t}/.`)),b.warn(s instanceof Error?s.message:String(s))}}async function $S(e){let t=`http://localhost:${e}/up`,r=Date.now();for(;Date.now()-r<gh;){try{if((await fetch(t)).ok)return}catch{}await new Promise(i=>setTimeout(i,qS))}throw new Error(`Spree did not become healthy within ${gh/1e3}s`)}async function AS(e){let t=await ne("spree:cli:ensure_api_key",e),r=t.match(/pk_[A-Za-z0-9_-]+/);if(!r)throw new Error(`Could not extract API key from Rails output: ${t}`);return r[0]}async function CS(e,t){let{token:r}=await Xo(e,t,!0);return r}function ES(e,t){let r=jn.join(e,"apps","storefront",".env.local");if(!zr.existsSync(r))return;let i=zr.readFileSync(r,"utf-8");zr.writeFileSync(r,i.replace(/SPREE_PUBLISHABLE_KEY=.*/,`SPREE_PUBLISHABLE_KEY=${t}`))}async function PS(e){let t=SS(),r=t==="darwin"?"open":t==="win32"?"start":"xdg-open";try{await ct(`${r} ${e}`,{stdio:"ignore"})}catch{}}function wh(e){e.command("dev").description("Run the app in the foreground \u2014 the API, plus the React Dashboard dev server when apps/dashboard exists; Ctrl+C stops them").action(async()=>{let t=_();if(Fe(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${_e.default.bold("pnpm server:dev")} from the monorepo root instead of ${_e.default.bold("spree dev")}.`,"It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source."].join(`
417
+ `)),process.exit(1)),Pr(t.projectDir,t.port),!qr(t.projectDir)&&!ba.existsSync(Jo(t.projectDir))&&!ba.existsSync(Yt(t.projectDir))){let a=Sn(t.projectDir)!==void 0;if(!a)try{a=!await mm(t.projectDir)}catch{}if(a){b.info("First run detected \u2014 completing setup automatically."),await _a({sampleData:!0,open:!0});return}}let r=Nr(t.projectDir)&&Gr(t.projectDir);Nr(t.projectDir)&&!r&&In(t.projectDir),W(["",...r?[_e.default.bold("Admin Dashboard (React, Developer Preview)"),` ${_e.default.cyan(`http://localhost:${5173}`)}`,` Email: ${Ht}`,` Password: ${Kt}`,` ${_e.default.dim(`Live-reloading from apps/dashboard/ \u2014 classic admin: http://localhost:${t.port}/admin`)}`]:[_e.default.bold("Admin Dashboard"),` ${_e.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${Ht}`,` Password: ${Kt}`],"",_e.default.bold("Store API"),` ${_e.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,""].join(`
418
+ `),"Spree Commerce"),b.info(`Starting services \u2014 ${r?"API + dashboard logs":"web + worker logs"} stream below. ${_e.default.bold("Ctrl+C")} stops them (databases keep running; ${_e.default.bold("spree stop")} shuts everything down).
419
+ `);let i=()=>{};process.on("SIGINT",i);let n,s=null;try{if(await dt(t.projectDir),qr(t.projectDir)){let a=TS.join(t.projectDir,"backend/app/assets/builds/spree/admin/application.css");if(!ba.existsSync(a)){let c=E();c.start("Compiling admin dashboard stylesheets...");try{await qn(t.projectDir),c.stop("Admin dashboard stylesheets compiled.")}catch{c.stop("Could not compile admin dashboard stylesheets \u2014 admin pages may 500.")}}try{await hm(t.projectDir),b.info("Watching admin dashboard stylesheets \u2014 edits recompile live.")}catch{}}s=r?On(t.projectDir):null,n=await X(["up","web","worker"],t.projectDir,{stdio:"inherit",reject:!1})}finally{s?.stop(),process.off("SIGINT",i)}let o=n.exitCode??0;o!==0&&o!==130&&(O(`docker compose exited with code ${o} \u2014 see the output above.`),process.exit(o)),Tt(`${r?"API + dashboard":"Web + worker"} stopped. Databases keep running \u2014 ${_e.default.bold("spree stop")} shuts everything down.`)})}import Vr from"fs";import wa from"path";var he=M(K(),1);function xh(e){e.command("eject").description("Switch to the dev compose: bind-mount ./backend with hot reload").action(async()=>{let t=_(),r=wa.join(t.projectDir,"backend");Vr.existsSync(r)||(console.error(`
420
+ ${he.default.red("Error:")} No backend/ directory found.
421
+ `),process.exit(1));let i=wa.join(t.projectDir,"docker-compose.dev.yml");Vr.existsSync(i)||(console.error(`
422
+ ${he.default.red("Error:")} No docker-compose.dev.yml found.
423
+ `),process.exit(1));let n=Vr.readFileSync(i,"utf-8");n.includes("- .:/rails")&&(n=n.replace("- .:/rails","- ./backend:/rails"),Vr.writeFileSync(i,n)),Vr.writeFileSync(wa.join(t.projectDir,"docker-compose.yml"),n),console.log(`
424
+ ${he.default.bold("Switching to dev compose (bind-mounts ./backend)...")}
423
425
  `),await dt(t.projectDir),await X(["up","-d"],t.projectDir,{stdio:"inherit"}),console.log(`
424
- ${me.default.bold("Preparing the development database...")}
425
- `),await F(["bin/rails","db:prepare"],t.projectDir,{tty:!1}),console.log(`
426
- ${me.default.bold("Building admin dashboard stylesheets...")}
427
- `),await xn(t.projectDir),W([`Backend is now bind-mounted from ${me.default.bold("./backend")} \u2014 edits are live.`,"",`The dev stack uses its own ${me.default.bold("spree_development")} database (just`,`created and seeded). Load demo products with ${me.default.bold("spree sample-data")}.`,"","You can now customize:",` ${me.default.dim("backend/app/")} \u2014 models, controllers, services (instant reload)`,` ${me.default.dim("backend/config/")} \u2014 Rails configuration (instant reload)`,` ${me.default.dim("backend/Gemfile")} \u2014 add gems via ${me.default.bold("spree bundle add <gem>")}`,"",`Rebuild only on Dockerfile / .ruby-version changes: ${me.default.bold("spree build")}`].join(`
428
- `),"Ejected!")})}function hh(e){e.command("exec").description("Run an arbitrary command inside the web container").argument("<command...>","command and arguments to run").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await F(t,r.projectDir)})}var kS=new Set(["migration","controller","scaffold","scaffold_controller","mailer","job","channel","helper","resource","integration_test","system_test","task","generator","benchmark"]);function yh(e){e.command("generate").alias("g").description("Run a generator (Spree generators auto-prefixed; Rails built-ins forwarded as-is)").argument("<name>","generator name (`model`, `model_decorator`, `migration`, \u2026)").argument("[args...]","arguments to pass to the generator").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=_(),n=t.includes(":")||kS.has(t)?t:`spree:${t}`;await F(["bin/rails","g",n,...r],i.projectDir)})}function fh(e){e.command("logs").description("Stream service logs").argument("[service]","service name (web or worker)","web").action(async t=>{let r=_();await kn(t,r.projectDir)})}var En=U(Y(),1);function gh(e){e.command("migrate").description("Install pending Spree migrations from gems, then run them (`spree:install:migrations` + `db:migrate`)").argument("[args...]","extra args forwarded to db:migrate").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();console.log(`
429
- ${En.default.bold("\u2192 Installing pending Spree migrations from gems...")}`),await F(["bin/rails","spree:install:migrations"],r.projectDir),console.log(`
430
- ${En.default.bold("\u2192 Running db:migrate...")}`),await F(["bin/rails","db:migrate",...t],r.projectDir),W(`Run ${En.default.bold("spree migrate:status")} to inspect the migration log.`,"Migrations up to date")}),e.command("migrate:rollback").description("Roll back the last migration (`STEP=n` to roll back n steps)").argument("[args...]","extra args forwarded to db:rollback (e.g. STEP=2)").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await F(["bin/rails","db:rollback",...t],r.projectDir)}),e.command("migrate:status").description("Show migration status (`bin/rails db:migrate:status`)").action(async()=>{let t=_();await F(["bin/rails","db:migrate:status"],t.projectDir)})}import{platform as vS}from"os";function _h(e){e.command("open").description("Open the admin dashboard in the browser").action(async()=>{let r=`http://localhost:${_().port}/admin`,i=vS();await ct(`${i==="darwin"?"open":i==="win32"?"start":"xdg-open"} ${r}`)})}import ha from"fs";import tr from"path";import{fileURLToPath as SS}from"url";var z=U(Y(),1);import tt from"fs";import Pn from"path";function wh(e){let{src:t,dst:r,vars:i,skip:n,force:s}=e;if(!tt.existsSync(t))throw new Error(`Template source not found: ${t}`);if(tt.existsSync(r)){if(tt.readdirSync(r).length>0&&!s)throw new Error(`Destination ${r} is not empty. Pass force=true to overwrite.`)}else tt.mkdirSync(r,{recursive:!0});xh(t,r,"",i,n)}function xh(e,t,r,i,n){let s=Pn.join(e,r);for(let o of tt.readdirSync(s,{withFileTypes:!0})){let a=r?`${r}/${o.name}`:o.name;if(n?.(a))continue;let c=kh(ma(o.name,i)),d=Pn.join(e,a);if(o.isDirectory()){let h=r?`${bh(r,i)}/${c}`:c,f=Pn.join(t,h);tt.mkdirSync(f,{recursive:!0}),xh(e,t,a,i,n);continue}let p=c.endsWith(".tt"),u=p?c.slice(0,-3):c,l=r?`${bh(r,i)}/${u}`:u,m=Pn.join(t,l);if(p){let h=tt.readFileSync(d,"utf8");tt.writeFileSync(m,ma(h,i))}else tt.copyFileSync(d,m)}}function ma(e,t){return e.replace(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,(r,i)=>Object.hasOwn(t,i)?t[i]:r)}function bh(e,t){return e.split("/").map(r=>kh(ma(r,t))).join("/")}function kh(e){if(e.includes("/")||e.includes("\\")||e==="..")throw new Error(`Template variable produced an unsafe path segment: "${e}"`);return e}var qS="../../templates/plugin",Tn=["MIT","Apache-2.0","BSD-3-Clause"];function Sh(e){e.command("plugin").description("Scaffold and manage Spree plugins (dashboard + Rails engine)").command("new").description("Scaffold a new Spree plugin monorepo (dashboard plugin half today; Rails engine coming soon)").argument("[name]","Plugin name (e.g. brands). If omitted, you will be prompted.").option("--ruby-name <name>","Ruby gem name (default: spree_<name>)").option("--module-name <name>","Ruby module / TS namespace (default: PascalCase of the gem name)").option("--npm-scope <scope>","npm scope, e.g. @acme (default: unscoped)").option("--author <name>","Author name (default: git config user.name)").option("--author-email <email>","Author email (default: git config user.email)").option("--license <license>",`License: ${Tn.join(", ")} (default: MIT)`).option("-y, --yes","Non-interactive: accept the default for every prompt not answered by a flag",!1).option("--no-dashboard","Skip the dashboard plugin half").option("--no-engine","Skip the Rails engine half (currently always skipped \u2014 engine support coming soon)").option("--no-install","Skip running pnpm install").option("--force","Overwrite a non-empty destination directory").action(async(r,i)=>{ni(z.default.bgCyan(z.default.black(" Spree Plugin Scaffolder ")));let n=await $S(r,i);D(n)&&(O("Scaffolding cancelled."),process.exit(0));let s=tr.resolve(process.cwd(),n.name);ha.existsSync(s)&&ha.readdirSync(s).length>0&&!i.force&&(O(`Destination ${z.default.bold(s)} is not empty. Choose a different name or rerun with ${z.default.cyan("--force")}.`),process.exit(1));let o=CS(n),a=IS(),c=E();c.start(`Scaffolding ${z.default.cyan(n.name)}...`);try{wh({src:a,dst:s,vars:o,skip:ES(n),force:i.force})}catch(d){c.stop("Scaffolding failed."),b.error(d instanceof Error?d.message:String(d)),process.exit(1)}c.stop(`Created ${z.default.cyan(s)}`),i.install?await PS(s,n):b.info(z.default.dim("Skipping dependency install \u2014 run them yourself when ready.")),TS(n,s,i.install),Et("Happy hacking!")})}async function $S(e,t){let r=g=>{if(!g)return"Required";if(!/^[a-z][a-z0-9-]*$/.test(g))return'Use lowercase letters, digits, and dashes (e.g. "brands" or "loyalty-points")'};if(e!==void 0){let g=r(e);g&&(b.error(`Invalid plugin name ${z.default.bold(e)}: ${g}`),process.exit(2))}e===void 0&&t.yes&&(b.error("Pass the plugin name as an argument when using --yes: spree plugin new <name> -y"),process.exit(2));let i=e??await le({message:"Plugin name",placeholder:"brands",validate:r});if(D(i))return i;let n=`spree_${i.replace(/-/g,"_")}`,s=await er({flag:"--ruby-name",flagValue:t.rubyName,fallback:n,yes:t.yes,validate:g=>g&&/^[a-z][a-z0-9_]*$/.test(g)?void 0:'Use lowercase letters, digits, and underscores (e.g. "spree_brands")',prompt:()=>le({message:"Ruby gem name",placeholder:n,initialValue:n,validate:g=>g&&/^[a-z][a-z0-9_]*$/.test(g)?void 0:'Use lowercase letters, digits, and underscores (e.g. "spree_brands")'})});if(D(s))return s;let o=RS(s),a=await er({flag:"--module-name",flagValue:t.moduleName,fallback:o,yes:t.yes,validate:g=>g&&/^[A-Z][A-Za-z0-9]*$/.test(g)?void 0:'PascalCase (e.g. "SpreeBrands")',prompt:()=>le({message:"Ruby module / TS namespace",placeholder:o,initialValue:o,validate:g=>g&&/^[A-Z][A-Za-z0-9]*$/.test(g)?void 0:'PascalCase (e.g. "SpreeBrands")'})});if(D(a))return a;let c=g=>!g||/^@[a-z0-9][a-z0-9-]*$/.test(g)?void 0:"Must start with @ and contain lowercase letters/digits/dashes",d=await er({flag:"--npm-scope",flagValue:t.npmScope,fallback:"",yes:t.yes,validate:c,prompt:()=>le({message:"npm scope (optional, leave blank for unscoped)",placeholder:"@my-org",initialValue:"",validate:c})});if(D(d))return d;let p=t.author===void 0?await vh("user.name"):void 0,u=await er({flag:"--author",flagValue:t.author,fallback:p,yes:t.yes,validate:g=>g?void 0:"Required",prompt:()=>le({message:"Author name",placeholder:"Jane Developer",initialValue:p??"",validate:g=>g?void 0:"Required"})});if(D(u))return u;let l=g=>g&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(g)?void 0:"Enter a valid email",m=t.authorEmail===void 0?await vh("user.email"):void 0,h=await er({flag:"--author-email",flagValue:t.authorEmail,fallback:m,yes:t.yes,validate:l,prompt:()=>le({message:"Author email",placeholder:"jane@example.com",initialValue:m??"",validate:l})});if(D(h))return h;let f=g=>g&&Tn.includes(g)?void 0:`Must be one of: ${Tn.join(", ")}`,x=await er({flag:"--license",flagValue:t.license,fallback:"MIT",yes:t.yes,validate:f,prompt:()=>oi({message:"License",options:Tn.map(g=>({value:g,label:g})),initialValue:"MIT"})});if(D(x))return x;let w=t.dashboard===!1?!1:t.yes||await AS("Include dashboard plugin?",!0);if(D(w))return w;let S=!1;return t.engine!==!1&&b.warn("Rails engine generation is coming in a future release. For now, scaffold the dashboard half here and use `spree-extension create` for the Ruby side."),!w&&!S&&(O("Nothing to scaffold (dashboard half declined)."),process.exit(1)),{name:i,rubyName:s,moduleName:a,npmScope:d.trim(),authorName:u,authorEmail:h,license:x,includeDashboard:w,includeEngine:S}}async function AS(e,t){return await Ke({message:e,initialValue:t})}async function er(e){if(e.flagValue!==void 0){let t=e.validate(e.flagValue);return t&&(b.error(`Invalid value for ${z.default.cyan(e.flag)}: ${t}`),process.exit(2)),e.flagValue}if(e.yes){let t=e.validate(e.fallback);return(e.fallback===void 0||t)&&(b.error(`--yes could not resolve a default for ${z.default.cyan(e.flag)}`+(t?` (${t})`:"")+` \u2014 pass ${z.default.cyan(e.flag)} explicitly.`),process.exit(2)),e.fallback}return e.prompt()}async function vh(e){try{let{stdout:t}=await ct(`git config --get ${e}`);return t.trim()||void 0}catch{return}}function CS(e){let t=e.npmScope?`${e.npmScope}/${e.name}`:e.name;return{name:e.name,plugin_name:e.name,ruby_name:e.rubyName,module_name:e.moduleName,npm_scope:e.npmScope,npm_package_name:t,npm_dashboard_package:e.npmScope?`${e.npmScope}/${e.name}-dashboard`:`${e.name}-dashboard`,author_name:e.authorName,author_email:e.authorEmail,license:e.license,year:String(new Date().getFullYear())}}function ES(e){let t=!e.includeDashboard,r=!e.includeEngine;return i=>!!(t&&(i==="packages/dashboard"||i.startsWith("packages/dashboard/"))||r&&(i==="engine"||i.startsWith("engine/")))}async function PS(e,t){let r=E();if(t.includeDashboard){r.start("Running pnpm install...");try{await ct("pnpm install",{cwd:e,stdio:"pipe"}),r.stop("pnpm install complete.")}catch(i){r.stop(z.default.yellow("pnpm install failed \u2014 run it manually.")),b.warn(i instanceof Error?i.message:String(i))}}if(t.includeEngine){r.start("Running bundle install in engine/...");try{await ct("bundle install",{cwd:tr.join(e,"engine"),stdio:"pipe"}),r.stop("bundle install complete.")}catch(i){r.stop(z.default.yellow("bundle install failed \u2014 run it manually.")),b.warn(i instanceof Error?i.message:String(i))}}}function TS(e,t,r){let i=[""];i.push(z.default.bold("Next steps")),i.push(` ${z.default.dim("cd")} ${tr.relative(process.cwd(),t)||"."}`),r||(e.includeDashboard&&i.push(` ${z.default.dim("pnpm")} install`),e.includeEngine&&i.push(` ${z.default.dim("cd engine && bundle")} install && ${z.default.dim("cd ..")}`)),e.includeDashboard&&(i.push(""),i.push(z.default.bold("Dashboard plugin")),i.push(` Edit ${z.default.cyan("packages/dashboard/src/index.tsx")} to register nav entries and slot widgets.`),i.push(` Add pages as file routes in ${z.default.cyan("packages/dashboard/src/routes/")} \u2014 compiled into the host's typed route tree.`),i.push(` See ${z.default.cyan("https://spreecommerce.org/docs/developer/dashboard/plugins/overview")}`)),e.includeEngine&&(i.push(""),i.push(z.default.bold("Rails engine")),i.push(` Edit ${z.default.cyan(`engine/app/controllers/spree/api/v3/admin/${e.rubyName}_controller.rb`)}`),i.push(` See ${z.default.cyan("https://spreecommerce.org/docs/developer/contributing/creating-an-extension")}`)),i.push(""),W(i.join(`
431
- `),"Your plugin is scaffolded.")}function RS(e){return e.split(/[_-]/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function IS(){let e=tr.dirname(SS(import.meta.url)),t=[tr.resolve(e,qS),tr.resolve(e,"templates/plugin")];for(let r of t)if(ha.existsSync(r))return r;throw new Error(`Plugin template not found. Looked in:
426
+ ${he.default.bold("Preparing the development database...")}
427
+ `),await B(["bin/rails","db:prepare"],t.projectDir,{tty:!1}),console.log(`
428
+ ${he.default.bold("Building admin dashboard stylesheets...")}
429
+ `),await qn(t.projectDir),W([`Backend is now bind-mounted from ${he.default.bold("./backend")} \u2014 edits are live.`,"",`The dev stack uses its own ${he.default.bold("spree_development")} database (just`,`created and seeded). Load demo products with ${he.default.bold("spree sample-data")}.`,"","You can now customize:",` ${he.default.dim("backend/app/")} \u2014 models, controllers, services (instant reload)`,` ${he.default.dim("backend/config/")} \u2014 Rails configuration (instant reload)`,` ${he.default.dim("backend/Gemfile")} \u2014 add gems via ${he.default.bold("spree bundle add <gem>")}`,"",`Rebuild only on Dockerfile / .ruby-version changes: ${he.default.bold("spree build")}`].join(`
430
+ `),"Ejected!")})}function kh(e){e.command("exec").description("Run an arbitrary command inside the web container").argument("<command...>","command and arguments to run").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await B(t,r.projectDir)})}var RS=new Set(["migration","controller","scaffold","scaffold_controller","mailer","job","channel","helper","resource","integration_test","system_test","task","generator","benchmark"]);function vh(e){e.command("generate").alias("g").description("Run a generator (Spree generators auto-prefixed; Rails built-ins forwarded as-is)").argument("<name>","generator name (`model`, `model_decorator`, `migration`, \u2026)").argument("[args...]","arguments to pass to the generator").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=_(),n=t.includes(":")||RS.has(t)?t:`spree:${t}`;await B(["bin/rails","g",n,...r],i.projectDir)})}function Sh(e){e.command("logs").description("Stream service logs").argument("[service]","service name (web or worker)","web").action(async t=>{let r=_();await $n(t,r.projectDir)})}var Dn=M(K(),1);function qh(e){e.command("migrate").description("Install pending Spree migrations from gems, then run them (`spree:install:migrations` + `db:migrate`)").argument("[args...]","extra args forwarded to db:migrate").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();console.log(`
431
+ ${Dn.default.bold("\u2192 Installing pending Spree migrations from gems...")}`),await B(["bin/rails","spree:install:migrations"],r.projectDir),console.log(`
432
+ ${Dn.default.bold("\u2192 Running db:migrate...")}`),await B(["bin/rails","db:migrate",...t],r.projectDir),W(`Run ${Dn.default.bold("spree migrate:status")} to inspect the migration log.`,"Migrations up to date")}),e.command("migrate:rollback").description("Roll back the last migration (`STEP=n` to roll back n steps)").argument("[args...]","extra args forwarded to db:rollback (e.g. STEP=2)").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await B(["bin/rails","db:rollback",...t],r.projectDir)}),e.command("migrate:status").description("Show migration status (`bin/rails db:migrate:status`)").action(async()=>{let t=_();await B(["bin/rails","db:migrate:status"],t.projectDir)})}import{platform as IS}from"os";function $h(e){e.command("open").description("Open the admin dashboard in the browser").action(async()=>{let r=`http://localhost:${_().port}/admin`,i=IS();await ct(`${i==="darwin"?"open":i==="win32"?"start":"xdg-open"} ${r}`)})}import ka from"fs";import nr from"path";import{fileURLToPath as OS}from"url";var z=M(K(),1);import tt from"fs";import Ln from"path";function Ch(e){let{src:t,dst:r,vars:i,skip:n,force:s}=e;if(!tt.existsSync(t))throw new Error(`Template source not found: ${t}`);if(tt.existsSync(r)){if(tt.readdirSync(r).length>0&&!s)throw new Error(`Destination ${r} is not empty. Pass force=true to overwrite.`)}else tt.mkdirSync(r,{recursive:!0});Eh(t,r,"",i,n)}function Eh(e,t,r,i,n){let s=Ln.join(e,r);for(let o of tt.readdirSync(s,{withFileTypes:!0})){let a=r?`${r}/${o.name}`:o.name;if(n?.(a))continue;let c=Ph(xa(o.name,i)),d=Ln.join(e,a);if(o.isDirectory()){let h=r?`${Ah(r,i)}/${c}`:c,f=Ln.join(t,h);tt.mkdirSync(f,{recursive:!0}),Eh(e,t,a,i,n);continue}let p=c.endsWith(".tt"),u=p?c.slice(0,-3):c,l=r?`${Ah(r,i)}/${u}`:u,m=Ln.join(t,l);if(p){let h=tt.readFileSync(d,"utf8");tt.writeFileSync(m,xa(h,i))}else tt.copyFileSync(d,m)}}function xa(e,t){return e.replace(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,(r,i)=>Object.hasOwn(t,i)?t[i]:r)}function Ah(e,t){return e.split("/").map(r=>Ph(xa(r,t))).join("/")}function Ph(e){if(e.includes("/")||e.includes("\\")||e==="..")throw new Error(`Template variable produced an unsafe path segment: "${e}"`);return e}var jS="../../templates/plugin",Mn=["MIT","Apache-2.0","BSD-3-Clause"];function Rh(e){e.command("plugin").description("Scaffold and manage Spree plugins (dashboard + Rails engine)").command("new").description("Scaffold a new Spree plugin monorepo (dashboard plugin half today; Rails engine coming soon)").argument("[name]","Plugin name (e.g. brands). If omitted, you will be prompted.").option("--ruby-name <name>","Ruby gem name (default: spree_<name>)").option("--module-name <name>","Ruby module / TS namespace (default: PascalCase of the gem name)").option("--npm-scope <scope>","npm scope, e.g. @acme (default: unscoped)").option("--author <name>","Author name (default: git config user.name)").option("--author-email <email>","Author email (default: git config user.email)").option("--license <license>",`License: ${Mn.join(", ")} (default: MIT)`).option("-y, --yes","Non-interactive: accept the default for every prompt not answered by a flag",!1).option("--no-dashboard","Skip the dashboard plugin half").option("--no-engine","Skip the Rails engine half (currently always skipped \u2014 engine support coming soon)").option("--no-install","Skip running pnpm install").option("--force","Overwrite a non-empty destination directory").action(async(r,i)=>{di(z.default.bgCyan(z.default.black(" Spree Plugin Scaffolder ")));let n=await DS(r,i);D(n)&&(O("Scaffolding cancelled."),process.exit(0));let s=nr.resolve(process.cwd(),n.name);ka.existsSync(s)&&ka.readdirSync(s).length>0&&!i.force&&(O(`Destination ${z.default.bold(s)} is not empty. Choose a different name or rerun with ${z.default.cyan("--force")}.`),process.exit(1));let o=MS(n),a=GS(),c=E();c.start(`Scaffolding ${z.default.cyan(n.name)}...`);try{Ch({src:a,dst:s,vars:o,skip:FS(n),force:i.force})}catch(d){c.stop("Scaffolding failed."),b.error(d instanceof Error?d.message:String(d)),process.exit(1)}c.stop(`Created ${z.default.cyan(s)}`),i.install?await BS(s,n):b.info(z.default.dim("Skipping dependency install \u2014 run them yourself when ready.")),US(n,s,i.install),Tt("Happy hacking!")})}async function DS(e,t){let r=g=>{if(!g)return"Required";if(!/^[a-z][a-z0-9-]*$/.test(g))return'Use lowercase letters, digits, and dashes (e.g. "brands" or "loyalty-points")'};if(e!==void 0){let g=r(e);g&&(b.error(`Invalid plugin name ${z.default.bold(e)}: ${g}`),process.exit(2))}e===void 0&&t.yes&&(b.error("Pass the plugin name as an argument when using --yes: spree plugin new <name> -y"),process.exit(2));let i=e??await le({message:"Plugin name",placeholder:"brands",validate:r});if(D(i))return i;let n=`spree_${i.replace(/-/g,"_")}`,s=await ir({flag:"--ruby-name",flagValue:t.rubyName,fallback:n,yes:t.yes,validate:g=>g&&/^[a-z][a-z0-9_]*$/.test(g)?void 0:'Use lowercase letters, digits, and underscores (e.g. "spree_brands")',prompt:()=>le({message:"Ruby gem name",placeholder:n,initialValue:n,validate:g=>g&&/^[a-z][a-z0-9_]*$/.test(g)?void 0:'Use lowercase letters, digits, and underscores (e.g. "spree_brands")'})});if(D(s))return s;let o=NS(s),a=await ir({flag:"--module-name",flagValue:t.moduleName,fallback:o,yes:t.yes,validate:g=>g&&/^[A-Z][A-Za-z0-9]*$/.test(g)?void 0:'PascalCase (e.g. "SpreeBrands")',prompt:()=>le({message:"Ruby module / TS namespace",placeholder:o,initialValue:o,validate:g=>g&&/^[A-Z][A-Za-z0-9]*$/.test(g)?void 0:'PascalCase (e.g. "SpreeBrands")'})});if(D(a))return a;let c=g=>!g||/^@[a-z0-9][a-z0-9-]*$/.test(g)?void 0:"Must start with @ and contain lowercase letters/digits/dashes",d=await ir({flag:"--npm-scope",flagValue:t.npmScope,fallback:"",yes:t.yes,validate:c,prompt:()=>le({message:"npm scope (optional, leave blank for unscoped)",placeholder:"@my-org",initialValue:"",validate:c})});if(D(d))return d;let p=t.author===void 0?await Th("user.name"):void 0,u=await ir({flag:"--author",flagValue:t.author,fallback:p,yes:t.yes,validate:g=>g?void 0:"Required",prompt:()=>le({message:"Author name",placeholder:"Jane Developer",initialValue:p??"",validate:g=>g?void 0:"Required"})});if(D(u))return u;let l=g=>g&&/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(g)?void 0:"Enter a valid email",m=t.authorEmail===void 0?await Th("user.email"):void 0,h=await ir({flag:"--author-email",flagValue:t.authorEmail,fallback:m,yes:t.yes,validate:l,prompt:()=>le({message:"Author email",placeholder:"jane@example.com",initialValue:m??"",validate:l})});if(D(h))return h;let f=g=>g&&Mn.includes(g)?void 0:`Must be one of: ${Mn.join(", ")}`,x=await ir({flag:"--license",flagValue:t.license,fallback:"MIT",yes:t.yes,validate:f,prompt:()=>li({message:"License",options:Mn.map(g=>({value:g,label:g})),initialValue:"MIT"})});if(D(x))return x;let w=t.dashboard===!1?!1:t.yes||await LS("Include dashboard plugin?",!0);if(D(w))return w;let v=!1;return t.engine!==!1&&b.warn("Rails engine generation is coming in a future release. For now, scaffold the dashboard half here and use `spree-extension create` for the Ruby side."),!w&&!v&&(O("Nothing to scaffold (dashboard half declined)."),process.exit(1)),{name:i,rubyName:s,moduleName:a,npmScope:d.trim(),authorName:u,authorEmail:h,license:x,includeDashboard:w,includeEngine:v}}async function LS(e,t){return await Ke({message:e,initialValue:t})}async function ir(e){if(e.flagValue!==void 0){let t=e.validate(e.flagValue);return t&&(b.error(`Invalid value for ${z.default.cyan(e.flag)}: ${t}`),process.exit(2)),e.flagValue}if(e.yes){let t=e.validate(e.fallback);return(e.fallback===void 0||t)&&(b.error(`--yes could not resolve a default for ${z.default.cyan(e.flag)}`+(t?` (${t})`:"")+` \u2014 pass ${z.default.cyan(e.flag)} explicitly.`),process.exit(2)),e.fallback}return e.prompt()}async function Th(e){try{let{stdout:t}=await ct(`git config --get ${e}`);return t.trim()||void 0}catch{return}}function MS(e){let t=e.npmScope?`${e.npmScope}/${e.name}`:e.name;return{name:e.name,plugin_name:e.name,ruby_name:e.rubyName,module_name:e.moduleName,npm_scope:e.npmScope,npm_package_name:t,npm_dashboard_package:e.npmScope?`${e.npmScope}/${e.name}-dashboard`:`${e.name}-dashboard`,author_name:e.authorName,author_email:e.authorEmail,license:e.license,year:String(new Date().getFullYear())}}function FS(e){let t=!e.includeDashboard,r=!e.includeEngine;return i=>!!(t&&(i==="packages/dashboard"||i.startsWith("packages/dashboard/"))||r&&(i==="engine"||i.startsWith("engine/")))}async function BS(e,t){let r=E();if(t.includeDashboard){r.start("Running pnpm install...");try{await ct("pnpm install",{cwd:e,stdio:"pipe"}),r.stop("pnpm install complete.")}catch(i){r.stop(z.default.yellow("pnpm install failed \u2014 run it manually.")),b.warn(i instanceof Error?i.message:String(i))}}if(t.includeEngine){r.start("Running bundle install in engine/...");try{await ct("bundle install",{cwd:nr.join(e,"engine"),stdio:"pipe"}),r.stop("bundle install complete.")}catch(i){r.stop(z.default.yellow("bundle install failed \u2014 run it manually.")),b.warn(i instanceof Error?i.message:String(i))}}}function US(e,t,r){let i=[""];i.push(z.default.bold("Next steps")),i.push(` ${z.default.dim("cd")} ${nr.relative(process.cwd(),t)||"."}`),r||(e.includeDashboard&&i.push(` ${z.default.dim("pnpm")} install`),e.includeEngine&&i.push(` ${z.default.dim("cd engine && bundle")} install && ${z.default.dim("cd ..")}`)),e.includeDashboard&&(i.push(""),i.push(z.default.bold("Dashboard plugin")),i.push(` Edit ${z.default.cyan("packages/dashboard/src/index.tsx")} to register nav entries and slot widgets.`),i.push(` Add pages as file routes in ${z.default.cyan("packages/dashboard/src/routes/")} \u2014 compiled into the host's typed route tree.`),i.push(` See ${z.default.cyan("https://spreecommerce.org/docs/developer/dashboard/plugins/overview")}`)),e.includeEngine&&(i.push(""),i.push(z.default.bold("Rails engine")),i.push(` Edit ${z.default.cyan(`engine/app/controllers/spree/api/v3/admin/${e.rubyName}_controller.rb`)}`),i.push(` See ${z.default.cyan("https://spreecommerce.org/docs/developer/contributing/creating-an-extension")}`)),i.push(""),W(i.join(`
433
+ `),"Your plugin is scaffolded.")}function NS(e){return e.split(/[_-]/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function GS(){let e=nr.dirname(OS(import.meta.url)),t=[nr.resolve(e,jS),nr.resolve(e,"templates/plugin")];for(let r of t)if(ka.existsSync(r))return r;throw new Error(`Plugin template not found. Looked in:
432
434
  ${t.join(`
433
435
  `)}
434
436
 
435
- Reinstall @spree/cli to fix.`)}function qh(e){e.command("rails").description("Run a Rails command (`bin/rails \u2026`) inside the web container").argument("<args...>","arguments to pass to bin/rails").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await F(["bin/rails",...t],r.projectDir)})}function $h(e){e.command("rake").description("Run a rake task (`bin/rake \u2026`) inside the web container").argument("<args...>","task name and arguments").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await F(["bin/rake",...t],r.projectDir)})}function Ah(e){e.command("restart").description("Restart web + worker in place (does not reload Gemfile or compose changes)").action(async()=>{let t=_(),r=E();r.start("Restarting web + worker...");try{await X(["restart","web","worker"],t.projectDir),r.stop("Services restarted.")}catch(i){throw r.stop("Restart failed."),i}})}function Ch(e){e.command("routes").description("Show Rails routes (`bin/rails routes`)").argument("[args...]","arguments to pass to bin/rails routes").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await F(["bin/rails","routes",...t],r.projectDir)})}function Eh(e){e.command("rspec").description("Run RSpec tests (`bundle exec rspec \u2026`) inside the web container").argument("[args...]","files, line numbers, and flags to pass to rspec").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await ut(["bundle","exec","rspec",...t],r.projectDir,{env:{RAILS_ENV:"test"},edgeHint:"then re-run spree rspec"})})}function Ph(e){e.command("sample-data").description("Load sample data (products, categories, images)").action(async()=>{let t=_(),r=E();r.start("Loading sample data..."),await ne("spree:load_sample_data",t.projectDir),r.stop("Sample data loaded.")})}function Th(e){e.command("seed").description("Seed the database").action(async()=>{let t=_(),r=E();r.start("Seeding database..."),await ne("db:seed",t.projectDir),r.stop("Database seeded.")})}function Rh(e){e.command("shell").alias("bash").description("Open an interactive bash shell inside the web container").action(async()=>{let t=_();await ut(["bash"],t.projectDir,{edgeHint:"then open the shell"})})}function Ih(e){e.command("stop").description("Stop services").action(async()=>{let t=_(),r=E();r.start("Stopping services..."),await X(["stop"],t.projectDir),r.stop("Services stopped.")})}function Oh(e){e.command("task").description("Run a Spree rake task (auto-prefixes `spree:`)").argument("<name>","task name (without `spree:` prefix)").argument("[args...]","arguments to pass to the task").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=_();await F(["bin/rake",`spree:${t}`,...r],i.projectDir)})}function jh(e){e.command("update").description("Pull latest image and recreate containers").action(async()=>{let t=_();b.step("Pulling latest images..."),await X(["pull"],t.projectDir,{stdio:"inherit"});let r=E();r.start("Recreating containers..."),await dt(t.projectDir,{stdio:"ignore"}),await X(["up","-d"],t.projectDir),r.stop("Containers recreated."),b.success("Update complete! Migrations will run automatically on startup."),b.info("Run `spree logs` to follow the startup progress.")})}import Dh from"fs";import OS from"path";var de=U(Y(),1);function Lh(e){e.command("upgrade").description("Walk through a Spree version upgrade (bundle + migrate + spree:upgrade)").option("--plan","print the plan via spree:upgrade DRY_RUN=1; skip bundle + migrate").option("--step <id>","run a single rake step by id (skips bundle + migrate)").option("--to <version>","explicit target version (auto-detected from installed gem otherwise)").option("--yes","skip prompts on automated steps").action(async t=>{let r=_();await jS(r.projectDir),t.plan||t.step||(await DS(r.projectDir,t),await MS(r.projectDir,t)),await FS(r.projectDir,t),t.plan||US(r.projectDir)})}async function jS(e){let t=i=>{O(i.join(`
436
- `)),process.exit(1)};Me(e)&&t(["This is a monorepo edge project (SPREE_PATH set in .env).",`Run the upgrade from the monorepo root with ${de.default.bold("pnpm server:*")} \u2014 the`,"project-local docker-compose.yml is not the running config here."]);let r;try{r=await vt("web",e)}catch(i){return t(["Could not inspect the Docker stack from this directory.",` ${de.default.dim(String(i.message).split(`
437
- `)[0])}`,"",`Run ${de.default.bold("spree upgrade")} from your project root (the directory holding the`,".env with SECRET_KEY_BASE), and make sure Docker is running."])}r||t(["The web container is not running.",`Upgrade runs migrations and the ${de.default.bold("spree:upgrade")} rake against your live`,`database, so the stack must be up. Start it with ${de.default.bold("spree dev")}, then`,"re-run `spree upgrade`."])}async function DS(e,t){if(!t.yes){let i=await Ke({message:"Run `bundle update` to bump Spree gems?",initialValue:!0});if(D(i)&&(O("Upgrade aborted."),process.exit(0)),!i){b.info("Skipping `bundle update`.");return}}let r=await LS(e);if(r.length===0)throw new Error('No Spree gems detected in Gemfile.lock. Confirm the project has `gem "spree"` (or `spree_core`/`spree_admin`) in its Gemfile.');b.step(de.default.bold(`bundle update ${r.join(" ")}`)),await F(["bundle","update",...r],e)}async function LS(e){try{let{stdout:t}=await J("docker",["compose","exec","-T","web","sh","-c","bundle list --name-only | grep '^spree'"],{cwd:e});return t.split(`
437
+ Reinstall @spree/cli to fix.`)}function Ih(e){e.command("rails").description("Run a Rails command (`bin/rails \u2026`) inside the web container").argument("<args...>","arguments to pass to bin/rails").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await B(["bin/rails",...t],r.projectDir)})}function Oh(e){e.command("rake").description("Run a rake task (`bin/rake \u2026`) inside the web container").argument("<args...>","task name and arguments").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await B(["bin/rake",...t],r.projectDir)})}function jh(e){e.command("restart").description("Restart web + worker in place (does not reload Gemfile or compose changes)").action(async()=>{let t=_(),r=E();r.start("Restarting web + worker...");try{await X(["restart","web","worker"],t.projectDir),r.stop("Services restarted.")}catch(i){throw r.stop("Restart failed."),i}})}function Dh(e){e.command("routes").description("Show Rails routes (`bin/rails routes`)").argument("[args...]","arguments to pass to bin/rails routes").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await B(["bin/rails","routes",...t],r.projectDir)})}function Lh(e){e.command("rspec").description("Run RSpec tests (`bundle exec rspec \u2026`) inside the web container").argument("[args...]","files, line numbers, and flags to pass to rspec").allowUnknownOption(!0).passThroughOptions(!0).action(async t=>{let r=_();await ut(["bundle","exec","rspec",...t],r.projectDir,{env:{RAILS_ENV:"test"},edgeHint:"then re-run spree rspec"})})}function Mh(e){e.command("sample-data").description("Load sample data (products, categories, images)").action(async()=>{let t=_(),r=E();r.start("Loading sample data..."),await ne("spree:load_sample_data",t.projectDir),r.stop("Sample data loaded.")})}function Fh(e){e.command("seed").description("Seed the database").action(async()=>{let t=_(),r=E();r.start("Seeding database..."),await ne("db:seed",t.projectDir),r.stop("Database seeded.")})}function Bh(e){e.command("shell").alias("bash").description("Open an interactive bash shell inside the web container").action(async()=>{let t=_();await ut(["bash"],t.projectDir,{edgeHint:"then open the shell"})})}function Uh(e){e.command("stop").description("Stop services").action(async()=>{let t=_(),r=E();r.start("Stopping services..."),await X(["stop"],t.projectDir),r.stop("Services stopped.")})}function Nh(e){e.command("task").description("Run a Spree rake task (auto-prefixes `spree:`)").argument("<name>","task name (without `spree:` prefix)").argument("[args...]","arguments to pass to the task").allowUnknownOption(!0).passThroughOptions(!0).action(async(t,r)=>{let i=_();await B(["bin/rake",`spree:${t}`,...r],i.projectDir)})}function Gh(e){e.command("update").description("Pull latest image and recreate containers").action(async()=>{let t=_();b.step("Pulling latest images..."),await X(["pull"],t.projectDir,{stdio:"inherit"});let r=E();r.start("Recreating containers..."),await dt(t.projectDir,{stdio:"ignore"}),await X(["up","-d"],t.projectDir),r.stop("Containers recreated."),b.success("Update complete! Migrations will run automatically on startup."),b.info("Run `spree logs` to follow the startup progress.")})}import zh from"fs";import zS from"path";var de=M(K(),1);function Vh(e){e.command("upgrade").description("Walk through a Spree version upgrade (bundle + migrate + spree:upgrade)").option("--plan","print the plan via spree:upgrade DRY_RUN=1; skip bundle + migrate").option("--step <id>","run a single rake step by id (skips bundle + migrate)").option("--to <version>","explicit target version (auto-detected from installed gem otherwise)").option("--yes","skip prompts on automated steps").action(async t=>{let r=_();await VS(r.projectDir),t.plan||t.step||(await WS(r.projectDir,t),await KS(r.projectDir,t)),await YS(r.projectDir,t),t.plan||XS(r.projectDir)})}async function VS(e){let t=i=>{O(i.join(`
438
+ `)),process.exit(1)};Fe(e)&&t(["This is a monorepo edge project (SPREE_PATH set in .env).",`Run the upgrade from the monorepo root with ${de.default.bold("pnpm server:*")} \u2014 the`,"project-local docker-compose.yml is not the running config here."]);let r;try{r=await vt("web",e)}catch(i){return t(["Could not inspect the Docker stack from this directory.",` ${de.default.dim(String(i.message).split(`
439
+ `)[0])}`,"",`Run ${de.default.bold("spree upgrade")} from your project root (the directory holding the`,".env with SECRET_KEY_BASE), and make sure Docker is running."])}r||t(["The web container is not running.",`Upgrade runs migrations and the ${de.default.bold("spree:upgrade")} rake against your live`,`database, so the stack must be up. Start it with ${de.default.bold("spree dev")}, then`,"re-run `spree upgrade`."])}async function WS(e,t){if(!t.yes){let i=await Ke({message:"Run `bundle update` to bump Spree gems?",initialValue:!0});if(D(i)&&(O("Upgrade aborted."),process.exit(0)),!i){b.info("Skipping `bundle update`.");return}}let r=await HS(e);if(r.length===0)throw new Error('No Spree gems detected in Gemfile.lock. Confirm the project has `gem "spree"` (or `spree_core`/`spree_admin`) in its Gemfile.');b.step(de.default.bold(`bundle update ${r.join(" ")}`)),await B(["bundle","update",...r],e)}async function HS(e){try{let{stdout:t}=await J("docker",["compose","exec","-T","web","sh","-c","bundle list --name-only | grep '^spree'"],{cwd:e});return t.split(`
438
440
  `).map(r=>r.trim()).filter(r=>r.length>0&&r.startsWith("spree"))}catch(t){let r=t;if(r.exitCode===1&&!r.stderr?.trim())return[];throw new Error("Could not list gems in the web container \u2014 the bundle looks out of sync.\nRun `spree bundle install` first, then re-run `spree upgrade`."+(r.stderr?.trim()?`
439
441
 
440
- ${r.stderr.trim()}`:""))}}async function MS(e,t){if(!t.yes){let r=await Ke({message:"Install + run pending migrations?",initialValue:!0});if(D(r)&&(O("Upgrade aborted."),process.exit(0)),!r){b.info("Skipping migrations.");return}}b.step(de.default.bold("spree:install:migrations + db:migrate")),await F(["bin/rails","spree:install:migrations","db:migrate"],e)}async function FS(e,t){let r={};t.plan&&(r.DRY_RUN="1"),t.step&&(r.STEP=t.step),t.to&&(r.TO=t.to),b.step(de.default.bold("spree:upgrade")),await F(["bin/rake","spree:upgrade"],e,{env:r})}function BS(e){let t="Update @spree/sdk in any storefront or integration consuming the API",r=OS.join(e,"apps","storefront","package.json");if(!Dh.existsSync(r))return t;try{let i=JSON.parse(Dh.readFileSync(r,"utf-8")),n=i.dependencies?.["@spree/sdk"]??i.devDependencies?.["@spree/sdk"];return n?`Update @spree/sdk in apps/storefront (currently ${n}) to the release matching the new Spree version`:t}catch{return t}}function US(e){W([`The manifest only ran ${de.default.bold("rake-automatable")} steps.`,"","Don't forget the manual parts from the upgrade doc:",` ${de.default.dim("- Schedule Spree::StockReservations::ExpireJob (cron)")}`,` ${de.default.dim(`- ${BS(e)}`)}`,` ${de.default.dim("- Review behavior changes (cart, availability, payment-method types)")}`,` ${de.default.dim("- Audit custom decorators against renamed APIs")}`,"",`Full checklist: ${de.default.cyan("https://spreecommerce.org/docs/developer/upgrades")}`].join(`
441
- `),"Next steps")}var Mh=U(Y(),1);function Fh(e){e.command("user").description("Manage admin users").command("create").description("Create an admin user").option("--email <email>","admin email").option("--password <password>","admin password").action(async r=>{let i=_(),n=r.email,s=r.password;if(!n){let a=await le({message:"Admin email:",placeholder:"admin@example.com",validate(c){if(!c)return"Email is required";if(!c.includes("@"))return"Invalid email"}});D(a)&&(O("Cancelled."),process.exit(0)),n=a}if(!s){let a=await si({message:"Admin password:",validate(c){if(!c||c.length<6)return"Password must be at least 6 characters"}});D(a)&&(O("Cancelled."),process.exit(0)),s=a}let o=E();o.start("Creating admin user..."),await ne("spree:cli:create_admin",i.projectDir,{EMAIL:n,PASSWORD:s}),o.stop("Admin user created."),b.success(`Email: ${Mh.default.cyan(n)}`)})}import{createRequire as NS}from"module";var GS=NS(import.meta.url),Bh=GS("../package.json").version;var T=new Ea().name("spree").description("CLI for managing Spree Commerce projects").version(Bh).enablePositionalOptions().showSuggestionAfterError(!0).showHelpAfterError("(run `spree --help` for usage)").exitOverride(e=>{(e.code.startsWith("commander.help")||e.code==="commander.version")&&process.exit(0),process.exit(2)});uh(T);mm(T);lh(T);Ih(T);Ah(T);jh(T);fh(T);mh(T);rh(T);yh(T);gh(T);ch(T);Ch(T);Lh(T);hh(T);qh(T);ih(T);$h(T);Oh(T);Eh(T);ah(T);Rh(T);Fh(T);Qm(T);_h(T);Th(T);Ph(T);Sh(T);Xm(T);th(T);oh(T);async function zS(){try{await T.parseAsync()}catch(e){e instanceof Error&&"code"in e&&(e.code==="commander.helpDisplayed"||e.code==="commander.version")&&process.exit(0),e instanceof Error&&"code"in e&&String(e.code).startsWith("commander.")&&process.exit(2);let t=e instanceof Error&&e.constructor.name==="CredentialError"?2:1,r=e instanceof Error?e.message:"An unexpected error occurred.";console.error(`
442
- ${Uh.default.red("Error:")} ${r}
443
- `),process.exit(t)}}zS();
442
+ ${r.stderr.trim()}`:""))}}async function KS(e,t){if(!t.yes){let r=await Ke({message:"Install + run pending migrations?",initialValue:!0});if(D(r)&&(O("Upgrade aborted."),process.exit(0)),!r){b.info("Skipping migrations.");return}}b.step(de.default.bold("spree:install:migrations + db:migrate")),await B(["bin/rails","spree:install:migrations","db:migrate"],e)}async function YS(e,t){let r={};t.plan&&(r.DRY_RUN="1"),t.step&&(r.STEP=t.step),t.to&&(r.TO=t.to),b.step(de.default.bold("spree:upgrade")),await B(["bin/rake","spree:upgrade"],e,{env:r})}function JS(e){let t="Update @spree/sdk in any storefront or integration consuming the API",r=zS.join(e,"apps","storefront","package.json");if(!zh.existsSync(r))return t;try{let i=JSON.parse(zh.readFileSync(r,"utf-8")),n=i.dependencies?.["@spree/sdk"]??i.devDependencies?.["@spree/sdk"];return n?`Update @spree/sdk in apps/storefront (currently ${n}) to the release matching the new Spree version`:t}catch{return t}}function XS(e){W([`The manifest only ran ${de.default.bold("rake-automatable")} steps.`,"","Don't forget the manual parts from the upgrade doc:",` ${de.default.dim("- Schedule Spree::StockReservations::ExpireJob (cron)")}`,` ${de.default.dim(`- ${JS(e)}`)}`,` ${de.default.dim("- Review behavior changes (cart, availability, payment-method types)")}`,` ${de.default.dim("- Audit custom decorators against renamed APIs")}`,"",`Full checklist: ${de.default.cyan("https://spreecommerce.org/docs/developer/upgrades")}`].join(`
443
+ `),"Next steps")}var Wh=M(K(),1);function Hh(e){e.command("user").description("Manage admin users").command("create").description("Create an admin user").option("--email <email>","admin email").option("--password <password>","admin password").action(async r=>{let i=_(),n=r.email,s=r.password;if(!n){let a=await le({message:"Admin email:",placeholder:"admin@example.com",validate(c){if(!c)return"Email is required";if(!c.includes("@"))return"Invalid email"}});D(a)&&(O("Cancelled."),process.exit(0)),n=a}if(!s){let a=await ui({message:"Admin password:",validate(c){if(!c||c.length<6)return"Password must be at least 6 characters"}});D(a)&&(O("Cancelled."),process.exit(0)),s=a}let o=E();o.start("Creating admin user..."),await ne("spree:cli:create_admin",i.projectDir,{EMAIL:n,PASSWORD:s}),o.stop("Admin user created."),b.success(`Email: ${Wh.default.cyan(n)}`)})}import{createRequire as ZS}from"module";var QS=ZS(import.meta.url),Kh=QS("../package.json").version;var T=new La().name("spree").description("CLI for managing Spree Commerce projects").version(Kh).enablePositionalOptions().showSuggestionAfterError(!0).showHelpAfterError("(run `spree --help` for usage)").exitOverride(e=>{(e.code.startsWith("commander.help")||e.code==="commander.version")&&process.exit(0),process.exit(2)});bh(T);xm(T);wh(T);Uh(T);jh(T);Gh(T);Sh(T);xh(T);dh(T);vh(T);qh(T);fh(T);Dh(T);Vh(T);kh(T);Ih(T);uh(T);Oh(T);Nh(T);Lh(T);yh(T);Bh(T);Hh(T);ah(T);$h(T);Fh(T);Mh(T);Rh(T);sh(T);ph(T);hh(T);async function eq(){try{await T.parseAsync()}catch(e){e instanceof Error&&"code"in e&&(e.code==="commander.helpDisplayed"||e.code==="commander.version")&&process.exit(0),e instanceof Error&&"code"in e&&String(e.code).startsWith("commander.")&&process.exit(2);let t=e instanceof Error&&e.constructor.name==="CredentialError"?2:1,r=e instanceof Error?e.message:"An unexpected error occurred.";console.error(`
444
+ ${Yh.default.red("Error:")} ${r}
445
+ `),process.exit(t)}}eq();