@spree/cli 2.3.9 → 2.4.1

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 (28) hide show
  1. package/dist/index.js +189 -167
  2. package/dist/templates/dashboard-starter/.env.example +4 -0
  3. package/dist/templates/dashboard-starter/README.md +36 -0
  4. package/dist/templates/dashboard-starter/biome.json +60 -0
  5. package/dist/templates/dashboard-starter/gitignore.template +6 -0
  6. package/dist/templates/dashboard-starter/index.html +27 -0
  7. package/dist/templates/dashboard-starter/package.json +33 -0
  8. package/dist/templates/dashboard-starter/src/main.tsx +30 -0
  9. package/dist/templates/dashboard-starter/src/plugins.ts +19 -0
  10. package/dist/templates/dashboard-starter/src/routeTree.gen.ts +1140 -0
  11. package/dist/templates/dashboard-starter/src/styles.css +8 -0
  12. package/dist/templates/dashboard-starter/tsconfig.json +20 -0
  13. package/dist/templates/dashboard-starter/vite.config.ts +33 -0
  14. package/dist/templates/plugin/LICENSE.tt +3 -0
  15. package/dist/templates/plugin/README.md.tt +52 -0
  16. package/dist/templates/plugin/package.json.tt +19 -0
  17. package/dist/templates/plugin/packages/dashboard/biome.json +24 -0
  18. package/dist/templates/plugin/packages/dashboard/package.json.tt +49 -0
  19. package/dist/templates/plugin/packages/dashboard/src/client.ts.tt +29 -0
  20. package/dist/templates/plugin/packages/dashboard/src/index.tsx.tt +89 -0
  21. package/dist/templates/plugin/packages/dashboard/src/locales/en.json.tt +25 -0
  22. package/dist/templates/plugin/packages/dashboard/src/pages/{{name}}-list.tsx.tt +50 -0
  23. package/dist/templates/plugin/packages/dashboard/src/routes/{{name}}.index.tsx.tt +26 -0
  24. package/dist/templates/plugin/packages/dashboard/src/slots/product-{{name}}-card.tsx.tt +33 -0
  25. package/dist/templates/plugin/packages/dashboard/src/types.ts.tt +17 -0
  26. package/dist/templates/plugin/packages/dashboard/tsconfig.json +26 -0
  27. package/dist/templates/plugin/pnpm-workspace.yaml +2 -0
  28. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,173 +1,185 @@
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 ph=Object.create;var Wo=Object.defineProperty;var dh=Object.getOwnPropertyDescriptor;var uh=Object.getOwnPropertyNames;var lh=Object.getPrototypeOf,mh=Object.prototype.hasOwnProperty;var ae=(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 S=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var hh=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of uh(t))!mh.call(e,n)&&n!==r&&Wo(e,n,{get:()=>t[n],enumerable:!(i=dh(t,n))||i.enumerable});return e};var G=(e,t,r)=>(r=e!=null?ph(lh(e)):{},hh(t||!e||!e.__esModule?Wo(r,"default",{value:e,enumerable:!0}):r,e));var Nt=S(mn=>{"use strict";var vr=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}},ln=class extends vr{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};mn.CommanderError=vr;mn.InvalidArgumentError=ln});var qr=S(yn=>{"use strict";var{InvalidArgumentError:yh}=Nt(),hn=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 yh(`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 fh(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}yn.Argument=hn;yn.humanReadableArgName=fh});var _n=S(gn=>{"use strict";var{humanReadableArgName:gh}=qr(),fn=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=>gh(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 Ho(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 Rh=Object.create;var ca=Object.defineProperty;var Oh=Object.getOwnPropertyDescriptor;var jh=Object.getOwnPropertyNames;var Dh=Object.getPrototypeOf,Lh=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 Mh=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of jh(t))!Lh.call(e,n)&&n!==r&&ca(e,n,{get:()=>t[n],enumerable:!(i=Oh(t,n))||i.enumerable});return e};var U=(e,t,r)=>(r=e!=null?Rh(Dh(e)):{},Mh(t||!e||!e.__esModule?ca(r,"default",{value:e,enumerable:!0}):r,e));var Qt=A(An=>{"use strict";var Or=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}},$n=class extends Or{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};An.CommanderError=Or;An.InvalidArgumentError=$n});var jr=A(En=>{"use strict";var{InvalidArgumentError:Fh}=Qt(),Cn=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 Fh(`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 Bh(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}En.Argument=Cn;En.humanReadableArgName=Bh});var In=A(Tn=>{"use strict";var{humanReadableArgName:Uh}=jr(),Pn=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=>Uh(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 pa(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 Ho(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}gn.Help=fn;gn.stripColor=Ho});var kn=S(wn=>{"use strict";var{InvalidArgumentError:_h}=Nt(),bn=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=bh(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 _h(`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?Ko(this.name().replace(/^no-/,"")):Ko(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}},xn=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 Ko(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function bh(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 pa(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}Tn.Help=Pn;Tn.stripColor=pa});var Dn=A(jn=>{"use strict";var{InvalidArgumentError:Nh}=Qt(),Rn=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=Gh(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 Nh(`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?da(this.name().replace(/^no-/,"")):da(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}},On=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 da(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function Gh(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}}wn.Option=bn;wn.DualOptions=xn});var Jo=S(Yo=>{"use strict";function xh(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 wh(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=xh(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}}jn.Option=Rn;jn.DualOptions=On});var la=A(ua=>{"use strict";function zh(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 Vh(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=zh(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]}?)`:""}Yo.suggestSimilar=wh});var ea=S(Cn=>{"use strict";var kh=ae("events").EventEmitter,vn=ae("child_process"),Me=ae("path"),Sr=ae("fs"),T=ae("process"),{Argument:vh,humanReadableArgName:qh}=qr(),{CommanderError:qn}=Nt(),{Help:Sh,stripColor:$h}=_n(),{Option:Xo,DualOptions:Ch}=kn(),{suggestSimilar:Qo}=Jo(),Sn=class e extends kh{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=>T.stdout.write(r),writeErr:r=>T.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>T.stdout.isTTY?T.stdout.columns:void 0,getErrHelpWidth:()=>T.stderr.isTTY?T.stderr.columns:void 0,getOutHasColors:()=>$n()??(T.stdout.isTTY&&T.stdout.hasColors?.()),getErrHasColors:()=>$n()??(T.stderr.isTTY&&T.stderr.hasColors?.()),stripColor:r=>$h(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 Sh,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 vh(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 qn(t,r,i)),T.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 Xo(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 Xo)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){T.versions?.electron&&(r.from="electron");let n=T.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=T.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":T.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(Sr.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]}?)`:""}ua.suggestSimilar=Vh});var fa=A(Un=>{"use strict";var Wh=he("events").EventEmitter,Ln=he("child_process"),ze=he("path"),Dr=he("fs"),R=he("process"),{Argument:Hh,humanReadableArgName:Kh}=jr(),{CommanderError:Mn}=Qt(),{Help:Yh,stripColor:Jh}=In(),{Option:ma,DualOptions:Xh}=Dn(),{suggestSimilar:ha}=la(),Fn=class e extends Wh{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=>R.stdout.write(r),writeErr:r=>R.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>R.stdout.isTTY?R.stdout.columns:void 0,getErrHelpWidth:()=>R.stderr.isTTY?R.stderr.columns:void 0,getOutHasColors:()=>Bn()??(R.stdout.isTTY&&R.stdout.hasColors?.()),getErrHasColors:()=>Bn()??(R.stderr.isTTY&&R.stderr.hasColors?.()),stripColor:r=>Jh(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 Yh,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 Hh(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 Mn(t,r,i)),R.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 ma(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 ma)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){R.versions?.electron&&(r.from="electron");let n=R.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=R.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":R.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(Dr.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=Me.resolve(p,u);if(Sr.existsSync(l))return l;if(n.includes(Me.extname(u)))return;let m=n.find(h=>Sr.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=Sr.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=Me.resolve(Me.dirname(p),a)}if(a){let p=s(a,o);if(!p&&!t._executableFile&&this._scriptPath){let u=Me.basename(this._scriptPath,Me.extname(this._scriptPath));u!==this._name&&(p=s(a,`${u}-${t._name}`))}o=p||o}i=n.includes(Me.extname(o));let c;T.platform!=="win32"?i?(r.unshift(o),r=Zo(T.execArgv).concat(r),c=vn.spawn(T.argv[0],r,{stdio:"inherit"})):c=vn.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),r.unshift(o),r=Zo(T.execArgv).concat(r),c=vn.spawn(T.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{T.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 qn(p,"commander.executeSubCommandAsync","(close)")):T.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)T.exit(1);else{let u=new qn(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=ze.resolve(p,u);if(Dr.existsSync(l))return l;if(n.includes(ze.extname(u)))return;let m=n.find(h=>Dr.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=Dr.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=ze.resolve(ze.dirname(p),a)}if(a){let p=s(a,o);if(!p&&!t._executableFile&&this._scriptPath){let u=ze.basename(this._scriptPath,ze.extname(this._scriptPath));u!==this._name&&(p=s(a,`${u}-${t._name}`))}o=p||o}i=n.includes(ze.extname(o));let c;R.platform!=="win32"?i?(r.unshift(o),r=ya(R.execArgv).concat(r),c=Ln.spawn(R.argv[0],r,{stdio:"inherit"})):c=Ln.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),r.unshift(o),r=ya(R.execArgv).concat(r),c=Ln.spawn(R.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{R.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 Mn(p,"commander.executeSubCommandAsync","(close)")):R.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)R.exit(1);else{let u=new Mn(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 T.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()}`,T.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Ch(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=Qo(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=Qo(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=>qh(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=Me.basename(t,Me.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(T.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 R.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()}`,R.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Xh(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=ha(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=ha(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=>Kh(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=ze.basename(t,ze.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(R.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 Zo(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 $n(){if(T.env.NO_COLOR||T.env.FORCE_COLOR==="0"||T.env.FORCE_COLOR==="false")return!1;if(T.env.FORCE_COLOR||T.env.CLICOLOR_FORCE!==void 0)return!0}Cn.Command=Sn;Cn.useColor=$n});var na=S(ue=>{"use strict";var{Argument:ta}=qr(),{Command:An}=ea(),{CommanderError:Ah,InvalidArgumentError:ra}=Nt(),{Help:Eh}=_n(),{Option:ia}=kn();ue.program=new An;ue.createCommand=e=>new An(e);ue.createOption=(e,t)=>new ia(e,t);ue.createArgument=(e,t)=>new ta(e,t);ue.Command=An;ue.Option=ia;ue.Argument=ta;ue.Help=Eh;ue.CommanderError=Ah;ue.InvalidArgumentError=ra;ue.InvalidOptionArgumentError=ra});var X=S((uq,En)=>{"use strict";var Cr=process||{},ca=Cr.argv||[],$r=Cr.env||{},Ph=!($r.NO_COLOR||ca.includes("--no-color"))&&(!!$r.FORCE_COLOR||ca.includes("--color")||Cr.platform==="win32"||(Cr.stdout||{}).isTTY&&$r.TERM!=="dumb"||!!$r.CI),Th=(e,t,r=e)=>i=>{let n=""+i,s=n.indexOf(t,e.length);return~s?e+Oh(n,t,r,s)+t:e+n+t},Oh=(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)},pa=(e=Ph)=>{let t=e?Th:()=>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")}};En.exports=pa();En.exports.createColors=pa});var Tn=S(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 Pn=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=Pn});var zt=S(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.DEFAULT_HEADER_ALIGNMENT=W.DEFAULT_ROW_ALIGNMENT=W.DEFAULT_HEADER_FONT_COLOR=W.DEFAULT_ROW_FONT_COLOR=W.COLORS=W.ALIGNMENTS=W.DEFAULT_TABLE_STYLE=W.DEFAULT_ROW_SEPARATOR=W.DEFAULT_COLUMN_LEN=void 0;W.DEFAULT_COLUMN_LEN=20;W.DEFAULT_ROW_SEPARATOR=!1;W.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"}};W.ALIGNMENTS=["right","left","center"];W.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];W.DEFAULT_ROW_FONT_COLOR="white";W.DEFAULT_HEADER_FONT_COLOR="white_bold";W.DEFAULT_ROW_ALIGNMENT="right";W.DEFAULT_HEADER_ALIGNMENT="center"});var la=S(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});var Bh=[{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}];On.default=Bh});var ma=S(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});var Uh=(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};In.default=Uh});var Rn=S(Vt=>{"use strict";var ya=Vt&&Vt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vt,"__esModule",{value:!0});var ha=ya(la()),Nh=ya(ma()),Gh=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,Nh.default)(e,ha.default,ha.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));Vt.default=Gh});var fa=S(Wt=>{"use strict";var zh=Wt&&Wt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wt,"__esModule",{value:!0});var Vh=zh(Rn()),Wh=e=>{let t=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),n=(0,Vh.default)(i);if(n<0)return-1;t+=n}return t};Wt.default=Wh});var _a=S(He=>{"use strict";var ga=He&&He.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(He,"__esModule",{value:!0});He.wcswidth=He.wcwidth=void 0;var Hh=ga(fa());He.wcswidth=Hh.default;var Kh=ga(Rn());He.wcwidth=Kh.default});var jn=S(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.findWidthInConsole=at.stripAnsi=void 0;var Yh=_a(),Jh=/\x1b\[\d{1,3}(;\d{1,3})*m/g,Xh=e=>e.replace(Jh,"");at.stripAnsi=Xh;var Qh=(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,Yh.wcswidth)(e),r};at.findWidthInConsole=Qh});var Ln=S(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.biggestWordInSentence=ve.textWithPadding=ve.splitTextIntoTextsOfMinLen=void 0;var Dn=jn(),Zh=(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,Dn.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};ve.splitTextIntoTextsOfMinLen=Zh;var ey=(e,t,r,i)=>{let n=(0,Dn.findWidthInConsole)(e,i),s=Math.floor((r-n)/2),o=r-s-n;if(r<n){let a=(0,ve.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,ve.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)}};ve.textWithPadding=ey;var ty=(e,t)=>e.split(" ").reduce((r,i)=>Math.max(r,(0,Dn.findWidthInConsole)(i,t)),0);ve.biggestWordInSentence=ty});var Ht=S(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.getWidthLimitedColumnsArray=M.createHeaderAsRow=M.renderTableHorizontalBorders=M.findLenOfColumn=M.createRow=M.createColumFromOnlyName=M.createTableHorizontalBorders=M.convertRawRowOptionsToStandard=M.evaluateCellText=M.cellText=void 0;var ba=jn(),Mn=Ln(),Fn=zt(),kt=(e,t)=>Math.max(e,t),ry=e=>e==null?"":`${e}`;M.cellText=ry;var iy=(e,t)=>t?`${t(e)}`:(0,M.cellText)(e);M.evaluateCellText=iy;var ny=e=>{if(e)return{color:e.color,separator:e.separator||Fn.DEFAULT_ROW_SEPARATOR}};M.convertRawRowOptionsToStandard=ny;var sy=({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};M.createTableHorizontalBorders=sy;var oy=e=>({name:e,title:e});M.createColumFromOnlyName=oy;var ay=(e,t,r)=>({color:e,separator:r,text:t});M.createRow=ay;var cy=(e,t,r)=>{let i=e.name,n=e.title,s=e.transform,o=kt(0,e?.minLen||0);return e.maxLen?(o=kt(o,kt(e.maxLen,(0,Mn.biggestWordInSentence)(n,r))),o=t.reduce((a,c)=>kt(a,(0,Mn.biggestWordInSentence)((0,M.evaluateCellText)(c.text[i],s),r)),o),o):(o=kt(o,(0,ba.findWidthInConsole)(n,r)),t.forEach(a=>{o=kt(o,(0,ba.findWidthInConsole)((0,M.evaluateCellText)(a.text[i],s),r))}),o)};M.findLenOfColumn=cy;var py=(e,t)=>(0,M.createTableHorizontalBorders)(e,t);M.renderTableHorizontalBorders=py;var dy=(e,t)=>{let r=Fn.DEFAULT_HEADER_FONT_COLOR,i=e(r,{},!1);return t.forEach(n=>{i.text[n.name]=n.title}),i};M.createHeaderAsRow=dy;var uy=(e,t,r)=>{let i={};return e.forEach(n=>{i[n.name]=(0,Mn.splitTextIntoTextsOfMinLen)((0,M.cellText)(t.text[n.name]),n.length||Fn.DEFAULT_COLUMN_LEN,r)}),i};M.getWidthLimitedColumnsArray=uy});var xa=S(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.rawColumnToInternalColumn=Fe.objIfExists=void 0;var ly=zt(),my=(e,t)=>t?{[e]:t}:{};Fe.objIfExists=my;var hy=(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,Fe.objIfExists)("color",e.color||t?.color)),(0,Fe.objIfExists)("maxLen",e.maxLen||t?.maxLen)),(0,Fe.objIfExists)("minLen",e.minLen||t?.minLen)),{alignment:e.alignment||t?.alignment||ly.DEFAULT_ROW_ALIGNMENT,transform:e.transform})};Fe.rawColumnToInternalColumn=hy});var wa=S(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.preProcessRows=vt.preProcessColumns=void 0;var yy=Ht(),fy=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)}))})},gy=e=>{e.enabledColumns.length&&(e.columns=e.columns.filter(t=>e.enabledColumns.includes(t.name)))},_y=e=>{e.disabledColumns.length&&(e.columns=e.columns.filter(t=>!e.disabledColumns.includes(t.name)))},by=e=>{e.columns.forEach(t=>{t.length=(0,yy.findLenOfColumn)(t,e.rows,e.charLength)})},xy=e=>{fy(e),_y(e),gy(e),by(e)};vt.preProcessColumns=xy;var wy=e=>{let t=e.rows.filter(r=>e.filterFunction(r.text)).sort((r,i)=>e.sortFunction(r.text,i.text));e.rows=t};vt.preProcessRows=wy});var Bn=S(le=>{"use strict";var va=le&&le.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(le,"__esModule",{value:!0});le.printSimpleTable=le.renderSimpleTable=le.renderTable=void 0;var qa=va(Tn()),Sa=Ln(),fe=zt(),Ke=Ht(),ky=va(Un()),ka=wa(),vy=(e,t,r,i,n,s,o,a)=>{let c=new qa.default(o);return c.addCharsWithColor("",e.vertical),t.forEach(d=>{let u=r<i[d.name].length?(0,Ke.cellText)(i[d.name][r]):"";c.addCharsWithColor(fe.DEFAULT_ROW_FONT_COLOR," "),c.addCharsWithColor(n&&fe.DEFAULT_HEADER_FONT_COLOR||d.color||s.color,(0,Sa.textWithPadding)(u,d.alignment||fe.DEFAULT_ROW_ALIGNMENT,d.length||fe.DEFAULT_COLUMN_LEN,a)),c.addCharsWithColor("",` ${e.vertical}`)}),c.renderConsole()},$a=(e,t,r,i,n,s)=>{let o=(0,Ke.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=vy(e,t,d,o,n,r,i,s);c.push(p)}return c},qy=(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},Sy=(e,t)=>{let r=[],i=qy(t,e.columns);return r=r.concat($a(e.tableStyle,e.columns,i,e.colorMap,void 0,e.charLength)),r},$y=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||fe.DEFAULT_COLUMN_LEN).reduce(s,1)},i=(0,Sa.textWithPadding)(e.title,fe.DEFAULT_HEADER_ALIGNMENT,r()),n=new qa.default(e.colorMap);return n.addCharsWithColor(fe.DEFAULT_HEADER_FONT_COLOR,i),t.push(n.renderConsole()),t},Cy=e=>{let t=[];t.push((0,Ke.renderTableHorizontalBorders)(e.tableStyle.headerTop,e.columns.map(i=>i.length||fe.DEFAULT_COLUMN_LEN)));let r=(0,Ke.createHeaderAsRow)(Ke.createRow,e.columns);return t=t.concat($a(e.tableStyle,e.columns,r,e.colorMap,!0)),t.push((0,Ke.renderTableHorizontalBorders)(e.tableStyle.headerBottom,e.columns.map(i=>i.length||fe.DEFAULT_COLUMN_LEN))),t},Ay=e=>{let t=[];return t.push((0,Ke.renderTableHorizontalBorders)(e.tableStyle.tableBottom,e.columns.map(r=>r.length||fe.DEFAULT_COLUMN_LEN))),t},Ey=(e,t)=>{let r=[],i=e.rows.length-1;return e.rows.indexOf(t)!==i&&t.separator&&r.push((0,Ke.renderTableHorizontalBorders)(e.tableStyle.rowSeparator,e.columns.map(s=>s.length||fe.DEFAULT_COLUMN_LEN))),r},Py=e=>{(0,ka.preProcessColumns)(e),(0,ka.preProcessRows)(e);let t=[];return $y(e).forEach(r=>t.push(r)),Cy(e).forEach(r=>t.push(r)),e.rows.forEach(r=>{Sy(e,r).forEach(i=>t.push(i)),Ey(e,r).forEach(i=>t.push(i))}),Ay(e).forEach(r=>t.push(r)),t.join(`
31
- `)};le.renderTable=Py;var Ty=(e,t)=>{let r=new ky.default(t);return r.addRows(e),(0,le.renderTable)(r)};le.renderSimpleTable=Ty;var Oy=(e,t)=>{console.log((0,le.renderSimpleTable)(e,t))};le.printSimpleTable=Oy});var Un=S(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});var Iy=Tn(),Ar=zt(),Nn=Ht(),Gn=xa(),Ry=Bn(),jy=()=>0,Dy=()=>!0,zn=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:Ar.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,Gn.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=Ar.DEFAULT_TABLE_STYLE,this.filterFunction=Dy,this.sortFunction=jy,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=Ar.DEFAULT_ROW_SEPARATOR,this.colorMap=Iy.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,Gn.rawColumnToInternalColumn)((0,Nn.createColumFromOnlyName)(i),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,Nn.createColumFromOnlyName)(t):t;this.columns.push((0,Gn.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,Nn.createRow)(r?.color||Ar.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,Ry.renderTable)(this)}};Vn.default=zn});var Aa=S(Kt=>{"use strict";var Ly=Kt&&Kt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Kt,"__esModule",{value:!0});var My=Ly(Un()),Ca=Ht(),Wn=class{constructor(t){this.table=new My.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,Ca.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,Ca.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Kt.default=Wn});var Yt=S(qe=>{"use strict";var Fy=qe&&qe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qe,"__esModule",{value:!0});qe.renderTable=qe.printTable=qe.Table=void 0;var By=Fy(Aa());qe.Table=By.default;var Ea=Bn();Object.defineProperty(qe,"printTable",{enumerable:!0,get:function(){return Ea.printSimpleTable}});Object.defineProperty(qe,"renderTable",{enumerable:!0,get:function(){return Ea.renderSimpleTable}})});var Qn=S((Vq,Wa)=>{"use strict";var Xn={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"},sf={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},of={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?Xn.up():"");return e&&(t+=Xn.left),t}};Wa.exports={cursor:Xn,scroll:sf,erase:of,beep:"\x07"}});var Oc=S((uC,Tc)=>{"use strict";Tc.exports=Pc;Pc.sync=Pg;var Ac=ae("fs");function Eg(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 Ec(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:Eg(t,r)}function Pc(e,t,r){Ac.stat(e,function(i,n){r(i,i?!1:Ec(n,e,t))})}function Pg(e,t){return Ec(Ac.statSync(e),e,t)}});var Lc=S((lC,Dc)=>{"use strict";Dc.exports=Rc;Rc.sync=Tg;var Ic=ae("fs");function Rc(e,t,r){Ic.stat(e,function(i,n){r(i,i?!1:jc(n,t))})}function Tg(e,t){return jc(Ic.statSync(e),t)}function jc(e,t){return e.isFile()&&Og(e,t)}function Og(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 Fc=S((hC,Mc)=>{"use strict";var mC=ae("fs"),ni;process.platform==="win32"||global.TESTING_WINDOWS?ni=Oc():ni=Lc();Mc.exports=fs;fs.sync=Ig;function fs(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){fs(e,t||{},function(s,o){s?n(s):i(o)})})}ni(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 ni.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Wc=S((yC,Vc)=>{"use strict";var Ct=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Bc=ae("path"),Rg=Ct?";":":",Uc=Fc(),Nc=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Gc=(e,t)=>{let r=t.colon||Rg,i=e.match(/\//)||Ct&&e.match(/\\/)?[""]:[...Ct?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],n=Ct?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Ct?n.split(r):[""];return Ct&&e.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:i,pathExt:s,pathExtExe:n}},zc=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});let{pathEnv:i,pathExt:n,pathExtExe:s}=Gc(e,t),o=[],a=d=>new Promise((p,u)=>{if(d===i.length)return t.all&&o.length?p(o):u(Nc(e));let l=i[d],m=/^".*"$/.test(l)?l.slice(1,-1):l,h=Bc.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];Uc(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)},jg=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:i,pathExtExe:n}=Gc(e,t),s=[];for(let o=0;o<r.length;o++){let a=r[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=Bc.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(Uc.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 Nc(e)};Vc.exports=zc;zc.sync=jg});var Kc=S((fC,gs)=>{"use strict";var Hc=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};gs.exports=Hc;gs.exports.default=Hc});var Qc=S((gC,Xc)=>{"use strict";var Yc=ae("path"),Dg=Wc(),Lg=Kc();function Jc(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=Dg.sync(e.command,{path:r[Lg({env:r})],pathExt:t?Yc.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=Yc.resolve(n?e.options.cwd:"",o)),o}function Mg(e){return Jc(e)||Jc(e,!0)}Xc.exports=Mg});var Zc=S((_C,bs)=>{"use strict";var _s=/([()\][%!^"`<>&|;, *?])/g;function Fg(e){return e=e.replace(_s,"^$1"),e}function Bg(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(_s,"^$1"),t&&(e=e.replace(_s,"^$1")),e}bs.exports.command=Fg;bs.exports.argument=Bg});var tp=S((bC,ep)=>{"use strict";ep.exports=/^#!(.*)/});var ip=S((xC,rp)=>{"use strict";var Ug=tp();rp.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 sp=S((wC,np)=>{"use strict";var xs=ae("fs"),Ng=ip();function Gg(e){let r=Buffer.alloc(150),i;try{i=xs.openSync(e,"r"),xs.readSync(i,r,0,150,0),xs.closeSync(i)}catch{}return Ng(r.toString())}np.exports=Gg});var pp=S((kC,cp)=>{"use strict";var zg=ae("path"),op=Qc(),ap=Zc(),Vg=sp(),Wg=process.platform==="win32",Hg=/\.(?:com|exe)$/i,Kg=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Yg(e){e.file=op(e);let t=e.file&&Vg(e.file);return t?(e.args.unshift(e.file),e.command=t,op(e)):e.file}function Jg(e){if(!Wg)return e;let t=Yg(e),r=!Hg.test(t);if(e.options.forceShell||r){let i=Kg.test(t);e.command=zg.normalize(e.command),e.command=ap.command(e.command),e.args=e.args.map(s=>ap.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:Jg(i)}cp.exports=Xg});var lp=S((vC,up)=>{"use strict";var ws=process.platform==="win32";function ks(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 Qg(e,t){if(!ws)return;let r=e.emit;e.emit=function(i,n){if(i==="exit"){let s=dp(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function dp(e,t){return ws&&e===1&&!t.file?ks(t.original,"spawn"):null}function Zg(e,t){return ws&&e===1&&!t.file?ks(t.original,"spawnSync"):null}up.exports={hookChildProcess:Qg,verifyENOENT:dp,verifyENOENTSync:Zg,notFoundError:ks}});var yp=S((qC,At)=>{"use strict";var mp=ae("child_process"),vs=pp(),qs=lp();function hp(e,t,r){let i=vs(e,t,r),n=mp.spawn(i.command,i.args,i.options);return qs.hookChildProcess(n,i),n}function e_(e,t,r){let i=vs(e,t,r),n=mp.spawnSync(i.command,i.args,i.options);return n.error=n.error||qs.verifyENOENTSync(n.status,i),n}At.exports=hp;At.exports.spawn=hp;At.exports.sync=e_;At.exports._parse=vs;At.exports._enoent=qs});var sa=G(na(),1),{program:tq,createCommand:rq,createArgument:iq,createOption:nq,CommanderError:sq,InvalidArgumentError:oq,InvalidOptionArgumentError:aq,Command:oa,Argument:cq,Option:aa,Help:pq}=sa.default;var oh=G(X(),1);function E(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 Ih(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 Rh=new Set(["page","limit","expand","sort","fields"]);function b(e){let t={};for(let[r,i]of Object.entries(e))if(i!==void 0){if(Rh.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 ot=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 da(e,t){let r=t.baseDelay*2**e,i=Math.random()*t.baseDelay;return Math.min(r+i,t.maxDelay)}function ua(e){return new Promise(t=>setTimeout(t,e))}function jh(){return`spree-sdk-retry-${crypto.randomUUID()}`}function Dh(e,t,r,i){return e==="GET"||e==="HEAD"||i?r.retryOnStatus.includes(t):t===429}function Lh(e,t,r){return t.retryOnNetworkError?e==="GET"||e==="HEAD"||r:!1}function Mh(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,_=a.channel??i?.channel,q=typeof window<"u"?window.location.origin:void 0,A=e.baseUrl||q;if(!A)throw new TypeError("sdk-core: baseUrl is required in non-browser environments (no window.location to resolve relative URLs against)");let P=new URL(`${e.baseUrl}${t}${o}`,A);m&&Object.entries(m).forEach(([z,v])=>{if(v!==void 0)if(Array.isArray(v))for(let Re of v)P.searchParams.append(z,String(Re));else P.searchParams.set(z,String(v))});let w={"Content-Type":"application/json",...u};r.headerValue&&(w[r.headerName]=r.headerValue),c&&(w.Authorization=`Bearer ${c}`),d&&(w["x-spree-token"]=d),h&&(w["x-spree-locale"]=h),f&&(w["x-spree-currency"]=f),x&&(w["x-spree-country"]=x),_&&(w["x-spree-channel"]=_);let O=p??(s!=="GET"&&s!=="HEAD"&&e.retryConfig?jh():void 0);O&&(w["Idempotency-Key"]=O);let R=!!O,U=e.retryConfig?e.retryConfig.maxRetries+1:1;for(let z=0;z<U;z++)try{let v=await e.fetchFn(P.toString(),{method:s,headers:w,body:l?JSON.stringify(l):void 0,credentials:e.credentials});if(!v.ok){if(!(z>=U-1)&&e.retryConfig&&Dh(s,v.status,e.retryConfig,R)){let N=v.headers.get("Retry-After"),se=N?Math.min(parseInt(N,10)*1e3,e.retryConfig.maxDelay):da(z,e.retryConfig);await ua(se);continue}let je=await v.json();throw new ot(je,v.status)}return v.status===204?void 0:v.status===202?v.headers.get("content-type")?.includes("application/json")?v.json():void 0:v.json()}catch(v){if(v instanceof ot)throw v;if(!(z>=U-1)&&e.retryConfig&&Lh(s,e.retryConfig,R)){let je=da(z,e.retryConfig);await ua(je);continue}throw v}throw new Error("Unexpected end of retry loop")}}var st={"Spree::Product":"/products","Spree::Variant":"/variants","Spree::Order":"/orders","Spree::User":"/customers","Spree::Category":"/categories","Spree::OptionType":"/option_types"},Fh=class{request;constructor(e){this.request=e}parentScopedCustomFields(e){return{list:(t,r,i)=>this.request("GET",`${e}/${t}/custom_fields`,{...i,params:r?b(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=st[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?b(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/products/${e}`,{...r,params:E(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?b(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/products/${e}/variants/${t}`,{...i,params:E(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?b(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(st["Spree::Product"]),translations:this.parentScopedTranslations("/products")};orders={list:(e,t)=>this.request("GET","/orders",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}`,{...r,params:E(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/items/${t}`,{...i,params:E(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/fulfillments/${t}`,{...i,params:E(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/orders/${e}/payments/${t}`,{...i,params:E(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?b(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?b(t):void 0}),get:(e,t,r)=>this.request("GET",`/orders/${e}/adjustments/${t}`,r)},customFields:this.parentScopedCustomFields(st["Spree::Order"])};optionTypes={list:(e,t)=>this.request("GET","/option_types",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/option_types/${e}`,{...r,params:E(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(st["Spree::OptionType"]),translations:this.parentScopedTranslations("/option_types")};paymentMethods={list:(e,t)=>this.request("GET","/payment_methods",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/payment_methods/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/price_lists/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/prices/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/promotions/${e}`,{...r,params:E(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?b(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?b(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?b(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/customer_groups/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/gift_cards/${e}`,{...r,params:E(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?b(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?b(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)};customers={list:(e,t)=>this.request("GET","/customers",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/customers/${e}`,{...r,params:E(t)}),creditCards:{list:(e,t,r)=>this.request("GET",`/customers/${e}/credit_cards`,{...r,params:t?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/credit_cards/${t}`,{...i,params:E(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/addresses/${t}`,{...i,params:E(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?b(t):void 0}),get:(e,t,r,i)=>this.request("GET",`/customers/${e}/store_credits/${t}`,{...i,params:E(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(st["Spree::User"])};categories={list:(e,t)=>this.request("GET","/categories",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/categories/${e}`,{...r,params:E(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?b(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(st["Spree::Category"]),translations:this.parentScopedTranslations("/categories")};variants={list:(e,t)=>this.request("GET","/variants",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/variants/${e}`,{...r,params:E(t)}),customFields:this.parentScopedCustomFields(st["Spree::Variant"])};taxCategories={list:(e,t)=>this.request("GET","/tax_categories",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/tax_categories/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/channels/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/markets/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/store_credit_categories/${e}`,{...r,params:E(t)})};stockLocations={list:(e,t)=>this.request("GET","/stock_locations",{...t,params:e?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_locations/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_items/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/stock_transfers/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/countries/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/admin_users/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/invitations/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/api_keys/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/allowed_origins/${e}`,{...r,params:E(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/webhook_endpoints/${e}`,{...r,params:E(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?b(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?b(e):void 0}),get:(e,t,r)=>this.request("GET",`/roles/${e}`,{...r,params:E(t)})}};function Gt(e){let t=e.baseUrl.replace(/\/$/,""),r=e.fetch||fetch.bind(globalThis),i=Ih(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}},_=()=>{let q=e.secretKey?{headerName:"X-Spree-Api-Key",headerValue:e.secretKey}:{headerName:"Authorization",headerValue:s?`Bearer ${s}`:""};return Mh(n,c,q)(l,m,x)};try{return await _()}catch(q){if(q instanceof ot&&q.status===401&&a&&!m.includes("/auth/")&&await a())return _();throw q}},p=new Fh(d),u=Object.create(p);return u.setStore=l=>{o=l},u.setToken=l=>{s=l},u.onUnauthorized=l=>{a=l},u}var xm=G(Yt(),1),we=G(X(),1);var Pa=G(X(),1);import Uy from"fs";var Hn=Symbol("no-body");async function Ta(e){if(e===void 0)return Hn;let t;if(e==="-")t=await Ny();else if(e.startsWith("@")){let r=e.slice(1);try{t=Uy.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 Ny(){process.stdin.isTTY&&process.stderr.write(`${Pa.default.dim("Reading request body from stdin \u2014 paste JSON and press Ctrl-D...")}
32
- `);let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}var Go=G(Yt(),1),de=G(X(),1);var yr=G(X(),1);import Ve from"fs";import tv from"os";import Ft from"path";var Er="spree@example.com",Pr="spree123";import Be from"fs";import ct from"path";function g(e=process.cwd()){let t=Gy(e),r=ct.join(t,"docker-compose.yml");if(!Be.existsSync(r))throw new Error(`Not a Spree project directory. No docker-compose.yml found.
33
- Run this command from a directory created with create-spree-app.`);let i=zy(t);return{mode:"docker",projectDir:t,port:i}}function Gy(e){if(ct.basename(e)!=="backend")return e;let t=ct.dirname(e);for(let r of["docker-compose.yml","docker-compose.dev.yml"]){let i=ct.join(t,r);if(Be.existsSync(i))try{if(/\.\/backend:\/rails(:\w+)?(\s|$)/m.test(Be.readFileSync(i,"utf-8")))return t}catch{}}return e}function Se(e){let t=ct.join(e,".env");if(!Be.existsSync(t))return!1;try{let r=Be.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function Or(e){let t=ct.join(e,"docker-compose.yml");if(!Be.existsSync(t))return!1;try{return/^\s*build\s*:/m.test(Be.readFileSync(t,"utf-8"))}catch{return!1}}function zy(e){let t=ct.join(e,".env");if(!Be.existsSync(t))return 3e3;let i=Be.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return i?Number(i[1]):3e3}import{styleText as Zn}from"util";import{stdout as ts,stdin as Ka}from"process";import*as Ye from"readline";import af from"readline";var Oa=(()=>{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}})(),Ia=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ra=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 Vy=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Wy=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ja=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Hy=/\t{1,1000}/y,Da=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"),Ky=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Yy=new RegExp("\\p{M}+","gu"),Jy={limit:1/0,ellipsis:""},La=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",s=t?.ellipsisWidth??(n?La(n,Jy,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=[[Ky,u],[Vy,o],[Wy,a],[Hy,c],[Da,d],[ja,l]],h=0,f=0,x=e.length,_=0,q=!1,A=x,P=Math.max(0,i-s),w=0,L=0,O=0,R=0;e:for(;;){if(L>w||f>=x&&f>h){let U=e.slice(w,L)||e.slice(h,f);_=0;for(let z of U.replaceAll(Yy,"")){let v=z.codePointAt(0)||0;if(Ia(v)?R=p:Ra(v)?R=l:R=u,O+R>P&&(A=Math.min(A,Math.max(w,h)+_)),O+R>i){q=!0;break e}_+=z.length,O+=R}w=L=0}if(f>=x)break e;for(let U=0,z=m.length;U<z;U++){let[v,Re]=m[U];if(v.lastIndex=f,v.test(e)){if(_=v===ja?Oa(e.slice(f,v.lastIndex)):v===Da?1:v.lastIndex-f,R=_*Re,O+R>P&&(A=Math.min(A,f+Math.floor((P-O)/Re))),O+R>i){q=!0;break e}O+=R,w=h,L=f,f=h=v.lastIndex;continue e}}f+=1}return{width:q?P:O,index:q?A:x,truncated:q,ellipsed:q&&i>=s}},Ma=La;var Xy={limit:1/0,ellipsis:"",ellipsisWidth:0},Qy=(e,t={})=>Ma(e,Xy,t).width,ie=Qy;var Ir="\x1B",Ga="\x9B",Zy=39,Yn="\x07",za="[",ef="]",Va="m",Jn=`${ef}8;;`,Fa=new RegExp(`(?:\\${za}(?<code>\\d+)m|\\${Jn}(?<uri>.*)${Yn})`,"y"),Ba=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},Ua=e=>`${Ir}${za}${e}${Va}`,Na=e=>`${Ir}${Jn}${e}${Yn}`,Kn=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,s=!1,o=e.at(-1),a=o===void 0?0:ie(o),c=i.next(),d=i.next(),p=0;for(;!c.done;){let u=c.value,l=ie(u);a+l<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===Ir||u===Ga)&&(n=!0,s=t.startsWith(Jn,p+1)),n?s?u===Yn&&(n=!1,s=!1):u===Va&&(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())},tf=e=>{let t=e.split(" "),r=t.length;for(;r&&!ie(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},rf=(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=ie(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=ie(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(""),Kn(a,l,t),c=ie(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){Kn(a,l,t),c=ie(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){Kn(a,l,t),c=ie(a.at(-1)??"");continue}a[a.length-1]+=l,c+=m}r.trim!==!1&&(a=a.map(u=>tf(u)));let d=a.join(`
34
- `),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===Ir||l===Ga){Fa.lastIndex=u+1;let h=Fa.exec(d)?.groups;if(h?.code!==void 0){let f=Number.parseFloat(h.code);n=f===Zy?void 0:f}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(d[u+1]===`
35
- `){s&&(i+=Na(""));let m=n?Ba(n):void 0;n&&m&&(i+=Ua(m))}else l===`
36
- `&&(n&&Ba(n)&&(i+=Ua(n)),s&&(i+=Na(s)))}return i},nf=/\r?\n/;function $e(e,t,r){return String(e).normalize().split(nf).map(i=>rf(i,t,r)).join(`
37
- `)}var te=G(Qn(),1);import{ReadStream as Ha}from"tty";function jr(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?jr(s,t<0?-1:1,r):s}var cf=["up","down","left","right","space","enter","cancel"],pf=["January","February","March","April","May","June","July","August","September","October","November","December"],Z={actions:new Set(cf),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:[...pf],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 rs(e,t){if(typeof e=="string")return Z.aliases.get(e)===t;for(let r of e)if(r!==void 0&&rs(r,t))return!0;return!1}function df(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 ya(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 Bn(){if(R.env.NO_COLOR||R.env.FORCE_COLOR==="0"||R.env.FORCE_COLOR==="false")return!1;if(R.env.FORCE_COLOR||R.env.CLICOLOR_FORCE!==void 0)return!0}Un.Command=Fn;Un.useColor=Bn});var wa=A(ge=>{"use strict";var{Argument:ga}=jr(),{Command:Nn}=fa(),{CommanderError:Zh,InvalidArgumentError:_a}=Qt(),{Help:Qh}=In(),{Option:ba}=Dn();ge.program=new Nn;ge.createCommand=e=>new Nn(e);ge.createOption=(e,t)=>new ba(e,t);ge.createArgument=(e,t)=>new ga(e,t);ge.Command=Nn;ge.Option=ba;ge.Argument=ga;ge.Help=Qh;ge.CommanderError=Zh;ge.InvalidArgumentError=_a;ge.InvalidOptionArgumentError=_a});var Y=A((tq,Gn)=>{"use strict";var Mr=process||{},Sa=Mr.argv||[],Lr=Mr.env||{},ey=!(Lr.NO_COLOR||Sa.includes("--no-color"))&&(!!Lr.FORCE_COLOR||Sa.includes("--color")||Mr.platform==="win32"||(Mr.stdout||{}).isTTY&&Lr.TERM!=="dumb"||!!Lr.CI),ty=(e,t,r=e)=>i=>{let n=""+i,s=n.indexOf(t,e.length);return~s?e+ry(n,t,r,s)+t:e+n+t},ry=(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)},qa=(e=ey)=>{let t=e?ty:()=>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")}};Gn.exports=qa();Gn.exports.createColors=qa});var Kn=A((pq,Ba)=>{"use strict";var Hn={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"},fy={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},gy={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?Hn.up():"");return e&&(t+=Hn.left),t}};Ba.exports={cursor:Hn,scroll:fy,erase:gy,beep:"\x07"}});var Sc=A((CA,vc)=>{"use strict";vc.exports=kc;kc.sync=Gf;var wc=he("fs");function Nf(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 xc(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:Nf(t,r)}function kc(e,t,r){wc.stat(e,function(i,n){r(i,i?!1:xc(n,e,t))})}function Gf(e,t){return xc(wc.statSync(e),e,t)}});var Ec=A((EA,Cc)=>{"use strict";Cc.exports=$c;$c.sync=zf;var qc=he("fs");function $c(e,t,r){qc.stat(e,function(i,n){r(i,i?!1:Ac(n,t))})}function zf(e,t){return Ac(qc.statSync(e),t)}function Ac(e,t){return e.isFile()&&Vf(e,t)}function Vf(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 Tc=A((TA,Pc)=>{"use strict";var PA=he("fs"),li;process.platform==="win32"||global.TESTING_WINDOWS?li=Sc():li=Ec();Pc.exports=ls;ls.sync=Wf;function ls(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){ls(e,t||{},function(s,o){s?n(s):i(o)})})}li(e,t||{},function(i,n){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,n=!1),r(i,n)})}function Wf(e,t){try{return li.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Mc=A((IA,Lc)=>{"use strict";var It=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ic=he("path"),Hf=It?";":":",Rc=Tc(),Oc=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),jc=(e,t)=>{let r=t.colon||Hf,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}},Dc=(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(Oc(e));let l=i[d],m=/^".*"$/.test(l)?l.slice(1,-1):l,h=Ic.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];Rc(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)},Kf=(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=Ic.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(Rc.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 Oc(e)};Lc.exports=Dc;Dc.sync=Kf});var Bc=A((RA,ms)=>{"use strict";var Fc=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};ms.exports=Fc;ms.exports.default=Fc});var zc=A((OA,Gc)=>{"use strict";var Uc=he("path"),Yf=Mc(),Jf=Bc();function Nc(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=Yf.sync(e.command,{path:r[Jf({env:r})],pathExt:t?Uc.delimiter:void 0})}catch{}finally{s&&process.chdir(i)}return o&&(o=Uc.resolve(n?e.options.cwd:"",o)),o}function Xf(e){return Nc(e)||Nc(e,!0)}Gc.exports=Xf});var Vc=A((jA,ys)=>{"use strict";var hs=/([()\][%!^"`<>&|;, *?])/g;function Zf(e){return e=e.replace(hs,"^$1"),e}function Qf(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(hs,"^$1"),t&&(e=e.replace(hs,"^$1")),e}ys.exports.command=Zf;ys.exports.argument=Qf});var Hc=A((DA,Wc)=>{"use strict";Wc.exports=/^#!(.*)/});var Yc=A((LA,Kc)=>{"use strict";var eg=Hc();Kc.exports=(e="")=>{let t=e.match(eg);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var Xc=A((MA,Jc)=>{"use strict";var fs=he("fs"),tg=Yc();function rg(e){let r=Buffer.alloc(150),i;try{i=fs.openSync(e,"r"),fs.readSync(i,r,0,150,0),fs.closeSync(i)}catch{}return tg(r.toString())}Jc.exports=rg});var tp=A((FA,ep)=>{"use strict";var ig=he("path"),Zc=zc(),Qc=Vc(),ng=Xc(),sg=process.platform==="win32",og=/\.(?:com|exe)$/i,ag=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function cg(e){e.file=Zc(e);let t=e.file&&ng(e.file);return t?(e.args.unshift(e.file),e.command=t,Zc(e)):e.file}function pg(e){if(!sg)return e;let t=cg(e),r=!og.test(t);if(e.options.forceShell||r){let i=ag.test(t);e.command=ig.normalize(e.command),e.command=Qc.command(e.command),e.args=e.args.map(s=>Qc.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 dg(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:pg(i)}ep.exports=dg});var np=A((BA,ip)=>{"use strict";var gs=process.platform==="win32";function _s(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 ug(e,t){if(!gs)return;let r=e.emit;e.emit=function(i,n){if(i==="exit"){let s=rp(n,t);if(s)return r.call(e,"error",s)}return r.apply(e,arguments)}}function rp(e,t){return gs&&e===1&&!t.file?_s(t.original,"spawn"):null}function lg(e,t){return gs&&e===1&&!t.file?_s(t.original,"spawnSync"):null}ip.exports={hookChildProcess:ug,verifyENOENT:rp,verifyENOENTSync:lg,notFoundError:_s}});var ap=A((UA,Rt)=>{"use strict";var sp=he("child_process"),bs=tp(),ws=np();function op(e,t,r){let i=bs(e,t,r),n=sp.spawn(i.command,i.args,i.options);return ws.hookChildProcess(n,i),n}function mg(e,t,r){let i=bs(e,t,r),n=sp.spawnSync(i.command,i.args,i.options);return n.error=n.error||ws.verifyENOENTSync(n.status,i),n}Rt.exports=op;Rt.exports.spawn=op;Rt.exports.sync=mg;Rt.exports._parse=bs;Rt.exports._enoent=ws});var jo=A(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.DEFAULT_COLOR_MAP=void 0;zt.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 Oo=class{constructor(t=zt.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}};zt.default=Oo});var wr=A(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.DEFAULT_HEADER_ALIGNMENT=J.DEFAULT_ROW_ALIGNMENT=J.DEFAULT_HEADER_FONT_COLOR=J.DEFAULT_ROW_FONT_COLOR=J.COLORS=J.ALIGNMENTS=J.DEFAULT_TABLE_STYLE=J.DEFAULT_ROW_SEPARATOR=J.DEFAULT_COLUMN_LEN=void 0;J.DEFAULT_COLUMN_LEN=20;J.DEFAULT_ROW_SEPARATOR=!1;J.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"}};J.ALIGNMENTS=["right","left","center"];J.COLORS=["red","green","yellow","white","blue","magenta","cyan","white_bold","reset"];J.DEFAULT_ROW_FONT_COLOR="white";J.DEFAULT_HEADER_FONT_COLOR="white_bold";J.DEFAULT_ROW_ALIGNMENT="right";J.DEFAULT_HEADER_ALIGNMENT="center"});var im=A(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});var Ek=[{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}];Do.default=Ek});var nm=A(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});var Pk=(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};Lo.default=Pk});var Mo=A(xr=>{"use strict";var om=xr&&xr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xr,"__esModule",{value:!0});var sm=om(im()),Tk=om(nm()),Ik=e=>e===0?0:e<32||e>=127&&e<160?-1:(0,Tk.default)(e,sm.default,sm.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));xr.default=Ik});var am=A(kr=>{"use strict";var Rk=kr&&kr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(kr,"__esModule",{value:!0});var Ok=Rk(Mo()),jk=e=>{let t=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),n=(0,Ok.default)(i);if(n<0)return-1;t+=n}return t};kr.default=jk});var pm=A(ct=>{"use strict";var cm=ct&&ct.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ct,"__esModule",{value:!0});ct.wcswidth=ct.wcwidth=void 0;var Dk=cm(am());ct.wcswidth=Dk.default;var Lk=cm(Mo());ct.wcwidth=Lk.default});var Fo=A(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.findWidthInConsole=St.stripAnsi=void 0;var Mk=pm(),Fk=/\x1b\[\d{1,3}(;\d{1,3})*m/g,Bk=e=>e.replace(Fk,"");St.stripAnsi=Bk;var Uk=(e,t)=>{let r=0;return e=(0,St.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,Mk.wcswidth)(e),r};St.findWidthInConsole=Uk});var Uo=A(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.biggestWordInSentence=De.textWithPadding=De.splitTextIntoTextsOfMinLen=void 0;var Bo=Fo(),Nk=(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,Bo.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};De.splitTextIntoTextsOfMinLen=Nk;var Gk=(e,t,r,i)=>{let n=(0,Bo.findWidthInConsole)(e,i),s=Math.floor((r-n)/2),o=r-s-n;if(r<n){let a=(0,De.splitTextIntoTextsOfMinLen)(e,r);return a.length===1?e:a.map(c=>(0,De.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)}};De.textWithPadding=Gk;var zk=(e,t)=>e.split(" ").reduce((r,i)=>Math.max(r,(0,Bo.findWidthInConsole)(i,t)),0);De.biggestWordInSentence=zk});var vr=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 dm=Fo(),No=Uo(),Go=wr(),Vt=(e,t)=>Math.max(e,t),Vk=e=>e==null?"":`${e}`;N.cellText=Vk;var Wk=(e,t)=>t?`${t(e)}`:(0,N.cellText)(e);N.evaluateCellText=Wk;var Hk=e=>{if(e)return{color:e.color,separator:e.separator||Go.DEFAULT_ROW_SEPARATOR}};N.convertRawRowOptionsToStandard=Hk;var Kk=({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=Kk;var Yk=e=>({name:e,title:e});N.createColumFromOnlyName=Yk;var Jk=(e,t,r)=>({color:e,separator:r,text:t});N.createRow=Jk;var Xk=(e,t,r)=>{let i=e.name,n=e.title,s=e.transform,o=Vt(0,e?.minLen||0);return e.maxLen?(o=Vt(o,Vt(e.maxLen,(0,No.biggestWordInSentence)(n,r))),o=t.reduce((a,c)=>Vt(a,(0,No.biggestWordInSentence)((0,N.evaluateCellText)(c.text[i],s),r)),o),o):(o=Vt(o,(0,dm.findWidthInConsole)(n,r)),t.forEach(a=>{o=Vt(o,(0,dm.findWidthInConsole)((0,N.evaluateCellText)(a.text[i],s),r))}),o)};N.findLenOfColumn=Xk;var Zk=(e,t)=>(0,N.createTableHorizontalBorders)(e,t);N.renderTableHorizontalBorders=Zk;var Qk=(e,t)=>{let r=Go.DEFAULT_HEADER_FONT_COLOR,i=e(r,{},!1);return t.forEach(n=>{i.text[n.name]=n.title}),i};N.createHeaderAsRow=Qk;var ev=(e,t,r)=>{let i={};return e.forEach(n=>{i[n.name]=(0,No.splitTextIntoTextsOfMinLen)((0,N.cellText)(t.text[n.name]),n.length||Go.DEFAULT_COLUMN_LEN,r)}),i};N.getWidthLimitedColumnsArray=ev});var um=A(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.rawColumnToInternalColumn=Xe.objIfExists=void 0;var tv=wr(),rv=(e,t)=>t?{[e]:t}:{};Xe.objIfExists=rv;var iv=(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,Xe.objIfExists)("color",e.color||t?.color)),(0,Xe.objIfExists)("maxLen",e.maxLen||t?.maxLen)),(0,Xe.objIfExists)("minLen",e.minLen||t?.minLen)),{alignment:e.alignment||t?.alignment||tv.DEFAULT_ROW_ALIGNMENT,transform:e.transform})};Xe.rawColumnToInternalColumn=iv});var lm=A(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.preProcessRows=Wt.preProcessColumns=void 0;var nv=vr(),sv=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)}))})},ov=e=>{e.enabledColumns.length&&(e.columns=e.columns.filter(t=>e.enabledColumns.includes(t.name)))},av=e=>{e.disabledColumns.length&&(e.columns=e.columns.filter(t=>!e.disabledColumns.includes(t.name)))},cv=e=>{e.columns.forEach(t=>{t.length=(0,nv.findLenOfColumn)(t,e.rows,e.charLength)})},pv=e=>{sv(e),av(e),ov(e),cv(e)};Wt.preProcessColumns=pv;var dv=e=>{let t=e.rows.filter(r=>e.filterFunction(r.text)).sort((r,i)=>e.sortFunction(r.text,i.text));e.rows=t};Wt.preProcessRows=dv});var zo=A(xe=>{"use strict";var hm=xe&&xe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xe,"__esModule",{value:!0});xe.printSimpleTable=xe.renderSimpleTable=xe.renderTable=void 0;var ym=hm(jo()),fm=Uo(),$e=wr(),pt=vr(),uv=hm(Vo()),mm=lm(),lv=(e,t,r,i,n,s,o,a)=>{let c=new ym.default(o);return c.addCharsWithColor("",e.vertical),t.forEach(d=>{let u=r<i[d.name].length?(0,pt.cellText)(i[d.name][r]):"";c.addCharsWithColor($e.DEFAULT_ROW_FONT_COLOR," "),c.addCharsWithColor(n&&$e.DEFAULT_HEADER_FONT_COLOR||d.color||s.color,(0,fm.textWithPadding)(u,d.alignment||$e.DEFAULT_ROW_ALIGNMENT,d.length||$e.DEFAULT_COLUMN_LEN,a)),c.addCharsWithColor("",` ${e.vertical}`)}),c.renderConsole()},gm=(e,t,r,i,n,s)=>{let o=(0,pt.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=lv(e,t,d,o,n,r,i,s);c.push(p)}return c},mv=(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},hv=(e,t)=>{let r=[],i=mv(t,e.columns);return r=r.concat(gm(e.tableStyle,e.columns,i,e.colorMap,void 0,e.charLength)),r},yv=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||$e.DEFAULT_COLUMN_LEN).reduce(s,1)},i=(0,fm.textWithPadding)(e.title,$e.DEFAULT_HEADER_ALIGNMENT,r()),n=new ym.default(e.colorMap);return n.addCharsWithColor($e.DEFAULT_HEADER_FONT_COLOR,i),t.push(n.renderConsole()),t},fv=e=>{let t=[];t.push((0,pt.renderTableHorizontalBorders)(e.tableStyle.headerTop,e.columns.map(i=>i.length||$e.DEFAULT_COLUMN_LEN)));let r=(0,pt.createHeaderAsRow)(pt.createRow,e.columns);return t=t.concat(gm(e.tableStyle,e.columns,r,e.colorMap,!0)),t.push((0,pt.renderTableHorizontalBorders)(e.tableStyle.headerBottom,e.columns.map(i=>i.length||$e.DEFAULT_COLUMN_LEN))),t},gv=e=>{let t=[];return t.push((0,pt.renderTableHorizontalBorders)(e.tableStyle.tableBottom,e.columns.map(r=>r.length||$e.DEFAULT_COLUMN_LEN))),t},_v=(e,t)=>{let r=[],i=e.rows.length-1;return e.rows.indexOf(t)!==i&&t.separator&&r.push((0,pt.renderTableHorizontalBorders)(e.tableStyle.rowSeparator,e.columns.map(s=>s.length||$e.DEFAULT_COLUMN_LEN))),r},bv=e=>{(0,mm.preProcessColumns)(e),(0,mm.preProcessRows)(e);let t=[];return yv(e).forEach(r=>t.push(r)),fv(e).forEach(r=>t.push(r)),e.rows.forEach(r=>{hv(e,r).forEach(i=>t.push(i)),_v(e,r).forEach(i=>t.push(i))}),gv(e).forEach(r=>t.push(r)),t.join(`
31
+ `)};xe.renderTable=bv;var wv=(e,t)=>{let r=new uv.default(t);return r.addRows(e),(0,xe.renderTable)(r)};xe.renderSimpleTable=wv;var xv=(e,t)=>{console.log((0,xe.renderSimpleTable)(e,t))};xe.printSimpleTable=xv});var Vo=A(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});var kv=jo(),hn=wr(),Wo=vr(),Ho=um(),vv=zo(),Sv=()=>0,qv=()=>!0,Ko=class{initSimple(t){this.columns=t.map(r=>({name:r,title:r,alignment:hn.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,Ho.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=hn.DEFAULT_TABLE_STYLE,this.filterFunction=qv,this.sortFunction=Sv,this.enabledColumns=[],this.disabledColumns=[],this.computedColumns=[],this.rowSeparator=hn.DEFAULT_ROW_SEPARATOR,this.colorMap=kv.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,Ho.rawColumnToInternalColumn)((0,Wo.createColumFromOnlyName)(i),this.defaultColumnOptions))})}addColumn(t){let r=typeof t=="string"?(0,Wo.createColumFromOnlyName)(t):t;this.columns.push((0,Ho.rawColumnToInternalColumn)(r,this.defaultColumnOptions))}addColumns(t){t.forEach(r=>{this.addColumn(r)})}addRow(t,r){this.createColumnFromRow(t),this.rows.push((0,Wo.createRow)(r?.color||hn.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,vv.renderTable)(this)}};Yo.default=Ko});var bm=A(Sr=>{"use strict";var $v=Sr&&Sr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Sr,"__esModule",{value:!0});var Av=$v(Vo()),_m=vr(),Jo=class{constructor(t){this.table=new Av.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,_m.convertRawRowOptionsToStandard)(r)),this}addRows(t,r){return this.table.addRows(t,(0,_m.convertRawRowOptionsToStandard)(r)),this}printTable(){let t=this.table.renderTable();console.log(t)}render(){return this.table.renderTable()}};Sr.default=Jo});var qr=A(Le=>{"use strict";var Cv=Le&&Le.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Le,"__esModule",{value:!0});Le.renderTable=Le.printTable=Le.Table=void 0;var Ev=Cv(bm());Le.Table=Ev.default;var wm=zo();Object.defineProperty(Le,"printTable",{enumerable:!0,get:function(){return wm.printSimpleTable}});Object.defineProperty(Le,"renderTable",{enumerable:!0,get:function(){return wm.renderSimpleTable}})});var xa=U(wa(),1),{program:VS,createCommand:WS,createArgument:HS,createOption:KS,CommanderError:YS,InvalidArgumentError:JS,InvalidOptionArgumentError:XS,Command:ka,Argument:ZS,Option:va,Help:QS}=xa.default;var Ph=U(Y(),1);import se from"fs";import le from"path";import{fileURLToPath as gk}from"url";import{styleText as Yn}from"util";import{stdout as Xn,stdin as Na}from"process";import*as tt from"readline";import _y from"readline";var $a=(()=>{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}})(),Aa=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ca=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 iy=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ny=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ea=/(?:(?![\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,Pa=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"),oy=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ay=new RegExp("\\p{M}+","gu"),cy={limit:1/0,ellipsis:""},Ta=(e,t={},r={})=>{let i=t.limit??1/0,n=t.ellipsis??"",s=t?.ellipsisWidth??(n?Ta(n,cy,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=[[oy,u],[iy,o],[ny,a],[sy,c],[Pa,d],[Ea,l]],h=0,f=0,x=e.length,w=0,S=!1,g=x,I=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(ay,"")){let $=H.codePointAt(0)||0;if(Aa($)?L=p:Ca($)?L=l:L=u,j+L>I&&(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[$,Be]=m[G];if($.lastIndex=f,$.test(e)){if(w=$===Ea?$a(e.slice(f,$.lastIndex)):$===Pa?1:$.lastIndex-f,L=w*Be,j+L>I&&(g=Math.min(g,f+Math.floor((I-j)/Be))),j+L>i){S=!0;break e}j+=L,v=h,B=f,f=h=$.lastIndex;continue e}}f+=1}return{width:S?I:j,index:S?g:x,truncated:S,ellipsed:S&&i>=s}},Ia=Ta;var py={limit:1/0,ellipsis:"",ellipsisWidth:0},dy=(e,t={})=>Ia(e,py,t).width,ae=dy;var Fr="\x1B",La="\x9B",uy=39,Vn="\x07",Ma="[",ly="]",Fa="m",Wn=`${ly}8;;`,Ra=new RegExp(`(?:\\${Ma}(?<code>\\d+)m|\\${Wn}(?<uri>.*)${Vn})`,"y"),Oa=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=>`${Fr}${Ma}${e}${Fa}`,Da=e=>`${Fr}${Wn}${e}${Vn}`,zn=(e,t,r)=>{let i=t[Symbol.iterator](),n=!1,s=!1,o=e.at(-1),a=o===void 0?0:ae(o),c=i.next(),d=i.next(),p=0;for(;!c.done;){let u=c.value,l=ae(u);a+l<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===Fr||u===La)&&(n=!0,s=t.startsWith(Wn,p+1)),n?s?u===Vn&&(n=!1,s=!1):u===Fa&&(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())},my=e=>{let t=e.split(" "),r=t.length;for(;r&&!ae(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},hy=(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=ae(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=ae(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(""),zn(a,l,t),c=ae(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){zn(a,l,t),c=ae(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){zn(a,l,t),c=ae(a.at(-1)??"");continue}a[a.length-1]+=l,c+=m}r.trim!==!1&&(a=a.map(u=>my(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===Fr||l===La){Ra.lastIndex=u+1;let h=Ra.exec(d)?.groups;if(h?.code!==void 0){let f=Number.parseFloat(h.code);n=f===uy?void 0:f}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(d[u+1]===`
33
+ `){s&&(i+=Da(""));let m=n?Oa(n):void 0;n&&m&&(i+=ja(m))}else l===`
34
+ `&&(n&&Oa(n)&&(i+=ja(n)),s&&(i+=Da(s)))}return i},yy=/\r?\n/;function Ee(e,t,r){return String(e).normalize().split(yy).map(i=>hy(i,t,r)).join(`
35
+ `)}var ne=U(Kn(),1);import{ReadStream as Ua}from"tty";function Ur(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?Ur(s,t<0?-1:1,r):s}var by=["up","down","left","right","space","enter","cancel"],wy=["January","February","March","April","May","June","July","August","September","October","November","December"],Q={actions:new Set(by),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:[...wy],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 Zn(e,t){if(typeof e=="string")return Q.aliases.get(e)===t;for(let r of e)if(r!==void 0&&Zn(r,t))return!0;return!1}function xy(e,t){if(e===t)return;let r=e.split(`
38
36
  `),i=t.split(`
39
- `),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 uf=globalThis.process.platform.startsWith("win"),es=Symbol("clack:cancel");function K(e){return e===es}function Rr(e,t){let r=e;r.isTTY&&r.setRawMode(t)}function Ya({input:e=Ka,output:t=ts,overwrite:r=!0,hideCursor:i=!0}={}){let n=Ye.createInterface({input:e,output:t,prompt:"",tabSize:1});Ye.emitKeypressEvents(e,n),e instanceof Ha&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:c})=>{let d=String(o);if(rs([d,a,c],"cancel")){i&&t.write(te.cursor.show),process.exit(0);return}if(!r)return;Ye.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{Ye.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(te.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(te.cursor.show),e instanceof Ha&&e.isTTY&&!uf&&e.setRawMode(!1),n.terminal=!1,n.close()}}var Jt=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,is=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function Xt(e,t,r,i=r,n){let s=Jt(e??ts);return $e(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 ky=globalThis.process.platform.startsWith("win"),Jn=Symbol("clack:cancel");function D(e){return e===Jn}function Br(e,t){let r=e;r.isTTY&&r.setRawMode(t)}function Ga({input:e=Na,output:t=Xn,overwrite:r=!0,hideCursor:i=!0}={}){let n=tt.createInterface({input:e,output:t,prompt:"",tabSize:1});tt.emitKeypressEvents(e,n),e instanceof Ua&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:c})=>{let d=String(o);if(Zn([d,a,c],"cancel")){i&&t.write(ne.cursor.show),process.exit(0);return}if(!r)return;tt.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{tt.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(ne.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(ne.cursor.show),e instanceof Ua&&e.isTTY&&!ky&&e.setRawMode(!1),n.terminal=!1,n.close()}}var er=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,Qn=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function tr(e,t,r,i=r,n){let s=er(e??Xn);return Ee(t,s-r.length,{hard:!0,trim:!1}).split(`
40
38
  `).map((o,a)=>{let c=n?n(o,a):o;return`${a===0?i:r}${c}`}).join(`
41
- `)}var Br=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=Ka,output:i=ts,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(es);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=af.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),Rr(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(te.cursor.show),this.output.off("resize",this.render),Rr(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(te.cursor.show),this.output.off("resize",this.render),Rr(this.input,!1),e(es)})})}_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&&Z.aliases.has(t.name)&&this.emit("cursor",Z.aliases.get(t.name)),Z.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")}rs([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(`
42
- `),Rr(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=$e(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
43
- `).length-1;this.output.write(te.cursor.move(-999,e*-1))}render(){let e=$e(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(te.cursor.hide);else{let t=df(this._prevFrame,e),r=is(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(te.cursor.move(0,s-n)),this.output.write(te.erase.lines(1));let o=e.split(`
44
- `);this.output.write(o[s]),this._prevFrame=e,this.output.write(te.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(te.cursor.move(0,a))}this.output.write(te.erase.down());let o=e.split(`
39
+ `)}var Wr=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=Na,output:i=Xn,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(Jn);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=_y.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),Br(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(ne.cursor.show),this.output.off("resize",this.render),Br(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(ne.cursor.show),this.output.off("resize",this.render),Br(this.input,!1),e(Jn)})})}_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&&Q.aliases.has(t.name)&&this.emit("cursor",Q.aliases.get(t.name)),Q.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")}Zn([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
+ `),Br(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Ee(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
41
+ `).length-1;this.output.write(ne.cursor.move(-999,e*-1))}render(){let e=Ee(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(ne.cursor.hide);else{let t=xy(this._prevFrame,e),r=Qn(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(ne.cursor.move(0,s-n)),this.output.write(ne.erase.lines(1));let o=e.split(`
42
+ `);this.output.write(o[s]),this._prevFrame=e,this.output.write(ne.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(ne.cursor.move(0,a))}this.output.write(ne.erase.down());let o=e.split(`
45
43
  `).slice(s);this.output.write(o.join(`
46
- `)),this._prevFrame=e;return}}this.output.write(te.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Dr=class extends Br{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(te.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Lr=class extends Br{_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}${Zn(["inverse","hidden"],"_")}`;let r=this.masked,i=r.slice(0,this.cursor),n=r.slice(this.cursor);return`${i}${Zn("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)})}},Mr=class extends Br{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?jr(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=jr(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=jr(this.cursor,1,this.options);break}this.changeValue()})}};var Fr=class extends Br{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}${Zn("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 cS}from"util";import me from"process";var Qt=G(Qn(),1);import{existsSync as mS,lstatSync as hS,readdirSync as yS}from"fs";import{dirname as gS,join as _S}from"path";function lf(){return me.platform!=="win32"?me.env.TERM!=="linux":!!me.env.CI||!!me.env.WT_SESSION||!!me.env.TERMINUS_SUBLIME||me.env.ConEmuTask==="{cmd::Cmder}"||me.env.TERM_PROGRAM==="Terminus-Sublime"||me.env.TERM_PROGRAM==="vscode"||me.env.TERM==="xterm-256color"||me.env.TERM==="alacritty"||me.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ns=lf(),mf=()=>process.env.CI==="true";var j=(e,t)=>ns?e:t,hf=j("\u25C6","*"),Xa=j("\u25A0","x"),Qa=j("\u25B2","x"),Gr=j("\u25C7","o"),bS=j("\u250C","T"),$=j("\u2502","|"),Je=j("\u2514","\u2014"),xS=j("\u2510","T"),wS=j("\u2518","\u2014"),ss=j("\u25CF",">"),Nr=j("\u25CB"," "),kS=j("\u25FB","[\u2022]"),vS=j("\u25FC","[+]"),qS=j("\u25FB","[ ]"),yf=j("\u25AA","\u2022"),Ja=j("\u2500","-"),ff=j("\u256E","+"),gf=j("\u251C","+"),_f=j("\u256F","+"),bf=j("\u2570","+"),SS=j("\u256D","+"),xf=j("\u25CF","\u2022"),wf=j("\u25C6","*"),kf=j("\u25B2","!"),vf=j("\u25A0","x"),zr=e=>{switch(e){case"initial":case"active":return y("cyan",hf);case"cancel":return y("red",Xa);case"error":return y("yellow",Qa);case"submit":return y("green",Gr)}},qf=e=>{switch(e){case"initial":case"active":return y("cyan",$);case"cancel":return y("red",$);case"error":return y("yellow",$);case"submit":return y("green",$)}},Sf=(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}},$f=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=Jt(i)-s,c=is(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=[],_=0;m&&_++,h&&_++;let q=l+(m?1:0),A=f-(h?1:0);for(let w=q;w<A;w++){let L=$e(r(t[w],w===e),a,{hard:!0,trim:!1}).split(`
47
- `);x.push(L),_+=L.length}if(_>p){let w=0,L=0,O=_,R=e-q,U=(z,v)=>Sf(x,O,z,v,p);m?({lineCount:O,removals:w}=U(0,R),O>p&&({lineCount:O,removals:L}=U(R+1,x.length))):({lineCount:O,removals:L}=U(R+1,x.length),O>p&&({lineCount:O,removals:w}=U(0,R))),w>0&&(m=!0,x.splice(0,w)),L>0&&(h=!0,x.splice(x.length-L,L))}let P=[];m&&P.push(d);for(let w of x)for(let L of w)P.push(L);return h&&P.push(d),P};var pt=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new Dr({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??Z.withGuide,n=`${zr(this.state)} `,s=i?`${y("gray",$)} `:"",o=Xt(e.output,e.message,s,n),a=`${i?`${y("gray",$)}
44
+ `)),this._prevFrame=e;return}}this.output.write(ne.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}};var Nr=class extends Wr{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(ne.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};var Gr=class extends Wr{_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}${Yn(["inverse","hidden"],"_")}`;let r=this.masked,i=r.slice(0,this.cursor),n=r.slice(this.cursor);return`${i}${Yn("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)})}},zr=class extends Wr{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?Ur(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Ur(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Ur(this.cursor,1,this.options);break}this.changeValue()})}};var Vr=class extends Wr{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}${Yn("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 $q}from"util";import _e from"process";var rr=U(Kn(),1);import{existsSync as Tq,lstatSync as Iq,readdirSync as Rq}from"fs";import{dirname as jq,join as Dq}from"path";function vy(){return _e.platform!=="win32"?_e.env.TERM!=="linux":!!_e.env.CI||!!_e.env.WT_SESSION||!!_e.env.TERMINUS_SUBLIME||_e.env.ConEmuTask==="{cmd::Cmder}"||_e.env.TERM_PROGRAM==="Terminus-Sublime"||_e.env.TERM_PROGRAM==="vscode"||_e.env.TERM==="xterm-256color"||_e.env.TERM==="alacritty"||_e.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var es=vy(),Sy=()=>process.env.CI==="true";var M=(e,t)=>es?e:t,qy=M("\u25C6","*"),Va=M("\u25A0","x"),Wa=M("\u25B2","x"),Yr=M("\u25C7","o"),$y=M("\u250C","T"),C=M("\u2502","|"),rt=M("\u2514","\u2014"),Lq=M("\u2510","T"),Mq=M("\u2518","\u2014"),ts=M("\u25CF",">"),Kr=M("\u25CB"," "),Fq=M("\u25FB","[\u2022]"),Bq=M("\u25FC","[+]"),Uq=M("\u25FB","[ ]"),Ay=M("\u25AA","\u2022"),za=M("\u2500","-"),Cy=M("\u256E","+"),Ey=M("\u251C","+"),Py=M("\u256F","+"),Ty=M("\u2570","+"),Nq=M("\u256D","+"),Iy=M("\u25CF","\u2022"),Ry=M("\u25C6","*"),Oy=M("\u25B2","!"),jy=M("\u25A0","x"),Jr=e=>{switch(e){case"initial":case"active":return y("cyan",qy);case"cancel":return y("red",Va);case"error":return y("yellow",Wa);case"submit":return y("green",Yr)}},Dy=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)}},Ly=(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}},My=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:s=0,rowPadding:o=4})=>{let a=er(i)-s,c=Qn(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=Ee(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,$)=>Ly(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 I=[];m&&I.push(d);for(let v of x)for(let B of v)I.push(B);return h&&I.push(d),I};var Ve=e=>{let t=e.active??"Yes",r=e.inactive??"No";return new Nr({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??Q.withGuide,n=`${Jr(this.state)} `,s=i?`${y("gray",C)} `:"",o=tr(e.output,e.message,s,n),a=`${i?`${y("gray",C)}
48
46
  `:""}${o}
49
- `,c=this.value?t:r;switch(this.state){case"submit":{let d=i?`${y("gray",$)} `:"";return`${a}${d}${y("dim",c)}`}case"cancel":{let d=i?`${y("gray",$)} `:"";return`${a}${d}${y(["strikethrough","dim"],c)}${i?`
50
- ${y("gray",$)}`:""}`}default:{let d=i?`${y("cyan",$)} `:"",p=i?y("cyan",Je):"";return`${a}${d}${this.value?`${y("green",ss)} ${t}`:`${y("dim",Nr)} ${y("dim",t)}`}${e.vertical?i?`
51
- ${y("cyan",$)} `:`
52
- `:` ${y("dim","/")} `}${this.value?`${y("dim",Nr)} ${y("dim",r)}`:`${y("green",ss)} ${r}`}
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",rt):"";return`${a}${d}${this.value?`${y("green",ts)} ${t}`:`${y("dim",Kr)} ${y("dim",t)}`}${e.vertical?i?`
49
+ ${y("cyan",C)} `:`
50
+ `:` ${y("dim","/")} `}${this.value?`${y("dim",Kr)} ${y("dim",r)}`:`${y("green",ts)} ${r}`}
53
51
  ${p}
54
- `}}}}).prompt()};var C={message:(e=[],{symbol:t=y("gray",$),secondarySymbol:r=y("gray",$),output:i=process.stdout,spacing:n=1,withGuide:s}={})=>{let o=[],a=s??Z.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??Q.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(`
55
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(`
56
54
  `)}
57
- `)},info:(e,t)=>{C.message(e,{...t,symbol:y("blue",xf)})},success:(e,t)=>{C.message(e,{...t,symbol:y("green",wf)})},step:(e,t)=>{C.message(e,{...t,symbol:y("green",Gr)})},warn:(e,t)=>{C.message(e,{...t,symbol:y("yellow",kf)})},warning:(e,t)=>{C.warn(e,t)},error:(e,t)=>{C.message(e,{...t,symbol:y("red",vf)})}},F=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Z.withGuide?`${y("gray",Je)} `:"";r.write(`${i}${y("red",e)}
55
+ `)},info:(e,t)=>{b.message(e,{...t,symbol:y("blue",Iy)})},success:(e,t)=>{b.message(e,{...t,symbol:y("green",Ry)})},step:(e,t)=>{b.message(e,{...t,symbol:y("green",Yr)})},warn:(e,t)=>{b.message(e,{...t,symbol:y("yellow",Oy)})},warning:(e,t)=>{b.warn(e,t)},error:(e,t)=>{b.message(e,{...t,symbol:y("red",jy)})}},O=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Q.withGuide?`${y("gray",rt)} `:"";r.write(`${i}${y("red",e)}
58
56
 
59
- `)};var Za=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Z.withGuide?`${y("gray",$)}
60
- ${y("gray",Je)} `:"";r.write(`${i}${e}
57
+ `)},Xr=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Q.withGuide?`${y("gray",$y)} `:"";r.write(`${i}${e}
58
+ `)},Ct=(e="",t)=>{let r=t?.output??process.stdout,i=t?.withGuide??Q.withGuide?`${y("gray",C)}
59
+ ${y("gray",rt)} `:"";r.write(`${i}${e}
61
60
 
62
- `)};var Cf=e=>y("dim",e),Af=(e,t,r)=>{let i={hard:!0,trim:!1},n=$e(e,t,i).split(`
63
- `),s=n.reduce((c,d)=>Math.max(ie(d),c),0),o=n.map(r).reduce((c,d)=>Math.max(ie(d),c),0),a=t-(o-s);return $e(e,a,i)},Y=(e="",t="",r)=>{let i=r?.output??me.stdout,n=r?.withGuide??Z.withGuide,s=r?.format??Cf,o=["",...Af(e,Jt(i)-6,s).split(`
64
- `).map(s),""],a=ie(t),c=Math.max(o.reduce((l,m)=>{let h=ie(m);return h>l?h:l},0),a)+2,d=o.map(l=>`${y("gray",$)} ${l}${" ".repeat(c-ie(l))}${y("gray",$)}`).join(`
65
- `),p=n?`${y("gray",$)}
66
- `:"",u=n?gf:bf;i.write(`${p}${y("green",Gr)} ${y("reset",t)} ${y("gray",Ja.repeat(Math.max(c-a-1,1))+ff)}
61
+ `)};var Fy=e=>y("dim",e),By=(e,t,r)=>{let i={hard:!0,trim:!1},n=Ee(e,t,i).split(`
62
+ `),s=n.reduce((c,d)=>Math.max(ae(d),c),0),o=n.map(r).reduce((c,d)=>Math.max(ae(d),c),0),a=t-(o-s);return Ee(e,a,i)},W=(e="",t="",r)=>{let i=r?.output??_e.stdout,n=r?.withGuide??Q.withGuide,s=r?.format??Fy,o=["",...By(e,er(i)-6,s).split(`
63
+ `).map(s),""],a=ae(t),c=Math.max(o.reduce((l,m)=>{let h=ae(m);return h>l?h:l},0),a)+2,d=o.map(l=>`${y("gray",C)} ${l}${" ".repeat(c-ae(l))}${y("gray",C)}`).join(`
64
+ `),p=n?`${y("gray",C)}
65
+ `:"",u=n?Ey:Ty;i.write(`${p}${y("green",Yr)} ${y("reset",t)} ${y("gray",za.repeat(Math.max(c-a-1,1))+Cy)}
67
66
  ${d}
68
- ${y("gray",u+Ja.repeat(c+2)+_f)}
69
- `)},Vr=e=>new Lr({validate:e.validate,mask:e.mask??yf,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??Z.withGuide,r=`${t?`${y("gray",$)}
70
- `:""}${zr(this.state)} ${e.message}
71
- `,i=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let s=t?`${y("yellow",$)} `:"",o=t?`${y("yellow",Je)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${r.trim()}
67
+ ${y("gray",u+za.repeat(c+2)+Py)}
68
+ `)},Zr=e=>new Gr({validate:e.validate,mask:e.mask??Ay,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??Q.withGuide,r=`${t?`${y("gray",C)}
69
+ `:""}${Jr(this.state)} ${e.message}
70
+ `,i=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let s=t?`${y("yellow",C)} `:"",o=t?`${y("yellow",rt)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${r.trim()}
72
71
  ${s}${a}
73
72
  ${o}${y("yellow",this.error)}
74
- `}case"submit":{let s=t?`${y("gray",$)} `:"",o=n?y("dim",n):"";return`${r}${s}${o}`}case"cancel":{let s=t?`${y("gray",$)} `:"",o=n?y(["strikethrough","dim"],n):"";return`${r}${s}${o}${n&&t?`
75
- ${y("gray",$)}`:""}`}default:{let s=t?`${y("cyan",$)} `:"",o=t?y("cyan",Je):"";return`${r}${s}${i}
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
+ ${y("gray",C)}`:""}`}default:{let s=t?`${y("cyan",C)} `:"",o=t?y("cyan",rt):"";return`${r}${s}${i}
76
75
  ${o}
77
- `}}}}).prompt();var Ef=e=>y("magenta",e),B=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:s=ns?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ns?80:120,signal:a,...c}={})=>{let d=mf(),p,u,l=!1,m=!1,h="",f,x=performance.now(),_=Jt(r),q=c?.styleFrame??Ef,A=N=>{let se=N>1?n??Z.messages.error:i??Z.messages.cancel;m=N===1,l&&(je(se,N),m&&typeof t=="function"&&t())},P=()=>A(2),w=()=>A(1),L=()=>{process.on("uncaughtExceptionMonitor",P),process.on("unhandledRejection",P),process.on("SIGINT",w),process.on("SIGTERM",w),process.on("exit",A),a&&a.addEventListener("abort",w)},O=()=>{process.removeListener("uncaughtExceptionMonitor",P),process.removeListener("unhandledRejection",P),process.removeListener("SIGINT",w),process.removeListener("SIGTERM",w),process.removeListener("exit",A),a&&a.removeEventListener("abort",w)},R=()=>{if(f===void 0)return;d&&r.write(`
78
- `);let N=$e(f,_,{hard:!0,trim:!1}).split(`
79
- `);N.length>1&&r.write(Qt.cursor.up(N.length-1)),r.write(Qt.cursor.to(0)),r.write(Qt.erase.down())},U=N=>N.replace(/\.+$/,""),z=N=>{let se=(performance.now()-N)/1e3,De=Math.floor(se/60),Le=Math.floor(se%60);return De>0?`[${De}m ${Le}s]`:`[${Le}s]`},v=c.withGuide??Z.withGuide,Re=(N="")=>{l=!0,p=Ya({output:r}),h=U(N),x=performance.now(),v&&r.write(`${y("gray",$)}
80
- `);let se=0,De=0;L(),u=setInterval(()=>{if(d&&h===f)return;R(),f=h;let Le=q(s[se]),kr;if(d)kr=`${Le} ${h}...`;else if(e==="timer")kr=`${Le} ${h} ${z(x)}`;else{let ch=".".repeat(Math.floor(De)).slice(0,3);kr=`${Le} ${h}${ch}`}let ah=$e(kr,_,{hard:!0,trim:!1});r.write(ah),se=se+1<s.length?se+1:0,De=De<4?De+.125:0},o)},je=(N="",se=0,De=!1)=>{if(!l)return;l=!1,clearInterval(u),R();let Le=se===0?y("green",Gr):se===1?y("red",Xa):y("red",Qa);h=N??h,De||(e==="timer"?r.write(`${Le} ${h} ${z(x)}
81
- `):r.write(`${Le} ${h}
82
- `)),O(),p()};return{start:Re,stop:(N="")=>je(N,0),message:(N="")=>{h=U(N??h)},cancel:(N="")=>je(N,1),error:(N="")=>je(N,2),clear:()=>je("",0,!0),get isCancelled(){return m}}},$S={light:j("\u2500","-"),heavy:j("\u2501","="),block:j("\u2588","#")};var Ur=(e,t)=>e.includes(`
76
+ `}}}}).prompt();var Uy=e=>y("magenta",e),P=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:n,frames:s=es?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=es?80:120,signal:a,...c}={})=>{let d=Sy(),p,u,l=!1,m=!1,h="",f,x=performance.now(),w=er(r),S=c?.styleFrame??Uy,g=V=>{let de=V>1?n??Q.messages.error:i??Q.messages.cancel;m=V===1,l&&(Ue(de,V),m&&typeof t=="function"&&t())},I=()=>g(2),v=()=>g(1),B=()=>{process.on("uncaughtExceptionMonitor",I),process.on("unhandledRejection",I),process.on("SIGINT",v),process.on("SIGTERM",v),process.on("exit",g),a&&a.addEventListener("abort",v)},j=()=>{process.removeListener("uncaughtExceptionMonitor",I),process.removeListener("unhandledRejection",I),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=Ee(f,w,{hard:!0,trim:!1}).split(`
78
+ `);V.length>1&&r.write(rr.cursor.up(V.length-1)),r.write(rr.cursor.to(0)),r.write(rr.erase.down())},G=V=>V.replace(/\.+$/,""),H=V=>{let de=(performance.now()-V)/1e3,Ne=Math.floor(de/60),Ge=Math.floor(de%60);return Ne>0?`[${Ne}m ${Ge}s]`:`[${Ge}s]`},$=c.withGuide??Q.withGuide,Be=(V="")=>{l=!0,p=Ga({output:r}),h=G(V),x=performance.now(),$&&r.write(`${y("gray",C)}
79
+ `);let de=0,Ne=0;B(),u=setInterval(()=>{if(d&&h===f)return;L(),f=h;let Ge=S(s[de]),Rr;if(d)Rr=`${Ge} ${h}...`;else if(e==="timer")Rr=`${Ge} ${h} ${H(x)}`;else{let Ih=".".repeat(Math.floor(Ne)).slice(0,3);Rr=`${Ge} ${h}${Ih}`}let Th=Ee(Rr,w,{hard:!0,trim:!1});r.write(Th),de=de+1<s.length?de+1:0,Ne=Ne<4?Ne+.125:0},o)},Ue=(V="",de=0,Ne=!1)=>{if(!l)return;l=!1,clearInterval(u),L();let Ge=de===0?y("green",Yr):de===1?y("red",Va):y("red",Wa);h=V??h,Ne||(e==="timer"?r.write(`${Ge} ${h} ${H(x)}
80
+ `):r.write(`${Ge} ${h}
81
+ `)),j(),p()};return{start:Be,stop:(V="")=>Ue(V,0),message:(V="")=>{h=G(V??h)},cancel:(V="")=>Ue(V,1),error:(V="")=>Ue(V,2),clear:()=>Ue("",0,!0),get isCancelled(){return m}}},Gq={light:M("\u2500","-"),heavy:M("\u2501","="),block:M("\u2588","#")};var Hr=(e,t)=>e.includes(`
83
82
  `)?e.split(`
84
83
  `).map(r=>t(r)).join(`
85
- `):t(e),ec=e=>{let t=(r,i)=>{let n=r.label??String(r.value);switch(i){case"disabled":return`${y("gray",Nr)} ${Ur(n,s=>y("gray",s))}${r.hint?` ${y("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${Ur(n,s=>y("dim",s))}`;case"active":return`${y("green",ss)} ${n}${r.hint?` ${y("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${Ur(n,s=>y(["strikethrough","dim"],s))}`;default:return`${y("dim",Nr)} ${Ur(n,s=>y("dim",s))}`}};return new Mr({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??Z.withGuide,i=`${zr(this.state)} `,n=`${qf(this.state)} `,s=Xt(e.output,e.message,n,i),o=`${r?`${y("gray",$)}
84
+ `):t(e),Qr=e=>{let t=(r,i)=>{let n=r.label??String(r.value);switch(i){case"disabled":return`${y("gray",Kr)} ${Hr(n,s=>y("gray",s))}${r.hint?` ${y("dim",`(${r.hint??"disabled"})`)}`:""}`;case"selected":return`${Hr(n,s=>y("dim",s))}`;case"active":return`${y("green",ts)} ${n}${r.hint?` ${y("dim",`(${r.hint})`)}`:""}`;case"cancelled":return`${Hr(n,s=>y(["strikethrough","dim"],s))}`;default:return`${y("dim",Kr)} ${Hr(n,s=>y("dim",s))}`}};return new zr({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let r=e.withGuide??Q.withGuide,i=`${Jr(this.state)} `,n=`${Dy(this.state)} `,s=tr(e.output,e.message,n,i),o=`${r?`${y("gray",C)}
86
85
  `:""}${s}
87
- `;switch(this.state){case"submit":{let a=r?`${y("gray",$)} `:"",c=Xt(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${c}`}case"cancel":{let a=r?`${y("gray",$)} `:"",c=Xt(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${c}${r?`
88
- ${y("gray",$)}`:""}`}default:{let a=r?`${y("cyan",$)} `:"",c=r?y("cyan",Je):"",d=o.split(`
89
- `).length,p=r?2:1;return`${o}${a}${$f({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(`
86
+ `;switch(this.state){case"submit":{let a=r?`${y("gray",C)} `:"",c=tr(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${c}`}case"cancel":{let a=r?`${y("gray",C)} `:"",c=tr(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${c}${r?`
87
+ ${y("gray",C)}`:""}`}default:{let a=r?`${y("cyan",C)} `:"",c=r?y("cyan",rt):"",d=o.split(`
88
+ `).length,p=r?2:1;return`${o}${a}${My({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(`
90
89
  ${a}`)}
91
90
  ${c}
92
- `}}}}).prompt()};var CS=`${y("gray",$)} `;var dt=e=>new Fr({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??Z.withGuide,r=`${`${t?`${y("gray",$)}
93
- `:""}${zr(this.state)} `}${e.message}
94
- `,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=t?y("yellow",Je):"";return`${r.trim()}
91
+ `}}}}).prompt()};var zq=`${y("gray",C)} `;var ue=e=>new Vr({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??Q.withGuide,r=`${`${t?`${y("gray",C)}
92
+ `:""}${Jr(this.state)} `}${e.message}
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",rt):"";return`${r.trim()}
95
94
  ${a}${n}
96
95
  ${c}${o}
97
- `}case"submit":{let o=s?` ${y("dim",s)}`:"",a=t?y("gray",$):"";return`${r}${a}${o}`}case"cancel":{let o=s?` ${y(["strikethrough","dim"],s)}`:"",a=t?y("gray",$):"";return`${r}${a}${o}${s.trim()?`
98
- ${a}`:""}`}default:{let o=t?`${y("cyan",$)} `:"",a=t?y("cyan",Je):"";return`${r}${o}${n}
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
+ ${a}`:""}`}default:{let o=t?`${y("cyan",C)} `:"",a=t?y("cyan",rt):"";return`${r}${o}${n}
99
98
  ${a}
100
- `}}}}).prompt();function V(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 Pf}from"url";var qt=(e,t)=>{let r=as(Tf(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},Tf=e=>os(e)?e.toString():e,os=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,as=e=>e instanceof URL?Pf(e):e;var Wr=(e,t=[],r={})=>{let i=qt(e,"First argument"),[n,s]=V(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(!V(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[i,o,s]};import{ChildProcess as Mf}from"child_process";import{StringDecoder as Of}from"string_decoder";var{toString:tc}=Object.prototype,rc=e=>tc.call(e)==="[object ArrayBuffer]",J=e=>tc.call(e)==="[object Uint8Array]",Ue=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),If=new TextEncoder,ic=e=>If.encode(e),Rf=new TextDecoder,Hr=e=>Rf.decode(e),nc=(e,t)=>jf(e,t).join(""),jf=(e,t)=>{if(t==="utf8"&&e.every(s=>typeof s=="string"))return e;let r=new Of(t),i=e.map(s=>typeof s=="string"?ic(s):s).map(s=>r.write(s)),n=r.end();return n===""?i:[...i,n]},Zt=e=>e.length===1&&J(e[0])?e[0]:cs(Df(e)),Df=e=>e.map(t=>typeof t=="string"?ic(t):t),cs=e=>{let t=new Uint8Array(Lf(e)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t},Lf=e=>{let t=0;for(let r of e)t+=r.length;return t};var cc=e=>Array.isArray(e)&&Array.isArray(e.raw),pc=(e,t)=>{let r=[];for(let[s,o]of e.entries())r=Ff({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,{}]},Ff=({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}=Bf(n,e.raw[i]),c=oc(r,s,o);if(i===t.length)return c;let d=t[i],p=Array.isArray(d)?d.map(u=>ac(u)):[ac(d)];return oc(c,p,a)},Bf=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],i=0,n=sc.has(t[0]);for(let o=0,a=0;o<e.length;o+=1,a+=1){let c=t[a];if(sc.has(c))i!==o&&r.push(e.slice(i,o)),i=o+1;else if(c==="\\"){let d=t[a+1];d===`
101
- `?(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}},sc=new Set([" "," ","\r",`
102
- `]),Uf={x:3,u:5},oc=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],ac=e=>{let t=typeof e;if(t==="string")return e;if(t==="number")return String(e);if(V(e)&&("stdout"in e||"isMaxBuffer"in e))return Nf(e);throw e instanceof Mf||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`)},Nf=({stdout:e})=>{if(typeof e=="string")return e;if(J(e))return Hr(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 Ww}from"child_process";import{debuglog as Gf}from"util";import ps from"process";var ge=e=>Kr.includes(e),Kr=[ps.stdin,ps.stdout,ps.stderr],he=["stdin","stdout","stderr"],Yr=e=>he[e]??`stdio[${e}]`;var uc=e=>{let t={...e};for(let r of ls)t[r]=ds(e,r);return t},ds=(e,t)=>{let r=Array.from({length:zf(e)+1}),i=Vf(e[t],r,t);return Jf(i,t)},zf=({stdio:e})=>Array.isArray(e)?Math.max(e.length,he.length):he.length,Vf=(e,t,r)=>V(e)?Wf(e,t,r):t.fill(e),Wf=(e,t,r)=>{for(let i of Object.keys(e).sort(Hf))for(let n of Kf(i,r,t))t[n]=e[i];return t},Hf=(e,t)=>dc(e)<dc(t)?1:-1,dc=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,Kf=(e,t,r)=>{if(e==="ipc")return[r.length-1];let i=us(e);if(i===void 0||i===0)throw new TypeError(`"${t}.${e}" is invalid.
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 Ny}from"url";var Et=(e,t)=>{let r=is(Gy(e));if(typeof r!="string")throw new TypeError(`${t} must be a string or a file URL: ${r}.`);return r},Gy=e=>rs(e)?e.toString():e,rs=e=>typeof e!="string"&&e&&Object.getPrototypeOf(e)===String.prototype,is=e=>e instanceof URL?Ny(e):e;var ei=(e,t=[],r={})=>{let i=Et(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 Jy}from"child_process";import{StringDecoder as zy}from"string_decoder";var{toString:Ha}=Object.prototype,Ka=e=>Ha.call(e)==="[object ArrayBuffer]",Z=e=>Ha.call(e)==="[object Uint8Array]",We=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Vy=new TextEncoder,Ya=e=>Vy.encode(e),Wy=new TextDecoder,ti=e=>Wy.decode(e),Ja=(e,t)=>Hy(e,t).join(""),Hy=(e,t)=>{if(t==="utf8"&&e.every(s=>typeof s=="string"))return e;let r=new zy(t),i=e.map(s=>typeof s=="string"?Ya(s):s).map(s=>r.write(s)),n=r.end();return n===""?i:[...i,n]},ir=e=>e.length===1&&Z(e[0])?e[0]:ns(Ky(e)),Ky=e=>e.map(t=>typeof t=="string"?Ya(t):t),ns=e=>{let t=new Uint8Array(Yy(e)),r=0;for(let i of e)t.set(i,r),r+=i.length;return t},Yy=e=>{let t=0;for(let r of e)t+=r.length;return t};var ec=e=>Array.isArray(e)&&Array.isArray(e.raw),tc=(e,t)=>{let r=[];for(let[s,o]of e.entries())r=Xy({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,{}]},Xy=({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}=Zy(n,e.raw[i]),c=Za(r,s,o);if(i===t.length)return c;let d=t[i],p=Array.isArray(d)?d.map(u=>Qa(u)):[Qa(d)];return Za(c,p,a)},Zy=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],i=0,n=Xa.has(t[0]);for(let o=0,a=0;o<e.length;o+=1,a+=1){let c=t[a];if(Xa.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+=Qy[d]??1}}let s=i===e.length;return s||r.push(e.slice(i)),{nextTokens:r,leadingWhitespaces:n,trailingWhitespaces:s}},Xa=new Set([" "," ","\r",`
101
+ `]),Qy={x:3,u:5},Za=(e,t,r)=>r||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],Qa=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 ef(e);throw e instanceof Jy||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`)},ef=({stdout:e})=>{if(typeof e=="string")return e;if(Z(e))return ti(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 tf}from"util";import ss from"process";var ke=e=>ri.includes(e),ri=[ss.stdin,ss.stdout,ss.stderr],be=["stdin","stdout","stderr"],ii=e=>be[e]??`stdio[${e}]`;var ic=e=>{let t={...e};for(let r of cs)t[r]=os(e,r);return t},os=(e,t)=>{let r=Array.from({length:rf(e)+1}),i=nf(e[t],r,t);return pf(i,t)},rf=({stdio:e})=>Array.isArray(e)?Math.max(e.length,be.length):be.length,nf=(e,t,r)=>K(e)?sf(e,t,r):t.fill(e),sf=(e,t,r)=>{for(let i of Object.keys(e).sort(of))for(let n of af(i,r,t))t[n]=e[i];return t},of=(e,t)=>rc(e)<rc(t)?1:-1,rc=e=>e==="stdout"||e==="stderr"?0:e==="all"?2:1,af=(e,t,r)=>{if(e==="ipc")return[r.length-1];let i=as(e);if(i===void 0||i===0)throw new TypeError(`"${t}.${e}" is invalid.
103
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.
104
- Please set the "stdio" option to ensure that file descriptor exists.`);return i==="all"?[1,2]:[i]},us=e=>{if(e==="all")return e;if(he.includes(e))return he.indexOf(e);let t=Yf.exec(e);if(t!==null)return Number(t[1])},Yf=/^fd(\d+)$/,Jf=(e,t)=>e.map(r=>r===void 0?Qf[t]:r),Xf=Gf("execa").enabled?"full":"none",Qf={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:Xf,stripFinalNewline:!0},ls=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],Ne=(e,t)=>t==="ipc"?e.at(-1):e[t];var St=({verbose:e},t)=>ms(e,t)!=="none",$t=({verbose:e},t)=>!["none","short"].includes(ms(e,t)),lc=({verbose:e},t)=>{let r=ms(e,t);return Jr(r)?r:void 0},ms=(e,t)=>t===void 0?Zf(e):Ne(e,t),Zf=e=>e.find(t=>Jr(t))??Xr.findLast(t=>e.includes(t)),Jr=e=>typeof e=="function",Xr=["none","short","full"];import{inspect as wg}from"util";import{platform as eg}from"process";import{stripVTControlCharacters as tg}from"util";var mc=(e,t)=>{let r=[e,...t],i=r.join(" "),n=r.map(s=>ag(hc(s))).join(" ");return{command:i,escapedCommand:n}},er=e=>tg(e).split(`
105
- `).map(t=>hc(t)).join(`
106
- `),hc=e=>e.replaceAll(ng,t=>rg(t)),rg=e=>{let t=sg[e];if(t!==void 0)return t;let r=e.codePointAt(0),i=r.toString(16);return r<=og?`\\u${i.padStart(4,"0")}`:`\\U${i}`},ig=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},ng=ig(),sg={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},og=65535,ag=e=>cg.test(e)?e:eg==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,cg=/^[\w./-]+$/;import yc from"process";function hs(){let{env:e}=yc,{TERM:t,TERM_PROGRAM:r}=e;return yc.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 fc={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"},gc={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"},pg={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"},dg={...fc,...gc},ug={...fc,...pg},lg=hs(),mg=lg?dg:ug,Qr=mg,t$=Object.entries(gc);import hg from"tty";var yg=hg?.WriteStream?.prototype?.hasColors?.()??!1,k=(e,t)=>{if(!yg)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}},n$=k(0,0),_c=k(1,22),s$=k(2,22),o$=k(3,23),a$=k(4,24),c$=k(53,55),p$=k(7,27),d$=k(8,28),u$=k(9,29),l$=k(30,39),m$=k(31,39),h$=k(32,39),y$=k(33,39),f$=k(34,39),g$=k(35,39),_$=k(36,39),b$=k(37,39),Zr=k(90,39),x$=k(40,49),w$=k(41,49),k$=k(42,49),v$=k(43,49),q$=k(44,49),S$=k(45,49),$$=k(46,49),C$=k(47,49),A$=k(100,49),bc=k(91,39),E$=k(92,39),xc=k(93,39),P$=k(94,39),T$=k(95,39),O$=k(96,39),I$=k(97,39),R$=k(101,49),j$=k(102,49),D$=k(103,49),L$=k(104,49),M$=k(105,49),F$=k(106,49),B$=k(107,49);var vc=({type:e,message:t,timestamp:r,piped:i,commandId:n,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=fg(r),c=gg[e]({failed:s,reject:o,piped:i}),d=_g[e]({reject:o});return`${Zr(`[${a}]`)} ${Zr(`[${n}]`)} ${d(c)} ${d(t)}`},fg=e=>`${ei(e.getHours(),2)}:${ei(e.getMinutes(),2)}:${ei(e.getSeconds(),2)}.${ei(e.getMilliseconds(),3)}`,ei=(e,t)=>String(e).padStart(t,"0"),wc=({failed:e,reject:t})=>e?t?Qr.cross:Qr.warning:Qr.tick,gg={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:wc,duration:wc},kc=e=>e,_g={command:()=>_c,output:()=>kc,ipc:()=>kc,error:({reject:e})=>e?bc:xc,duration:()=>Zr};var qc=(e,t,r)=>{let i=lc(t,r);return e.map(({verboseLine:n,verboseObject:s})=>bg(n,s,i)).filter(n=>n!==void 0).map(n=>xg(n)).join("")},bg=(e,t,r)=>{if(r===void 0)return e;let i=r(e,t);if(typeof i=="string")return i},xg=e=>e.endsWith(`
103
+ Please set the "stdio" option to ensure that file descriptor exists.`);return i==="all"?[1,2]:[i]},as=e=>{if(e==="all")return e;if(be.includes(e))return be.indexOf(e);let t=cf.exec(e);if(t!==null)return Number(t[1])},cf=/^fd(\d+)$/,pf=(e,t)=>e.map(r=>r===void 0?uf[t]:r),df=tf("execa").enabled?"full":"none",uf={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:df,stripFinalNewline:!0},cs=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],He=(e,t)=>t==="ipc"?e.at(-1):e[t];var Pt=({verbose:e},t)=>ps(e,t)!=="none",Tt=({verbose:e},t)=>!["none","short"].includes(ps(e,t)),nc=({verbose:e},t)=>{let r=ps(e,t);return ni(r)?r:void 0},ps=(e,t)=>t===void 0?lf(e):He(e,t),lf=e=>e.find(t=>ni(t))??si.findLast(t=>e.includes(t)),ni=e=>typeof e=="function",si=["none","short","full"];import{inspect as Of}from"util";import{platform as mf}from"process";import{stripVTControlCharacters as hf}from"util";var sc=(e,t)=>{let r=[e,...t],i=r.join(" "),n=r.map(s=>wf(oc(s))).join(" ");return{command:i,escapedCommand:n}},nr=e=>hf(e).split(`
104
+ `).map(t=>oc(t)).join(`
105
+ `),oc=e=>e.replaceAll(gf,t=>yf(t)),yf=e=>{let t=_f[e];if(t!==void 0)return t;let r=e.codePointAt(0),i=r.toString(16);return r<=bf?`\\u${i.padStart(4,"0")}`:`\\U${i}`},ff=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},gf=ff(),_f={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},bf=65535,wf=e=>xf.test(e)?e:mf==="win32"?`"${e.replaceAll('"','""')}"`:`'${e.replaceAll("'","'\\''")}'`,xf=/^[\w./-]+$/;import ac from"process";function ds(){let{env:e}=ac,{TERM:t,TERM_PROGRAM:r}=e;return ac.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 cc={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"},pc={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"},kf={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"},vf={...cc,...pc},Sf={...cc,...kf},qf=ds(),$f=qf?vf:Sf,oi=$f,_$=Object.entries(pc);import Af from"tty";var Cf=Af?.WriteStream?.prototype?.hasColors?.()??!1,q=(e,t)=>{if(!Cf)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}},x$=q(0,0),dc=q(1,22),k$=q(2,22),v$=q(3,23),S$=q(4,24),q$=q(53,55),$$=q(7,27),A$=q(8,28),C$=q(9,29),E$=q(30,39),P$=q(31,39),T$=q(32,39),I$=q(33,39),R$=q(34,39),O$=q(35,39),j$=q(36,39),D$=q(37,39),ai=q(90,39),L$=q(40,49),M$=q(41,49),F$=q(42,49),B$=q(43,49),U$=q(44,49),N$=q(45,49),G$=q(46,49),z$=q(47,49),V$=q(100,49),uc=q(91,39),W$=q(92,39),lc=q(93,39),H$=q(94,39),K$=q(95,39),Y$=q(96,39),J$=q(97,39),X$=q(101,49),Z$=q(102,49),Q$=q(103,49),eA=q(104,49),tA=q(105,49),rA=q(106,49),iA=q(107,49);var yc=({type:e,message:t,timestamp:r,piped:i,commandId:n,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=Ef(r),c=Pf[e]({failed:s,reject:o,piped:i}),d=Tf[e]({reject:o});return`${ai(`[${a}]`)} ${ai(`[${n}]`)} ${d(c)} ${d(t)}`},Ef=e=>`${ci(e.getHours(),2)}:${ci(e.getMinutes(),2)}:${ci(e.getSeconds(),2)}.${ci(e.getMilliseconds(),3)}`,ci=(e,t)=>String(e).padStart(t,"0"),mc=({failed:e,reject:t})=>e?t?oi.cross:oi.warning:oi.tick,Pf={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:mc,duration:mc},hc=e=>e,Tf={command:()=>dc,output:()=>hc,ipc:()=>hc,error:({reject:e})=>e?uc:lc,duration:()=>ai};var fc=(e,t,r)=>{let i=nc(t,r);return e.map(({verboseLine:n,verboseObject:s})=>If(n,s,i)).filter(n=>n!==void 0).map(n=>Rf(n)).join("")},If=(e,t,r)=>{if(r===void 0)return e;let i=r(e,t);if(typeof i=="string")return i},Rf=e=>e.endsWith(`
107
106
  `)?e:`${e}
108
- `;var Ce=({type:e,verboseMessage:t,fdNumber:r,verboseInfo:i,result:n})=>{let s=kg({type:e,result:n,verboseInfo:i}),o=vg(t,s),a=qc(o,i,r);a!==""&&console.warn(a.slice(0,-1))},kg=({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}),vg=(e,t)=>e.split(`
109
- `).map(r=>qg({...t,message:r})),qg=e=>({verboseLine:vc(e),verboseObject:e}),ti=e=>{let t=typeof e=="string"?e:wg(e);return er(t).replaceAll(" "," ".repeat(Sg))},Sg=2;var Sc=(e,t)=>{St(t)&&Ce({type:"command",verboseMessage:e,verboseInfo:t})};var $c=(e,t,r)=>{Ag(e);let i=$g(e);return{verbose:e,escapedCommand:t,commandId:i,rawOptions:r}},$g=e=>St({verbose:e})?Cg++:void 0,Cg=0n,Ag=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(!Xr.includes(t)&&!Jr(t)){let r=Xr.map(i=>`'${i}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${r} or a function.`)}}};import{hrtime as Cc}from"process";var ri=()=>Cc.bigint(),ys=e=>Number(Cc.bigint()-e)/1e6;var ii=(e,t,r)=>{let i=ri(),{command:n,escapedCommand:s}=mc(e,t),o=ds(r,"verbose"),a=$c(o,s,{...r});return Sc(s,a),{command:n,escapedCommand:s,startTime:i,verboseInfo:a}};var $d=G(yp(),1);import ub from"path";import Sd from"process";import ai from"process";import ut from"path";function si(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 t_}from"util";import{execFile as r_,execFileSync as AC}from"child_process";import fp from"path";import{fileURLToPath as i_}from"url";var TC=t_(r_);function oi(e){return e instanceof URL?i_(e):e}function gp(e){return{*[Symbol.iterator](){let t=fp.resolve(oi(e)),r;for(;r!==t;)yield t,r=t,t=fp.resolve(t,"..")}}}var OC=10*1024*1024;var n_=({cwd:e=ai.cwd(),path:t=ai.env[si()],preferLocal:r=!0,execPath:i=ai.execPath,addExecPath:n=!0}={})=>{let s=ut.resolve(oi(e)),o=[],a=t.split(ut.delimiter);return r&&s_(o,a,s),n&&o_(o,a,i,s),t===""||t===ut.delimiter?`${o.join(ut.delimiter)}${t}`:[...o,t].join(ut.delimiter)},s_=(e,t,r)=>{for(let i of gp(r)){let n=ut.join(i,"node_modules/.bin");t.includes(n)||e.push(n)}},o_=(e,t,r,i)=>{let n=ut.resolve(i,oi(r),"..");t.includes(n)||e.push(n)},_p=({env:e=ai.env,...t}={})=>{e={...e};let r=si({env:e});return t.path=e[r],e[r]=n_(t),e};import{setTimeout as w_}from"timers/promises";var bp=(e,t,r)=>{let i=r?rr:tr,n=e instanceof _e?{}:{cause:e};return new i(t,n)},_e=class extends Error{},xp=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,kp,{value:!0,writable:!1,enumerable:!1,configurable:!1})},wp=e=>ci(e)&&kp in e,kp=Symbol("isExecaError"),ci=e=>Object.prototype.toString.call(e)==="[object Error]",tr=class extends Error{};xp(tr,tr.name);var rr=class extends Error{};xp(rr,rr.name);import{constants as ir}from"os";import{constants as d_}from"os";var vp=()=>{let e=Sp-qp+1;return Array.from({length:e},a_)},a_=(e,t)=>({name:`SIGRT${t+1}`,number:qp+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),qp=34,Sp=64;import{constants as c_}from"os";var $p=[{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 Ss=()=>{let e=vp();return[...$p,...e].map(p_)},p_=({name:e,number:t,description:r,action:i,forced:n=!1,standard:s})=>{let{signals:{[e]:o}}=c_,a=o!==void 0;return{name:e,number:a?o:t,description:r,supported:a,action:i,forced:n,standard:s}};var u_=()=>{let e=Ss();return Object.fromEntries(e.map(l_))},l_=({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}],Cp=u_(),m_=()=>{let e=Ss(),t=65,r=Array.from({length:t},(i,n)=>h_(n,e));return Object.assign({},...r)},h_=(e,t)=>{let r=y_(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}}},y_=(e,t)=>{let r=t.find(({name:i})=>d_.signals[i]===e);return r!==void 0?r:t.find(i=>i.number===e)},YC=m_();var Ep=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return Tp(e,t)},Pp=e=>e===0?e:Tp(e,"`subprocess.kill()`'s argument"),Tp=(e,t)=>{if(Number.isInteger(e))return f_(e,t);if(typeof e=="string")return __(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
110
- ${$s()}`)},f_=(e,t)=>{if(Ap.has(e))return Ap.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.
111
- ${$s()}`)},g_=()=>new Map(Object.entries(ir.signals).reverse().map(([e,t])=>[t,e])),Ap=g_(),__=(e,t)=>{if(e in ir.signals)return e;throw e.toUpperCase()in ir.signals?new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):new TypeError(`Invalid ${t} '${e}': this signal name does not exist.
112
- ${$s()}`)},$s=()=>`Available signal names: ${b_()}.
113
- Available signal numbers: ${x_()}.`,b_=()=>Object.keys(ir.signals).sort().map(e=>`'${e}'`).join(", "),x_=()=>[...new Set(Object.values(ir.signals).sort((e,t)=>e-t))].join(", "),pi=e=>Cp[e].description;var Op=e=>{if(e===!1)return e;if(e===!0)return k_;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},k_=1e3*5,Ip=({kill:e,options:{forceKillAfterDelay:t,killSignal:r},onInternalError:i,context:n,controller:s},o,a)=>{let{signal:c,error:d}=v_(o,a,r);q_(d,i);let p=e(c);return S_({kill:e,signal:c,forceKillAfterDelay:t,killSignal:r,killResult:p,context:n,controller:s}),p},v_=(e,t,r)=>{let[i=r,n]=ci(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&&!ci(n))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${n}`);return{signal:Pp(i),error:n}},q_=(e,t)=>{e!==void 0&&t.reject(e)},S_=async({kill:e,signal:t,forceKillAfterDelay:r,killSignal:i,killResult:n,context:s,controller:o})=>{t===i&&n&&Cs({kill:e,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},Cs=async({kill:e,forceKillAfterDelay:t,context:r,controllerSignal:i})=>{if(t!==!1)try{await w_(t,void 0,{signal:i}),e("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};import{once as $_}from"events";var di=async(e,t)=>{e.aborted||await $_(e,"abort",{signal:t})};var Rp=({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)}`)},jp=({subprocess:e,cancelSignal:t,gracefulCancel:r,context:i,controller:n})=>t===void 0||r?[]:[C_(e,t,i,n)],C_=async(e,t,r,{signal:i})=>{throw await di(t,i),r.terminationReason??="cancel",e.kill(),t.reason};import{scheduler as K_}from"timers/promises";import{promisify as V_}from"util";var Et=({methodName:e,isSubprocess:t,ipc:r,isConnected:i})=>{A_(e,t,r),As(e,t,i)},A_=(e,t,r)=>{if(!r)throw new Error(`${be(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},As=(e,t,r)=>{if(!r)throw new Error(`${be(e,t)} cannot be used: the ${Xe(t)} has already exited or disconnected.`)},Dp=e=>{throw new Error(`${be("getOneMessage",e)} could not complete: the ${Xe(e)} exited or disconnected.`)},Lp=e=>{throw new Error(`${be("sendMessage",e)} failed: the ${Xe(e)} is sending a message too, instead of listening to incoming messages.
107
+ `;var Pe=({type:e,verboseMessage:t,fdNumber:r,verboseInfo:i,result:n})=>{let s=jf({type:e,result:n,verboseInfo:i}),o=Df(t,s),a=fc(o,i,r);a!==""&&console.warn(a.slice(0,-1))},jf=({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}),Df=(e,t)=>e.split(`
108
+ `).map(r=>Lf({...t,message:r})),Lf=e=>({verboseLine:yc(e),verboseObject:e}),pi=e=>{let t=typeof e=="string"?e:Of(e);return nr(t).replaceAll(" "," ".repeat(Mf))},Mf=2;var gc=(e,t)=>{Pt(t)&&Pe({type:"command",verboseMessage:e,verboseInfo:t})};var _c=(e,t,r)=>{Uf(e);let i=Ff(e);return{verbose:e,escapedCommand:t,commandId:i,rawOptions:r}},Ff=e=>Pt({verbose:e})?Bf++:void 0,Bf=0n,Uf=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(!si.includes(t)&&!ni(t)){let r=si.map(i=>`'${i}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${r} or a function.`)}}};import{hrtime as bc}from"process";var di=()=>bc.bigint(),us=e=>Number(bc.bigint()-e)/1e6;var ui=(e,t,r)=>{let i=di(),{command:n,escapedCommand:s}=sc(e,t),o=os(r,"verbose"),a=_c(o,s,{...r});return gc(s,a),{command:n,escapedCommand:s,startTime:i,verboseInfo:a}};var _d=U(ap(),1);import S_ from"path";import gd from"process";import yi from"process";import ht from"path";function mi(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 hg}from"util";import{execFile as yg,execFileSync as VA}from"child_process";import cp from"path";import{fileURLToPath as fg}from"url";var KA=hg(yg);function hi(e){return e instanceof URL?fg(e):e}function pp(e){return{*[Symbol.iterator](){let t=cp.resolve(hi(e)),r;for(;r!==t;)yield t,r=t,t=cp.resolve(t,"..")}}}var YA=10*1024*1024;var gg=({cwd:e=yi.cwd(),path:t=yi.env[mi()],preferLocal:r=!0,execPath:i=yi.execPath,addExecPath:n=!0}={})=>{let s=ht.resolve(hi(e)),o=[],a=t.split(ht.delimiter);return r&&_g(o,a,s),n&&bg(o,a,i,s),t===""||t===ht.delimiter?`${o.join(ht.delimiter)}${t}`:[...o,t].join(ht.delimiter)},_g=(e,t,r)=>{for(let i of pp(r)){let n=ht.join(i,"node_modules/.bin");t.includes(n)||e.push(n)}},bg=(e,t,r,i)=>{let n=ht.resolve(i,hi(r),"..");t.includes(n)||e.push(n)},dp=({env:e=yi.env,...t}={})=>{e={...e};let r=mi({env:e});return t.path=e[r],e[r]=gg(t),e};import{setTimeout as Og}from"timers/promises";var up=(e,t,r)=>{let i=r?or:sr,n=e instanceof ve?{}:{cause:e};return new i(t,n)},ve=class extends Error{},lp=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,hp,{value:!0,writable:!1,enumerable:!1,configurable:!1})},mp=e=>fi(e)&&hp in e,hp=Symbol("isExecaError"),fi=e=>Object.prototype.toString.call(e)==="[object Error]",sr=class extends Error{};lp(sr,sr.name);var or=class extends Error{};lp(or,or.name);import{constants as ar}from"os";import{constants as vg}from"os";var yp=()=>{let e=gp-fp+1;return Array.from({length:e},wg)},wg=(e,t)=>({name:`SIGRT${t+1}`,number:fp+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),fp=34,gp=64;import{constants as xg}from"os";var _p=[{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 xs=()=>{let e=yp();return[..._p,...e].map(kg)},kg=({name:e,number:t,description:r,action:i,forced:n=!1,standard:s})=>{let{signals:{[e]:o}}=xg,a=o!==void 0;return{name:e,number:a?o:t,description:r,supported:a,action:i,forced:n,standard:s}};var Sg=()=>{let e=xs();return Object.fromEntries(e.map(qg))},qg=({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}],bp=Sg(),$g=()=>{let e=xs(),t=65,r=Array.from({length:t},(i,n)=>Ag(n,e));return Object.assign({},...r)},Ag=(e,t)=>{let r=Cg(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}}},Cg=(e,t)=>{let r=t.find(({name:i})=>vg.signals[i]===e);return r!==void 0?r:t.find(i=>i.number===e)},lC=$g();var xp=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return vp(e,t)},kp=e=>e===0?e:vp(e,"`subprocess.kill()`'s argument"),vp=(e,t)=>{if(Number.isInteger(e))return Eg(e,t);if(typeof e=="string")return Tg(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
109
+ ${ks()}`)},Eg=(e,t)=>{if(wp.has(e))return wp.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.
110
+ ${ks()}`)},Pg=()=>new Map(Object.entries(ar.signals).reverse().map(([e,t])=>[t,e])),wp=Pg(),Tg=(e,t)=>{if(e in ar.signals)return e;throw e.toUpperCase()in ar.signals?new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):new TypeError(`Invalid ${t} '${e}': this signal name does not exist.
111
+ ${ks()}`)},ks=()=>`Available signal names: ${Ig()}.
112
+ Available signal numbers: ${Rg()}.`,Ig=()=>Object.keys(ar.signals).sort().map(e=>`'${e}'`).join(", "),Rg=()=>[...new Set(Object.values(ar.signals).sort((e,t)=>e-t))].join(", "),gi=e=>bp[e].description;var Sp=e=>{if(e===!1)return e;if(e===!0)return jg;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},jg=1e3*5,qp=({kill:e,options:{forceKillAfterDelay:t,killSignal:r},onInternalError:i,context:n,controller:s},o,a)=>{let{signal:c,error:d}=Dg(o,a,r);Lg(d,i);let p=e(c);return Mg({kill:e,signal:c,forceKillAfterDelay:t,killSignal:r,killResult:p,context:n,controller:s}),p},Dg=(e,t,r)=>{let[i=r,n]=fi(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&&!fi(n))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${n}`);return{signal:kp(i),error:n}},Lg=(e,t)=>{e!==void 0&&t.reject(e)},Mg=async({kill:e,signal:t,forceKillAfterDelay:r,killSignal:i,killResult:n,context:s,controller:o})=>{t===i&&n&&vs({kill:e,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},vs=async({kill:e,forceKillAfterDelay:t,context:r,controllerSignal:i})=>{if(t!==!1)try{await Og(t,void 0,{signal:i}),e("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};import{once as Fg}from"events";var _i=async(e,t)=>{e.aborted||await Fg(e,"abort",{signal:t})};var $p=({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)}`)},Ap=({subprocess:e,cancelSignal:t,gracefulCancel:r,context:i,controller:n})=>t===void 0||r?[]:[Bg(e,t,i,n)],Bg=async(e,t,r,{signal:i})=>{throw await _i(t,i),r.terminationReason??="cancel",e.kill(),t.reason};import{scheduler as a_}from"timers/promises";import{promisify as n_}from"util";var Ot=({methodName:e,isSubprocess:t,ipc:r,isConnected:i})=>{Ug(e,t,r),Ss(e,t,i)},Ug=(e,t,r)=>{if(!r)throw new Error(`${Se(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Ss=(e,t,r)=>{if(!r)throw new Error(`${Se(e,t)} cannot be used: the ${it(t)} has already exited or disconnected.`)},Cp=e=>{throw new Error(`${Se("getOneMessage",e)} could not complete: the ${it(e)} exited or disconnected.`)},Ep=e=>{throw new Error(`${Se("sendMessage",e)} failed: the ${it(e)} is sending a message too, instead of listening to incoming messages.
114
113
  This can be fixed by both sending a message and listening to incoming messages at the same time:
115
114
 
116
115
  const [receivedMessage] = await Promise.all([
117
- ${be("getOneMessage",e)},
118
- ${be("sendMessage",e,"message, {strict: true}")},
119
- ]);`)},ui=(e,t)=>new Error(`${be("sendMessage",t)} failed when sending an acknowledgment response to the ${Xe(t)}.`,{cause:e}),Mp=e=>{throw new Error(`${be("sendMessage",e)} failed: the ${Xe(e)} is not listening to incoming messages.`)},Fp=e=>{throw new Error(`${be("sendMessage",e)} failed: the ${Xe(e)} exited without listening to incoming messages.`)},Bp=()=>new Error(`\`cancelSignal\` aborted: the ${Xe(!0)} disconnected.`),Up=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},Np=({error:e,methodName:t,isSubprocess:r})=>{if(e.code==="EPIPE")throw new Error(`${be(t,r)} cannot be used: the ${Xe(r)} is disconnecting.`,{cause:e})},Gp=({error:e,methodName:t,isSubprocess:r,message:i})=>{if(E_(e))throw new Error(`${be(t,r)}'s argument type is invalid: the message cannot be serialized: ${String(i)}.`,{cause:e})},E_=({code:e,message:t})=>P_.has(e)||T_.some(r=>t.includes(r)),P_=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),T_=["could not be cloned","circular structure","call stack size exceeded"],be=(e,t,r="")=>e==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${O_(t)}${e}(${r})`,O_=e=>e?"":"subprocess.",Xe=e=>e?"parent process":"subprocess",Pt=e=>{e.connected&&e.disconnect()};var Ae=()=>{let e={},t=new Promise((r,i)=>{Object.assign(e,{resolve:r,reject:i})});return Object.assign(t,e)};var mi=(e,t="stdin")=>{let{options:i,fileDescriptors:n}=Ee.get(e),s=zp(n,t,!0),o=e.stdio[s];if(o===null)throw new TypeError(Vp(s,t,i,!0));return o},Tt=(e,t="stdout")=>{let{options:i,fileDescriptors:n}=Ee.get(e),s=zp(n,t,!1),o=s==="all"?e.all:e.stdio[s];if(o==null)throw new TypeError(Vp(s,t,i,!1));return o},Ee=new WeakMap,zp=(e,t,r)=>{let i=I_(t,r);return R_(i,t,r,e),i},I_=(e,t)=>{let r=us(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(`"${nr(t)}" must not be "${e}".
116
+ ${Se("getOneMessage",e)},
117
+ ${Se("sendMessage",e,"message, {strict: true}")},
118
+ ]);`)},bi=(e,t)=>new Error(`${Se("sendMessage",t)} failed when sending an acknowledgment response to the ${it(t)}.`,{cause:e}),Pp=e=>{throw new Error(`${Se("sendMessage",e)} failed: the ${it(e)} is not listening to incoming messages.`)},Tp=e=>{throw new Error(`${Se("sendMessage",e)} failed: the ${it(e)} exited without listening to incoming messages.`)},Ip=()=>new Error(`\`cancelSignal\` aborted: the ${it(!0)} disconnected.`),Rp=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},Op=({error:e,methodName:t,isSubprocess:r})=>{if(e.code==="EPIPE")throw new Error(`${Se(t,r)} cannot be used: the ${it(r)} is disconnecting.`,{cause:e})},jp=({error:e,methodName:t,isSubprocess:r,message:i})=>{if(Ng(e))throw new Error(`${Se(t,r)}'s argument type is invalid: the message cannot be serialized: ${String(i)}.`,{cause:e})},Ng=({code:e,message:t})=>Gg.has(e)||zg.some(r=>t.includes(r)),Gg=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),zg=["could not be cloned","circular structure","call stack size exceeded"],Se=(e,t,r="")=>e==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${Vg(t)}${e}(${r})`,Vg=e=>e?"":"subprocess.",it=e=>e?"parent process":"subprocess",jt=e=>{e.connected&&e.disconnect()};var Te=()=>{let e={},t=new Promise((r,i)=>{Object.assign(e,{resolve:r,reject:i})});return Object.assign(t,e)};var xi=(e,t="stdin")=>{let{options:i,fileDescriptors:n}=Ie.get(e),s=Dp(n,t,!0),o=e.stdio[s];if(o===null)throw new TypeError(Lp(s,t,i,!0));return o},Dt=(e,t="stdout")=>{let{options:i,fileDescriptors:n}=Ie.get(e),s=Dp(n,t,!1),o=s==="all"?e.all:e.stdio[s];if(o==null)throw new TypeError(Lp(s,t,i,!1));return o},Ie=new WeakMap,Dp=(e,t,r)=>{let i=Wg(t,r);return Hg(i,t,r,e),i},Wg=(e,t)=>{let r=as(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(`"${cr(t)}" must not be "${e}".
120
119
  It must be ${i} or "fd3", "fd4" (and so on).
121
- It is optional and defaults to "${n}".`)},R_=(e,t,r,i)=>{let n=i[Wp(e)];if(n===void 0)throw new TypeError(`"${nr(r)}" must not be ${t}. That file descriptor does not exist.
122
- Please set the "stdio" option to ensure that file descriptor exists.`);if(n.direction==="input"&&!r)throw new TypeError(`"${nr(r)}" must not be ${t}. It must be a readable stream, not writable.`);if(n.direction!=="input"&&r)throw new TypeError(`"${nr(r)}" must not be ${t}. It must be a writable stream, not readable.`)},Vp=(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}=j_(e,r);return`The "${n}: ${li(s)}" option is incompatible with using "${nr(i)}: ${li(t)}".
123
- Please set this option with "pipe" instead.`},j_=(e,{stdin:t,stdout:r,stderr:i,stdio:n})=>{let s=Wp(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]}},Wp=e=>e==="all"?1:e,nr=e=>e?"to":"from",li=e=>typeof e=="string"?`'${e}'`:typeof e=="number"?`${e}`:"Stream";import{once as U_}from"events";import{addAbortListener as D_}from"events";var lt=(e,t,r)=>{let i=e.getMaxListeners();i===0||i===Number.POSITIVE_INFINITY||(e.setMaxListeners(i+t),D_(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))};import{EventEmitter as F_}from"events";import{once as L_}from"events";import{scheduler as M_}from"timers/promises";var hi=(e,t)=>{t&&Es(e)},Es=e=>{e.refCounted()},yi=(e,t)=>{t&&Ps(e)},Ps=e=>{e.unrefCounted()},Hp=(e,t)=>{t&&(Ps(e),Ps(e))},Kp=(e,t)=>{t&&(Es(e),Es(e))};var Yp=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i},n)=>{if(Qp(n)||ed(n))return;fi.has(e)||fi.set(e,[]);let s=fi.get(e);if(s.push(n),!(s.length>1))for(;s.length>0;){await Zp(e,i,n),await M_.yield();let o=await Xp({wrappedMessage:s[0],anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i});s.shift(),i.emit("message",o),i.emit("message:done")}},Jp=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:n})=>{Ts();let s=fi.get(e);for(;s?.length>0;)await L_(i,"message:done");e.removeListener("message",n),Kp(t,r),i.connected=!1,i.emit("disconnect")},fi=new WeakMap;var Qe=(e,t,r)=>{if(gi.has(e))return gi.get(e);let i=new F_;return i.connected=!0,gi.set(e,i),B_({ipcEmitter:i,anyProcess:e,channel:t,isSubprocess:r}),i},gi=new WeakMap,B_=({ipcEmitter:e,anyProcess:t,channel:r,isSubprocess:i})=>{let n=Yp.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e});t.on("message",n),t.once("disconnect",Jp.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e,boundOnMessage:n})),Hp(r,i)},_i=e=>{let t=gi.get(e);return t===void 0?e.channel!==null:t.connected};var td=({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:n})=>{if(!n)return i;let s=Qe(e,t,r),o=wi(e,s);return{id:N_++,type:xi,message:i,hasListeners:o}},N_=0n,rd=(e,t)=>{if(!(t?.type!==xi||t.hasListeners))for(let{id:r}of e)r!==void 0&&bi[r].resolve({isDeadlock:!0,hasListeners:!1})},Xp=async({wrappedMessage:e,anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:n})=>{if(e?.type!==xi||!t.connected)return e;let{id:s,message:o}=e,a={id:s,type:nd,message:wi(t,n)};try{await ki({anyProcess:t,channel:r,isSubprocess:i,ipc:!0},a)}catch(c){n.emit("strict:error",c)}return o},Qp=e=>{if(e?.type!==nd)return!1;let{id:t,message:r}=e;return bi[t]?.resolve({isDeadlock:!1,hasListeners:r}),!0},id=async(e,t,r)=>{if(e?.type!==xi)return;let i=Ae();bi[e.id]=i;let n=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([i,G_(t,r,n)]);s&&Lp(r),o||Mp(r)}finally{n.abort(),delete bi[e.id]}},bi={},G_=async(e,t,{signal:r})=>{lt(e,1,r),await U_(e,"disconnect",{signal:r}),Fp(t)},xi="execa:ipc:request",nd="execa:ipc:response";var sd=(e,t,r)=>{sr.has(e)||sr.set(e,new Set);let i=sr.get(e),n=Ae(),s=r?t.id:void 0,o={onMessageSent:n,id:s};return i.add(o),{outgoingMessages:i,outgoingMessage:o}},od=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},Zp=async(e,t,r)=>{for(;!wi(e,t)&&sr.get(e)?.size>0;){let i=[...sr.get(e)];rd(i,r),await Promise.all(i.map(({onMessageSent:n})=>n))}},sr=new WeakMap,wi=(e,t)=>t.listenerCount("message")>z_(e),z_=e=>Ee.has(e)&&!Ne(Ee.get(e).options.buffer,"ipc")?1:0;var ki=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},n,{strict:s=!1}={})=>{let o="sendMessage";return Et({methodName:o,isSubprocess:r,ipc:i,isConnected:e.connected}),W_({anyProcess:e,channel:t,methodName:o,isSubprocess:r,message:n,strict:s})},W_=async({anyProcess:e,channel:t,methodName:r,isSubprocess:i,message:n,strict:s})=>{let o=td({anyProcess:e,channel:t,isSubprocess:i,message:n,strict:s}),a=sd(e,o,s);try{await Is({anyProcess:e,methodName:r,isSubprocess:i,wrappedMessage:o,message:n})}catch(c){throw Pt(e),c}finally{od(a)}},Is=async({anyProcess:e,methodName:t,isSubprocess:r,wrappedMessage:i,message:n})=>{let s=H_(e);try{await Promise.all([id(i,e,r),s(i)])}catch(o){throw Np({error:o,methodName:t,isSubprocess:r}),Gp({error:o,methodName:t,isSubprocess:r,message:n}),o}},H_=e=>{if(Os.has(e))return Os.get(e);let t=V_(e.send.bind(e));return Os.set(e,t),t},Os=new WeakMap;var cd=(e,t)=>{let r="cancelSignal";return As(r,!1,e.connected),Is({anyProcess:e,methodName:r,isSubprocess:!1,wrappedMessage:{type:dd,message:t},message:t})},pd=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>(await Y_({anyProcess:e,channel:t,isSubprocess:r,ipc:i}),Rs.signal),Y_=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>{if(!ad){if(ad=!0,!i){Up();return}if(t===null){Ts();return}Qe(e,t,r),await K_.yield()}},ad=!1,ed=e=>e?.type!==dd?!1:(Rs.abort(e.message),!0),dd="execa:ipc:cancel",Ts=()=>{Rs.abort(Bp())},Rs=new AbortController;var ud=({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.")}},ld=({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:i,context:n,controller:s})=>r?[J_({subprocess:e,cancelSignal:t,forceKillAfterDelay:i,context:n,controller:s})]:[],J_=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:{signal:n}})=>{await di(t,n);let s=X_(t);throw await cd(e,s),Cs({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 Q_}from"timers/promises";var md=({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})`)},hd=(e,t,r,i)=>t===0||t===void 0?[]:[Z_(e,t,r,i)],Z_=async(e,t,r,{signal:i})=>{throw await Q_(t,void 0,{signal:i}),r.terminationReason??="timeout",e.kill(),new _e};import{execPath as eb,execArgv as tb}from"process";import yd from"path";var fd=({options:e})=>{if(e.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},gd=(e,t,{node:r=!1,nodePath:i=eb,nodeOptions:n=tb.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=qt(i,'The "nodePath" option'),d=yd.resolve(s,c),p={...a,nodePath:d,node:r,cwd:s};if(!r)return[e,t,p];if(yd.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 rb}from"v8";var _d=({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`.");sb[r](e)}},ib=e=>{try{rb(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:t})}},nb=e=>{try{JSON.stringify(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:t})}},sb={advanced:ib,json:nb},bd=async(e,t)=>{t!==void 0&&await e.sendMessage(t)};var wd=({encoding:e})=>{if(js.has(e))return;let t=ab(e);if(t!==void 0)throw new TypeError(`Invalid option \`encoding: ${vi(e)}\`.
124
- Please rename it to ${vi(t)}.`);let r=[...js].map(i=>vi(i)).join(", ");throw new TypeError(`Invalid option \`encoding: ${vi(e)}\`.
125
- Please rename it to one of: ${r}.`)},ob=new Set(["utf8","utf16le"]),ce=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),js=new Set([...ob,...ce]),ab=e=>{if(e===null)return"buffer";if(typeof e!="string")return;let t=e.toLowerCase();if(t in xd)return xd[t];if(js.has(t))return t},xd={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},vi=e=>typeof e=="string"?`"${e}"`:String(e);import{statSync as cb}from"fs";import pb from"path";import db from"process";var kd=(e=vd())=>{let t=qt(e,'The "cwd" option');return pb.resolve(t)},vd=()=>{try{return db.cwd()}catch(e){throw e.message=`The current directory does not exist.
126
- ${e.message}`,e}},qd=(e,t)=>{if(t===vd())return e;let r;try{r=cb(t)}catch(i){return`The "cwd" option is invalid: ${t}.
120
+ It is optional and defaults to "${n}".`)},Hg=(e,t,r,i)=>{let n=i[Mp(e)];if(n===void 0)throw new TypeError(`"${cr(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(`"${cr(r)}" must not be ${t}. It must be a readable stream, not writable.`);if(n.direction!=="input"&&r)throw new TypeError(`"${cr(r)}" must not be ${t}. It must be a writable stream, not readable.`)},Lp=(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}=Kg(e,r);return`The "${n}: ${wi(s)}" option is incompatible with using "${cr(i)}: ${wi(t)}".
122
+ Please set this option with "pipe" instead.`},Kg=(e,{stdin:t,stdout:r,stderr:i,stdio:n})=>{let s=Mp(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]}},Mp=e=>e==="all"?1:e,cr=e=>e?"to":"from",wi=e=>typeof e=="string"?`'${e}'`:typeof e=="number"?`${e}`:"Stream";import{once as e_}from"events";import{addAbortListener as Yg}from"events";var yt=(e,t,r)=>{let i=e.getMaxListeners();i===0||i===Number.POSITIVE_INFINITY||(e.setMaxListeners(i+t),Yg(r,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))};import{EventEmitter as Zg}from"events";import{once as Jg}from"events";import{scheduler as Xg}from"timers/promises";var ki=(e,t)=>{t&&qs(e)},qs=e=>{e.refCounted()},vi=(e,t)=>{t&&$s(e)},$s=e=>{e.unrefCounted()},Fp=(e,t)=>{t&&($s(e),$s(e))},Bp=(e,t)=>{t&&(qs(e),qs(e))};var Up=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i},n)=>{if(zp(n)||Wp(n))return;Si.has(e)||Si.set(e,[]);let s=Si.get(e);if(s.push(n),!(s.length>1))for(;s.length>0;){await Vp(e,i,n),await Xg.yield();let o=await Gp({wrappedMessage:s[0],anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i});s.shift(),i.emit("message",o),i.emit("message:done")}},Np=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:n})=>{As();let s=Si.get(e);for(;s?.length>0;)await Jg(i,"message:done");e.removeListener("message",n),Bp(t,r),i.connected=!1,i.emit("disconnect")},Si=new WeakMap;var nt=(e,t,r)=>{if(qi.has(e))return qi.get(e);let i=new Zg;return i.connected=!0,qi.set(e,i),Qg({ipcEmitter:i,anyProcess:e,channel:t,isSubprocess:r}),i},qi=new WeakMap,Qg=({ipcEmitter:e,anyProcess:t,channel:r,isSubprocess:i})=>{let n=Up.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e});t.on("message",n),t.once("disconnect",Np.bind(void 0,{anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:e,boundOnMessage:n})),Fp(r,i)},$i=e=>{let t=qi.get(e);return t===void 0?e.channel!==null:t.connected};var Hp=({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:n})=>{if(!n)return i;let s=nt(e,t,r),o=Ei(e,s);return{id:t_++,type:Ci,message:i,hasListeners:o}},t_=0n,Kp=(e,t)=>{if(!(t?.type!==Ci||t.hasListeners))for(let{id:r}of e)r!==void 0&&Ai[r].resolve({isDeadlock:!0,hasListeners:!1})},Gp=async({wrappedMessage:e,anyProcess:t,channel:r,isSubprocess:i,ipcEmitter:n})=>{if(e?.type!==Ci||!t.connected)return e;let{id:s,message:o}=e,a={id:s,type:Jp,message:Ei(t,n)};try{await Pi({anyProcess:t,channel:r,isSubprocess:i,ipc:!0},a)}catch(c){n.emit("strict:error",c)}return o},zp=e=>{if(e?.type!==Jp)return!1;let{id:t,message:r}=e;return Ai[t]?.resolve({isDeadlock:!1,hasListeners:r}),!0},Yp=async(e,t,r)=>{if(e?.type!==Ci)return;let i=Te();Ai[e.id]=i;let n=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([i,r_(t,r,n)]);s&&Ep(r),o||Pp(r)}finally{n.abort(),delete Ai[e.id]}},Ai={},r_=async(e,t,{signal:r})=>{yt(e,1,r),await e_(e,"disconnect",{signal:r}),Tp(t)},Ci="execa:ipc:request",Jp="execa:ipc:response";var Xp=(e,t,r)=>{pr.has(e)||pr.set(e,new Set);let i=pr.get(e),n=Te(),s=r?t.id:void 0,o={onMessageSent:n,id:s};return i.add(o),{outgoingMessages:i,outgoingMessage:o}},Zp=({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()},Vp=async(e,t,r)=>{for(;!Ei(e,t)&&pr.get(e)?.size>0;){let i=[...pr.get(e)];Kp(i,r),await Promise.all(i.map(({onMessageSent:n})=>n))}},pr=new WeakMap,Ei=(e,t)=>t.listenerCount("message")>i_(e),i_=e=>Ie.has(e)&&!He(Ie.get(e).options.buffer,"ipc")?1:0;var Pi=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},n,{strict:s=!1}={})=>{let o="sendMessage";return Ot({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=Hp({anyProcess:e,channel:t,isSubprocess:i,message:n,strict:s}),a=Xp(e,o,s);try{await Es({anyProcess:e,methodName:r,isSubprocess:i,wrappedMessage:o,message:n})}catch(c){throw jt(e),c}finally{Zp(a)}},Es=async({anyProcess:e,methodName:t,isSubprocess:r,wrappedMessage:i,message:n})=>{let s=o_(e);try{await Promise.all([Yp(i,e,r),s(i)])}catch(o){throw Op({error:o,methodName:t,isSubprocess:r}),jp({error:o,methodName:t,isSubprocess:r,message:n}),o}},o_=e=>{if(Cs.has(e))return Cs.get(e);let t=n_(e.send.bind(e));return Cs.set(e,t),t},Cs=new WeakMap;var ed=(e,t)=>{let r="cancelSignal";return Ss(r,!1,e.connected),Es({anyProcess:e,methodName:r,isSubprocess:!1,wrappedMessage:{type:rd,message:t},message:t})},td=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>(await c_({anyProcess:e,channel:t,isSubprocess:r,ipc:i}),Ps.signal),c_=async({anyProcess:e,channel:t,isSubprocess:r,ipc:i})=>{if(!Qp){if(Qp=!0,!i){Rp();return}if(t===null){As();return}nt(e,t,r),await a_.yield()}},Qp=!1,Wp=e=>e?.type!==rd?!1:(Ps.abort(e.message),!0),rd="execa:ipc:cancel",As=()=>{Ps.abort(Ip())},Ps=new AbortController;var id=({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.")}},nd=({subprocess:e,cancelSignal:t,gracefulCancel:r,forceKillAfterDelay:i,context:n,controller:s})=>r?[p_({subprocess:e,cancelSignal:t,forceKillAfterDelay:i,context:n,controller:s})]:[],p_=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:{signal:n}})=>{await _i(t,n);let s=d_(t);throw await ed(e,s),vs({kill:e.kill,forceKillAfterDelay:r,context:i,controllerSignal:n}),i.terminationReason??="gracefulCancel",t.reason},d_=({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 u_}from"timers/promises";var sd=({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})`)},od=(e,t,r,i)=>t===0||t===void 0?[]:[l_(e,t,r,i)],l_=async(e,t,r,{signal:i})=>{throw await u_(t,void 0,{signal:i}),r.terminationReason??="timeout",e.kill(),new ve};import{execPath as m_,execArgv as h_}from"process";import ad from"path";var cd=({options:e})=>{if(e.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}},pd=(e,t,{node:r=!1,nodePath:i=m_,nodeOptions:n=h_.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=Et(i,'The "nodePath" option'),d=ad.resolve(s,c),p={...a,nodePath:d,node:r,cwd:s};if(!r)return[e,t,p];if(ad.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 y_}from"v8";var dd=({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`.");__[r](e)}},f_=e=>{try{y_(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:t})}},g_=e=>{try{JSON.stringify(e)}catch(t){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:t})}},__={advanced:f_,json:g_},ud=async(e,t)=>{t!==void 0&&await e.sendMessage(t)};var md=({encoding:e})=>{if(Ts.has(e))return;let t=w_(e);if(t!==void 0)throw new TypeError(`Invalid option \`encoding: ${Ti(e)}\`.
123
+ Please rename it to ${Ti(t)}.`);let r=[...Ts].map(i=>Ti(i)).join(", ");throw new TypeError(`Invalid option \`encoding: ${Ti(e)}\`.
124
+ Please rename it to one of: ${r}.`)},b_=new Set(["utf8","utf16le"]),ye=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),Ts=new Set([...b_,...ye]),w_=e=>{if(e===null)return"buffer";if(typeof e!="string")return;let t=e.toLowerCase();if(t in ld)return ld[t];if(Ts.has(t))return t},ld={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},Ti=e=>typeof e=="string"?`"${e}"`:String(e);import{statSync as x_}from"fs";import k_ from"path";import v_ from"process";var hd=(e=yd())=>{let t=Et(e,'The "cwd" option');return k_.resolve(t)},yd=()=>{try{return v_.cwd()}catch(e){throw e.message=`The current directory does not exist.
125
+ ${e.message}`,e}},fd=(e,t)=>{if(t===yd())return e;let r;try{r=x_(t)}catch(i){return`The "cwd" option is invalid: ${t}.
127
126
  ${i.message}
128
127
  ${e}`}return r.isDirectory()?e:`The "cwd" option is not a directory: ${t}.
129
- ${e}`};var qi=(e,t,r)=>{r.cwd=kd(r.cwd);let[i,n,s]=gd(e,t,r),{command:o,args:a,options:c}=$d.default._parse(i,n,s),d=uc(c),p=lb(d);return md(p),wd(p),_d(p),Rp(p),ud(p),p.shell=as(p.shell),p.env=mb(p),p.killSignal=Ep(p.killSignal),p.forceKillAfterDelay=Op(p.forceKillAfterDelay),p.lines=p.lines.map((u,l)=>u&&!ce.has(p.encoding)&&p.buffer[l]),Sd.platform==="win32"&&ub.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:p}},lb=({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}),mb=({env:e,extendEnv:t,preferLocal:r,node:i,localDirectory:n,nodePath:s})=>{let o=t?{...Sd.env,...e}:e;return r||i?_p({env:o,cwd:n,execPath:s,preferLocal:r,addExecPath:i}):o};var Si=(e,t,r)=>r.shell&&t.length>0?[[e,...t].join(" "),[],r]:[e,t,r];import{inspect as Hb}from"util";function Ot(e){if(typeof e=="string")return hb(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return yb(e)}var hb=e=>e.at(-1)===Cd?e.slice(0,e.at(-2)===Ad?-2:-1):e,yb=e=>e.at(-1)===fb?e.subarray(0,e.at(-2)===gb?-2:-1):e,Cd=`
130
- `,fb=Cd.codePointAt(0),Ad="\r",gb=Ad.codePointAt(0);import{on as Gb}from"events";import{finished as zb}from"stream/promises";function xe(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 Ds(e,{checkOpen:t=!0}={}){return xe(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 mt(e,{checkOpen:t=!0}={}){return xe(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 Ls(e,t){return Ds(e,t)&&mt(e,t)}var _b=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Ms=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}}},Fs=Symbol();function Ed(){return this[Fs].next()}Object.defineProperty(Ed,"name",{value:"next"});function Pd(e){return this[Fs].return(e)}Object.defineProperty(Pd,"name",{value:"return"});var bb=Object.create(_b,{next:{enumerable:!0,configurable:!0,writable:!0,value:Ed},return:{enumerable:!0,configurable:!0,writable:!0,value:Pd}});function Bs({preventCancel:e=!1}={}){let t=this.getReader(),r=new Ms(t,e),i=Object.create(bb);return i[Fs]=r,i}var Td=e=>{if(mt(e,{checkOpen:!1})&&or.on!==void 0)return wb(e);if(typeof e?.[Symbol.asyncIterator]=="function")return e;if(xb.call(e)==="[object ReadableStream]")return Bs.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:xb}=Object.prototype,wb=async function*(e){let t=new AbortController,r={};kb(e,t,r);try{for await(let[i]of or.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()}},kb=async(e,t,r)=>{try{await or.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(i){r.error=i}finally{t.abort()}},or={};var It=async(e,{init:t,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{let d=Td(e),p=t();p.length=0;try{for await(let u of d){let l=qb(u),m=r[l](u,p);Rd({convertedChunk:m,state:p,getSize:i,truncateChunk:n,addChunk:s,maxBuffer:c})}return vb({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}},vb=({state:e,getSize:t,truncateChunk:r,addChunk:i,getFinalChunk:n,maxBuffer:s})=>{let o=n(e);o!==void 0&&Rd({convertedChunk:o,state:e,getSize:t,truncateChunk:r,addChunk:i,maxBuffer:s})},Rd=({convertedChunk:e,state:t,getSize:r,truncateChunk:i,addChunk:n,maxBuffer:s})=>{let o=r(e),a=t.length+o;if(a<=s){Od(e,t,n,a);return}let c=i(e,s-t.length);throw c!==void 0&&Od(c,t,n,s),new Pe},Od=(e,t,r,i)=>{t.contents=r(e,t,i),t.length=i},qb=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=Id.call(e);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Id.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Id}=Object.prototype,Pe=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Ge=e=>e,ar=()=>{},$i=({contents:e})=>e,Ci=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Ai=e=>e.length;async function Ei(e,t){return It(e,Ab,t)}var Sb=()=>({contents:[]}),$b=()=>1,Cb=(e,{contents:t})=>(t.push(e),t),Ab={init:Sb,convertChunk:{string:Ge,buffer:Ge,arrayBuffer:Ge,dataView:Ge,typedArray:Ge,others:Ge},getSize:$b,truncateChunk:ar,addChunk:Cb,getFinalChunk:ar,finalize:$i};async function Pi(e,t){return It(e,Lb,t)}var Eb=()=>({contents:new ArrayBuffer(0)}),Pb=e=>Tb.encode(e),Tb=new TextEncoder,jd=e=>new Uint8Array(e),Dd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ob=(e,t)=>e.slice(0,t),Ib=(e,{contents:t,length:r},i)=>{let n=Fd()?jb(t,i):Rb(t,i);return new Uint8Array(n).set(e,r),n},Rb=(e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(Md(t));return new Uint8Array(r).set(new Uint8Array(e),0),r},jb=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:Md(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r},Md=e=>Ld**Math.ceil(Math.log(e)/Math.log(Ld)),Ld=2,Db=({contents:e,length:t})=>Fd()?e:e.slice(0,t),Fd=()=>"resize"in ArrayBuffer.prototype,Lb={init:Eb,convertChunk:{string:Pb,buffer:jd,arrayBuffer:jd,dataView:Dd,typedArray:Dd,others:Ci},getSize:Ai,truncateChunk:Ob,addChunk:Ib,getFinalChunk:ar,finalize:Db};async function Oi(e,t){return It(e,Nb,t)}var Mb=()=>({contents:"",textDecoder:new TextDecoder}),Ti=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),Fb=(e,{contents:t})=>t+e,Bb=(e,t)=>e.slice(0,t),Ub=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},Nb={init:Mb,convertChunk:{string:Ge,buffer:Ti,arrayBuffer:Ti,dataView:Ti,typedArray:Ti,others:Ci},getSize:Ai,truncateChunk:Bb,addChunk:Fb,getFinalChunk:Ub,finalize:$i};Object.assign(or,{on:Gb,finished:zb});var Bd=({error:e,stream:t,readableObjectMode:r,lines:i,encoding:n,fdNumber:s})=>{if(!(e instanceof Pe))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",Ud=(e,t,r)=>{if(t.length!==r)return;let i=new Pe;throw i.maxBufferInfo={fdNumber:"ipc"},i},Nd=(e,t)=>{let{streamName:r,threshold:i,unit:n}=Wb(e,t);return`Command's ${r} was larger than ${i} ${n}`},Wb=(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=Ne(t,r);return r==="ipc"?{streamName:"IPC output",threshold:n,unit:"messages"}:{streamName:Yr(r),threshold:n,unit:i}},Gd=(e,t,r)=>e?.code==="ENOBUFS"&&t!==null&&t.some(i=>i!==null&&i.length>Ii(r)),zd=(e,t,r)=>{if(!t)return e;let i=Ii(r);return e.length>i?e.slice(0,i):e},Ii=([,e])=>e;var Wd=({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:_})=>{let q=i?.code,A=Kb({originalError:i,timedOut:c,timeout:x,isMaxBuffer:u,maxBuffer:f,errorCode:q,signal:n,signalDescription:s,exitCode:o,isCanceled:d,isGracefullyCanceled:p,isForcefullyTerminated:l,forceKillAfterDelay:m,killSignal:h}),P=Jb(i,_),w=P===void 0?"":`
131
- ${P}`,L=`${A}: ${a}${w}`,O=t===void 0?[e[2],e[1]]:[t],R=[L,...O,...e.slice(3),r.map(U=>Xb(U)).join(`
132
- `)].map(U=>er(Ot(Qb(U)))).filter(Boolean).join(`
133
-
134
- `);return{originalMessage:P,shortMessage:L,message:R}},Kb=({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=Yb(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?`${Nd(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"},Yb=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",Jb=(e,t)=>{if(e instanceof _e)return;let r=wp(e)?e.originalMessage:String(e?.message??e),i=er(qd(r,t));return i===""?void 0:i},Xb=e=>typeof e=="string"?e:Hb(e),Qb=e=>Array.isArray(e)?e.map(t=>Ot(Vd(t))).filter(Boolean).join(`
135
- `):Vd(e),Vd=e=>typeof e=="string"?e:J(e)?Hr(e):"";var Ri=({command:e,escapedCommand:t,stdio:r,all:i,ipcOutput:n,options:{cwd:s},startTime:o})=>Hd({command:e,escapedCommand:t,cwd:s,durationMs:ys(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:[]}),Rt=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:o})=>cr({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}),cr=({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:_,cwd:q,maxBuffer:A},isSync:P})=>{let{exitCode:w,signal:L,signalDescription:O}=ex(d,p),{originalMessage:R,shortMessage:U,message:z}=Wd({stdio:u,all:l,ipcOutput:m,originalError:e,signal:L,signalDescription:O,exitCode:w,escapedCommand:r,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,forceKillAfterDelay:x,killSignal:_,maxBuffer:A,timeout:f,cwd:q}),v=bp(e,z,P);return Object.assign(v,Zb({error:v,command:t,escapedCommand:r,startTime:i,timedOut:n,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:c,exitCode:w,signal:L,signalDescription:O,stdio:u,all:l,ipcOutput:m,cwd:q,originalMessage:R,shortMessage:U})),v},Zb=({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:_})=>Hd({shortMessage:_,originalMessage:x,command:t,escapedCommand:r,cwd:f,durationMs:ys(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:[]}),Hd=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),ex=(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 Kd=e=>Number.isFinite(e)?e:0;function tx(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(Kd(e*1e3)%1e3),nanoseconds:Math.trunc(Kd(e*1e6)%1e3)}}function rx(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 Us(e){switch(typeof e){case"number":{if(Number.isFinite(e))return tx(e);break}case"bigint":return rx(e)}throw new TypeError("Expected a finite number or bigint")}var ix=e=>e===0||e===0n,nx=(e,t)=>t===1||t===1n?e:`${e}s`,sx=1e-7,ox=24n*60n*60n*1000n;function Ns(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+sx);return(Math.round(l)/10**u).toFixed(u)},o=(p,u,l,m)=>{if(!((n.length===0||!t.colonNotation)&&ix(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?" "+nx(u,p):l;n.push(m)}},a=Us(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),_=f?h.toFixed(f):x;o(Number.parseFloat(_),"millisecond","ms",_)}}else{let p=(r?Number(e%ox):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 Yd=(e,t)=>{e.failed&&Ce({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var Jd=(e,t)=>{St(t)&&(Yd(e,t),ax(e,t))},ax=(e,t)=>{let r=`(done in ${Ns(e.durationMs)})`;Ce({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var jt=(e,t,{reject:r})=>{if(Jd(e,t),e.failed&&r)throw e;return e};import{readFileSync as vu}from"fs";var Zd=(e,t)=>ht(e)?"asyncGenerator":ru(e)?"generator":ji(e)?"fileUrl":lx(e)?"filePath":yx(e)?"webStream":xe(e,{checkOpen:!1})?"native":J(e)?"uint8Array":fx(e)?"asyncIterable":gx(e)?"iterable":Vs(e)?eu({transform:e},t):ux(e)?cx(e,t):"native",cx=(e,t)=>Ls(e.transform,{checkOpen:!1})?px(e,t):Vs(e.transform)?eu(e,t):dx(e,t),px=(e,t)=>(tu(e,t,"Duplex stream"),"duplex"),eu=(e,t)=>(tu(e,t,"web TransformStream"),"webTransform"),tu=({final:e,binary:t,objectMode:r},i,n)=>{Xd(e,`${i}.final`,n),Xd(t,`${i}.binary`,n),Gs(r,`${i}.objectMode`)},Xd=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},dx=({transform:e,final:t,binary:r,objectMode:i},n)=>{if(e!==void 0&&!Qd(e))throw new TypeError(`The \`${n}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(Ls(t,{checkOpen:!1}))throw new TypeError(`The \`${n}.final\` option must not be a Duplex stream.`);if(Vs(t))throw new TypeError(`The \`${n}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!Qd(t))throw new TypeError(`The \`${n}.final\` option must be a generator.`);return Gs(r,`${n}.binary`),Gs(i,`${n}.objectMode`),ht(e)||ht(t)?"asyncGenerator":"generator"},Gs=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},Qd=e=>ht(e)||ru(e),ht=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",ru=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",ux=e=>V(e)&&(e.transform!==void 0||e.final!==void 0),ji=e=>Object.prototype.toString.call(e)==="[object URL]",iu=e=>ji(e)&&e.protocol!=="file:",lx=e=>V(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>mx.has(t))&&zs(e.file),mx=new Set(["file","append"]),zs=e=>typeof e=="string",nu=(e,t)=>e==="native"&&typeof t=="string"&&!hx.has(t),hx=new Set(["ipc","ignore","inherit","overlapped","pipe"]),su=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",Di=e=>Object.prototype.toString.call(e)==="[object WritableStream]",yx=e=>su(e)||Di(e),Vs=e=>su(e?.readable)&&Di(e?.writable),fx=e=>ou(e)&&typeof e[Symbol.asyncIterator]=="function",gx=e=>ou(e)&&typeof e[Symbol.iterator]=="function",ou=e=>typeof e=="object"&&e!==null,ye=new Set(["generator","asyncGenerator","duplex","webTransform"]),Li=new Set(["fileUrl","filePath","fileNumber"]),Ws=new Set(["fileUrl","filePath"]),au=new Set([...Ws,"webStream","nodeStream"]),cu=new Set(["webTransform","duplex"]),Ze={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 Hs=(e,t,r,i)=>i==="output"?_x(e,t,r):bx(e,t,r),_x=(e,t,r)=>{let i=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:i,readableObjectMode:e??i}},bx=(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}},pu=(e,t)=>{let r=e.findLast(({type:i})=>ye.has(i));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var du=(e,t,r,i)=>[...e.filter(({type:n})=>!ye.has(n)),...xx(e,t,r,i)],xx=(e,t,r,{encoding:i})=>{let n=e.filter(({type:o})=>ye.has(o)),s=Array.from({length:n.length});for(let[o,a]of Object.entries(n))s[o]=wx({stdioItem:a,index:Number(o),newTransforms:s,optionName:t,direction:r,encoding:i});return Sx(s,r)},wx=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:i,optionName:n,direction:s,encoding:o})=>t==="duplex"?kx({stdioItem:e,optionName:n}):t==="webTransform"?vx({stdioItem:e,index:r,newTransforms:i,direction:s}):qx({stdioItem:e,index:r,newTransforms:i,direction:s,encoding:o}),kx=({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}}},vx=({stdioItem:e,stdioItem:{value:t},index:r,newTransforms:i,direction:n})=>{let{transform:s,objectMode:o}=V(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:c}=Hs(o,r,i,n);return{...e,value:{transform:s,writableObjectMode:a,readableObjectMode:c}}},qx=({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}=V(t)?t:{transform:t},u=c||ce.has(s),{writableObjectMode:l,readableObjectMode:m}=Hs(p,r,i,n);return{...e,value:{transform:o,final:a,binary:u,preserveNewlines:d,writableObjectMode:l,readableObjectMode:m}}},Sx=(e,t)=>t==="input"?e.reverse():e;import Ks from"process";var uu=(e,t,r)=>{let i=e.map(n=>$x(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)??Ex},$x=({type:e,value:t},r)=>Cx[r]??lu[e](t),Cx=["input","output","output"],Dt=()=>{},Ys=()=>"input",lu={generator:Dt,asyncGenerator:Dt,fileUrl:Dt,filePath:Dt,iterable:Ys,asyncIterable:Ys,uint8Array:Ys,webStream:e=>Di(e)?"output":"input",nodeStream(e){return mt(e,{checkOpen:!1})?Ds(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:Dt,duplex:Dt,native(e){let t=Ax(e);if(t!==void 0)return t;if(xe(e,{checkOpen:!1}))return lu.nodeStream(e)}},Ax=e=>{if([0,Ks.stdin].includes(e))return"input";if([1,2,Ks.stdout,Ks.stderr].includes(e))return"output"},Ex="output";var mu=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var hu=({stdio:e,ipc:t,buffer:r,...i},n,s)=>{let o=Px(e,i).map((a,c)=>yu(a,c));return s?Ox(o,r,n):mu(o,t)},Px=(e,t)=>{if(e===void 0)return he.map(i=>t[i]);if(Tx(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${he.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,he.length);return Array.from({length:r},(i,n)=>e[n])},Tx=e=>he.some(t=>e[t]!==void 0),yu=(e,t)=>Array.isArray(e)?e.map(r=>yu(r,t)):e??(t>=he.length?"ignore":"pipe"),Ox=(e,t,r)=>e.map((i,n)=>!t[n]&&n!==0&&!$t(r,n)&&Ix(i)?"ignore":i),Ix=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as Rx}from"fs";import jx from"tty";var gu=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:i,direction:n,isSync:s})=>!r||t!=="native"?e:s?Dx({stdioItem:e,fdNumber:i,direction:n}):Fx({stdioItem:e,fdNumber:i}),Dx=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i,direction:n})=>{let s=Lx({value:t,optionName:r,fdNumber:i,direction:n});if(s!==void 0)return s;if(xe(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},Lx=({value:e,optionName:t,fdNumber:r,direction:i})=>{let n=Mx(e,r);if(n!==void 0){if(i==="output")return{type:"fileNumber",value:n,optionName:t};if(jx.isatty(n))throw new TypeError(`The \`${t}: ${li(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Ue(Rx(n)),optionName:t}}},Mx=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=Kr.indexOf(e);if(r!==-1)return r},Fx=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i})=>t==="inherit"?{type:"nodeStream",value:fu(i,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:fu(t,t,r),optionName:r}:xe(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,fu=(e,t,r)=>{let i=Kr[e];if(i===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return i};var _u=({input:e,inputFile:t},r)=>r===0?[...Bx(e),...Nx(t)]:[],Bx=e=>e===void 0?[]:[{type:Ux(e),value:e,optionName:"input"}],Ux=e=>{if(mt(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(J(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},Nx=e=>e===void 0?[]:[{...Gx(e),optionName:"inputFile"}],Gx=e=>{if(ji(e))return{type:"fileUrl",value:e};if(zs(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var bu=e=>e.filter((t,r)=>e.every((i,n)=>t.value!==i.value||r>=n||t.type==="generator"||t.type==="asyncGenerator")),xu=({stdioItem:{type:e,value:t,optionName:r},direction:i,fileDescriptors:n,isSync:s})=>{let o=zx(n,e);if(o.length!==0){if(s){Vx({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});return}if(au.has(e))return wu({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});cu.has(e)&&Hx({otherStdioItems:o,type:e,value:t,optionName:r})}},zx=(e,t)=>e.flatMap(({direction:r,stdioItems:i})=>i.filter(n=>n.type===t).map((n=>({...n,direction:r})))),Vx=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{Ws.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=>Wx(a,r));if(s.length===0)return;let o=s.find(a=>a.direction!==n);return ku(o,i,t),n==="output"?s[0].stream:void 0},Wx=({type:e,value:t},r)=>e==="filePath"?t.file===r.file:e==="fileUrl"?t.href===r.href:t===r,Hx=({otherStdioItems:e,type:t,value:r,optionName:i})=>{let n=e.find(({value:{transform:s}})=>s===r.transform);ku(n,i,t)},ku=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${Ze[r]} that is the same.`)};var Mi=(e,t,r,i)=>{let s=hu(t,r,i).map((a,c)=>Kx({stdioOption:a,fdNumber:c,options:t,isSync:i})),o=rw({initialFileDescriptors:s,addProperties:e,options:t,isSync:i});return t.stdio=o.map(({stdioItems:a})=>sw(a)),o},Kx=({stdioOption:e,fdNumber:t,options:r,isSync:i})=>{let n=Yr(t),{stdioItems:s,isStdioArray:o}=Yx({stdioOption:e,fdNumber:t,options:r,optionName:n}),a=uu(s,t,n),c=s.map(u=>gu({stdioItem:u,isStdioArray:o,fdNumber:t,direction:a,isSync:i})),d=du(c,n,a,r),p=pu(d,a);return tw(d,p),{direction:a,objectMode:p,stdioItems:d}},Yx=({stdioOption:e,fdNumber:t,options:r,optionName:i})=>{let s=[...(Array.isArray(e)?e:[e]).map(c=>Jx(c,i)),..._u(r,t)],o=bu(s),a=o.length>1;return Xx(o,a,i),Zx(o),{stdioItems:o,isStdioArray:a}},Jx=(e,t)=>({type:Zd(e,t),value:e,optionName:t}),Xx=(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(Qx.has(i))throw new Error(`The \`${n}\` option must not include \`${i}\`.`)}},Qx=new Set(["ignore","ipc"]),Zx=e=>{for(let t of e)ew(t)},ew=({type:e,value:t,optionName:r})=>{if(iu(t))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
136
- For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(nu(e,t))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},tw=(e,t)=>{if(!t)return;let r=e.find(({type:i})=>Li.has(i));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},rw=({initialFileDescriptors:e,addProperties:t,options:r,isSync:i})=>{let n=[];try{for(let s of e)n.push(iw({fileDescriptor:s,fileDescriptors:n,addProperties:t,options:r,isSync:i}));return n}catch(s){throw Js(n),s}},iw=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:i,addProperties:n,options:s,isSync:o})=>{let a=r.map(c=>nw({stdioItem:c,addProperties:n,direction:e,options:s,fileDescriptors:i,isSync:o}));return{direction:e,objectMode:t,stdioItems:a}},nw=({stdioItem:e,addProperties:t,direction:r,options:i,fileDescriptors:n,isSync:s})=>{let o=xu({stdioItem:e,direction:r,fileDescriptors:n,isSync:s});return o!==void 0?{...e,stream:o}:{...e,...t[r][e.type](e,i)}},Js=e=>{for(let{stdioItems:t}of e)for(let{stream:r}of t)r!==void 0&&!ge(r)&&r.destroy()},sw=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)=>Mi(aw,e,t,!0),Te=({type:e,optionName:t})=>{$u(t,Ze[e])},ow=({optionName:e,value:t})=>((t==="ipc"||t==="overlapped")&&$u(e,`"${t}"`),{}),$u=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},qu={generator(){},asyncGenerator:Te,webStream:Te,nodeStream:Te,webTransform:Te,duplex:Te,asyncIterable:Te,native:ow},aw={input:{...qu,fileUrl:({value:e})=>({contents:[Ue(vu(e))]}),filePath:({value:{file:e}})=>({contents:[Ue(vu(e))]}),fileNumber:Te,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...qu,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:Te,string:Te,uint8Array:Te}};var ze=(e,{stripFinalNewline:t},r)=>Xs(t,r)&&e!==void 0&&!Array.isArray(e)?Ot(e):e,Xs=(e,t)=>t==="all"?e[1]||e[2]:e[t];import{Transform as Aw,getDefaultHighWaterMark as Lu}from"stream";var Fi=(e,t,r,i)=>e||r?void 0:Au(t,i),Zs=(e,t,r)=>r?e.flatMap(i=>Cu(i,t)):Cu(e,t),Cu=(e,t)=>{let{transform:r,final:i}=Au(t,{});return[...r(e),...i()]},Au=(e,t)=>(t.previousChunks="",{transform:cw.bind(void 0,t,e),final:dw.bind(void 0,t)}),cw=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]===`
137
- `){let o=pw(r,s,t,e),a=r.slice(n+1,s+1-o);i.length>0&&(a=Qs(i,a),i=""),yield a,n=s}n!==r.length-1&&(i=Qs(i,r.slice(n+1))),e.previousChunks=i},pw=(e,t,r,i)=>r?0:(i.isWindowsNewline=t!==0&&e[t-1]==="\r",i.isWindowsNewline?2:1),dw=function*({previousChunks:e}){e.length>0&&(yield e)},Eu=({binary:e,preserveNewlines:t,readableObjectMode:r,state:i})=>e||t||r?void 0:{transform:uw.bind(void 0,i)},uw=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:i,LF:n,concatBytes:s}=typeof t=="string"?lw:hw;if(t.at(-1)===n){yield t;return}yield s(t,e?i:r)},Qs=(e,t)=>`${e}${t}`,lw={windowsNewline:`\r
128
+ ${e}`};var Ii=(e,t,r)=>{r.cwd=hd(r.cwd);let[i,n,s]=pd(e,t,r),{command:o,args:a,options:c}=_d.default._parse(i,n,s),d=ic(c),p=q_(d);return sd(p),md(p),dd(p),$p(p),id(p),p.shell=is(p.shell),p.env=$_(p),p.killSignal=xp(p.killSignal),p.forceKillAfterDelay=Sp(p.forceKillAfterDelay),p.lines=p.lines.map((u,l)=>u&&!ye.has(p.encoding)&&p.buffer[l]),gd.platform==="win32"&&S_.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:p}},q_=({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}),$_=({env:e,extendEnv:t,preferLocal:r,node:i,localDirectory:n,nodePath:s})=>{let o=t?{...gd.env,...e}:e;return r||i?dp({env:o,cwd:n,execPath:s,preferLocal:r,addExecPath:i}):o};var Ri=(e,t,r)=>r.shell&&t.length>0?[[e,...t].join(" "),[],r]:[e,t,r];import{inspect as ob}from"util";function Lt(e){if(typeof e=="string")return A_(e);if(!(ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return C_(e)}var A_=e=>e.at(-1)===bd?e.slice(0,e.at(-2)===wd?-2:-1):e,C_=e=>e.at(-1)===E_?e.subarray(0,e.at(-2)===P_?-2:-1):e,bd=`
129
+ `,E_=bd.codePointAt(0),wd="\r",P_=wd.codePointAt(0);import{on as rb}from"events";import{finished as ib}from"stream/promises";function qe(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 Is(e,{checkOpen:t=!0}={}){return qe(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 ft(e,{checkOpen:t=!0}={}){return qe(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 Rs(e,t){return Is(e,t)&&ft(e,t)}var T_=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Os=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}}},js=Symbol();function xd(){return this[js].next()}Object.defineProperty(xd,"name",{value:"next"});function kd(e){return this[js].return(e)}Object.defineProperty(kd,"name",{value:"return"});var I_=Object.create(T_,{next:{enumerable:!0,configurable:!0,writable:!0,value:xd},return:{enumerable:!0,configurable:!0,writable:!0,value:kd}});function Ds({preventCancel:e=!1}={}){let t=this.getReader(),r=new Os(t,e),i=Object.create(I_);return i[js]=r,i}var vd=e=>{if(ft(e,{checkOpen:!1})&&dr.on!==void 0)return O_(e);if(typeof e?.[Symbol.asyncIterator]=="function")return e;if(R_.call(e)==="[object ReadableStream]")return Ds.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:R_}=Object.prototype,O_=async function*(e){let t=new AbortController,r={};j_(e,t,r);try{for await(let[i]of dr.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()}},j_=async(e,t,r)=>{try{await dr.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(i){r.error=i}finally{t.abort()}},dr={};var Mt=async(e,{init:t,convertChunk:r,getSize:i,truncateChunk:n,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{let d=vd(e),p=t();p.length=0;try{for await(let u of d){let l=L_(u),m=r[l](u,p);$d({convertedChunk:m,state:p,getSize:i,truncateChunk:n,addChunk:s,maxBuffer:c})}return D_({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}},D_=({state:e,getSize:t,truncateChunk:r,addChunk:i,getFinalChunk:n,maxBuffer:s})=>{let o=n(e);o!==void 0&&$d({convertedChunk:o,state:e,getSize:t,truncateChunk:r,addChunk:i,maxBuffer:s})},$d=({convertedChunk:e,state:t,getSize:r,truncateChunk:i,addChunk:n,maxBuffer:s})=>{let o=r(e),a=t.length+o;if(a<=s){Sd(e,t,n,a);return}let c=i(e,s-t.length);throw c!==void 0&&Sd(c,t,n,s),new Re},Sd=(e,t,r,i)=>{t.contents=r(e,t,i),t.length=i},L_=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=qd.call(e);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&qd.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:qd}=Object.prototype,Re=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Ke=e=>e,ur=()=>{},Oi=({contents:e})=>e,ji=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Di=e=>e.length;async function Li(e,t){return Mt(e,U_,t)}var M_=()=>({contents:[]}),F_=()=>1,B_=(e,{contents:t})=>(t.push(e),t),U_={init:M_,convertChunk:{string:Ke,buffer:Ke,arrayBuffer:Ke,dataView:Ke,typedArray:Ke,others:Ke},getSize:F_,truncateChunk:ur,addChunk:B_,getFinalChunk:ur,finalize:Oi};async function Mi(e,t){return Mt(e,J_,t)}var N_=()=>({contents:new ArrayBuffer(0)}),G_=e=>z_.encode(e),z_=new TextEncoder,Ad=e=>new Uint8Array(e),Cd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),V_=(e,t)=>e.slice(0,t),W_=(e,{contents:t,length:r},i)=>{let n=Td()?K_(t,i):H_(t,i);return new Uint8Array(n).set(e,r),n},H_=(e,t)=>{if(t<=e.byteLength)return e;let r=new ArrayBuffer(Pd(t));return new Uint8Array(r).set(new Uint8Array(e),0),r},K_=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;let r=new ArrayBuffer(t,{maxByteLength:Pd(t)});return new Uint8Array(r).set(new Uint8Array(e),0),r},Pd=e=>Ed**Math.ceil(Math.log(e)/Math.log(Ed)),Ed=2,Y_=({contents:e,length:t})=>Td()?e:e.slice(0,t),Td=()=>"resize"in ArrayBuffer.prototype,J_={init:N_,convertChunk:{string:G_,buffer:Ad,arrayBuffer:Ad,dataView:Cd,typedArray:Cd,others:ji},getSize:Di,truncateChunk:V_,addChunk:W_,getFinalChunk:ur,finalize:Y_};async function Bi(e,t){return Mt(e,tb,t)}var X_=()=>({contents:"",textDecoder:new TextDecoder}),Fi=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),Z_=(e,{contents:t})=>t+e,Q_=(e,t)=>e.slice(0,t),eb=({textDecoder:e})=>{let t=e.decode();return t===""?void 0:t},tb={init:X_,convertChunk:{string:Ke,buffer:Fi,arrayBuffer:Fi,dataView:Fi,typedArray:Fi,others:ji},getSize:Di,truncateChunk:Q_,addChunk:Z_,getFinalChunk:eb,finalize:Oi};Object.assign(dr,{on:rb,finished:ib});var Id=({error:e,stream:t,readableObjectMode:r,lines:i,encoding:n,fdNumber:s})=>{if(!(e instanceof Re))throw e;if(s==="all")return e;let o=nb(r,i,n);throw e.maxBufferInfo={fdNumber:s,unit:o},t.destroy(),e},nb=(e,t,r)=>e?"objects":t?"lines":r==="buffer"?"bytes":"characters",Rd=(e,t,r)=>{if(t.length!==r)return;let i=new Re;throw i.maxBufferInfo={fdNumber:"ipc"},i},Od=(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=He(t,r);return r==="ipc"?{streamName:"IPC output",threshold:n,unit:"messages"}:{streamName:ii(r),threshold:n,unit:i}},jd=(e,t,r)=>e?.code==="ENOBUFS"&&t!==null&&t.some(i=>i!==null&&i.length>Ui(r)),Dd=(e,t,r)=>{if(!t)return e;let i=Ui(r);return e.length>i?e.slice(0,i):e},Ui=([,e])=>e;var Md=({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=ab({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}),I=pb(i,w),v=I===void 0?"":`
130
+ ${I}`,B=`${g}: ${a}${v}`,j=t===void 0?[e[2],e[1]]:[t],L=[B,...j,...e.slice(3),r.map(G=>db(G)).join(`
131
+ `)].map(G=>nr(Lt(ub(G)))).filter(Boolean).join(`
132
+
133
+ `);return{originalMessage:I,shortMessage:B,message:L}},ab=({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=cb(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?`${Od(e,n)}${h}`:s!==void 0?`Command failed with ${s}${h}`:u?`Command was killed with ${m} (${gi(m)})${h}`:o!==void 0?`Command was killed with ${o} (${a})`:c!==void 0?`Command failed with exit code ${c}`:"Command failed"},cb=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",pb=(e,t)=>{if(e instanceof ve)return;let r=mp(e)?e.originalMessage:String(e?.message??e),i=nr(fd(r,t));return i===""?void 0:i},db=e=>typeof e=="string"?e:ob(e),ub=e=>Array.isArray(e)?e.map(t=>Lt(Ld(t))).filter(Boolean).join(`
134
+ `):Ld(e),Ld=e=>typeof e=="string"?e:Z(e)?ti(e):"";var Ni=({command:e,escapedCommand:t,stdio:r,all:i,ipcOutput:n,options:{cwd:s},startTime:o})=>Fd({command:e,escapedCommand:t,cwd:s,durationMs:us(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:[]}),Ft=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:o})=>lr({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}),lr=({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:I})=>{let{exitCode:v,signal:B,signalDescription:j}=mb(d,p),{originalMessage:L,shortMessage:G,message:H}=Md({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}),$=up(e,H,I);return Object.assign($,lb({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})),$},lb=({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})=>Fd({shortMessage:w,originalMessage:x,command:t,escapedCommand:r,cwd:f,durationMs:us(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:[]}),Fd=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),mb=(e,t)=>{let r=e===null?void 0:e,i=t===null?void 0:t,n=i===void 0?void 0:gi(t);return{exitCode:r,signal:i,signalDescription:n}};var Bd=e=>Number.isFinite(e)?e:0;function hb(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(Bd(e*1e3)%1e3),nanoseconds:Math.trunc(Bd(e*1e6)%1e3)}}function yb(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 Ls(e){switch(typeof e){case"number":{if(Number.isFinite(e))return hb(e);break}case"bigint":return yb(e)}throw new TypeError("Expected a finite number or bigint")}var fb=e=>e===0||e===0n,gb=(e,t)=>t===1||t===1n?e:`${e}s`,_b=1e-7,bb=24n*60n*60n*1000n;function Ms(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+_b);return(Math.round(l)/10**u).toFixed(u)},o=(p,u,l,m)=>{if(!((n.length===0||!t.colonNotation)&&fb(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?" "+gb(u,p):l;n.push(m)}},a=Ls(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%bb):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 Ud=(e,t)=>{e.failed&&Pe({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})};var Nd=(e,t)=>{Pt(t)&&(Ud(e,t),wb(e,t))},wb=(e,t)=>{let r=`(done in ${Ms(e.durationMs)})`;Pe({type:"duration",verboseMessage:r,verboseInfo:t,result:e})};var Bt=(e,t,{reject:r})=>{if(Nd(e,t),e.failed&&r)throw e;return e};import{readFileSync as yu}from"fs";var Vd=(e,t)=>gt(e)?"asyncGenerator":Kd(e)?"generator":Gi(e)?"fileUrl":qb(e)?"filePath":Cb(e)?"webStream":qe(e,{checkOpen:!1})?"native":Z(e)?"uint8Array":Eb(e)?"asyncIterable":Pb(e)?"iterable":Us(e)?Wd({transform:e},t):Sb(e)?xb(e,t):"native",xb=(e,t)=>Rs(e.transform,{checkOpen:!1})?kb(e,t):Us(e.transform)?Wd(e,t):vb(e,t),kb=(e,t)=>(Hd(e,t,"Duplex stream"),"duplex"),Wd=(e,t)=>(Hd(e,t,"web TransformStream"),"webTransform"),Hd=({final:e,binary:t,objectMode:r},i,n)=>{Gd(e,`${i}.final`,n),Gd(t,`${i}.binary`,n),Fs(r,`${i}.objectMode`)},Gd=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${r}.`)},vb=({transform:e,final:t,binary:r,objectMode:i},n)=>{if(e!==void 0&&!zd(e))throw new TypeError(`The \`${n}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(Rs(t,{checkOpen:!1}))throw new TypeError(`The \`${n}.final\` option must not be a Duplex stream.`);if(Us(t))throw new TypeError(`The \`${n}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!zd(t))throw new TypeError(`The \`${n}.final\` option must be a generator.`);return Fs(r,`${n}.binary`),Fs(i,`${n}.objectMode`),gt(e)||gt(t)?"asyncGenerator":"generator"},Fs=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new TypeError(`The \`${t}\` option must use a boolean.`)},zd=e=>gt(e)||Kd(e),gt=e=>Object.prototype.toString.call(e)==="[object AsyncGeneratorFunction]",Kd=e=>Object.prototype.toString.call(e)==="[object GeneratorFunction]",Sb=e=>K(e)&&(e.transform!==void 0||e.final!==void 0),Gi=e=>Object.prototype.toString.call(e)==="[object URL]",Yd=e=>Gi(e)&&e.protocol!=="file:",qb=e=>K(e)&&Object.keys(e).length>0&&Object.keys(e).every(t=>$b.has(t))&&Bs(e.file),$b=new Set(["file","append"]),Bs=e=>typeof e=="string",Jd=(e,t)=>e==="native"&&typeof t=="string"&&!Ab.has(t),Ab=new Set(["ipc","ignore","inherit","overlapped","pipe"]),Xd=e=>Object.prototype.toString.call(e)==="[object ReadableStream]",zi=e=>Object.prototype.toString.call(e)==="[object WritableStream]",Cb=e=>Xd(e)||zi(e),Us=e=>Xd(e?.readable)&&zi(e?.writable),Eb=e=>Zd(e)&&typeof e[Symbol.asyncIterator]=="function",Pb=e=>Zd(e)&&typeof e[Symbol.iterator]=="function",Zd=e=>typeof e=="object"&&e!==null,we=new Set(["generator","asyncGenerator","duplex","webTransform"]),Vi=new Set(["fileUrl","filePath","fileNumber"]),Ns=new Set(["fileUrl","filePath"]),Qd=new Set([...Ns,"webStream","nodeStream"]),eu=new Set(["webTransform","duplex"]),st={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 Gs=(e,t,r,i)=>i==="output"?Tb(e,t,r):Ib(e,t,r),Tb=(e,t,r)=>{let i=t!==0&&r[t-1].value.readableObjectMode;return{writableObjectMode:i,readableObjectMode:e??i}},Ib=(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}},tu=(e,t)=>{let r=e.findLast(({type:i})=>we.has(i));return r===void 0?!1:t==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var ru=(e,t,r,i)=>[...e.filter(({type:n})=>!we.has(n)),...Rb(e,t,r,i)],Rb=(e,t,r,{encoding:i})=>{let n=e.filter(({type:o})=>we.has(o)),s=Array.from({length:n.length});for(let[o,a]of Object.entries(n))s[o]=Ob({stdioItem:a,index:Number(o),newTransforms:s,optionName:t,direction:r,encoding:i});return Mb(s,r)},Ob=({stdioItem:e,stdioItem:{type:t},index:r,newTransforms:i,optionName:n,direction:s,encoding:o})=>t==="duplex"?jb({stdioItem:e,optionName:n}):t==="webTransform"?Db({stdioItem:e,index:r,newTransforms:i,direction:s}):Lb({stdioItem:e,index:r,newTransforms:i,direction:s,encoding:o}),jb=({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}}},Db=({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}=Gs(o,r,i,n);return{...e,value:{transform:s,writableObjectMode:a,readableObjectMode:c}}},Lb=({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}=Gs(p,r,i,n);return{...e,value:{transform:o,final:a,binary:u,preserveNewlines:d,writableObjectMode:l,readableObjectMode:m}}},Mb=(e,t)=>t==="input"?e.reverse():e;import zs from"process";var iu=(e,t,r)=>{let i=e.map(n=>Fb(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)??Nb},Fb=({type:e,value:t},r)=>Bb[r]??nu[e](t),Bb=["input","output","output"],Ut=()=>{},Vs=()=>"input",nu={generator:Ut,asyncGenerator:Ut,fileUrl:Ut,filePath:Ut,iterable:Vs,asyncIterable:Vs,uint8Array:Vs,webStream:e=>zi(e)?"output":"input",nodeStream(e){return ft(e,{checkOpen:!1})?Is(e,{checkOpen:!1})?void 0:"input":"output"},webTransform:Ut,duplex:Ut,native(e){let t=Ub(e);if(t!==void 0)return t;if(qe(e,{checkOpen:!1}))return nu.nodeStream(e)}},Ub=e=>{if([0,zs.stdin].includes(e))return"input";if([1,2,zs.stdout,zs.stderr].includes(e))return"output"},Nb="output";var su=(e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e;var ou=({stdio:e,ipc:t,buffer:r,...i},n,s)=>{let o=Gb(e,i).map((a,c)=>au(a,c));return s?Vb(o,r,n):su(o,t)},Gb=(e,t)=>{if(e===void 0)return be.map(i=>t[i]);if(zb(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${be.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,be.length);return Array.from({length:r},(i,n)=>e[n])},zb=e=>be.some(t=>e[t]!==void 0),au=(e,t)=>Array.isArray(e)?e.map(r=>au(r,t)):e??(t>=be.length?"ignore":"pipe"),Vb=(e,t,r)=>e.map((i,n)=>!t[n]&&n!==0&&!Tt(r,n)&&Wb(i)?"ignore":i),Wb=e=>e==="pipe"||Array.isArray(e)&&e.every(t=>t==="pipe");import{readFileSync as Hb}from"fs";import Kb from"tty";var pu=({stdioItem:e,stdioItem:{type:t},isStdioArray:r,fdNumber:i,direction:n,isSync:s})=>!r||t!=="native"?e:s?Yb({stdioItem:e,fdNumber:i,direction:n}):Zb({stdioItem:e,fdNumber:i}),Yb=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i,direction:n})=>{let s=Jb({value:t,optionName:r,fdNumber:i,direction:n});if(s!==void 0)return s;if(qe(t,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},Jb=({value:e,optionName:t,fdNumber:r,direction:i})=>{let n=Xb(e,r);if(n!==void 0){if(i==="output")return{type:"fileNumber",value:n,optionName:t};if(Kb.isatty(n))throw new TypeError(`The \`${t}: ${wi(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:We(Hb(n)),optionName:t}}},Xb=(e,t)=>{if(e==="inherit")return t;if(typeof e=="number")return e;let r=ri.indexOf(e);if(r!==-1)return r},Zb=({stdioItem:e,stdioItem:{value:t,optionName:r},fdNumber:i})=>t==="inherit"?{type:"nodeStream",value:cu(i,t,r),optionName:r}:typeof t=="number"?{type:"nodeStream",value:cu(t,t,r),optionName:r}:qe(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:r}:e,cu=(e,t,r)=>{let i=ri[e];if(i===void 0)throw new TypeError(`The \`${r}: ${t}\` option is invalid: no such standard stream.`);return i};var du=({input:e,inputFile:t},r)=>r===0?[...Qb(e),...tw(t)]:[],Qb=e=>e===void 0?[]:[{type:ew(e),value:e,optionName:"input"}],ew=e=>{if(ft(e,{checkOpen:!1}))return"nodeStream";if(typeof e=="string")return"string";if(Z(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},tw=e=>e===void 0?[]:[{...rw(e),optionName:"inputFile"}],rw=e=>{if(Gi(e))return{type:"fileUrl",value:e};if(Bs(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var uu=e=>e.filter((t,r)=>e.every((i,n)=>t.value!==i.value||r>=n||t.type==="generator"||t.type==="asyncGenerator")),lu=({stdioItem:{type:e,value:t,optionName:r},direction:i,fileDescriptors:n,isSync:s})=>{let o=iw(n,e);if(o.length!==0){if(s){nw({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});return}if(Qd.has(e))return mu({otherStdioItems:o,type:e,value:t,optionName:r,direction:i});eu.has(e)&&ow({otherStdioItems:o,type:e,value:t,optionName:r})}},iw=(e,t)=>e.flatMap(({direction:r,stdioItems:i})=>i.filter(n=>n.type===t).map((n=>({...n,direction:r})))),nw=({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})=>{Ns.has(t)&&mu({otherStdioItems:e,type:t,value:r,optionName:i,direction:n})},mu=({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 hu(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,ow=({otherStdioItems:e,type:t,value:r,optionName:i})=>{let n=e.find(({value:{transform:s}})=>s===r.transform);hu(n,i,t)},hu=(e,t,r)=>{if(e!==void 0)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${st[r]} that is the same.`)};var Wi=(e,t,r,i)=>{let s=ou(t,r,i).map((a,c)=>aw({stdioOption:a,fdNumber:c,options:t,isSync:i})),o=yw({initialFileDescriptors:s,addProperties:e,options:t,isSync:i});return t.stdio=o.map(({stdioItems:a})=>_w(a)),o},aw=({stdioOption:e,fdNumber:t,options:r,isSync:i})=>{let n=ii(t),{stdioItems:s,isStdioArray:o}=cw({stdioOption:e,fdNumber:t,options:r,optionName:n}),a=iu(s,t,n),c=s.map(u=>pu({stdioItem:u,isStdioArray:o,fdNumber:t,direction:a,isSync:i})),d=ru(c,n,a,r),p=tu(d,a);return hw(d,p),{direction:a,objectMode:p,stdioItems:d}},cw=({stdioOption:e,fdNumber:t,options:r,optionName:i})=>{let s=[...(Array.isArray(e)?e:[e]).map(c=>pw(c,i)),...du(r,t)],o=uu(s),a=o.length>1;return dw(o,a,i),lw(o),{stdioItems:o,isStdioArray:a}},pw=(e,t)=>({type:Vd(e,t),value:e,optionName:t}),dw=(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(uw.has(i))throw new Error(`The \`${n}\` option must not include \`${i}\`.`)}},uw=new Set(["ignore","ipc"]),lw=e=>{for(let t of e)mw(t)},mw=({type:e,value:t,optionName:r})=>{if(Yd(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(Jd(e,t))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},hw=(e,t)=>{if(!t)return;let r=e.find(({type:i})=>Vi.has(i));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},yw=({initialFileDescriptors:e,addProperties:t,options:r,isSync:i})=>{let n=[];try{for(let s of e)n.push(fw({fileDescriptor:s,fileDescriptors:n,addProperties:t,options:r,isSync:i}));return n}catch(s){throw Ws(n),s}},fw=({fileDescriptor:{direction:e,objectMode:t,stdioItems:r},fileDescriptors:i,addProperties:n,options:s,isSync:o})=>{let a=r.map(c=>gw({stdioItem:c,addProperties:n,direction:e,options:s,fileDescriptors:i,isSync:o}));return{direction:e,objectMode:t,stdioItems:a}},gw=({stdioItem:e,addProperties:t,direction:r,options:i,fileDescriptors:n,isSync:s})=>{let o=lu({stdioItem:e,direction:r,fileDescriptors:n,isSync:s});return o!==void 0?{...e,stream:o}:{...e,...t[r][e.type](e,i)}},Ws=e=>{for(let{stdioItems:t}of e)for(let{stream:r}of t)r!==void 0&&!ke(r)&&r.destroy()},_w=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 gu=(e,t)=>Wi(ww,e,t,!0),Oe=({type:e,optionName:t})=>{_u(t,st[e])},bw=({optionName:e,value:t})=>((t==="ipc"||t==="overlapped")&&_u(e,`"${t}"`),{}),_u=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},fu={generator(){},asyncGenerator:Oe,webStream:Oe,nodeStream:Oe,webTransform:Oe,duplex:Oe,asyncIterable:Oe,native:bw},ww={input:{...fu,fileUrl:({value:e})=>({contents:[We(yu(e))]}),filePath:({value:{file:e}})=>({contents:[We(yu(e))]}),fileNumber:Oe,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...fu,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:Oe,string:Oe,uint8Array:Oe}};var Ye=(e,{stripFinalNewline:t},r)=>Hs(t,r)&&e!==void 0&&!Array.isArray(e)?Lt(e):e,Hs=(e,t)=>t==="all"?e[1]||e[2]:e[t];import{Transform as Uw,getDefaultHighWaterMark as Eu}from"stream";var Hi=(e,t,r,i)=>e||r?void 0:wu(t,i),Ys=(e,t,r)=>r?e.flatMap(i=>bu(i,t)):bu(e,t),bu=(e,t)=>{let{transform:r,final:i}=wu(t,{});return[...r(e),...i()]},wu=(e,t)=>(t.previousChunks="",{transform:xw.bind(void 0,t,e),final:vw.bind(void 0,t)}),xw=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=kw(r,s,t,e),a=r.slice(n+1,s+1-o);i.length>0&&(a=Ks(i,a),i=""),yield a,n=s}n!==r.length-1&&(i=Ks(i,r.slice(n+1))),e.previousChunks=i},kw=(e,t,r,i)=>r?0:(i.isWindowsNewline=t!==0&&e[t-1]==="\r",i.isWindowsNewline?2:1),vw=function*({previousChunks:e}){e.length>0&&(yield e)},xu=({binary:e,preserveNewlines:t,readableObjectMode:r,state:i})=>e||t||r?void 0:{transform:Sw.bind(void 0,i)},Sw=function*({isWindowsNewline:e=!1},t){let{unixNewline:r,windowsNewline:i,LF:n,concatBytes:s}=typeof t=="string"?qw:Aw;if(t.at(-1)===n){yield t;return}yield s(t,e?i:r)},Ks=(e,t)=>`${e}${t}`,qw={windowsNewline:`\r
138
137
  `,unixNewline:`
139
138
  `,LF:`
140
- `,concatBytes:Qs},mw=(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},hw={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:mw};import{Buffer as yw}from"buffer";var Pu=(e,t)=>e?void 0:fw.bind(void 0,t),fw=function*(e,t){if(typeof t!="string"&&!J(t)&&!yw.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},Tu=(e,t)=>e?gw.bind(void 0,t):_w.bind(void 0,t),gw=function*(e,t){Ou(e,t),yield t},_w=function*(e,t){if(Ou(e,t),typeof t!="string"&&!J(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},Ou=(e,t)=>{if(t==null)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
139
+ `,concatBytes:Ks},$w=(e,t)=>{let r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},Aw={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:$w};import{Buffer as Cw}from"buffer";var ku=(e,t)=>e?void 0:Ew.bind(void 0,t),Ew=function*(e,t){if(typeof t!="string"&&!Z(t)&&!Cw.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},vu=(e,t)=>e?Pw.bind(void 0,t):Tw.bind(void 0,t),Pw=function*(e,t){Su(e,t),yield t},Tw=function*(e,t){if(Su(e,t),typeof t!="string"&&!Z(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},Su=(e,t)=>{if(t==null)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.
141
140
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
142
- if (condition) { yield value; }`)};import{Buffer as bw}from"buffer";import{StringDecoder as xw}from"string_decoder";var Bi=(e,t,r)=>{if(r)return;if(e)return{transform:ww.bind(void 0,new TextEncoder)};let i=new xw(t);return{transform:kw.bind(void 0,i),final:vw.bind(void 0,i)}},ww=function*(e,t){bw.isBuffer(t)?yield Ue(t):typeof t=="string"?yield e.encode(t):yield t},kw=function*(e,t){yield J(t)?e.write(t):t},vw=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as Iu}from"util";var eo=Iu(async(e,t,r,i)=>{t.currentIterable=e(...r);try{for await(let n of t.currentIterable)i.push(n)}finally{delete t.currentIterable}}),Ui=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Sw}=t[r];for await(let n of i(e))yield*Ui(n,t,r+1)},Ru=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*qw(r,Number(t),e)},qw=async function*(e,t,r){if(e!==void 0)for await(let i of e())yield*Ui(i,r,t+1)},ju=Iu(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Sw=function*(e){yield e};var to=(e,t,r,i)=>{try{for(let n of e(...t))r.push(n);i()}catch(n){i(n)}},Du=(e,t)=>[...t.flatMap(r=>[...yt(r,e,0)]),...pr(e)],yt=function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Cw}=t[r];for(let n of i(e))yield*yt(n,t,r+1)},pr=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*$w(r,Number(t),e)},$w=function*(e,t,r){if(e!==void 0)for(let i of e())yield*yt(i,r,t+1)},Cw=function*(e){yield e};var ro=({value:e,value:{transform:t,final:r,writableObjectMode:i,readableObjectMode:n},optionName:s},{encoding:o})=>{let a={},c=Mu(e,o,s),d=ht(t),p=ht(r),u=d?eo.bind(void 0,Ui,a):to.bind(void 0,yt),l=d||p?eo.bind(void 0,Ru,a):to.bind(void 0,pr),m=d||p?ju.bind(void 0,a):void 0;return{stream:new Aw({writableObjectMode:i,writableHighWaterMark:Lu(i),readableObjectMode:n,readableHighWaterMark:Lu(n),transform(f,x,_){u([f,c,0],this,_)},flush(f){l([c],this,f)},destroy:m})}},Ni=(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=Mu(o,r,a);e=Du(c,e)}return e},Mu=({transform:e,final:t,binary:r,writableObjectMode:i,readableObjectMode:n,preserveNewlines:s},o,a)=>{let c={};return[{transform:Pu(i,a)},Bi(r,o,i),Fi(r,s,i,c),{transform:e,final:t},{transform:Tu(n,a)},Eu({binary:r,preserveNewlines:s,readableObjectMode:n,state:c})].filter(Boolean)};var Fu=(e,t)=>{for(let r of Ew(e))Pw(e,r,t)},Ew=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),Pw=(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 ${Ze[a]} with synchronous methods.`)}let o=n.map(({contents:a})=>a).map(a=>Tw(a,i));r.input=Zt(o)},Tw=(e,t)=>{let r=Ni(e,t,"utf8",!0);return Ow(r),Zt(r)},Ow=e=>{let t=e.find(r=>typeof r!="string"&&!J(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 Dw,appendFileSync as Lw}from"fs";var Gi=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:i})=>i!=="all"&&$t(r,i)&&!ce.has(t)&&Iw(i)&&(e.some(({type:n,value:s})=>n==="native"&&Rw.has(s))||e.every(({type:n})=>ye.has(n))),Iw=e=>e===1||e===2,Rw=new Set(["pipe","overlapped"]),Bu=async(e,t,r,i)=>{for await(let n of e)jw(t)||Nu(n,r,i)},Uu=(e,t,r)=>{for(let i of e)Nu(i,t,r)},jw=e=>e._readableState.pipes.length>0,Nu=(e,t,r)=>{let i=ti(e);Ce({type:"output",verboseMessage:i,fdNumber:t,verboseInfo:r})};var Gu=({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)=>Mw({result:c,fileDescriptors:e,fdNumber:d,state:s,outputFiles:o,isMaxBuffer:i,verboseInfo:n},r)),...s}},Mw=({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=zd(e,s,u),m=Ue(l),{stdioItems:h,objectMode:f}=t[r],x=Fw([m],h,c,i),{serializedResult:_,finalResult:q=_}=Bw({chunks:x,objectMode:f,encoding:c,lines:d,stripFinalNewline:p,fdNumber:r});Uw({serializedResult:_,fdNumber:r,state:i,verboseInfo:o,encoding:c,stdioItems:h,objectMode:f});let A=a[r]?q:void 0;try{return i.error===void 0&&Nw(_,h,n),A}catch(P){return i.error=P,A}},Fw=(e,t,r,i)=>{try{return Ni(e,t,r,!1)}catch(n){return i.error=n,e}},Bw=({chunks:e,objectMode:t,encoding:r,lines:i,stripFinalNewline:n,fdNumber:s})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:Zt(e)};let o=nc(e,r);return i[s]?{serializedResult:o,finalResult:Zs(o,!n[s],t)}:{serializedResult:o}},Uw=({serializedResult:e,fdNumber:t,state:r,verboseInfo:i,encoding:n,stdioItems:s,objectMode:o})=>{if(!Gi({stdioItems:s,encoding:n,verboseInfo:i,fdNumber:t}))return;let a=Zs(e,!1,o);try{Uu(a,t,i)}catch(c){r.error??=c}},Nw=(e,t,r)=>{for(let{path:i,append:n}of t.filter(({type:s})=>Li.has(s))){let s=typeof i=="string"?i:i.toString();n||r.has(s)?Lw(i,e):(r.add(s),Dw(i,e))}};var zu=([,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]:J(e)&&J(t)?cs([e,t]):`${e}${t}`};import{once as io}from"events";var Vu=async(e,t)=>{let[r,i]=await Gw(e);return t.isForcefullyTerminated??=!1,[r,i]},Gw=async e=>{let[t,r]=await Promise.allSettled([io(e,"spawn"),io(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?Wu(e):r.value},Wu=async e=>{try{return await io(e,"exit")}catch{return Wu(e)}},Hu=async e=>{let[t,r]=await e;if(!zw(t,r)&&no(t,r))throw new _e;return[t,r]},zw=(e,t)=>e===void 0&&t===void 0,no=(e,t)=>e!==0||t!==null;var Ku=({error:e,status:t,signal:r,output:i},{maxBuffer:n})=>{let s=Vw(e,t,r),o=s?.code==="ETIMEDOUT",a=Gd(s,i,n);return{resultError:s,exitCode:t,signal:r,timedOut:o,isMaxBuffer:a}},Vw=(e,t,r)=>e!==void 0?e:no(t,r)?new _e:void 0;var Yu=(e,t,r)=>{let{file:i,commandArguments:n,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:d,fileDescriptors:p}=Hw(e,t,r),u=Jw({file:i,commandArguments:n,options:d,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:p,startTime:a});return jt(u,c,d)},Hw=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=ii(e,t,r),a=Kw(r),{file:c,commandArguments:d,options:p}=qi(e,t,a);Yw(p);let u=Su(p,o);return{file:c,commandArguments:d,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},Kw=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Yw=({ipc:e,ipcInput:t,detached:r,cancelSignal:i})=>{t&&zi("ipcInput"),e&&zi("ipc: true"),r&&zi("detached: true"),i&&zi("cancelSignal")},zi=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Jw=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Xw({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}=Ku(c,r),{output:h,error:f=d}=Gu({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:m,verboseInfo:s}),x=h.map((q,A)=>ze(q,r,A)),_=ze(zu(h,r),r,"all");return Zw({error:f,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m,stdio:x,all:_,options:r,command:i,escapedCommand:n,startTime:a})},Xw=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:s,startTime:o})=>{try{Fu(s,r);let a=Qw(r);return Ww(...Si(e,t,a))}catch(a){return Rt({error:a,command:i,escapedCommand:n,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Qw=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:Ii(t)}),Zw=({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?Ri({command:c,escapedCommand:d,stdio:s,all:o,ipcOutput:[],options:a,startTime:p}):cr({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 Bk}from"events";import{spawn as Uk}from"child_process";import el from"process";import{once as so,on as e0}from"events";var Ju=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0,filter:s}={})=>(Et({methodName:"getOneMessage",isSubprocess:r,ipc:i,isConnected:_i(e)}),t0({anyProcess:e,channel:t,isSubprocess:r,filter:s,reference:n})),t0=async({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:n})=>{hi(t,n);let s=Qe(e,t,r),o=new AbortController;try{return await Promise.race([r0(s,i,o),i0(s,r,o),n0(s,r,o)])}catch(a){throw Pt(e),a}finally{o.abort(),yi(t,n)}},r0=async(e,t,{signal:r})=>{if(t===void 0){let[i]=await so(e,"message",{signal:r});return i}for await(let[i]of e0(e,"message",{signal:r}))if(t(i))return i},i0=async(e,t,{signal:r})=>{await so(e,"disconnect",{signal:r}),Dp(t)},n0=async(e,t,{signal:r})=>{let[i]=await so(e,"strict:error",{signal:r});throw ui(i,t)};import{once as Qu,on as s0}from"events";var Zu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0}={})=>oo({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:!r,reference:n}),oo=({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:n,reference:s})=>{Et({methodName:"getEachMessage",isSubprocess:r,ipc:i,isConnected:_i(e)}),hi(t,s);let o=Qe(e,t,r),a=new AbortController,c={};return o0(e,o,a),a0({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),c0({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:r,shouldAwait:n,controller:a,state:c,reference:s})},o0=async(e,t,r)=>{try{await Qu(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},a0=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{let[n]=await Qu(e,"strict:error",{signal:r.signal});i.error=ui(n,t),r.abort()}catch{}},c0=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:i,shouldAwait:n,controller:s,state:o,reference:a}){try{for await(let[c]of s0(r,"message",{signal:s.signal}))Xu(o),yield c}catch{Xu(o)}finally{s.abort(),yi(t,a),i||Pt(e),n&&await e}},Xu=({error:e})=>{if(e)throw e};var tl=(e,{ipc:t})=>{Object.assign(e,il(e,!1,t))},rl=()=>{let e=el,t=!0,r=el.channel!==void 0;return{...il(e,t,r),getCancelSignal:pd.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},il=(e,t,r)=>({sendMessage:ki.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:Ju.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 p0}from"child_process";import{PassThrough as d0,Readable as u0,Writable as l0,Duplex as m0}from"stream";var nl=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,verboseInfo:o})=>{Js(i);let a=new p0;h0(a,i),Object.assign(a,{readable:y0,writable:f0,duplex:g0});let c=Rt({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:!1}),d=_0(c,o,n);return{subprocess:a,promise:d}},h0=(e,t)=>{let r=dr(),i=dr(),n=dr(),s=Array.from({length:t.length-3},dr),o=dr(),a=[r,i,n,...s];Object.assign(e,{stdin:r,stdout:i,stderr:n,all:o,stdio:a})},dr=()=>{let e=new d0;return e.end(),e},y0=()=>new u0({read(){}}),f0=()=>new l0({write(){}}),g0=()=>new m0({read(){},write(){}}),_0=async(e,t,r)=>jt(e,t,r);import{createReadStream as sl,createWriteStream as ol}from"fs";import{Buffer as b0}from"buffer";import{Readable as ur,Writable as x0,Duplex as w0}from"stream";var cl=(e,t)=>Mi(k0,e,t,!1),lr=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${Ze[e]}.`)},al={fileNumber:lr,generator:ro,asyncGenerator:ro,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let i=t||r;return{stream:w0.fromWeb(e,{objectMode:i})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},k0={input:{...al,fileUrl:({value:e})=>({stream:sl(e)}),filePath:({value:{file:e}})=>({stream:sl(e)}),webStream:({value:e})=>({stream:ur.fromWeb(e)}),iterable:({value:e})=>({stream:ur.from(e)}),asyncIterable:({value:e})=>({stream:ur.from(e)}),string:({value:e})=>({stream:ur.from(e)}),uint8Array:({value:e})=>({stream:ur.from(b0.from(e))})},output:{...al,fileUrl:({value:e})=>({stream:ol(e)}),filePath:({value:{file:e,append:t}})=>({stream:ol(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:x0.fromWeb(e)}),iterable:lr,asyncIterable:lr,string:lr,uint8Array:lr}};import{on as v0,once as pl}from"events";import{PassThrough as q0,getDefaultHighWaterMark as S0}from"stream";import{finished as ll}from"stream/promises";function ft(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let n of e)co(n);let t=e.some(({readableObjectMode:n})=>n),r=$0(e,t),i=new ao({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let n of e)i.add(n);return i}var $0=(e,t)=>{if(e.length===0)return S0(t);let r=e.filter(({readableObjectMode:i})=>i===t).map(({readableHighWaterMark:i})=>i);return Math.max(...r)},ao=class extends q0{#t=new Set([]);#r=new Set([]);#e=new Set([]);#i;#s=Symbol("unpipe");#n=new WeakMap;add(t){if(co(t),this.#t.has(t))return;this.#t.add(t),this.#i??=C0(this,this.#t,this.#s);let r=P0({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(co(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)}},C0=async(e,t,r)=>{Vi(e,dl);let i=new AbortController;try{await Promise.race([A0(e,i),E0(e,t,r,i)])}finally{i.abort(),Vi(e,-dl)}},A0=async(e,{signal:t})=>{try{await ll(e,{signal:t,cleanup:!0})}catch(r){throw ml(e,r),r}},E0=async(e,t,r,{signal:i})=>{for await(let[n]of v0(e,"unpipe",{signal:i}))t.has(n)&&n.emit(r)},co=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},P0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,onFinished:s,unpipeEvent:o})=>{Vi(e,ul);let a=new AbortController;try{await Promise.race([T0(s,t,a),O0({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(),Vi(e,-ul)}r.size>0&&r.size===i.size+n.size&&(i.size===0&&n.size>0?po(e):R0(e))},T0=async(e,t,{signal:r})=>{try{await e,r.aborted||po(t)}catch(i){r.aborted||ml(t,i)}},O0=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:{signal:s}})=>{try{await ll(t,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&i.add(t)}catch(o){if(s.aborted||!r.has(t))return;hl(o)?n.add(t):yl(e,o)}},I0=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:n,controller:{signal:s}})=>{if(await pl(e,n,{signal:s}),!e.readable)return pl(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},R0=e=>{e.writable&&e.end()},ml=(e,t)=>{hl(t)?po(e):yl(e,t)},hl=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",po=e=>{(e.readable||e.writable)&&e.destroy()},yl=(e,t)=>{e.destroyed||(e.once("error",j0),e.destroy(t))},j0=()=>{},Vi=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},dl=2,ul=1;import{finished as fl}from"stream/promises";var Lt=(e,t)=>{e.pipe(t),D0(e,t),L0(e,t)},D0=async(e,t)=>{if(!(ge(e)||ge(t))){try{await fl(e,{cleanup:!0,readable:!0,writable:!1})}catch{}uo(t)}},uo=e=>{e.writable&&e.end()},L0=async(e,t)=>{if(!(ge(e)||ge(t))){try{await fl(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lo(e)}},lo=e=>{e.readable&&e.destroy()};var gl=(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})=>ye.has(c)))M0(e,a,o,n);for(let{stream:a}of s.filter(({type:c})=>!ye.has(c)))B0({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]:ft(s);Lt(o,n)}},M0=(e,t,r,i)=>{r==="output"?Lt(e.stdio[i],t):Lt(t,e.stdio[i]);let n=F0[i];n!==void 0&&(e[n]=t),e.stdio[i]=t},F0=["stdin","stdout","stderr"],B0=({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})=>{ge(e)&&lt(e,N0,t)},N0=2;import{addAbortListener as V0}from"events";var gt=[];gt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&gt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&gt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Wi=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",mo=Symbol.for("signal-exit emitter"),ho=globalThis,G0=Object.defineProperty.bind(Object),yo=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ho[mo])return ho[mo];G0(ho,mo,{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}},Hi=class{},z0=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),fo=class extends Hi{onExit(){return()=>{}}load(){}unload(){}},go=class extends Hi{#t=_o.platform==="win32"?"SIGINT":"SIGHUP";#r=new yo;#e;#i;#s;#n={};#o=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of gt)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(!Wi(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 gt)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,gt.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 Wi(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"&&Wi(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)}},_o=globalThis.process,{onExit:_l,load:OI,unload:II}=z0(Wi(_o)?new go(_o):new fo);var bl=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let n=_l(()=>{e.kill()});V0(i,()=>{n()})};var wl=({source:e,sourcePromise:t,boundOptions:r,createNested:i},...n)=>{let s=ri(),{destination:o,destinationStream:a,destinationError:c,from:d,unpipeSignal:p}=W0(r,i,n),{sourceStream:u,sourceError:l}=K0(e,d),{options:m,fileDescriptors:h}=Ee.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:l,destination:o,destinationStream:a,destinationError:c,unpipeSignal:p,fileDescriptors:h,startTime:s}},W0=(e,t,r)=>{try{let{destination:i,pipeOptions:{from:n,to:s,unpipeSignal:o}={}}=H0(e,t,...r),a=mi(i,s);return{destination:i,destinationStream:a,from:n,unpipeSignal:o}}catch(i){return{destinationError:i}}},H0=(e,t,r,...i)=>{if(Array.isArray(r))return{destination:t(xl,e)(r,...i),pipeOptions:e};if(typeof r=="string"||r instanceof URL||os(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]=Wr(r,...i);return{destination:t(xl)(n,s,o),pipeOptions:o}}if(Ee.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}`)},xl=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),K0=(e,t)=>{try{return{sourceStream:Tt(e,t)}}catch(r){return{sourceError:r}}};var vl=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i,fileDescriptors:n,sourceOptions:s,startTime:o})=>{let a=Y0({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i});if(a!==void 0)throw bo({error:a,fileDescriptors:n,sourceOptions:s,startTime:o})},Y0=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i})=>{if(t!==void 0&&i!==void 0)return i;if(i!==void 0)return lo(e),i;if(t!==void 0)return uo(r),t},bo=({error:e,fileDescriptors:t,sourceOptions:r,startTime:i})=>Rt({error:e,command:kl,escapedCommand:kl,fileDescriptors:t,options:r,startTime:i,isSync:!1}),kl="source.pipe(destination)";var ql=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 J0}from"stream/promises";var Sl=(e,t,r)=>{let i=Ki.has(t)?Q0(e,t):X0(e,t);return lt(e,ek,r.signal),lt(t,tk,r.signal),Z0(t),i},X0=(e,t)=>{let r=ft([e]);return Lt(r,t),Ki.set(t,r),r},Q0=(e,t)=>{let r=Ki.get(t);return r.add(e),r},Z0=async e=>{try{await J0(e,{cleanup:!0,readable:!1,writable:!0})}catch{}Ki.delete(e)},Ki=new WeakMap,ek=2,tk=1;import{aborted as rk}from"util";var $l=(e,t)=>e===void 0?[]:[ik(e,t)],ik=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:i,sourceOptions:n,startTime:s})=>{await rk(e,t),await r.remove(t);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw bo({error:o,fileDescriptors:i,sourceOptions:n,startTime:s})};var Yi=(e,...t)=>{if(V(t[0]))return Yi.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...i}=wl(e,...t),n=nk({...i,destination:r});return n.pipe=Yi.bind(void 0,{...e,source:r,sourcePromise:n,boundOptions:{}}),n},nk=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:i,destination:n,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:d})=>{let p=sk(e,n);vl({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([ql(p),...$l(a,{sourceStream:t,mergedStream:l,sourceOptions:r,fileDescriptors:c,startTime:d})])}finally{u.abort()}},sk=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as lk}from"timers/promises";import{on as ok}from"events";import{getDefaultHighWaterMark as ak}from"stream";var Ji=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:i,encoding:n,preserveNewlines:s})=>{let o=new AbortController;return ck(t,o),Al({stream:e,controller:o,binary:r,shouldEncode:!e.readableObjectMode&&i,encoding:n,shouldSplit:!e.readableObjectMode,preserveNewlines:s})},ck=async(e,t)=>{try{await e}catch{}finally{t.abort()}},xo=({stream:e,onStreamEnd:t,lines:r,encoding:i,stripFinalNewline:n,allMixed:s})=>{let o=new AbortController;pk(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})},pk=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=ok(e,"data",{signal:t.signal,highWaterMark:Cl,highWatermark:Cl});return dk({onStdoutChunk:a,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})},wo=ak(!0),Cl=wo,dk=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o}){let a=uk({binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of e)yield*yt(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*pr(a)}},uk=({binary:e,shouldEncode:t,encoding:r,shouldSplit:i,preserveNewlines:n})=>[Bi(e,r,!t),Fi(e,n,!i,{})].filter(Boolean);var El=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=mk({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:a,verboseInfo:d,streamInfo:p});if(!n){await Promise.all([hk(e),u]);return}let l=Xs(c,r),m=xo({stream:e,onStreamEnd:t,lines:o,encoding:i,stripFinalNewline:l,allMixed:a}),[h]=await Promise.all([yk({stream:e,iterable:m,fdNumber:r,encoding:i,maxBuffer:s,lines:o}),u]);return h},mk=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:n,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Gi({stdioItems:o[r]?.stdioItems,encoding:i,verboseInfo:s,fdNumber:r}))return;let a=xo({stream:e,onStreamEnd:t,lines:!0,encoding:i,stripFinalNewline:!0,allMixed:n});await Bu(a,e,r,s)},hk=async e=>{await lk(),e.readableFlowing===null&&e.resume()},yk=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:i,encoding:n,maxBuffer:s,lines:o})=>{try{return t||o?await Ei(r,{maxBuffer:s}):n==="buffer"?new Uint8Array(await Pi(r,{maxBuffer:s})):await Oi(r,{maxBuffer:s})}catch(a){return Pl(Bd({error:a,stream:e,readableObjectMode:t,lines:o,encoding:n,fdNumber:i}))}},ko=async e=>{try{return await e}catch(t){return Pl(t)}},Pl=({bufferedData:e})=>rc(e)?new Uint8Array(e):e;import{finished as fk}from"stream/promises";var mr=async(e,t,r,{isSameDirection:i,stopOnExit:n=!1}={})=>{let s=gk(e,r),o=new AbortController;try{await Promise.race([...n?[r.exitPromise]:[],fk(e,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||xk(a,t,r,i)}finally{o.abort()}},gk=(e,{originalStreams:[t],subprocess:r})=>{let i={stdinCleanedUp:!1};return e===t&&_k(e,r,i),i},_k=(e,t,r)=>{let{_destroy:i}=e;e._destroy=(...n)=>{bk(t,r),i.call(e,...n)}},bk=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},xk=(e,t,r,i)=>{if(!wk(e,t,r,i))throw e},wk=(e,t,r,i=!0)=>r.propagating?Tl(e)||Xi(e):(r.propagating=!0,vo(r,t)===i?Tl(e):Xi(e)),vo=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",Xi=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",Tl=e=>e?.code==="EPIPE";var Ol=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>e.stdio.map((c,d)=>qo({stream:c,fdNumber:d,encoding:t,buffer:r[d],maxBuffer:i[d],lines:n[d],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),qo=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=mr(e,t,d);if(vo(d,t)){await p;return}let[u]=await Promise.all([El({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 Il=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?ft([e,t].filter(Boolean)):void 0,Rl=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>qo({...kk(e,r),fdNumber:"all",encoding:t,maxBuffer:i[1]+i[2],lines:n[1]||n[2],allMixed:vk(e),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),kk=({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}},vk=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as qk}from"events";var jl=e=>$t(e,"ipc"),Dl=(e,t)=>{let r=ti(e);Ce({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var Ll=async({subprocess:e,buffer:t,maxBuffer:r,ipc:i,ipcOutput:n,verboseInfo:s})=>{if(!i)return n;let o=jl(s),a=Ne(t,"ipc"),c=Ne(r,"ipc");for await(let d of oo({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:i,shouldAwait:!1,reference:!0}))a&&(Ud(e,n,c),n.push(d)),o&&Dl(d,s);return n},Ml=async(e,t)=>(await Promise.allSettled([e]),t);var Fl=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:_})=>{let q=Vu(e,l),A={originalStreams:f,fileDescriptors:h,subprocess:e,exitPromise:q,propagating:!1},P=Ol({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:A}),w=Rl({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:A}),L=[],O=Ll({subprocess:e,buffer:r,maxBuffer:i,ipc:p,ipcOutput:L,verboseInfo:m}),R=Sk(f,e,A),U=$k(h,A);try{return await Promise.race([Promise.all([{},Hu(q),Promise.all(P),w,O,bd(e,u),...R,...U]),x,Ck(e,_),...hd(e,s,l,_),...jp({subprocess:e,cancelSignal:o,gracefulCancel:a,context:l,controller:_}),...ld({subprocess:e,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:l,controller:_})])}catch(z){return l.terminationReason??="other",Promise.all([{error:z},q,Promise.all(P.map(v=>ko(v))),ko(w),Ml(O,L),Promise.allSettled(R),Promise.allSettled(U)])}},Sk=(e,t,r)=>e.map((i,n)=>i===t.stdio[n]?void 0:mr(i,n,r)),$k=(e,t)=>e.flatMap(({stdioItems:r},i)=>r.filter(({value:n,stream:s=n})=>xe(s,{checkOpen:!1})&&!ge(s)).map(({type:n,value:s,stream:o=s})=>mr(o,i,t,{isSameDirection:ye.has(n),stopOnExit:n==="native"}))),Ck=async(e,{signal:t})=>{let[r]=await qk(e,"error",{signal:t});throw r};var Bl=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hr=(e,t,r)=>{let i=e[r];i.has(t)||i.set(t,[]);let n=i.get(t),s=Ae();return n.push(s),{resolve:s.resolve.bind(s),promises:n}},Mt=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 Ak}from"stream";import{callbackify as Ek}from"util";import{finished as Ul}from"stream/promises";var So=async e=>{if(e!==void 0)try{await $o(e)}catch{}},Nl=async e=>{if(e!==void 0)try{await Co(e)}catch{}},$o=async e=>{await Ul(e,{cleanup:!0,readable:!1,writable:!0})},Co=async e=>{await Ul(e,{cleanup:!0,readable:!0,writable:!1})},Qi=async(e,t)=>{if(await e,t)throw t},Zi=(e,t,r)=>{r&&!Xi(r)?e.destroy(r):t&&e.destroy()};var Gl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,binary:n=!0,preserveNewlines:s=!0}={})=>{let o=n||ce.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Ao(e,i,t),{readableEncoding:d,readableObjectMode:p,readableHighWaterMark:u}=Eo(a,o),{read:l,onStdoutDataDone:m}=Po({subprocessStdout:a,subprocess:e,binary:o,encoding:r,preserveNewlines:s}),h=new Ak({read:l,destroy:Ek(Oo.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:u,objectMode:p,encoding:d});return To({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},Ao=(e,t,r)=>{let i=Tt(e,t),n=hr(r,i,"readableDestroy");return{subprocessStdout:i,waitReadableDestroy:n}},Eo=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},i)=>i?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:wo},Po=({subprocessStdout:e,subprocess:t,binary:r,encoding:i,preserveNewlines:n})=>{let s=Ae(),o=Ji({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:i,preserveNewlines:n});return{read(){Pk(this,o,s)},onStdoutDataDone:s}},Pk=async(e,t,r)=>{try{let{value:i,done:n}=await t.next();n?r.resolve():e.push(i)}catch{}},To=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:i,subprocessStdin:n})=>{try{await Co(e),await i,await So(n),await t,r.readable&&r.push(null)}catch(s){await So(n),zl(r,s)}},Oo=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},i)=>{await Mt(r,t)&&(zl(e,i),await Qi(t,i))},zl=(e,t)=>{Zi(e,e.readable,t)};import{Writable as Tk}from"stream";import{callbackify as Vl}from"util";var Wl=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}=Io(e,r,t),o=new Tk({...Ro(i,e,n),destroy:Vl(Do.bind(void 0,{subprocessStdin:i,subprocess:e,waitWritableFinal:n,waitWritableDestroy:s})),highWaterMark:i.writableHighWaterMark,objectMode:i.writableObjectMode});return jo(i,o),o},Io=(e,t,r)=>{let i=mi(e,t),n=hr(r,i,"writableFinal"),s=hr(r,i,"writableDestroy");return{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}},Ro=(e,t,r)=>({write:Ok.bind(void 0,e),final:Vl(Ik.bind(void 0,e,t,r))}),Ok=(e,t,r,i)=>{e.write(t,r)?i():e.once("drain",i)},Ik=async(e,t,r)=>{await Mt(r,t)&&(e.writable&&e.end(),await t)},jo=async(e,t,r)=>{try{await $o(e),t.writable&&t.end()}catch(i){await Nl(r),Hl(t,i)}},Do=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:i},n)=>{await Mt(r,t),await Mt(i,t)&&(Hl(e,n),await Qi(t,n))},Hl=(e,t)=>{Zi(e,e.writable,t)};import{Duplex as Rk}from"stream";import{callbackify as jk}from"util";var Kl=({subprocess:e,concurrentStreams:t,encoding:r},{from:i,to:n,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ce.has(r),{subprocessStdout:c,waitReadableDestroy:d}=Ao(e,i,t),{subprocessStdin:p,waitWritableFinal:u,waitWritableDestroy:l}=Io(e,n,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=Eo(c,a),{read:x,onStdoutDataDone:_}=Po({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:o}),q=new Rk({read:x,...Ro(p,e,u),destroy:jk(Dk.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 To({subprocessStdout:c,onStdoutDataDone:_,readable:q,subprocess:e,subprocessStdin:p}),jo(p,q,c),q},Dk=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),Do({subprocessStdin:t,subprocess:r,waitWritableFinal:n,waitWritableDestroy:s},o)])};var Lo=(e,t,{from:r,binary:i=!1,preserveNewlines:n=!1}={})=>{let s=i||ce.has(t),o=Tt(e,r),a=Ji({subprocessStdout:o,subprocess:e,binary:s,shouldEncode:!0,encoding:t,preserveNewlines:n});return Lk(a,o,e)},Lk=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var Yl=(e,{encoding:t})=>{let r=Bl();e.readable=Gl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=Wl.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=Kl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=Lo.bind(void 0,e,t),e[Symbol.asyncIterator]=Lo.bind(void 0,e,t,{})};var Jl=(e,t)=>{for(let[r,i]of Fk){let n=i.value.bind(t);Reflect.defineProperty(e,r,{...i,value:n})}},Mk=(async()=>{})().constructor.prototype,Fk=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Mk,e)]);var Xl=(e,t,r,i)=>{let{file:n,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:d,options:p,fileDescriptors:u}=Nk(e,t,r),{subprocess:l,promise:m}=zk({file:n,commandArguments:s,options:p,startTime:c,verboseInfo:d,command:o,escapedCommand:a,fileDescriptors:u});return l.pipe=Yi.bind(void 0,{source:l,sourcePromise:m,boundOptions:{},createNested:i}),Jl(l,m),Ee.set(l,{options:p,fileDescriptors:u}),l},Nk=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=ii(e,t,r),{file:a,commandArguments:c,options:d}=qi(e,t,r),p=Gk(d),u=cl(p,o);return{file:a,commandArguments:c,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},Gk=({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}},zk=({file:e,commandArguments:t,options:r,startTime:i,verboseInfo:n,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Uk(...Si(e,t,r))}catch(h){return nl({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:i,verboseInfo:n})}let d=new AbortController;Bk(Number.POSITIVE_INFINITY,d.signal);let p=[...c.stdio];gl(c,a,d),bl(c,r,d);let u={},l=Ae();c.kill=Ip.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:l,context:u,controller:d}),c.all=Il(c,r),Yl(c,r),tl(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 Fl({subprocess:e,options:t,context:c,verboseInfo:i,fileDescriptors:n,originalStreams:s,onInternalError:d,controller:p});p.abort(),d.resolve();let _=h.map((P,w)=>ze(P,t,w)),q=ze(f,t,"all"),A=Wk({errorInfo:u,exitCode:l,signal:m,stdio:_,all:q,ipcOutput:x,context:c,options:t,command:o,escapedCommand:a,startTime:r});return jt(A,i,t)},Wk=({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?cr({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 Pe,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,options:a,startTime:p,isSync:!1}):Ri({command:c,escapedCommand:d,stdio:i,all:n,ipcOutput:s,options:a,startTime:p});var en=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,Hk(i,e[i],n)]));return{...e,...r}},Hk=(e,t,r)=>Kk.has(e)&&V(t)&&V(r)?{...t,...r}:r,Kk=new Set(["env",...ls]);var et=(e,t,r,i)=>{let n=(o,a,c)=>et(o,a,r,c),s=(...o)=>Yk({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:i,createNested:n},...o);return i!==void 0&&i(s,n,t),s},Yk=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:i,createNested:n},s,...o)=>{if(V(s))return n(e,en(r,s),i);let{file:a,commandArguments:c,options:d,isSync:p}=Jk({mapArguments:e,firstArgument:s,nextArguments:o,deepOptions:t,boundOptions:r});return p?Yu(a,c,d):Xl(a,c,d,n)},Jk=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:i,boundOptions:n})=>{let s=cc(t)?pc(t,r):[t,...r],[o,a,c]=Wr(...s),d=en(en(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 Ql=({file:e,commandArguments:t})=>em(e,t),Zl=({file:e,commandArguments:t})=>({...em(e,t),isSync:!0}),em=(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(Qk)){let n=r.at(-1);n&&n.endsWith("\\")?r[r.length-1]=`${n.slice(0,-1)} ${i}`:r.push(i)}return r},Qk=/ +/g;var tm=(e,t,r)=>{e.sync=t(Zk,r),e.s=e.sync},rm=({options:e})=>im(e),Zk=({options:e})=>({...im(e),isSync:!0}),im=e=>({options:{...ev(e),...e}}),ev=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},nm={preferLocal:!0};var pe=et(()=>({})),kD=et(()=>({isSync:!0})),tn=et(Ql),vD=et(Zl),qD=et(fd),SD=et(rm,{},nm,tm),{sendMessage:$D,getOneMessage:CD,getEachMessage:AD,getCancelSignal:ED}=rl();var sm=G(X(),1);async function H(e,t,r){return pe("docker",["compose",...e],{cwd:t,...r})}async function tt(e,t){try{await H(["up","-d","--no-deps","web"],e,{stdio:t?.stdio??"inherit"})}catch{}}async function ee(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 pe("docker",i,{cwd:t});return n.split(`
141
+ if (condition) { yield value; }`)};import{Buffer as Iw}from"buffer";import{StringDecoder as Rw}from"string_decoder";var Ki=(e,t,r)=>{if(r)return;if(e)return{transform:Ow.bind(void 0,new TextEncoder)};let i=new Rw(t);return{transform:jw.bind(void 0,i),final:Dw.bind(void 0,i)}},Ow=function*(e,t){Iw.isBuffer(t)?yield We(t):typeof t=="string"?yield e.encode(t):yield t},jw=function*(e,t){yield Z(t)?e.write(t):t},Dw=function*(e){let t=e.end();t!==""&&(yield t)};import{callbackify as qu}from"util";var Js=qu(async(e,t,r,i)=>{t.currentIterable=e(...r);try{for await(let n of t.currentIterable)i.push(n)}finally{delete t.currentIterable}}),Yi=async function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Mw}=t[r];for await(let n of i(e))yield*Yi(n,t,r+1)},$u=async function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Lw(r,Number(t),e)},Lw=async function*(e,t,r){if(e!==void 0)for await(let i of e())yield*Yi(i,r,t+1)},Au=qu(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Mw=function*(e){yield e};var Xs=(e,t,r,i)=>{try{for(let n of e(...t))r.push(n);i()}catch(n){i(n)}},Cu=(e,t)=>[...t.flatMap(r=>[..._t(r,e,0)]),...mr(e)],_t=function*(e,t,r){if(r===t.length){yield e;return}let{transform:i=Bw}=t[r];for(let n of i(e))yield*_t(n,t,r+1)},mr=function*(e){for(let[t,{final:r}]of Object.entries(e))yield*Fw(r,Number(t),e)},Fw=function*(e,t,r){if(e!==void 0)for(let i of e())yield*_t(i,r,t+1)},Bw=function*(e){yield e};var Zs=({value:e,value:{transform:t,final:r,writableObjectMode:i,readableObjectMode:n},optionName:s},{encoding:o})=>{let a={},c=Pu(e,o,s),d=gt(t),p=gt(r),u=d?Js.bind(void 0,Yi,a):Xs.bind(void 0,_t),l=d||p?Js.bind(void 0,$u,a):Xs.bind(void 0,mr),m=d||p?Au.bind(void 0,a):void 0;return{stream:new Uw({writableObjectMode:i,writableHighWaterMark:Eu(i),readableObjectMode:n,readableHighWaterMark:Eu(n),transform(f,x,w){u([f,c,0],this,w)},flush(f){l([c],this,f)},destroy:m})}},Ji=(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=Pu(o,r,a);e=Cu(c,e)}return e},Pu=({transform:e,final:t,binary:r,writableObjectMode:i,readableObjectMode:n,preserveNewlines:s},o,a)=>{let c={};return[{transform:ku(i,a)},Ki(r,o,i),Hi(r,s,i,c),{transform:e,final:t},{transform:vu(n,a)},xu({binary:r,preserveNewlines:s,readableObjectMode:n,state:c})].filter(Boolean)};var Tu=(e,t)=>{for(let r of Nw(e))Gw(e,r,t)},Nw=e=>new Set(Object.entries(e).filter(([,{direction:t}])=>t==="input").map(([t])=>Number(t))),Gw=(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 ${st[a]} with synchronous methods.`)}let o=n.map(({contents:a})=>a).map(a=>zw(a,i));r.input=ir(o)},zw=(e,t)=>{let r=Ji(e,t,"utf8",!0);return Vw(r),ir(r)},Vw=e=>{let t=e.find(r=>typeof r!="string"&&!Z(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 Yw,appendFileSync as Jw}from"fs";var Xi=({stdioItems:e,encoding:t,verboseInfo:r,fdNumber:i})=>i!=="all"&&Tt(r,i)&&!ye.has(t)&&Ww(i)&&(e.some(({type:n,value:s})=>n==="native"&&Hw.has(s))||e.every(({type:n})=>we.has(n))),Ww=e=>e===1||e===2,Hw=new Set(["pipe","overlapped"]),Iu=async(e,t,r,i)=>{for await(let n of e)Kw(t)||Ou(n,r,i)},Ru=(e,t,r)=>{for(let i of e)Ou(i,t,r)},Kw=e=>e._readableState.pipes.length>0,Ou=(e,t,r)=>{let i=pi(e);Pe({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)=>Xw({result:c,fileDescriptors:e,fdNumber:d,state:s,outputFiles:o,isMaxBuffer:i,verboseInfo:n},r)),...s}},Xw=({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=Dd(e,s,u),m=We(l),{stdioItems:h,objectMode:f}=t[r],x=Zw([m],h,c,i),{serializedResult:w,finalResult:S=w}=Qw({chunks:x,objectMode:f,encoding:c,lines:d,stripFinalNewline:p,fdNumber:r});ex({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&&tx(w,h,n),g}catch(I){return i.error=I,g}},Zw=(e,t,r,i)=>{try{return Ji(e,t,r,!1)}catch(n){return i.error=n,e}},Qw=({chunks:e,objectMode:t,encoding:r,lines:i,stripFinalNewline:n,fdNumber:s})=>{if(t)return{serializedResult:e};if(r==="buffer")return{serializedResult:ir(e)};let o=Ja(e,r);return i[s]?{serializedResult:o,finalResult:Ys(o,!n[s],t)}:{serializedResult:o}},ex=({serializedResult:e,fdNumber:t,state:r,verboseInfo:i,encoding:n,stdioItems:s,objectMode:o})=>{if(!Xi({stdioItems:s,encoding:n,verboseInfo:i,fdNumber:t}))return;let a=Ys(e,!1,o);try{Ru(a,t,i)}catch(c){r.error??=c}},tx=(e,t,r)=>{for(let{path:i,append:n}of t.filter(({type:s})=>Vi.has(s))){let s=typeof i=="string"?i:i.toString();n||r.has(s)?Jw(i,e):(r.add(s),Yw(i,e))}};var Du=([,e,t],r)=>{if(r.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Ye(t,r,"all")]:Array.isArray(t)?[Ye(e,r,"all"),...t]:Z(e)&&Z(t)?ns([e,t]):`${e}${t}`};import{once as Qs}from"events";var Lu=async(e,t)=>{let[r,i]=await rx(e);return t.isForcefullyTerminated??=!1,[r,i]},rx=async e=>{let[t,r]=await Promise.allSettled([Qs(e,"spawn"),Qs(e,"exit")]);return t.status==="rejected"?[]:r.status==="rejected"?Mu(e):r.value},Mu=async e=>{try{return await Qs(e,"exit")}catch{return Mu(e)}},Fu=async e=>{let[t,r]=await e;if(!ix(t,r)&&eo(t,r))throw new ve;return[t,r]},ix=(e,t)=>e===void 0&&t===void 0,eo=(e,t)=>e!==0||t!==null;var Bu=({error:e,status:t,signal:r,output:i},{maxBuffer:n})=>{let s=nx(e,t,r),o=s?.code==="ETIMEDOUT",a=jd(s,i,n);return{resultError:s,exitCode:t,signal:r,timedOut:o,isMaxBuffer:a}},nx=(e,t,r)=>e!==void 0?e:eo(t,r)?new ve:void 0;var Uu=(e,t,r)=>{let{file:i,commandArguments:n,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:d,fileDescriptors:p}=ox(e,t,r),u=px({file:i,commandArguments:n,options:d,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:p,startTime:a});return Bt(u,c,d)},ox=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=ui(e,t,r),a=ax(r),{file:c,commandArguments:d,options:p}=Ii(e,t,a);cx(p);let u=gu(p,o);return{file:c,commandArguments:d,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},ax=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,cx=({ipc:e,ipcInput:t,detached:r,cancelSignal:i})=>{t&&Zi("ipcInput"),e&&Zi("ipc: true"),r&&Zi("detached: true"),i&&Zi("cancelSignal")},Zi=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},px=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=dx({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}=Bu(c,r),{output:h,error:f=d}=ju({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:m,verboseInfo:s}),x=h.map((S,g)=>Ye(S,r,g)),w=Ye(Du(h,r),r,"all");return lx({error:f,exitCode:p,signal:u,timedOut:l,isMaxBuffer:m,stdio:x,all:w,options:r,command:i,escapedCommand:n,startTime:a})},dx=({file:e,commandArguments:t,options:r,command:i,escapedCommand:n,fileDescriptors:s,startTime:o})=>{try{Tu(s,r);let a=ux(r);return sx(...Ri(e,t,a))}catch(a){return Ft({error:a,command:i,escapedCommand:n,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},ux=({encoding:e,maxBuffer:t,...r})=>({...r,encoding:"buffer",maxBuffer:Ui(t)}),lx=({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?Ni({command:c,escapedCommand:d,stdio:s,all:o,ipcOutput:[],options:a,startTime:p}):lr({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 Q0}from"events";import{spawn as ek}from"child_process";import Wu from"process";import{once as to,on as mx}from"events";var Nu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0,filter:s}={})=>(Ot({methodName:"getOneMessage",isSubprocess:r,ipc:i,isConnected:$i(e)}),hx({anyProcess:e,channel:t,isSubprocess:r,filter:s,reference:n})),hx=async({anyProcess:e,channel:t,isSubprocess:r,filter:i,reference:n})=>{ki(t,n);let s=nt(e,t,r),o=new AbortController;try{return await Promise.race([yx(s,i,o),fx(s,r,o),gx(s,r,o)])}catch(a){throw jt(e),a}finally{o.abort(),vi(t,n)}},yx=async(e,t,{signal:r})=>{if(t===void 0){let[i]=await to(e,"message",{signal:r});return i}for await(let[i]of mx(e,"message",{signal:r}))if(t(i))return i},fx=async(e,t,{signal:r})=>{await to(e,"disconnect",{signal:r}),Cp(t)},gx=async(e,t,{signal:r})=>{let[i]=await to(e,"strict:error",{signal:r});throw bi(i,t)};import{once as zu,on as _x}from"events";var Vu=({anyProcess:e,channel:t,isSubprocess:r,ipc:i},{reference:n=!0}={})=>ro({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:!r,reference:n}),ro=({anyProcess:e,channel:t,isSubprocess:r,ipc:i,shouldAwait:n,reference:s})=>{Ot({methodName:"getEachMessage",isSubprocess:r,ipc:i,isConnected:$i(e)}),ki(t,s);let o=nt(e,t,r),a=new AbortController,c={};return bx(e,o,a),wx({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),xx({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:r,shouldAwait:n,controller:a,state:c,reference:s})},bx=async(e,t,r)=>{try{await zu(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},wx=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{let[n]=await zu(e,"strict:error",{signal:r.signal});i.error=bi(n,t),r.abort()}catch{}},xx=async function*({anyProcess:e,channel:t,ipcEmitter:r,isSubprocess:i,shouldAwait:n,controller:s,state:o,reference:a}){try{for await(let[c]of _x(r,"message",{signal:s.signal}))Gu(o),yield c}catch{Gu(o)}finally{s.abort(),vi(t,a),i||jt(e),n&&await e}},Gu=({error:e})=>{if(e)throw e};var Hu=(e,{ipc:t})=>{Object.assign(e,Yu(e,!1,t))},Ku=()=>{let e=Wu,t=!0,r=Wu.channel!==void 0;return{...Yu(e,t,r),getCancelSignal:td.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})}},Yu=(e,t,r)=>({sendMessage:Pi.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getOneMessage:Nu.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r}),getEachMessage:Vu.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:r})});import{ChildProcess as kx}from"child_process";import{PassThrough as vx,Readable as Sx,Writable as qx,Duplex as $x}from"stream";var Ju=({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,verboseInfo:o})=>{Ws(i);let a=new kx;Ax(a,i),Object.assign(a,{readable:Cx,writable:Ex,duplex:Px});let c=Ft({error:e,command:t,escapedCommand:r,fileDescriptors:i,options:n,startTime:s,isSync:!1}),d=Tx(c,o,n);return{subprocess:a,promise:d}},Ax=(e,t)=>{let r=hr(),i=hr(),n=hr(),s=Array.from({length:t.length-3},hr),o=hr(),a=[r,i,n,...s];Object.assign(e,{stdin:r,stdout:i,stderr:n,all:o,stdio:a})},hr=()=>{let e=new vx;return e.end(),e},Cx=()=>new Sx({read(){}}),Ex=()=>new qx({write(){}}),Px=()=>new $x({read(){},write(){}}),Tx=async(e,t,r)=>Bt(e,t,r);import{createReadStream as Xu,createWriteStream as Zu}from"fs";import{Buffer as Ix}from"buffer";import{Readable as yr,Writable as Rx,Duplex as Ox}from"stream";var el=(e,t)=>Wi(jx,e,t,!1),fr=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${st[e]}.`)},Qu={fileNumber:fr,generator:Zs,asyncGenerator:Zs,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:r}}){let i=t||r;return{stream:Ox.fromWeb(e,{objectMode:i})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},jx={input:{...Qu,fileUrl:({value:e})=>({stream:Xu(e)}),filePath:({value:{file:e}})=>({stream:Xu(e)}),webStream:({value:e})=>({stream:yr.fromWeb(e)}),iterable:({value:e})=>({stream:yr.from(e)}),asyncIterable:({value:e})=>({stream:yr.from(e)}),string:({value:e})=>({stream:yr.from(e)}),uint8Array:({value:e})=>({stream:yr.from(Ix.from(e))})},output:{...Qu,fileUrl:({value:e})=>({stream:Zu(e)}),filePath:({value:{file:e,append:t}})=>({stream:Zu(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:Rx.fromWeb(e)}),iterable:fr,asyncIterable:fr,string:fr,uint8Array:fr}};import{on as Dx,once as tl}from"events";import{PassThrough as Lx,getDefaultHighWaterMark as Mx}from"stream";import{finished as nl}from"stream/promises";function bt(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(let n of e)no(n);let t=e.some(({readableObjectMode:n})=>n),r=Fx(e,t),i=new io({objectMode:t,writableHighWaterMark:r,readableHighWaterMark:r});for(let n of e)i.add(n);return i}var Fx=(e,t)=>{if(e.length===0)return Mx(t);let r=e.filter(({readableObjectMode:i})=>i===t).map(({readableHighWaterMark:i})=>i);return Math.max(...r)},io=class extends Lx{#t=new Set([]);#r=new Set([]);#e=new Set([]);#i;#s=Symbol("unpipe");#n=new WeakMap;add(t){if(no(t),this.#t.has(t))return;this.#t.add(t),this.#i??=Bx(this,this.#t,this.#s);let r=Gx({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(no(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)}},Bx=async(e,t,r)=>{Qi(e,rl);let i=new AbortController;try{await Promise.race([Ux(e,i),Nx(e,t,r,i)])}finally{i.abort(),Qi(e,-rl)}},Ux=async(e,{signal:t})=>{try{await nl(e,{signal:t,cleanup:!0})}catch(r){throw sl(e,r),r}},Nx=async(e,t,r,{signal:i})=>{for await(let[n]of Dx(e,"unpipe",{signal:i}))t.has(n)&&n.emit(r)},no=e=>{if(typeof e?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},Gx=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,onFinished:s,unpipeEvent:o})=>{Qi(e,il);let a=new AbortController;try{await Promise.race([zx(s,t,a),Vx({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:a}),Wx({stream:t,streams:r,ended:i,aborted:n,unpipeEvent:o,controller:a})])}finally{a.abort(),Qi(e,-il)}r.size>0&&r.size===i.size+n.size&&(i.size===0&&n.size>0?so(e):Hx(e))},zx=async(e,t,{signal:r})=>{try{await e,r.aborted||so(t)}catch(i){r.aborted||sl(t,i)}},Vx=async({passThroughStream:e,stream:t,streams:r,ended:i,aborted:n,controller:{signal:s}})=>{try{await nl(t,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(t)&&i.add(t)}catch(o){if(s.aborted||!r.has(t))return;ol(o)?n.add(t):al(e,o)}},Wx=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:n,controller:{signal:s}})=>{if(await tl(e,n,{signal:s}),!e.readable)return tl(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},Hx=e=>{e.writable&&e.end()},sl=(e,t)=>{ol(t)?so(e):al(e,t)},ol=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",so=e=>{(e.readable||e.writable)&&e.destroy()},al=(e,t)=>{e.destroyed||(e.once("error",Kx),e.destroy(t))},Kx=()=>{},Qi=(e,t)=>{let r=e.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&e.setMaxListeners(r+t)},rl=2,il=1;import{finished as cl}from"stream/promises";var Nt=(e,t)=>{e.pipe(t),Yx(e,t),Jx(e,t)},Yx=async(e,t)=>{if(!(ke(e)||ke(t))){try{await cl(e,{cleanup:!0,readable:!0,writable:!1})}catch{}oo(t)}},oo=e=>{e.writable&&e.end()},Jx=async(e,t)=>{if(!(ke(e)||ke(t))){try{await cl(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ao(e)}},ao=e=>{e.readable&&e.destroy()};var pl=(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})=>we.has(c)))Xx(e,a,o,n);for(let{stream:a}of s.filter(({type:c})=>!we.has(c)))Qx({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]:bt(s);Nt(o,n)}},Xx=(e,t,r,i)=>{r==="output"?Nt(e.stdio[i],t):Nt(t,e.stdio[i]);let n=Zx[i];n!==void 0&&(e[n]=t),e.stdio[i]=t},Zx=["stdin","stdout","stderr"],Qx=({subprocess:e,stream:t,direction:r,fdNumber:i,pipeGroups:n,controller:s})=>{if(t===void 0)return;e0(t,s);let[o,a]=r==="output"?[t,e.stdio[i]]:[e.stdio[i],t],c=n.get(o)??[];n.set(o,[...c,a])},e0=(e,{signal:t})=>{ke(e)&&yt(e,t0,t)},t0=2;import{addAbortListener as n0}from"events";var wt=[];wt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var en=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",co=Symbol.for("signal-exit emitter"),po=globalThis,r0=Object.defineProperty.bind(Object),uo=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(po[co])return po[co];r0(po,co,{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}},tn=class{},i0=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),lo=class extends tn{onExit(){return()=>{}}load(){}unload(){}},mo=class extends tn{#t=ho.platform==="win32"?"SIGINT":"SIGHUP";#r=new uo;#e;#i;#s;#n={};#o=!1;constructor(t){super(),this.#e=t,this.#n={};for(let r of wt)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(!en(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 wt)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,wt.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 en(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"&&en(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)}},ho=globalThis.process,{onExit:dl,load:YR,unload:JR}=i0(en(ho)?new mo(ho):new lo);var ul=(e,{cleanup:t,detached:r},{signal:i})=>{if(!t||r)return;let n=dl(()=>{e.kill()});n0(i,()=>{n()})};var ml=({source:e,sourcePromise:t,boundOptions:r,createNested:i},...n)=>{let s=di(),{destination:o,destinationStream:a,destinationError:c,from:d,unpipeSignal:p}=s0(r,i,n),{sourceStream:u,sourceError:l}=a0(e,d),{options:m,fileDescriptors:h}=Ie.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}={}}=o0(e,t,...r),a=xi(i,s);return{destination:i,destinationStream:a,from:n,unpipeSignal:o}}catch(i){return{destinationError:i}}},o0=(e,t,r,...i)=>{if(Array.isArray(r))return{destination:t(ll,e)(r,...i),pipeOptions:e};if(typeof r=="string"||r instanceof URL||rs(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]=ei(r,...i);return{destination:t(ll)(n,s,o),pipeOptions:o}}if(Ie.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}`)},ll=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),a0=(e,t)=>{try{return{sourceStream:Dt(e,t)}}catch(r){return{sourceError:r}}};var yl=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i,fileDescriptors:n,sourceOptions:s,startTime:o})=>{let a=c0({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i});if(a!==void 0)throw yo({error:a,fileDescriptors:n,sourceOptions:s,startTime:o})},c0=({sourceStream:e,sourceError:t,destinationStream:r,destinationError:i})=>{if(t!==void 0&&i!==void 0)return i;if(i!==void 0)return ao(e),i;if(t!==void 0)return oo(r),t},yo=({error:e,fileDescriptors:t,sourceOptions:r,startTime:i})=>Ft({error:e,command:hl,escapedCommand:hl,fileDescriptors:t,options:r,startTime:i,isSync:!1}),hl="source.pipe(destination)";var fl=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 p0}from"stream/promises";var gl=(e,t,r)=>{let i=rn.has(t)?u0(e,t):d0(e,t);return yt(e,m0,r.signal),yt(t,h0,r.signal),l0(t),i},d0=(e,t)=>{let r=bt([e]);return Nt(r,t),rn.set(t,r),r},u0=(e,t)=>{let r=rn.get(t);return r.add(e),r},l0=async e=>{try{await p0(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rn.delete(e)},rn=new WeakMap,m0=2,h0=1;import{aborted as y0}from"util";var _l=(e,t)=>e===void 0?[]:[f0(e,t)],f0=async(e,{sourceStream:t,mergedStream:r,fileDescriptors:i,sourceOptions:n,startTime:s})=>{await y0(e,t),await r.remove(t);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw yo({error:o,fileDescriptors:i,sourceOptions:n,startTime:s})};var nn=(e,...t)=>{if(K(t[0]))return nn.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:r,...i}=ml(e,...t),n=g0({...i,destination:r});return n.pipe=nn.bind(void 0,{...e,source:r,sourcePromise:n,boundOptions:{}}),n},g0=async({sourcePromise:e,sourceStream:t,sourceOptions:r,sourceError:i,destination:n,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:d})=>{let p=_0(e,n);yl({sourceStream:t,sourceError:i,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:d});let u=new AbortController;try{let l=gl(t,s,u);return await Promise.race([fl(p),..._l(a,{sourceStream:t,mergedStream:l,sourceOptions:r,fileDescriptors:c,startTime:d})])}finally{u.abort()}},_0=(e,t)=>Promise.allSettled([e,t]);import{setImmediate as q0}from"timers/promises";import{on as b0}from"events";import{getDefaultHighWaterMark as w0}from"stream";var sn=({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:i,encoding:n,preserveNewlines:s})=>{let o=new AbortController;return x0(t,o),wl({stream:e,controller:o,binary:r,shouldEncode:!e.readableObjectMode&&i,encoding:n,shouldSplit:!e.readableObjectMode,preserveNewlines:s})},x0=async(e,t)=>{try{await e}catch{}finally{t.abort()}},fo=({stream:e,onStreamEnd:t,lines:r,encoding:i,stripFinalNewline:n,allMixed:s})=>{let o=new AbortController;k0(t,o,e);let a=e.readableObjectMode&&!s;return wl({stream:e,controller:o,binary:i==="buffer",shouldEncode:!a,encoding:i,shouldSplit:!a&&r,preserveNewlines:!n})},k0=async(e,t,r)=>{try{await e}catch{r.destroy()}finally{t.abort()}},wl=({stream:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})=>{let a=b0(e,"data",{signal:t.signal,highWaterMark:bl,highWatermark:bl});return v0({onStdoutChunk:a,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o})},go=w0(!0),bl=go,v0=async function*({onStdoutChunk:e,controller:t,binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o}){let a=S0({binary:r,shouldEncode:i,encoding:n,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of e)yield*_t(c,a,0)}catch(c){if(!t.signal.aborted)throw c}finally{yield*mr(a)}},S0=({binary:e,shouldEncode:t,encoding:r,shouldSplit:i,preserveNewlines:n})=>[Ki(e,r,!t),Hi(e,n,!i,{})].filter(Boolean);var xl=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=$0({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:a,verboseInfo:d,streamInfo:p});if(!n){await Promise.all([A0(e),u]);return}let l=Hs(c,r),m=fo({stream:e,onStreamEnd:t,lines:o,encoding:i,stripFinalNewline:l,allMixed:a}),[h]=await Promise.all([C0({stream:e,iterable:m,fdNumber:r,encoding:i,maxBuffer:s,lines:o}),u]);return h},$0=async({stream:e,onStreamEnd:t,fdNumber:r,encoding:i,allMixed:n,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Xi({stdioItems:o[r]?.stdioItems,encoding:i,verboseInfo:s,fdNumber:r}))return;let a=fo({stream:e,onStreamEnd:t,lines:!0,encoding:i,stripFinalNewline:!0,allMixed:n});await Iu(a,e,r,s)},A0=async e=>{await q0(),e.readableFlowing===null&&e.resume()},C0=async({stream:e,stream:{readableObjectMode:t},iterable:r,fdNumber:i,encoding:n,maxBuffer:s,lines:o})=>{try{return t||o?await Li(r,{maxBuffer:s}):n==="buffer"?new Uint8Array(await Mi(r,{maxBuffer:s})):await Bi(r,{maxBuffer:s})}catch(a){return kl(Id({error:a,stream:e,readableObjectMode:t,lines:o,encoding:n,fdNumber:i}))}},_o=async e=>{try{return await e}catch(t){return kl(t)}},kl=({bufferedData:e})=>Ka(e)?new Uint8Array(e):e;import{finished as E0}from"stream/promises";var gr=async(e,t,r,{isSameDirection:i,stopOnExit:n=!1}={})=>{let s=P0(e,r),o=new AbortController;try{await Promise.race([...n?[r.exitPromise]:[],E0(e,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||R0(a,t,r,i)}finally{o.abort()}},P0=(e,{originalStreams:[t],subprocess:r})=>{let i={stdinCleanedUp:!1};return e===t&&T0(e,r,i),i},T0=(e,t,r)=>{let{_destroy:i}=e;e._destroy=(...n)=>{I0(t,r),i.call(e,...n)}},I0=({exitCode:e,signalCode:t},r)=>{(e!==null||t!==null)&&(r.stdinCleanedUp=!0)},R0=(e,t,r,i)=>{if(!O0(e,t,r,i))throw e},O0=(e,t,r,i=!0)=>r.propagating?vl(e)||on(e):(r.propagating=!0,bo(r,t)===i?vl(e):on(e)),bo=({fileDescriptors:e},t)=>t!=="all"&&e[t].direction==="input",on=e=>e?.code==="ERR_STREAM_PREMATURE_CLOSE",vl=e=>e?.code==="EPIPE";var Sl=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>e.stdio.map((c,d)=>wo({stream:c,fdNumber:d,encoding:t,buffer:r[d],maxBuffer:i[d],lines:n[d],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),wo=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=gr(e,t,d);if(bo(d,t)){await p;return}let[u]=await Promise.all([xl({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 ql=({stdout:e,stderr:t},{all:r})=>r&&(e||t)?bt([e,t].filter(Boolean)):void 0,$l=({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>wo({...j0(e,r),fdNumber:"all",encoding:t,maxBuffer:i[1]+i[2],lines:n[1]||n[2],allMixed:D0(e),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),j0=({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}},D0=({all:e,stdout:t,stderr:r})=>e&&t&&r&&t.readableObjectMode!==r.readableObjectMode;import{once as L0}from"events";var Al=e=>Tt(e,"ipc"),Cl=(e,t)=>{let r=pi(e);Pe({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:t})};var El=async({subprocess:e,buffer:t,maxBuffer:r,ipc:i,ipcOutput:n,verboseInfo:s})=>{if(!i)return n;let o=Al(s),a=He(t,"ipc"),c=He(r,"ipc");for await(let d of ro({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:i,shouldAwait:!1,reference:!0}))a&&(Rd(e,n,c),n.push(d)),o&&Cl(d,s);return n},Pl=async(e,t)=>(await Promise.allSettled([e]),t);var Tl=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=Lu(e,l),g={originalStreams:f,fileDescriptors:h,subprocess:e,exitPromise:S,propagating:!1},I=Sl({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),v=$l({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:n,stripFinalNewline:d,verboseInfo:m,streamInfo:g}),B=[],j=El({subprocess:e,buffer:r,maxBuffer:i,ipc:p,ipcOutput:B,verboseInfo:m}),L=M0(f,e,g),G=F0(h,g);try{return await Promise.race([Promise.all([{},Fu(S),Promise.all(I),v,j,ud(e,u),...L,...G]),x,B0(e,w),...od(e,s,l,w),...Ap({subprocess:e,cancelSignal:o,gracefulCancel:a,context:l,controller:w}),...nd({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(I.map($=>_o($))),_o(v),Pl(j,B),Promise.allSettled(L),Promise.allSettled(G)])}},M0=(e,t,r)=>e.map((i,n)=>i===t.stdio[n]?void 0:gr(i,n,r)),F0=(e,t)=>e.flatMap(({stdioItems:r},i)=>r.filter(({value:n,stream:s=n})=>qe(s,{checkOpen:!1})&&!ke(s)).map(({type:n,value:s,stream:o=s})=>gr(o,i,t,{isSameDirection:we.has(n),stopOnExit:n==="native"}))),B0=async(e,{signal:t})=>{let[r]=await L0(e,"error",{signal:t});throw r};var Il=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),_r=(e,t,r)=>{let i=e[r];i.has(t)||i.set(t,[]);let n=i.get(t),s=Te();return n.push(s),{resolve:s.resolve.bind(s),promises:n}},Gt=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 U0}from"stream";import{callbackify as N0}from"util";import{finished as Rl}from"stream/promises";var xo=async e=>{if(e!==void 0)try{await ko(e)}catch{}},Ol=async e=>{if(e!==void 0)try{await vo(e)}catch{}},ko=async e=>{await Rl(e,{cleanup:!0,readable:!1,writable:!0})},vo=async e=>{await Rl(e,{cleanup:!0,readable:!0,writable:!1})},an=async(e,t)=>{if(await e,t)throw t},cn=(e,t,r)=>{r&&!on(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||ye.has(r),{subprocessStdout:a,waitReadableDestroy:c}=So(e,i,t),{readableEncoding:d,readableObjectMode:p,readableHighWaterMark:u}=qo(a,o),{read:l,onStdoutDataDone:m}=$o({subprocessStdout:a,subprocess:e,binary:o,encoding:r,preserveNewlines:s}),h=new U0({read:l,destroy:N0(Co.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:c})),highWaterMark:u,objectMode:p,encoding:d});return Ao({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},So=(e,t,r)=>{let i=Dt(e,t),n=_r(r,i,"readableDestroy");return{subprocessStdout:i,waitReadableDestroy:n}},qo=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r},i)=>i?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:r}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:go},$o=({subprocessStdout:e,subprocess:t,binary:r,encoding:i,preserveNewlines:n})=>{let s=Te(),o=sn({subprocessStdout:e,subprocess:t,binary:r,shouldEncode:!r,encoding:i,preserveNewlines:n});return{read(){G0(this,o,s)},onStdoutDataDone:s}},G0=async(e,t,r)=>{try{let{value:i,done:n}=await t.next();n?r.resolve():e.push(i)}catch{}},Ao=async({subprocessStdout:e,onStdoutDataDone:t,readable:r,subprocess:i,subprocessStdin:n})=>{try{await vo(e),await i,await xo(n),await t,r.readable&&r.push(null)}catch(s){await xo(n),Dl(r,s)}},Co=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:r},i)=>{await Gt(r,t)&&(Dl(e,i),await an(t,i))},Dl=(e,t)=>{cn(e,e.readable,t)};import{Writable as z0}from"stream";import{callbackify as Ll}from"util";var Ml=({subprocess:e,concurrentStreams:t},{to:r}={})=>{let{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}=Eo(e,r,t),o=new z0({...Po(i,e,n),destroy:Ll(Io.bind(void 0,{subprocessStdin:i,subprocess:e,waitWritableFinal:n,waitWritableDestroy:s})),highWaterMark:i.writableHighWaterMark,objectMode:i.writableObjectMode});return To(i,o),o},Eo=(e,t,r)=>{let i=xi(e,t),n=_r(r,i,"writableFinal"),s=_r(r,i,"writableDestroy");return{subprocessStdin:i,waitWritableFinal:n,waitWritableDestroy:s}},Po=(e,t,r)=>({write:V0.bind(void 0,e),final:Ll(W0.bind(void 0,e,t,r))}),V0=(e,t,r,i)=>{e.write(t,r)?i():e.once("drain",i)},W0=async(e,t,r)=>{await Gt(r,t)&&(e.writable&&e.end(),await t)},To=async(e,t,r)=>{try{await ko(e),t.writable&&t.end()}catch(i){await Ol(r),Fl(t,i)}},Io=async({subprocessStdin:e,subprocess:t,waitWritableFinal:r,waitWritableDestroy:i},n)=>{await Gt(r,t),await Gt(i,t)&&(Fl(e,n),await an(t,n))},Fl=(e,t)=>{cn(e,e.writable,t)};import{Duplex as H0}from"stream";import{callbackify as K0}from"util";var Bl=({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}=So(e,i,t),{subprocessStdin:p,waitWritableFinal:u,waitWritableDestroy:l}=Eo(e,n,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=qo(c,a),{read:x,onStdoutDataDone:w}=$o({subprocessStdout:c,subprocess:e,binary:a,encoding:r,preserveNewlines:o}),S=new H0({read:x,...Po(p,e,u),destroy:K0(Y0.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 Ao({subprocessStdout:c,onStdoutDataDone:w,readable:S,subprocess:e,subprocessStdin:p}),To(p,S,c),S},Y0=async({subprocessStdout:e,subprocessStdin:t,subprocess:r,waitReadableDestroy:i,waitWritableFinal:n,waitWritableDestroy:s},o)=>{await Promise.all([Co({subprocessStdout:e,subprocess:r,waitReadableDestroy:i},o),Io({subprocessStdin:t,subprocess:r,waitWritableFinal:n,waitWritableDestroy:s},o)])};var Ro=(e,t,{from:r,binary:i=!1,preserveNewlines:n=!1}={})=>{let s=i||ye.has(t),o=Dt(e,r),a=sn({subprocessStdout:o,subprocess:e,binary:s,shouldEncode:!0,encoding:t,preserveNewlines:n});return J0(a,o,e)},J0=async function*(e,t,r){try{yield*e}finally{t.readable&&t.destroy(),await r}};var Ul=(e,{encoding:t})=>{let r=Il();e.readable=jl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.writable=Ml.bind(void 0,{subprocess:e,concurrentStreams:r}),e.duplex=Bl.bind(void 0,{subprocess:e,concurrentStreams:r,encoding:t}),e.iterable=Ro.bind(void 0,e,t),e[Symbol.asyncIterator]=Ro.bind(void 0,e,t,{})};var Nl=(e,t)=>{for(let[r,i]of Z0){let n=i.value.bind(t);Reflect.defineProperty(e,r,{...i,value:n})}},X0=(async()=>{})().constructor.prototype,Z0=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(X0,e)]);var Gl=(e,t,r,i)=>{let{file:n,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:d,options:p,fileDescriptors:u}=tk(e,t,r),{subprocess:l,promise:m}=ik({file:n,commandArguments:s,options:p,startTime:c,verboseInfo:d,command:o,escapedCommand:a,fileDescriptors:u});return l.pipe=nn.bind(void 0,{source:l,sourcePromise:m,boundOptions:{},createNested:i}),Nl(l,m),Ie.set(l,{options:p,fileDescriptors:u}),l},tk=(e,t,r)=>{let{command:i,escapedCommand:n,startTime:s,verboseInfo:o}=ui(e,t,r),{file:a,commandArguments:c,options:d}=Ii(e,t,r),p=rk(d),u=el(p,o);return{file:a,commandArguments:c,command:i,escapedCommand:n,startTime:s,verboseInfo:o,options:p,fileDescriptors:u}},rk=({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}},ik=({file:e,commandArguments:t,options:r,startTime:i,verboseInfo:n,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=ek(...Ri(e,t,r))}catch(h){return Ju({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:i,verboseInfo:n})}let d=new AbortController;Q0(Number.POSITIVE_INFINITY,d.signal);let p=[...c.stdio];pl(c,a,d),ul(c,r,d);let u={},l=Te();c.kill=qp.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:l,context:u,controller:d}),c.all=ql(c,r),Ul(c,r),Hu(c,r);let m=nk({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}},nk=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 Tl({subprocess:e,options:t,context:c,verboseInfo:i,fileDescriptors:n,originalStreams:s,onInternalError:d,controller:p});p.abort(),d.resolve();let w=h.map((I,v)=>Ye(I,t,v)),S=Ye(f,t,"all"),g=sk({errorInfo:u,exitCode:l,signal:m,stdio:w,all:S,ipcOutput:x,context:c,options:t,command:o,escapedCommand:a,startTime:r});return Bt(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?lr({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 Re,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:r,stdio:i,all:n,ipcOutput:s,options:a,startTime:p,isSync:!1}):Ni({command:c,escapedCommand:d,stdio:i,all:n,ipcOutput:s,options:a,startTime:p});var pn=(e,t)=>{let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,ok(i,e[i],n)]));return{...e,...r}},ok=(e,t,r)=>ak.has(e)&&K(t)&&K(r)?{...t,...r}:r,ak=new Set(["env",...cs]);var ot=(e,t,r,i)=>{let n=(o,a,c)=>ot(o,a,r,c),s=(...o)=>ck({mapArguments:e,deepOptions:r,boundOptions:t,setBoundExeca:i,createNested:n},...o);return i!==void 0&&i(s,n,t),s},ck=({mapArguments:e,deepOptions:t={},boundOptions:r={},setBoundExeca:i,createNested:n},s,...o)=>{if(K(s))return n(e,pn(r,s),i);let{file:a,commandArguments:c,options:d,isSync:p}=pk({mapArguments:e,firstArgument:s,nextArguments:o,deepOptions:t,boundOptions:r});return p?Uu(a,c,d):Gl(a,c,d,n)},pk=({mapArguments:e,firstArgument:t,nextArguments:r,deepOptions:i,boundOptions:n})=>{let s=ec(t)?tc(t,r):[t,...r],[o,a,c]=ei(...s),d=pn(pn(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 zl=({file:e,commandArguments:t})=>Wl(e,t),Vl=({file:e,commandArguments:t})=>({...Wl(e,t),isSync:!0}),Wl=(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]=dk(e);return{file:r,commandArguments:i}},dk=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(uk)){let n=r.at(-1);n&&n.endsWith("\\")?r[r.length-1]=`${n.slice(0,-1)} ${i}`:r.push(i)}return r},uk=/ +/g;var Hl=(e,t,r)=>{e.sync=t(lk,r),e.s=e.sync},Kl=({options:e})=>Yl(e),lk=({options:e})=>({...Yl(e),isSync:!0}),Yl=e=>({options:{...mk(e),...e}}),mk=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},Jl={preferLocal:!0};var re=ot(()=>({})),FD=ot(()=>({isSync:!0})),at=ot(zl),BD=ot(Vl),UD=ot(cd),ND=ot(Kl,{},Jl,Hl),{sendMessage:GD,getOneMessage:zD,getEachMessage:VD,getCancelSignal:WD}=Ku();var ce=U(Y(),1);var dn="spree@example.com",un="spree123";import Je from"fs";import xt from"path";function _(e=process.cwd()){let t=hk(e),r=xt.join(t,"docker-compose.yml");if(!Je.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=yk(t);return{mode:"docker",projectDir:t,port:i}}function hk(e){if(xt.basename(e)!=="backend")return e;let t=xt.dirname(e);for(let r of["docker-compose.yml","docker-compose.dev.yml"]){let i=xt.join(t,r);if(Je.existsSync(i))try{if(/\.\/backend:\/rails(:\w+)?(\s|$)/m.test(Je.readFileSync(i,"utf-8")))return t}catch{}}return e}function je(e){let t=xt.join(e,".env");if(!Je.existsSync(t))return!1;try{let r=Je.readFileSync(t,"utf-8");return/^\s*SPREE_PATH\s*=/m.test(r)}catch{return!1}}function mn(e){let t=xt.join(e,"docker-compose.yml");if(!Je.existsSync(t))return!1;try{return/^\s*build\s*:/m.test(Je.readFileSync(t,"utf-8"))}catch{return!1}}function yk(e){let t=xt.join(e,".env");if(!Je.existsSync(t))return 3e3;let i=Je.readFileSync(t,"utf-8").match(/^SPREE_PORT=(\d+)/m);return i?Number(i[1]):3e3}function em(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(`
143
+ ${ce.default.red("Error:")} Unknown component: ${t}. Try: dashboard
144
+ `),process.exit(2)),Xr(ce.default.bgCyan(ce.default.black(" Spree Dashboard ")));let i=_();await _k(i,{template:r.template??process.env.SPREE_DASHBOARD_TEMPLATE??bk(),install:r.install}),Ct("Done!")})}async function _k(e,t){let r=le.join(e.projectDir,"apps","dashboard"),i=le.join(r,".env.local");if(se.existsSync(r)){if(se.existsSync(i)){b.warn(`${ce.default.bold("apps/dashboard/")} already exists. Nothing to do.`);return}Zl(i,e.port),Xl(e.projectDir,Ql(e.projectDir,r)),b.info(`Wrote missing ${ce.default.bold("apps/dashboard/.env.local")}. Nothing else to do.`);return}let n=P();n.start("Fetching dashboard starter...");try{await xk(t.template,r),wk(r)}catch(a){n.stop("Fetch failed."),b.error(a instanceof Error?a.message:String(a)),process.exit(1)}n.stop(`Created ${ce.default.cyan("apps/dashboard/")}`),Zl(i,e.port);let s=Ql(e.projectDir,r),o=Xl(e.projectDir,s);if(o==="amended"?b.info(`Amended ${ce.default.bold("render.yaml")}: the backend service now builds the dashboard and serves it at ${ce.default.cyan("/dashboard")} \u2014 same origin, nothing else to configure.`):o==="unrecognized"&&b.warn(`${ce.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 re(s,["install"],{cwd:r}),n.stop("Dependencies installed.")}catch(a){n.stop(ce.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:",` ${ce.default.cyan("cd apps/dashboard && "+(t.install?"":"pnpm install && ")+"pnpm dev")}`,"",`Then open ${ce.default.bold(`http://localhost:${5173}`)} and sign in`,"with your admin email and password."].join(`
145
+ `),"Dashboard added!")}function bk(){let e=le.dirname(gk(import.meta.url)),t=[le.resolve(e,"../../templates/dashboard-starter"),le.resolve(e,"templates/dashboard-starter")];for(let r of t)if(se.existsSync(le.join(r,"package.json")))return r;console.error(`
146
+ ${ce.default.red("Error:")} Bundled dashboard template not found. In the monorepo, run ${ce.default.cyan("pnpm build")} in packages/cli first (it generates the template), or pass --template <path|git-url>.
147
+ `),process.exit(1)}function Xl(e,t){let r=le.join(e,"render.yaml");if(!se.existsSync(r))return"no-blueprint";let i=se.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
148
+ ${u}# origin as the API, so no CORS or cookie configuration).
149
+ ${u}- key: SPREE_DASHBOARD_DIST_PATH
150
+ ${u} value: ../apps/dashboard/dist
151
+ `,m=a.indexOf("buildCommand:")+p.index+p[0].length;return a=`${a.slice(0,m)}
152
+ ${l.replace(/\n$/,"")}${a.slice(m)}`,se.writeFileSync(r,a),"amended"}function wk(e){let t=le.join(e,"gitignore.template");se.existsSync(t)&&se.renameSync(t,le.join(e,".gitignore"))}async function xk(e,t){if(se.existsSync(e)&&se.statSync(e).isDirectory()){se.cpSync(e,t,{recursive:!0,filter:r=>{let i=le.basename(r);return i!=="node_modules"&&i!=="dist"&&i!==".git"}});return}await re("git",["clone","--depth","1","--",e,t]),se.rmSync(le.join(t,".git"),{recursive:!0,force:!0})}function Zl(e,t){se.writeFileSync(e,["# URL of your Spree API server. No credentials belong in this file \u2014","# every VITE_-prefixed value is compiled into the client bundle.",`VITE_SPREE_API_URL=http://localhost:${t}`,""].join(`
153
+ `))}function Ql(e,t){for(let r of[t,e]){if(se.existsSync(le.join(r,"pnpm-lock.yaml")))return"pnpm";if(se.existsSync(le.join(r,"yarn.lock")))return"yarn";if(se.existsSync(le.join(r,"package-lock.json")))return"npm"}return"pnpm"}function E(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 kk(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 vk=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(vk.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 vt=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 tm(e,t){let r=t.baseDelay*2**e,i=Math.random()*t.baseDelay;return Math.min(r+i,t.maxDelay)}function rm(e){return new Promise(t=>setTimeout(t,e))}function Sk(){return`spree-sdk-retry-${crypto.randomUUID()}`}function qk(e,t,r,i){return e==="GET"||e==="HEAD"||i?r.retryOnStatus.includes(t):t===429}function $k(e,t,r){return t.retryOnNetworkError?e==="GET"||e==="HEAD"||r:!1}function Ak(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 I=new URL(`${e.baseUrl}${t}${o}`,g);m&&Object.entries(m).forEach(([H,$])=>{if($!==void 0)if(Array.isArray($))for(let Be of $)I.searchParams.append(H,String(Be));else I.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?Sk():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(I.toString(),{method:s,headers:v,body:l?JSON.stringify(l):void 0,credentials:e.credentials});if(!$.ok){if(!(H>=G-1)&&e.retryConfig&&qk(s,$.status,e.retryConfig,L)){let V=$.headers.get("Retry-After"),de=V?Math.min(parseInt(V,10)*1e3,e.retryConfig.maxDelay):tm(H,e.retryConfig);await rm(de);continue}let Ue=await $.json();throw new vt(Ue,$.status)}return $.status===204?void 0:$.status===202?$.headers.get("content-type")?.includes("application/json")?$.json():void 0:$.json()}catch($){if($ instanceof vt)throw $;if(!(H>=G-1)&&e.retryConfig&&$k(s,e.retryConfig,L)){let Ue=tm(H,e.retryConfig);await rm(Ue);continue}throw $}throw new Error("Unexpected end of retry loop")}}var kt={"Spree::Product":"/products","Spree::Variant":"/variants","Spree::Order":"/orders","Spree::User":"/customers","Spree::Category":"/categories","Spree::OptionType":"/option_types"},Ck=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=kt[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:E(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:E(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(kt["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:E(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:E(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:E(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:E(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(kt["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:E(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(kt["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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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(kt["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:E(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(kt["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:E(t)}),customFields:this.parentScopedCustomFields(kt["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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(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:E(t)})}};function br(e){let t=e.baseUrl.replace(/\/$/,""),r=e.fetch||fetch.bind(globalThis),i=kk(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 Ak(n,c,S)(l,m,x)};try{return await w()}catch(S){if(S instanceof vt&&S.status===401&&a&&!m.includes("/auth/")&&await a())return w();throw S}},p=new Ck(d),u=Object.create(p);return u.setStore=l=>{o=l},u.setToken=l=>{s=l},u.onUnauthorized=l=>{a=l},u}var Mm=U(qr(),1),Ae=U(Y(),1);var xm=U(Y(),1);import Pv from"fs";var Xo=Symbol("no-body");async function km(e){if(e===void 0)return Xo;let t;if(e==="-")t=await Tv();else if(e.startsWith("@")){let r=e.slice(1);try{t=Pv.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 Tv(){process.stdin.isTTY&&process.stderr.write(`${xm.default.dim("Reading request body from stdin \u2014 paste JSON and press Ctrl-D...")}
154
+ `);let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}var ia=U(qr(),1),fe=U(Y(),1);var $r=U(Y(),1);import Ze from"fs";import Iv from"os";import Ht from"path";var vm=U(Y(),1);async function X(e,t,r){return re("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 ie(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 re("docker",i,{cwd:t});return n.split(`
143
155
  `).filter(s=>!s.startsWith("[")).join(`
144
- `).trim()}async function _t(e,t){let{stdout:r}=await pe("docker",["compose","ps",e,"--format","{{.State}}"],{cwd:t});return r.split(`
145
- `).some(i=>i.trim()==="running")}async function D(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 pe("docker",a,{cwd:t,stdio:"inherit"})}async function rn(e){await D(["bin/rails","spree:admin:tailwindcss:build"],e,{tty:!1})}async function om(e){await D(["bin/rails","spree:admin:tailwindcss:watch"],e,{detach:!0})}async function Mo(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 pe("docker",o,{cwd:t,...s?{stdin:"inherit",stdout:"inherit",stderr:["pipe","inherit"]}:{stdio:"inherit"}})}async function rt(e,t,r={}){let{service:i="web",env:n,edgeHint:s}=r;if(await _t(i,t)){await D(e,t,{service:i,env:n});return}Se(t)&&(F([`The ${i} container is not running, and this is a monorepo edge project.`,`Run ${sm.default.bold("pnpm server:dev")} from the monorepo root${s?` \u2014 ${s}`:""}.`].join(`
146
- `)),process.exit(1)),C.info(`${i} container is not running \u2014 using a one-off container (\`docker compose run\`) instead.`),await Mo(e,t,{service:i,env:n})}async function nn(e,t){await pe("docker",["compose","logs","-f",e],{cwd:t,stdio:"inherit"})}var Fo=`http://localhost:${3e3}`,it=class extends Error{};function am(){return process.env.XDG_CONFIG_HOME?Ft.join(process.env.XDG_CONFIG_HOME,"spree"):Ft.join(tv.homedir(),".config","spree")}function bt(){return Ft.join(am(),"config.json")}function Bo(e){return e?.code==="ENOENT"}function fr(){let e;try{e=Ve.readFileSync(bt(),"utf-8")}catch(t){if(Bo(t))return{profiles:{}};throw t}try{let t=JSON.parse(e);return{...t,profiles:t.profiles??{}}}catch{let t=`${bt()}.bak`;try{Ve.renameSync(bt(),t)}catch{}return process.stderr.write(`${yr.default.yellow(`warning: ${bt()} was not valid JSON; moved it to ${t} and starting fresh.`)}
147
- `),{profiles:{}}}}function Uo(e){Ve.mkdirSync(am(),{recursive:!0,mode:448}),cm(bt(),`${JSON.stringify(e,null,2)}
148
- `)}function cm(e,t){Ve.writeFileSync(e,t,{mode:384}),Ve.chmodSync(e,384)}function sn(e){return Ft.join(e,".spree","credentials.json")}function rv(e){let t;try{t=Ve.readFileSync(sn(e),"utf-8")}catch(r){if(Bo(r))return null;throw r}try{return JSON.parse(t)}catch{return null}}function iv(e,t){let r=sn(e),i=Ft.dirname(r);Ve.mkdirSync(i,{recursive:!0,mode:448}),nv(Ft.join(i,".gitignore")),cm(r,`${JSON.stringify(t,null,2)}
149
- `)}function nv(e){let t="";try{t=Ve.readFileSync(e,"utf-8")}catch(i){if(!Bo(i))throw i}t.split(`
150
- `).some(i=>i.trim()==="*")||Ve.writeFileSync(e,t&&!t.endsWith(`
156
+ `).trim()}async function qt(e,t){let{stdout:r}=await re("docker",["compose","ps",e,"--format","{{.State}}"],{cwd:t});return r.split(`
157
+ `).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 re("docker",a,{cwd:t,stdio:"inherit"})}async function yn(e){await F(["bin/rails","spree:admin:tailwindcss:build"],e,{tty:!1})}async function Sm(e){await F(["bin/rails","spree:admin:tailwindcss:watch"],e,{detach:!0})}async function Zo(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 re("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 qt(i,t)){await F(e,t,{service:i,env:n});return}je(t)&&(O([`The ${i} container is not running, and this is a monorepo edge project.`,`Run ${vm.default.bold("pnpm server:dev")} from the monorepo root${s?` \u2014 ${s}`:""}.`].join(`
158
+ `)),process.exit(1)),b.info(`${i} container is not running \u2014 using a one-off container (\`docker compose run\`) instead.`),await Zo(e,t,{service:i,env:n})}async function fn(e,t){await re("docker",["compose","logs","-f",e],{cwd:t,stdio:"inherit"})}var Qo=`http://localhost:${3e3}`,lt=class extends Error{};function qm(){return process.env.XDG_CONFIG_HOME?Ht.join(process.env.XDG_CONFIG_HOME,"spree"):Ht.join(Iv.homedir(),".config","spree")}function $t(){return Ht.join(qm(),"config.json")}function ea(e){return e?.code==="ENOENT"}function Ar(){let e;try{e=Ze.readFileSync($t(),"utf-8")}catch(t){if(ea(t))return{profiles:{}};throw t}try{let t=JSON.parse(e);return{...t,profiles:t.profiles??{}}}catch{let t=`${$t()}.bak`;try{Ze.renameSync($t(),t)}catch{}return process.stderr.write(`${$r.default.yellow(`warning: ${$t()} was not valid JSON; moved it to ${t} and starting fresh.`)}
159
+ `),{profiles:{}}}}function ta(e){Ze.mkdirSync(qm(),{recursive:!0,mode:448}),$m($t(),`${JSON.stringify(e,null,2)}
160
+ `)}function $m(e,t){Ze.writeFileSync(e,t,{mode:384}),Ze.chmodSync(e,384)}function gn(e){return Ht.join(e,".spree","credentials.json")}function Rv(e){let t;try{t=Ze.readFileSync(gn(e),"utf-8")}catch(r){if(ea(r))return null;throw r}try{return JSON.parse(t)}catch{return null}}function Ov(e,t){let r=gn(e),i=Ht.dirname(r);Ze.mkdirSync(i,{recursive:!0,mode:448}),jv(Ht.join(i,".gitignore")),$m(r,`${JSON.stringify(t,null,2)}
161
+ `)}function jv(e){let t="";try{t=Ze.readFileSync(e,"utf-8")}catch(i){if(!ea(i))throw i}t.split(`
162
+ `).some(i=>i.trim()==="*")||Ze.writeFileSync(e,t&&!t.endsWith(`
151
163
  `)?`${t}
152
164
  *
153
165
  `:`${t}*
154
- `)}function on(e){return e.slice(0,12)}async function No(e,t,r=!1){r||process.stderr.write(`${yr.default.dim("No credentials found \u2014 minting a read-only API key via the dev stack...")}
155
- `);let i;try{i=await ee("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(`
156
- `)[0]:String(o);throw new it(`Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.
157
- ${yr.default.dim(a)}`)}let n=i.match(/sk_[A-Za-z0-9_-]+/);if(!n)throw new it("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 iv(e,s),r||process.stderr.write(`${yr.default.dim("Saved to .spree/credentials.json (scopes: read_all)")}
158
- `),s}async function gr(e,t={}){let{allowMint:r=!0,cwd:i=process.cwd()}=t,n=fr(),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 it(`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=g(i);p=l.projectDir,u=l.port}catch{}if(p){let l=`http://localhost:${u}`,m=!s||s.replace(/\/$/,"")===l,h=rv(p);!h&&r&&m&&(h=await No(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=Fo),!c||!d)throw new it(["No Admin API credentials found. Provide them via one of (host and key resolve together per source):"," - flags: --api-key <sk_...> (host defaults to "+Fo+"; pass --base-url for a remote store)"," - env: SPREE_API_KEY (host defaults to "+Fo+"; 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(`
159
- `));return{baseUrl:c,apiKey:d,source:a?.source??"flags",profileName:a?.profileName,tokenPrefix:on(d),scopes:a?.scopes}}function _r(e,t="json"){if(e!=null){if(t==="table"){let r=av(e);if(r){(0,Go.printTable)(r.map(pm));return}let i=pm(e);(0,Go.printTable)(Object.entries(i).map(([n,s])=>({field:n,value:s})));return}process.stdout.isTTY?process.stdout.write(`${ov(JSON.stringify(e,null,2))}
166
+ `)}function _n(e){return e.slice(0,12)}async function ra(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...")}
167
+ `);let i;try{i=await ie("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(`
168
+ `)[0]:String(o);throw new lt(`Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.
169
+ ${$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 Ov(e,s),r||process.stderr.write(`${$r.default.dim("Saved to .spree/credentials.json (scopes: read_all)")}
170
+ `),s}async function Cr(e,t={}){let{allowMint:r=!0,cwd:i=process.cwd()}=t,n=Ar(),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=Rv(p);!h&&r&&m&&(h=await ra(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=Qo),!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 "+Qo+"; pass --base-url for a remote store)"," - env: SPREE_API_KEY (host defaults to "+Qo+"; 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(`
171
+ `));return{baseUrl:c,apiKey:d,source:a?.source??"flags",profileName:a?.profileName,tokenPrefix:_n(d),scopes:a?.scopes}}function Er(e,t="json"){if(e!=null){if(t==="table"){let r=Mv(e);if(r){(0,ia.printTable)(r.map(Am));return}let i=Am(e);(0,ia.printTable)(Object.entries(i).map(([n,s])=>({field:n,value:s})));return}process.stdout.isTTY?process.stdout.write(`${Lv(JSON.stringify(e,null,2))}
160
172
  `):process.stdout.write(`${JSON.stringify(e)}
161
- `)}}var sv=/("(?:\\.|[^"\\])*"(\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function ov(e){return e.replace(sv,(t,r,i,n,s)=>r!==void 0?i?de.default.cyan(r.slice(0,-i.length))+i:de.default.green(r):n!==void 0?de.default.yellow(n):s!==void 0?de.default.yellow(s):t)}function av(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:null}function pm(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 xt(e,t={}){if(e instanceof ot){let i=e.details?`
162
- ${JSON.stringify({details:e.details},null,2)}`:"";process.stderr.write(`${de.default.red(`${e.code}:`)} ${e.message}${i}
163
- `);let n=e.details?.required_scope;typeof n=="string"&&process.stderr.write(`${de.default.dim(`Hint: this key lacks \`${n}\`. Create one that has it and use it:`)}
164
- ${de.default.dim(` spree api-key create --type secret --scopes ${n}`)}
165
- ${de.default.dim(" then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>")}
166
- `),process.exit(1)}if(e instanceof it&&(process.stderr.write(`${de.default.red("error:")} ${e.message}
167
- `),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(`${de.default.red("error:")} could not reach the server${s}${n?`: ${n}`:""}
168
- `),process.stderr.write(`${de.default.dim("Hint: check the URL, or run `spree api status` to diagnose reachability and credentials.")}
169
- `),process.exit(2)}let r=e instanceof Error?e.message:String(e);process.stderr.write(`${de.default.red("error:")} ${r}
170
- `),process.exit(2)}function um(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=dm(e.page,"--page")),e.limit!==void 0&&(r.limit=dm(e.limit,"--limit")),e.expand&&(r.expand=e.expand),e.fields&&(r.fields=e.fields),r}function dm(e,t){if(!/^[1-9]\d*$/.test(e))throw new Error(`Invalid ${t} "${e}" \u2014 expected a positive integer`);return Number(e)}function br(e){let t=e.startsWith("/")?e:`/${e}`,r="/api/v3/admin";return t===r?"/":t.startsWith(`${r}/`)?t.slice(r.length):t}var Bt=G(X(),1);async function xr(e,t){let r=Gt({baseUrl:e,secretKey:t,retry:!1});try{return{status:"connected",storeName:(await r.request("GET","/store",{}))?.name}}catch(i){return i instanceof ot?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 lm(e,t){let r=Gt({baseUrl:e,secretKey:t,retry:!1});try{return(await r.apiKeys.current()).scopes??null}catch{return null}}function an(e){return e.status==="unauthorized"||e.status==="unreachable"}function cn(e){return{connected:Bt.default.green(`connected${e.storeName?` (${e.storeName})`:""}`),forbidden:Bt.default.green("connected")+Bt.default.dim(" (key valid; lacks read_settings for store details)"),unauthorized:Bt.default.red("key rejected (401)"),unreachable:Bt.default.red(`unreachable \u2014 ${e.message}`)}[e.status]}var mm={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.
173
+ `)}}var Dv=/("(?:\\.|[^"\\])*"(\s*:)?)|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function Lv(e){return e.replace(Dv,(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 Mv(e){return Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.data)?e.data:null}function Am(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 At(e,t={}){if(e instanceof vt){let i=e.details?`
174
+ ${JSON.stringify({details:e.details},null,2)}`:"";process.stderr.write(`${fe.default.red(`${e.code}:`)} ${e.message}${i}
175
+ `);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:`)}
176
+ ${fe.default.dim(` spree api-key create --type secret --scopes ${n}`)}
177
+ ${fe.default.dim(" then pass it via --api-key <sk_...> or export SPREE_API_KEY=<sk_...>")}
178
+ `),process.exit(1)}if(e instanceof lt&&(process.stderr.write(`${fe.default.red("error:")} ${e.message}
179
+ `),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}`:""}
180
+ `),process.stderr.write(`${fe.default.dim("Hint: check the URL, or run `spree api status` to diagnose reachability and credentials.")}
181
+ `),process.exit(2)}let r=e instanceof Error?e.message:String(e);process.stderr.write(`${fe.default.red("error:")} ${r}
182
+ `),process.exit(2)}function Em(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=Cm(e.page,"--page")),e.limit!==void 0&&(r.limit=Cm(e.limit,"--limit")),e.expand&&(r.expand=e.expand),e.fields&&(r.fields=e.fields),r}function Cm(e,t){if(!/^[1-9]\d*$/.test(e))throw new Error(`Invalid ${t} "${e}" \u2014 expected a positive integer`);return Number(e)}function Pr(e){let t=e.startsWith("/")?e:`/${e}`,r="/api/v3/admin";return t===r?"/":t.startsWith(`${r}/`)?t.slice(r.length):t}var Kt=U(Y(),1);async function Tr(e,t){let r=br({baseUrl:e,secretKey:t,retry:!1});try{return{status:"connected",storeName:(await r.request("GET","/store",{}))?.name}}catch(i){return i instanceof vt?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 Pm(e,t){let r=br({baseUrl:e,secretKey:t,retry:!1});try{return(await r.apiKeys.current()).scopes??null}catch{return null}}function bn(e){return e.status==="unauthorized"||e.status==="unreachable"}function wn(e){return{connected:Kt.default.green(`connected${e.storeName?` (${e.storeName})`:""}`),forbidden:Kt.default.green("connected")+Kt.default.dim(" (key valid; lacks read_settings for store details)"),unauthorized:Kt.default.red("key rejected (401)"),unreachable:Kt.default.red(`unreachable \u2014 ${e.message}`)}[e.status]}var Tm={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.
171
183
 
172
184
  ## Authentication
173
185
 
@@ -249,7 +261,7 @@ the full member list inline (recommended only for single-record
249
261
  reads \u2014 embed cost scales with membership size).
250
262
 
251
263
 
252
- **Required scope:** \`read_customers\` (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:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `customers`.",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer group with embedded customers",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"404":{description:"customer group not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Updates name, description, or membership. `customer_ids` is a\nfull-set replacement \u2014 the server reconciles the membership to\nmatch the array, adding new IDs and removing ones not present.\nSend `customer_ids: []` to clear all members.\n\n\n**Required scope:** `write_customers` (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:"customer group updated",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string",nullable:!0},customer_ids:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Delete a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.\n\n**Required scope:** `write_customers` (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:{"204":{description:"customer group deleted"}}}},"/api/v3/admin/customers/{customer_id}/addresses":{get:{summary:"List customer addresses",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved addresses.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"addresses found",content:{"application/json":{}}}}},post:{summary:"Create a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new address to the customer's address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default \u2014 the previous default loses its flag in the same transaction.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"address created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},address1:{type:"string"},address2:{type:"string"},city:{type:"string"},postal_code:{type:"string"},country_iso:{type:"string",description:"ISO-2 country code (e.g. US)"},state_abbr:{type:"string",description:"State/province abbreviation (e.g. NY)"},phone:{type:"string"},company:{type:"string"},label:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}}},"/api/v3/admin/customers/{customer_id}/addresses/{id}":{patch:{summary:"Update a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a customer address.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"address updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{city:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}},delete:{summary:"Delete a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes the address. If it was a default, the customer loses that default (no auto-promotion).\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"address deleted"}}}},"/api/v3/admin/customers/{customer_id}/credit_cards":{get:{summary:"List customer credit cards",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit cards found",content:{"application/json":{}}}}}},"/api/v3/admin/customers/{customer_id}/credit_cards/{id}":{get:{summary:"Show a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a saved credit card by ID.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit card found",content:{"application/json":{}}}}},delete:{summary:"Delete a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a saved credit card.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"credit card deleted"}}}},"/api/v3/admin/customers/{customer_id}/store_credits":{get:{summary:"List customer store credits",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns store credits issued to the customer.\n\n**Required scope:** `read_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"store credits found",content:{"application/json":{}}}}},post:{summary:"Issue a store credit to a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"`created_by` is set automatically from the authenticated admin.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"store credit created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount","currency","category_id"],properties:{amount:{type:"string"},currency:{type:"string"},category_id:{type:"string",description:"StoreCreditCategory ID"},memo:{type:"string"}}}}}}}},"/api/v3/admin/customers/{customer_id}/store_credits/{id}":{patch:{summary:"Update a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Update memo / category / amount. The amount can only be changed if `amount_used == 0`.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"store credit updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"string"},category_id:{type:"string"},memo:{type:"string"}}}}}}},delete:{summary:"Delete a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes an unused store credit (amount_used == 0). Returns 422 otherwise.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"store credit deleted"}}}},"/api/v3/admin/customers":{get:{summary:"List customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of customers. Supports Ransack search/filters.\n\n**Required scope:** `read_customers` (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,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[search]",in:"query",required:!1,description:"Email + name full-text-ish search",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., addresses, store_credits). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customers found",content:{"application/json":{}}}}},post:{summary:"Create a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a customer. No welcome email is sent automatically.\n\n**Required scope:** `write_customers` (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:"customer created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["email"],properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}}},"/api/v3/admin/customers/{id}":{get:{summary:"Show a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns full customer details including computed order stats (orders_count, total_spent, last_order_completed_at).\n\n**Required scope:** `read_customers` (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,description:"Customer ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations: addresses, orders, store_credits, default_billing_address, default_shipping_address",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer found",content:{"application/json":{}}}}},patch:{summary:"Update a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates customer attributes. `tags` replaces the full set.\n\n**Required scope:** `write_customers` (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:"customer updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}},delete:{summary:"Delete a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a customer. Returns 422 if the customer has any orders.\n\n**Required scope:** `write_customers` (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:"customer deleted"}}}},"/api/v3/admin/customers/bulk_add_to_groups":{post:{summary:"Bulk-add customers to groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Attaches each customer in `ids` to every group in `customer_group_ids`.\nIdempotent \u2014 customers already in a group are skipped server-side.\nGroups from sibling stores are silently ignored. Returns counts of\ncustomers and groups that were processed (post store-scoping).\n\n\n**Required scope:** `write_customers` (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:"customers added to groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_from_groups":{post:{summary:"Bulk-remove customers from groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Detaches each customer in `ids` from every group in `customer_group_ids`.\nNo-op for non-members. Groups from sibling stores are silently ignored.\n\n\n**Required scope:** `write_customers` (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:"customers removed from groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_add_tags":{post:{summary:"Bulk-add tags to customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds each tag name in `tags` to every customer in `ids`. Tags are\nupserted by name; re-adding an existing tag is a no-op.\n\n\n**Required scope:** `write_customers` (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:"tags added",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_tags":{post:{summary:"Bulk-remove tags from customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Removes each tag name in `tags` from every customer in `ids`. No-op\nfor customers that don't carry the tag.\n\n\n**Required scope:** `write_customers` (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:"tags removed",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/exports":{get:{summary:"List exports",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"exports found",content:{"application/json":{}}}}},post:{summary:"Create an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:'Queues a CSV export. The `type` selects the dataset; `search_params` is an\noptional Ransack query (same shape used by the `q[...]` params on list endpoints)\nthat filters which records are exported. Pass `record_selection: "all"` to\nclear the filter server-side and export everything in scope.\n\nGeneration is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,\nthen redirect the browser to `download_url` to fetch the file.\n\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export queued",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["type"],properties:{type:{type:"string",enum:["Spree::Exports::Products","Spree::Exports::Orders","Spree::Exports::Customers","Spree::Exports::ProductTranslations","Spree::Exports::GiftCards","Spree::Exports::CouponCodes","Spree::Exports::NewsletterSubscribers"]},record_selection:{type:"string",enum:["filtered","all"],description:'Set to "all" to ignore search_params and export everything in scope.'},search_params:{type:"object",description:"Ransack query hash. Same predicates accepted by the list endpoint.",additionalProperties:!0}}}}}}}},"/api/v3/admin/exports/{id}":{get:{summary:"Show an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns export status. While `done` is `false`, the SPA continues polling.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export found",content:{"application/json":{}}}}},delete:{summary:"Delete an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the export and purges its attachment.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export deleted"}}}},"/api/v3/admin/exports/{id}/download":{get:{summary:"Download an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL \u2014 a top-level navigation cannot carry the JWT.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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/orders/{order_id}/fulfillments":{get:{summary:"List fulfillments",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all shipments for an order.\n\n**Required scope:** `read_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"fulfillments found",content:{"application/json":{}}}}},post:{summary:"Create a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Manually creates a fulfillment on a completed order, bypassing order routing \u2014 for example to mirror a shipment handled by an external carrier or 3PL. Moves the requested line item quantities out of their current fulfillments; when `items` is omitted, every not-yet-shipped unit is moved. Pass `status: 'shipped'` to register an already-shipped fulfillment (fires shipped webhooks and freezes cost/carrier). When `delivery_method_id` is omitted, the fulfillment inherits the delivery method and cost of the source fulfillment(s) it fully drains \u2014 keeping the order total unchanged; partially drained splits get no carrier when shipped, and pending fulfillments are otherwise (re)priced by the standard rate engine, which selects the lowest-cost available rate. Pass `cost` to set an explicit shipping cost instead (e.g. the 3PL price) \u2014 note this changes the order total and payment state, and is guaranteed to persist only with `status: 'shipped'` (pending fulfillments are re-priced by the rate engine).\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"fulfillment created",content:{"application/json":{}}},"422":{description:"order not completed",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["stock_location_id"],properties:{stock_location_id:{type:"string",description:"Stock location the fulfillment ships from"},tracking:{type:"string",description:"Carrier tracking number, or a full https:// tracking link \u2014 a full URL is served back as tracking_url unchanged instead of being templated into the delivery method tracking URL"},delivery_method_id:{type:"string",description:"Delivery method (carrier) to attach as the selected rate. Defaults to the delivery method of the fully drained source fulfillment(s)"},cost:{type:"string",description:"Explicit shipping cost. Defaults to the summed cost of the fully drained source fulfillment(s), which keeps the order total unchanged; an explicit cost changes the order total and payment state. Guaranteed to persist only with status: 'shipped' \u2014 pending fulfillments are re-priced by the rate engine"},status:{type:"string",enum:["shipped"],description:"Pass 'shipped' to register the fulfillment as already shipped"},items:{type:"array",description:"Line item quantities to fulfill. Omit to fulfill every not-yet-shipped unit.",items:{type:"object",required:["item_id","quantity"],properties:{item_id:{type:"string",description:"Line item ID"},quantity:{type:"integer"}}}},metadata:{type:"object",additionalProperties:!0}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}":{get:{summary:"Show a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns details of a specific shipment.\n\n**Required scope:** `read_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"shipment found",content:{"application/json":{}}}}},patch:{summary:"Update a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a fulfillment (tracking, delivery rate).\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"shipment updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{tracking:{type:"string",description:"Carrier tracking number, or a full https:// tracking link served back as tracking_url unchanged"},selected_delivery_rate_id:{type:"string",description:"Delivery rate ID (dr_...) to select"}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/fulfill":{patch:{summary:"Fulfill a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Marks a fulfillment as fulfilled.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment fulfilled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":{patch:{summary:"Cancel a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Cancels a fulfillment.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment canceled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":{patch:{summary:"Resume a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Resumes a canceled fulfillment.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment resumed",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":{patch:{summary:"Split a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Transfers items from this shipment to a new shipment at a different stock location.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment split",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["variant_id","quantity"],properties:{variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer"},stock_location_id:{type:"string",description:"Target stock location ID"}}}}}}}},"/api/v3/admin/gift_card_batches":{get:{summary:"List gift card batches",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift card batches issued by the current store. Each batch\ngroups the cards generated together for a campaign or bulk-issuance\n\u2014 the cards themselves live under `/admin/gift_cards` and reference\nthe batch via `gift_card_batch_id`.\n\n\n**Required scope:** `read_gift_cards` (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:"Records per page",schema:{type:"integer"}},{name:"q[prefix_cont]",in:"query",required:!1,description:"Filter by prefix (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending.",schema:{type:"string"}}],responses:{"200":{description:"gift card batches found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCardBatch"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a batch of gift cards in a single call. The server generates\n`codes_count` cards inline for small batches (configurable via\n`Spree.config.gift_card_batch_web_limit`, default 500) or enqueues\na background job for larger ones. Each card's code is the batch\n`prefix` followed by random hex.\n\n\n**Required scope:** `write_gift_cards` (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:"gift card batch created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["prefix","amount","codes_count"],properties:{prefix:{type:"string",description:"Lowercased and prepended to every generated code."},amount:{type:"string",description:"Decimal amount per card, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},codes_count:{type:"integer",description:"Number of cards to generate. Capped at `gift_card_batch_limit`."},expires_at:{type:"string",nullable:!0}}}}}}}},"/api/v3/admin/gift_card_batches/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card batch prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single batch.\n\n**Required scope:** `read_gift_cards` (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:"gift card batch found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"404":{description:"gift card batch not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/gift_cards":{get:{summary:"List gift cards",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift cards issued by the current store. Filter by\n`q[code_cont]` for code search, `q[user_id_eq]` for cards issued\nto a specific customer, or `q[state_eq]` for status filtering.\n\n\n**Required scope:** `read_gift_cards` (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:"q[code_cont]",in:"query",required:!1,description:"Filter by gift card code (contains)",schema:{type:"string"}},{name:"q[state_eq]",in:"query",required:!1,description:"Filter by status (active, redeemed, partially_redeemed, canceled)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift cards found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCard"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a gift card scoped to the current store. The code is\nauto-generated when omitted. `currency` defaults to the store's\nconfigured currency. Pass `user_id` (prefixed ID) to attach the\ncard to a specific customer.\n\n\n**Required scope:** `write_gift_cards` (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:"gift card created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount"],properties:{amount:{type:"string",description:"Decimal amount, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},code:{type:"string",description:"Optional caller-supplied code. Auto-generated when omitted."},expires_at:{type:"string",description:"ISO 8601 date.",nullable:!0},user_id:{type:"string",description:"Optional customer prefixed ID.",nullable:!0}}}}}}}},"/api/v3/admin/gift_cards/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single gift card.\n\n**Required scope:** `read_gift_cards` (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:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift card found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"404":{description:"gift card not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:`Updates an active gift card's editable attributes. Redeemed or
264
+ **Required scope:** \`read_customers\` (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:"expand",in:"query",required:!1,description:"Comma-separated associations to embed. Supported: `customers`.",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer group with embedded customers",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"404":{description:"customer group not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Updates name, description, or membership. `customer_ids` is a\nfull-set replacement \u2014 the server reconciles the membership to\nmatch the array, adding new IDs and removing ones not present.\nSend `customer_ids: []` to clear all members.\n\n\n**Required scope:** `write_customers` (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:"customer group updated",content:{"application/json":{schema:{$ref:"#/components/schemas/CustomerGroup"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{name:{type:"string"},description:{type:"string",nullable:!0},customer_ids:{type:"array",items:{type:"string"}}}}}}}},delete:{summary:"Delete a customer group",tags:["Customer Groups"],security:[{api_key:[],bearer_auth:[]}],description:"Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.\n\n**Required scope:** `write_customers` (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:{"204":{description:"customer group deleted"}}}},"/api/v3/admin/customers/{customer_id}/addresses":{get:{summary:"List customer addresses",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved addresses.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"addresses found",content:{"application/json":{}}}}},post:{summary:"Create a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds a new address to the customer's address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default \u2014 the previous default loses its flag in the same transaction.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"address created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{first_name:{type:"string"},last_name:{type:"string"},address1:{type:"string"},address2:{type:"string"},city:{type:"string"},postal_code:{type:"string"},country_iso:{type:"string",description:"ISO-2 country code (e.g. US)"},state_abbr:{type:"string",description:"State/province abbreviation (e.g. NY)"},phone:{type:"string"},company:{type:"string"},label:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}}},"/api/v3/admin/customers/{customer_id}/addresses/{id}":{patch:{summary:"Update a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a customer address.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"address updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{city:{type:"string"},is_default_billing:{type:"boolean"},is_default_shipping:{type:"boolean"}}}}}}},delete:{summary:"Delete a customer address",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes the address. If it was a default, the customer loses that default (no auto-promotion).\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"address deleted"}}}},"/api/v3/admin/customers/{customer_id}/credit_cards":{get:{summary:"List customer credit cards",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the customer's saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit cards found",content:{"application/json":{}}}}}},"/api/v3/admin/customers/{customer_id}/credit_cards/{id}":{get:{summary:"Show a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a saved credit card by ID.\n\n**Required scope:** `read_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"credit card found",content:{"application/json":{}}}}},delete:{summary:"Delete a customer credit card",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a saved credit card.\n\n**Required scope:** `write_customers` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"credit card deleted"}}}},"/api/v3/admin/customers/{customer_id}/store_credits":{get:{summary:"List customer store credits",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns store credits issued to the customer.\n\n**Required scope:** `read_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"store credits found",content:{"application/json":{}}}}},post:{summary:"Issue a store credit to a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"`created_by` is set automatically from the authenticated admin.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}}],responses:{"201":{description:"store credit created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount","currency","category_id"],properties:{amount:{type:"string"},currency:{type:"string"},category_id:{type:"string",description:"StoreCreditCategory ID"},memo:{type:"string"}}}}}}}},"/api/v3/admin/customers/{customer_id}/store_credits/{id}":{patch:{summary:"Update a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Update memo / category / amount. The amount can only be changed if `amount_used == 0`.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"200":{description:"store credit updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{amount:{type:"string"},category_id:{type:"string"},memo:{type:"string"}}}}}}},delete:{summary:"Delete a store credit",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes an unused store credit (amount_used == 0). Returns 422 otherwise.\n\n**Required scope:** `write_store_credits` (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:"customer_id",in:"path",required:!0,schema:{type:"string"}},{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{"204":{description:"store credit deleted"}}}},"/api/v3/admin/customers":{get:{summary:"List customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a paginated list of customers. Supports Ransack search/filters.\n\n**Required scope:** `read_customers` (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,schema:{type:"integer"}},{name:"limit",in:"query",required:!1,schema:{type:"integer"}},{name:"q[search]",in:"query",required:!1,description:"Email + name full-text-ish search",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., addresses, store_credits). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customers found",content:{"application/json":{}}}}},post:{summary:"Create a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Creates a customer. No welcome email is sent automatically.\n\n**Required scope:** `write_customers` (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:"customer created",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["email"],properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}}},"/api/v3/admin/customers/{id}":{get:{summary:"Show a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Returns full customer details including computed order stats (orders_count, total_spent, last_order_completed_at).\n\n**Required scope:** `read_customers` (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,description:"Customer ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations: addresses, orders, store_credits, default_billing_address, default_shipping_address",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"customer found",content:{"application/json":{}}}}},patch:{summary:"Update a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Updates customer attributes. `tags` replaces the full set.\n\n**Required scope:** `write_customers` (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:"customer updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{email:{type:"string"},first_name:{type:"string"},last_name:{type:"string"},phone:{type:"string"},accepts_email_marketing:{type:"boolean"},internal_note:{type:"string"},tags:{type:"array",items:{type:"string"}},metadata:{type:"object"}}}}}}},delete:{summary:"Delete a customer",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Deletes a customer. Returns 422 if the customer has any orders.\n\n**Required scope:** `write_customers` (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:"customer deleted"}}}},"/api/v3/admin/customers/bulk_add_to_groups":{post:{summary:"Bulk-add customers to groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Attaches each customer in `ids` to every group in `customer_group_ids`.\nIdempotent \u2014 customers already in a group are skipped server-side.\nGroups from sibling stores are silently ignored. Returns counts of\ncustomers and groups that were processed (post store-scoping).\n\n\n**Required scope:** `write_customers` (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:"customers added to groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_from_groups":{post:{summary:"Bulk-remove customers from groups",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Detaches each customer in `ids` from every group in `customer_group_ids`.\nNo-op for non-members. Groups from sibling stores are silently ignored.\n\n\n**Required scope:** `write_customers` (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:"customers removed from groups",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},customer_group_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","customer_group_ids"],properties:{ids:{type:"array",items:{type:"string"}},customer_group_ids:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_add_tags":{post:{summary:"Bulk-add tags to customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Adds each tag name in `tags` to every customer in `ids`. Tags are\nupserted by name; re-adding an existing tag is a no-op.\n\n\n**Required scope:** `write_customers` (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:"tags added",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_tags":{post:{summary:"Bulk-remove tags from customers",tags:["Customers"],security:[{api_key:[],bearer_auth:[]}],description:"Removes each tag name in `tags` from every customer in `ids`. No-op\nfor customers that don't carry the tag.\n\n\n**Required scope:** `write_customers` (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:"tags removed",content:{"application/json":{schema:{type:"object",properties:{customer_count:{type:"integer"},tag_count:{type:"integer"}}}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["ids","tags"],properties:{ids:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}}}}}}}}},"/api/v3/admin/exports":{get:{summary:"List exports",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"exports found",content:{"application/json":{}}}}},post:{summary:"Create an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:'Queues a CSV export. The `type` selects the dataset; `search_params` is an\noptional Ransack query (same shape used by the `q[...]` params on list endpoints)\nthat filters which records are exported. Pass `record_selection: "all"` to\nclear the filter server-side and export everything in scope.\n\nGeneration is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,\nthen redirect the browser to `download_url` to fetch the file.\n\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export queued",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["type"],properties:{type:{type:"string",enum:["Spree::Exports::Products","Spree::Exports::Orders","Spree::Exports::Customers","Spree::Exports::ProductTranslations","Spree::Exports::GiftCards","Spree::Exports::CouponCodes","Spree::Exports::NewsletterSubscribers"]},record_selection:{type:"string",enum:["filtered","all"],description:'Set to "all" to ignore search_params and export everything in scope.'},search_params:{type:"object",description:"Ransack query hash. Same predicates accepted by the list endpoint.",additionalProperties:!0},results_url:{type:"string",description:"Absolute URL of your admin exports view; the export-done email uses it as the download button target. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/exports/{id}":{get:{summary:"Show an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Returns export status. While `done` is `false`, the SPA continues polling.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export found",content:{"application/json":{}}}}},delete:{summary:"Delete an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Removes the export and purges its attachment.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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:"export deleted"}}}},"/api/v3/admin/exports/{id}/download":{get:{summary:"Download an export",tags:["Exports"],security:[{api_key:[],bearer_auth:[]}],description:"Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL \u2014 a top-level navigation cannot carry the JWT.\n\n**Required scope:** the read scope of the exported resource \u2014 `read_products` for product exports, `read_customers` for customer exports, 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/orders/{order_id}/fulfillments":{get:{summary:"List fulfillments",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns all shipments for an order.\n\n**Required scope:** `read_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"fulfillments found",content:{"application/json":{}}}}},post:{summary:"Create a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Manually creates a fulfillment on a completed order, bypassing order routing \u2014 for example to mirror a shipment handled by an external carrier or 3PL. Moves the requested line item quantities out of their current fulfillments; when `items` is omitted, every not-yet-shipped unit is moved. Pass `status: 'shipped'` to register an already-shipped fulfillment (fires shipped webhooks and freezes cost/carrier). When `delivery_method_id` is omitted, the fulfillment inherits the delivery method and cost of the source fulfillment(s) it fully drains \u2014 keeping the order total unchanged; partially drained splits get no carrier when shipped, and pending fulfillments are otherwise (re)priced by the standard rate engine, which selects the lowest-cost available rate. Pass `cost` to set an explicit shipping cost instead (e.g. the 3PL price) \u2014 note this changes the order total and payment state, and is guaranteed to persist only with `status: 'shipped'` (pending fulfillments are re-priced by the rate engine).\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}}],responses:{"201":{description:"fulfillment created",content:{"application/json":{}}},"422":{description:"order not completed",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["stock_location_id"],properties:{stock_location_id:{type:"string",description:"Stock location the fulfillment ships from"},tracking:{type:"string",description:"Carrier tracking number, or a full https:// tracking link \u2014 a full URL is served back as tracking_url unchanged instead of being templated into the delivery method tracking URL"},delivery_method_id:{type:"string",description:"Delivery method (carrier) to attach as the selected rate. Defaults to the delivery method of the fully drained source fulfillment(s)"},cost:{type:"string",description:"Explicit shipping cost. Defaults to the summed cost of the fully drained source fulfillment(s), which keeps the order total unchanged; an explicit cost changes the order total and payment state. Guaranteed to persist only with status: 'shipped' \u2014 pending fulfillments are re-priced by the rate engine"},status:{type:"string",enum:["shipped"],description:"Pass 'shipped' to register the fulfillment as already shipped"},items:{type:"array",description:"Line item quantities to fulfill. Omit to fulfill every not-yet-shipped unit.",items:{type:"object",required:["item_id","quantity"],properties:{item_id:{type:"string",description:"Line item ID"},quantity:{type:"integer"}}}},metadata:{type:"object",additionalProperties:!0}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}":{get:{summary:"Show a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Returns details of a specific shipment.\n\n**Required scope:** `read_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}},{name:"expand",in:"query",required:!1,description:"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.",schema:{type:"string"}}],responses:{"200":{description:"shipment found",content:{"application/json":{}}}}},patch:{summary:"Update a shipment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Updates a fulfillment (tracking, delivery rate).\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"shipment updated",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",properties:{tracking:{type:"string",description:"Carrier tracking number, or a full https:// tracking link served back as tracking_url unchanged"},selected_delivery_rate_id:{type:"string",description:"Delivery rate ID (dr_...) to select"}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/fulfill":{patch:{summary:"Fulfill a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Marks a fulfillment as fulfilled.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment fulfilled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":{patch:{summary:"Cancel a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Cancels a fulfillment.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment canceled",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":{patch:{summary:"Resume a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Resumes a canceled fulfillment.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment resumed",content:{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":{patch:{summary:"Split a fulfillment",tags:["Fulfillments"],security:[{api_key:[],bearer_auth:[]}],description:"Transfers items from this shipment to a new shipment at a different stock location.\n\n**Required scope:** `write_fulfillments` (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:"order_id",in:"path",required:!0,description:"Order ID",schema:{type:"string"}},{name:"id",in:"path",required:!0,description:"Fulfillment ID",schema:{type:"string"}}],responses:{"200":{description:"fulfillment split",content:{"application/json":{}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["variant_id","quantity"],properties:{variant_id:{type:"string",description:"Variant ID"},quantity:{type:"integer"},stock_location_id:{type:"string",description:"Target stock location ID"}}}}}}}},"/api/v3/admin/gift_card_batches":{get:{summary:"List gift card batches",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift card batches issued by the current store. Each batch\ngroups the cards generated together for a campaign or bulk-issuance\n\u2014 the cards themselves live under `/admin/gift_cards` and reference\nthe batch via `gift_card_batch_id`.\n\n\n**Required scope:** `read_gift_cards` (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:"Records per page",schema:{type:"integer"}},{name:"q[prefix_cont]",in:"query",required:!1,description:"Filter by prefix (contains)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending.",schema:{type:"string"}}],responses:{"200":{description:"gift card batches found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCardBatch"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}}}},post:{summary:"Create a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a batch of gift cards in a single call. The server generates\n`codes_count` cards inline for small batches (configurable via\n`Spree.config.gift_card_batch_web_limit`, default 500) or enqueues\na background job for larger ones. Each card's code is the batch\n`prefix` followed by random hex.\n\n\n**Required scope:** `write_gift_cards` (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:"gift card batch created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["prefix","amount","codes_count"],properties:{prefix:{type:"string",description:"Lowercased and prepended to every generated code."},amount:{type:"string",description:"Decimal amount per card, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},codes_count:{type:"integer",description:"Number of cards to generate. Capped at `gift_card_batch_limit`."},expires_at:{type:"string",nullable:!0}}}}}}}},"/api/v3/admin/gift_card_batches/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card batch prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card batch",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single batch.\n\n**Required scope:** `read_gift_cards` (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:"gift card batch found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCardBatch"}}}},"404":{description:"gift card batch not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/gift_cards":{get:{summary:"List gift cards",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns the gift cards issued by the current store. Filter by\n`q[code_cont]` for code search, `q[user_id_eq]` for cards issued\nto a specific customer, or `q[state_eq]` for status filtering.\n\n\n**Required scope:** `read_gift_cards` (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:"q[code_cont]",in:"query",required:!1,description:"Filter by gift card code (contains)",schema:{type:"string"}},{name:"q[state_eq]",in:"query",required:!1,description:"Filter by status (active, redeemed, partially_redeemed, canceled)",schema:{type:"string"}},{name:"sort",in:"query",required:!1,description:"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).",schema:{type:"string"}},{name:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift cards found",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{$ref:"#/components/schemas/GiftCard"}},meta:{$ref:"#/components/schemas/PaginationMeta"}},required:["data","meta"]}}}},"401":{description:"unauthorized",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},post:{summary:"Create a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Issues a gift card scoped to the current store. The code is\nauto-generated when omitted. `currency` defaults to the store's\nconfigured currency. Pass `user_id` (prefixed ID) to attach the\ncard to a specific customer.\n\n\n**Required scope:** `write_gift_cards` (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:"gift card created",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"422":{description:"validation error",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}},requestBody:{content:{"application/json":{schema:{type:"object",required:["amount"],properties:{amount:{type:"string",description:"Decimal amount, greater than zero."},currency:{type:"string",description:"ISO 4217 currency code. Defaults to the store currency."},code:{type:"string",description:"Optional caller-supplied code. Auto-generated when omitted."},expires_at:{type:"string",description:"ISO 8601 date.",nullable:!0},user_id:{type:"string",description:"Optional customer prefixed ID.",nullable:!0}}}}}}}},"/api/v3/admin/gift_cards/{id}":{parameters:[{name:"id",in:"path",required:!0,description:"Gift card prefixed ID",schema:{type:"string"}}],get:{summary:"Get a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:"Returns a single gift card.\n\n**Required scope:** `read_gift_cards` (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:"fields",in:"query",required:!1,description:"Comma-separated list of fields to include. id is always included.",schema:{type:"string"}}],responses:{"200":{description:"gift card found",content:{"application/json":{schema:{$ref:"#/components/schemas/GiftCard"}}}},"404":{description:"gift card not found",content:{"application/json":{schema:{$ref:"#/components/schemas/ErrorResponse"}}}}}},patch:{summary:"Update a gift card",tags:["Gift Cards"],security:[{api_key:[],bearer_auth:[]}],description:`Updates an active gift card's editable attributes. Redeemed or
253
265
  partially-redeemed cards cannot be edited.
254
266
 
255
267
 
@@ -348,24 +360,29 @@ accepts Spree's payloads.
348
360
  repeated delivery failures), no notification email is sent.
349
361
 
350
362
 
351
- **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"]}}}}}}},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"]},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},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},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"},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"},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","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","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 ym=new Set(["get","post","put","patch","delete"]);function pn(){return mm}function pv(e){let t=e.description?.match(/\*\*Required scope:\*\* (.+?) \(for API-key authentication\)\./);return t?t[1].replaceAll("`",""):"\u2014"}function fm(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(!ym.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:pv(a),summary:c})}}return r}function gm(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=br(n),o=hm(e,i,a=>a===s);return o.length>0?o:hm(e,i,a=>dv(a,s))}function hm(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))ym.has(a)&&(t&&a!==t||i.push({method:a.toUpperCase(),path:o,summary:c.summary,description:c.description,parameters:Ut(c.parameters,e),requestBody:Ut(c.requestBody,e),responses:Ut(c.responses,e)}))}return i}function dv(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 uv=8;function Ut(e,t,r=[]){if(Array.isArray(e))return e.map(o=>Ut(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>=uv||!(o in t.components.schemas)?{$ref:n}:Ut(t.components.schemas[o],t,[...r,o])}let s={};for(let[o,a]of Object.entries(i))s[o]=Ut(a,t,r);return s}function lv(e,t){return[...t,e]}function wm(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 km(){return new aa("--format <format>","output format").choices(["json","table"]).default("json")}function _m(e){return wm(e).addOption(km())}async function bm(e){let t=await gr({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile});return{client:Gt({baseUrl:t.baseUrl,secretKey:t.apiKey,...e.storeId?{storeId:e.storeId}:{}}),credentials:t}}function vm(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(`
352
- `)),_m(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)",lv,[]).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=um(i),{client:o,credentials:a}=await bm(i);n=a.baseUrl;let c=await o.request("GET",br(r),{params:s});_r(c,i.format)}catch(s){xt(s,{baseUrl:n})}});for(let r of["post","patch","delete"])_m(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 Ta(n.data),{client:a,credentials:c}=await bm(n);s=c.baseUrl;let d=await a.request(r.toUpperCase(),br(i),{...o===Hn?{}:{body:o}});_r(d,n.format)}catch(o){xt(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(km()).action(r=>{let i=fm(pn(),{resource:r.resource,search:r.search});if(i.length===0){process.stderr.write(`No endpoints match.
353
- `),process.exitCode=1;return}if(r.format==="table"){(0,xm.printTable)(i.map(n=>({Method:n.method,Path:n.path,Scope:n.scope,Summary:n.summary})));return}_r(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=gm(pn(),r);if(i.length===0){process.stderr.write(`No operation matches "${r}". Try \`spree api endpoints --search ${r.split(/\s+/).pop()}\`.
354
- `),process.exitCode=1;return}let n=/\s/.test(r.trim());_r(n&&i.length===1?i[0]:i,"json")}),wm(t.command("status").description("Show resolved credentials, server reachability, and the bundled spec version")).action(async r=>{try{let i=await gr({baseUrl:r.baseUrl,apiKey:r.apiKey,profile:r.profile},{allowMint:!1}),n=await xr(i.baseUrl,i.apiKey),s=pn(),o=cn(n),a=[`${we.default.bold("Base URL:")} ${i.baseUrl}`,`${we.default.bold("Credentials:")} ${i.source}${i.profileName?` (${i.profileName})`:""}, key ${i.tokenPrefix}${we.default.dim("\u2026")}`],c=n.status==="unreachable"||n.status==="unauthorized"?null:await lm(i.baseUrl,i.apiKey);c!==null?a.push(`${we.default.bold("Scopes:")} ${c.length?c.join(", "):we.default.dim("(none)")}`):i.scopes?.length&&a.push(`${we.default.bold("Scopes:")} ${i.scopes.join(", ")} ${we.default.dim("(local snapshot from mint time \u2014 may be stale)")}`),a.push(`${we.default.bold("Server:")} ${o}`),a.push(`${we.default.bold("Bundled spec:")} ${s.info?.version??"unknown"} ${we.default.dim("(spree api endpoints/schema reflect this snapshot, not the live server)")}`),process.stdout.write(`${a.join(`
363
+ **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 Rm=new Set(["get","post","put","patch","delete"]);function xn(){return Tm}function Bv(e){let t=e.description?.match(/\*\*Required scope:\*\* (.+?) \(for API-key authentication\)\./);return t?t[1].replaceAll("`",""):"\u2014"}function Om(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(!Rm.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:Bv(a),summary:c})}}return r}function jm(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=Pr(n),o=Im(e,i,a=>a===s);return o.length>0?o:Im(e,i,a=>Uv(a,s))}function Im(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))Rm.has(a)&&(t&&a!==t||i.push({method:a.toUpperCase(),path:o,summary:c.summary,description:c.description,parameters:Yt(c.parameters,e),requestBody:Yt(c.requestBody,e),responses:Yt(c.responses,e)}))}return i}function Uv(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 Nv=8;function Yt(e,t,r=[]){if(Array.isArray(e))return e.map(o=>Yt(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>=Nv||!(o in t.components.schemas)?{$ref:n}:Yt(t.components.schemas[o],t,[...r,o])}let s={};for(let[o,a]of Object.entries(i))s[o]=Yt(a,t,r);return s}function Gv(e,t){return[...t,e]}function Fm(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 Bm(){return new va("--format <format>","output format").choices(["json","table"]).default("json")}function Dm(e){return Fm(e).addOption(Bm())}async function Lm(e){let t=await Cr({baseUrl:e.baseUrl,apiKey:e.apiKey,profile:e.profile});return{client:br({baseUrl:t.baseUrl,secretKey:t.apiKey,...e.storeId?{storeId:e.storeId}:{}}),credentials:t}}function Um(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(`
364
+ `)),Dm(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)",Gv,[]).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=Em(i),{client:o,credentials:a}=await Lm(i);n=a.baseUrl;let c=await o.request("GET",Pr(r),{params:s});Er(c,i.format)}catch(s){At(s,{baseUrl:n})}});for(let r of["post","patch","delete"])Dm(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 km(n.data),{client:a,credentials:c}=await Lm(n);s=c.baseUrl;let d=await a.request(r.toUpperCase(),Pr(i),{...o===Xo?{}:{body:o}});Er(d,n.format)}catch(o){At(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(Bm()).action(r=>{let i=Om(xn(),{resource:r.resource,search:r.search});if(i.length===0){process.stderr.write(`No endpoints match.
365
+ `),process.exitCode=1;return}if(r.format==="table"){(0,Mm.printTable)(i.map(n=>({Method:n.method,Path:n.path,Scope:n.scope,Summary:n.summary})));return}Er(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=jm(xn(),r);if(i.length===0){process.stderr.write(`No operation matches "${r}". Try \`spree api endpoints --search ${r.split(/\s+/).pop()}\`.
366
+ `),process.exitCode=1;return}let n=/\s/.test(r.trim());Er(n&&i.length===1?i[0]:i,"json")}),Fm(t.command("status").description("Show resolved credentials, server reachability, and the bundled spec version")).action(async r=>{try{let i=await Cr({baseUrl:r.baseUrl,apiKey:r.apiKey,profile:r.profile},{allowMint:!1}),n=await Tr(i.baseUrl,i.apiKey),s=xn(),o=wn(n),a=[`${Ae.default.bold("Base URL:")} ${i.baseUrl}`,`${Ae.default.bold("Credentials:")} ${i.source}${i.profileName?` (${i.profileName})`:""}, key ${i.tokenPrefix}${Ae.default.dim("\u2026")}`],c=n.status==="unreachable"||n.status==="unauthorized"?null:await Pm(i.baseUrl,i.apiKey);c!==null?a.push(`${Ae.default.bold("Scopes:")} ${c.length?c.join(", "):Ae.default.dim("(none)")}`):i.scopes?.length&&a.push(`${Ae.default.bold("Scopes:")} ${i.scopes.join(", ")} ${Ae.default.dim("(local snapshot from mint time \u2014 may be stale)")}`),a.push(`${Ae.default.bold("Server:")} ${o}`),a.push(`${Ae.default.bold("Bundled spec:")} ${s.info?.version??"unknown"} ${Ae.default.dim("(spree api endpoints/schema reflect this snapshot, not the live server)")}`),process.stdout.write(`${a.join(`
355
367
  `)}
356
- `),an(n)&&(process.exitCode=1)}catch(i){xt(i,{baseUrl:r.baseUrl})}})}var qm=G(Yt(),1),We=G(X(),1);function Sm(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=g(),n=r.name,s=r.type,o=r.scopes;if(!n){let m=await dt({message:"Key name:",placeholder:"My Storefront",validate(h){if(!h)return"Name is required"}});K(m)&&(F("Cancelled."),process.exit(0)),n=m}if(!s){let m=await ec({message:"Key type:",options:[{value:"publishable",label:"Publishable (for storefronts)"},{value:"secret",label:"Secret (for server-to-server)"}]});K(m)&&(F("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 dt({message:"Scopes (comma-separated):",placeholder:"read_all",initialValue:"read_all",validate(h){if(!h)return"Secret keys require at least one scope"}});K(m)&&(F("Cancelled."),process.exit(0)),o=m}let a=B();a.start("Creating API key...");let c=await ee("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=[`${We.default.bold("Name:")} ${n}`,`${We.default.bold("Type:")} ${s}`,`${We.default.bold("Token:")} ${We.default.cyan(u)}`];s==="secret"&&(l.push(`${We.default.bold("Scopes:")} ${o}`),l.push(""),l.push(We.default.yellow("Save this token now \u2014 secret keys cannot be retrieved later."))),Y(l.join(`
357
- `),"API Key")}),t.command("list").description("List API keys").action(async()=>{let r=g(),i=B();i.start("Fetching API keys...");let n=await ee("spree:cli:list_api_keys",r.projectDir);i.stop("");let s=n.trim().split(`
358
- `).filter(Boolean);if(s.length===0){C.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"?We.default.green(m):We.default.red(m??"")}});(0,qm.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=g(),n=B();n.start("Revoking API key...");let o=(await ee("spree:cli:revoke_api_key",i.projectDir,{ID:r})).trim();n.stop(`API key "${o}" revoked.`)})}var $m=G(Yt(),1),Q=G(X(),1);function Cm(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(`${Q.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\`).
359
- `),process.exit(2));let i=r.baseUrl;if(!i){let d=await dt({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://"}});K(d)&&(F("Cancelled."),process.exit(130)),i=d}i=i.replace(/\/$/,"");let n=await Vr({message:"Secret API key (sk_...):",validate(d){if(!d)return"Key is required";if(!d.startsWith("sk_"))return"Admin API keys start with sk_"}});K(n)&&(F("Cancelled."),process.exit(130));let s=n,o=B();o.start("Validating credentials...");let a=await xr(i,s);a.status==="unauthorized"&&(o.stop(Q.default.red("The server rejected this key (401). Check the key and try again.")),process.exit(2)),a.status==="unreachable"&&(o.stop(Q.default.red(`Could not reach ${i}: ${a.message}`)),process.exit(2)),o.stop(a.storeName?`Connected to ${Q.default.bold(a.storeName)}.`:"Credentials accepted (key lacks read_settings, so the store name is hidden \u2014 that is fine).");let c=fr();c.profiles[r.profile]={baseUrl:i,token:s},c.defaultProfile||=r.profile,Uo(c),Y([`${Q.default.bold("Profile:")} ${r.profile}${c.defaultProfile===r.profile?Q.default.dim(" (default)"):""}`,`${Q.default.bold("Base URL:")} ${i}`,`${Q.default.bold("Key:")} ${on(s)}${Q.default.dim("\u2026")}`,"",Q.default.dim(`Saved to ${bt()}`)].join(`
360
- `),"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 gr({profile:r.profile},{allowMint:!1})}catch(a){xt(a)}let n=B();n.start("Checking server...");let s=await xr(i.baseUrl,i.apiKey);n.stop("");let o=cn(s);Y([`${Q.default.bold("Source:")} ${i.source}${i.profileName?` (${i.profileName})`:""}`,`${Q.default.bold("Base URL:")} ${i.baseUrl}`,`${Q.default.bold("Key:")} ${i.tokenPrefix}${Q.default.dim("\u2026")}`,...i.scopes?[`${Q.default.bold("Scopes:")} ${i.scopes.join(", ")}`]:[],`${Q.default.bold("Server:")} ${o}`].join(`
361
- `),"Auth status"),an(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=g().projectDir}catch(o){xt(o)}(await import("fs")).rmSync(sn(n),{force:!0}),C.success("Removed project credentials. The next `spree api` call mints a fresh read-only key.");return}let i=fr();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(`${Q.default.red("error:")} no profile named "${r.profile}".${s}
362
- `),process.exit(2)}delete i.profiles[r.profile],i.defaultProfile===r.profile&&(i.defaultProfile=Object.keys(i.profiles)[0]),Uo(i),C.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=fr(),i=Object.keys(r.profiles);if(i.length===0){C.info("No profiles saved. Run `spree auth login` to add one.");return}(0,$m.printTable)(i.map(n=>({Profile:r.defaultProfile===n?`${n} *`:n,"Base URL":r.profiles[n].baseUrl,Key:`${on(r.profiles[n].token)}\u2026`})))})}import mv from"path";var nt=G(X(),1);function Am(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)").action(async t=>{let r=g();if(Se(r.projectDir)&&(F(["This project uses SPREE_PATH for monorepo development.",`Use ${nt.default.bold("pnpm server:build")} from the monorepo root instead of ${nt.default.bold("spree build")}.`,"It builds against the edge compose overlay the running stack was started with."].join(`
363
- `)),process.exit(1)),Or(r.projectDir)||(console.error(`
364
- ${nt.default.red("Error:")} docker-compose.yml has no \`build:\` section. Run ${nt.default.bold("spree eject")} first to switch to a build-from-source stack.
365
- `),process.exit(1)),t.resetBundle){if(!t.yes){let n=await pt({message:"Wipe the bundle_cache volume? Any gems added via `spree bundle add` since the last image build will be lost.",initialValue:!1});(K(n)||!n)&&(F("Build cancelled."),process.exit(0))}let i=B();i.start("Wiping bundle_cache volume...");try{await H(["down"],r.projectDir,{stdio:"ignore"});let s=`${await hv(r.projectDir)}_bundle_cache`;await yv(s,r.projectDir)?(await pe("docker",["volume","rm",s],{cwd:r.projectDir,stdio:"ignore"}),i.stop("bundle_cache volume wiped.")):i.stop(`bundle_cache volume not present (looked for ${s}).`)}catch(n){throw i.stop("Failed to wipe bundle_cache volume."),n}}console.log(`
366
- ${nt.default.bold("Rebuilding dev image...")}
367
- `),await H(["build","web","worker"],r.projectDir,{stdio:"inherit"}),Y([`Image rebuilt. Start the stack with ${nt.default.bold("spree dev")}.`,t.resetBundle?`On next boot, gems will re-seed into a fresh ${nt.default.dim("bundle_cache")} volume.`:""].filter(Boolean).join(`
368
- `),"Build complete")})}async function hv(e){try{let{stdout:t}=await pe("docker",["compose","config","--format","json"],{cwd:e}),r=JSON.parse(t);if(r.name)return r.name}catch{}return mv.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}async function yv(e,t){try{return await pe("docker",["volume","inspect",e],{cwd:t,stdio:"ignore"}),!0}catch{return!1}}function Em(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=g();await rt(["bundle",...t],r.projectDir,{edgeHint:"the edge stack heals gem drift on boot"})})}var Pm=["/admin_users","/allowed_origins","/api_keys","/auth","/categories","/channels","/custom_field_definitions","/customer_groups","/customers","/exports","/gift_card_batches","/gift_cards","/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 Tm=["bash","zsh","fish"],gv=["eq","not_eq","cont","not_cont","start","end","in","not_in","gt","gteq","lt","lteq","null","not_null","present","blank"],_v=["get","post","patch","delete","endpoints","schema","status"],bv=["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 xv(e){let[t,r,...i]=e,n=e[e.length-1]??"",s=e[e.length-2]??"";if(e.length<=1)return dn(["api","auth",...wv],n);if((s==="-q"||s==="--query")&&n.includes("_")&&!n.includes("=")){let o=n.slice(0,n.lastIndexOf("_")+1);return gv.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 dn(bv,o).map(c=>a+c)}if(t==="api"){if(e.length===2)return dn(_v,n);if(["get","post","patch","delete","schema"].includes(r)&&i.length<=1)return dn(Pm,n)}return[]}var wv=["api-key","dev","console","migrate"];function dn(e,t){return t?e.filter(r=>r.startsWith(t)):e}function kv(e){return e==="fish"?`# spree fish completion \u2014 eval "$(spree completion fish)"
368
+ `),bn(n)&&(process.exitCode=1)}catch(i){At(i,{baseUrl:r.baseUrl})}})}var Nm=U(qr(),1),Qe=U(Y(),1);function Gm(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 ue({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 Qr({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 ue({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=P();a.start("Creating API key...");let c=await ie("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=[`${Qe.default.bold("Name:")} ${n}`,`${Qe.default.bold("Type:")} ${s}`,`${Qe.default.bold("Token:")} ${Qe.default.cyan(u)}`];s==="secret"&&(l.push(`${Qe.default.bold("Scopes:")} ${o}`),l.push(""),l.push(Qe.default.yellow("Save this token now \u2014 secret keys cannot be retrieved later."))),W(l.join(`
369
+ `),"API Key")}),t.command("list").description("List API keys").action(async()=>{let r=_(),i=P();i.start("Fetching API keys...");let n=await ie("spree:cli:list_api_keys",r.projectDir);i.stop("");let s=n.trim().split(`
370
+ `).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"?Qe.default.green(m):Qe.default.red(m??"")}});(0,Nm.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=P();n.start("Revoking API key...");let o=(await ie("spree:cli:revoke_api_key",i.projectDir,{ID:r})).trim();n.stop(`API key "${o}" revoked.`)})}var zm=U(qr(),1),te=U(Y(),1);function Vm(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(`${te.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\`).
371
+ `),process.exit(2));let i=r.baseUrl;if(!i){let d=await ue({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 Zr({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=P();o.start("Validating credentials...");let a=await Tr(i,s);a.status==="unauthorized"&&(o.stop(te.default.red("The server rejected this key (401). Check the key and try again.")),process.exit(2)),a.status==="unreachable"&&(o.stop(te.default.red(`Could not reach ${i}: ${a.message}`)),process.exit(2)),o.stop(a.storeName?`Connected to ${te.default.bold(a.storeName)}.`:"Credentials accepted (key lacks read_settings, so the store name is hidden \u2014 that is fine).");let c=Ar();c.profiles[r.profile]={baseUrl:i,token:s},c.defaultProfile||=r.profile,ta(c),W([`${te.default.bold("Profile:")} ${r.profile}${c.defaultProfile===r.profile?te.default.dim(" (default)"):""}`,`${te.default.bold("Base URL:")} ${i}`,`${te.default.bold("Key:")} ${_n(s)}${te.default.dim("\u2026")}`,"",te.default.dim(`Saved to ${$t()}`)].join(`
372
+ `),"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 Cr({profile:r.profile},{allowMint:!1})}catch(a){At(a)}let n=P();n.start("Checking server...");let s=await Tr(i.baseUrl,i.apiKey);n.stop("");let o=wn(s);W([`${te.default.bold("Source:")} ${i.source}${i.profileName?` (${i.profileName})`:""}`,`${te.default.bold("Base URL:")} ${i.baseUrl}`,`${te.default.bold("Key:")} ${i.tokenPrefix}${te.default.dim("\u2026")}`,...i.scopes?[`${te.default.bold("Scopes:")} ${i.scopes.join(", ")}`]:[],`${te.default.bold("Server:")} ${o}`].join(`
373
+ `),"Auth status"),bn(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){At(o)}(await import("fs")).rmSync(gn(n),{force:!0}),b.success("Removed project credentials. The next `spree api` call mints a fresh read-only key.");return}let i=Ar();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(`${te.default.red("error:")} no profile named "${r.profile}".${s}
374
+ `),process.exit(2)}delete i.profiles[r.profile],i.defaultProfile===r.profile&&(i.defaultProfile=Object.keys(i.profiles)[0]),ta(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=Ar(),i=Object.keys(r.profiles);if(i.length===0){b.info("No profiles saved. Run `spree auth login` to add one.");return}(0,zm.printTable)(i.map(n=>({Profile:r.defaultProfile===n?`${n} *`:n,"Base URL":r.profiles[n].baseUrl,Key:`${_n(r.profiles[n].token)}\u2026`})))})}import Jt from"fs";import zv from"os";import mt from"path";var oe=U(Y(),1);function Wm(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 Hv(_().projectDir,t.tag);return}await Vv(t)})}async function Vv(e){let t=_();if(je(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${oe.default.bold("pnpm server:build")} from the monorepo root instead of ${oe.default.bold("spree build")}.`,"It builds against the edge compose overlay the running stack was started with."].join(`
375
+ `)),process.exit(1)),mn(t.projectDir)||(console.error(`
376
+ ${oe.default.red("Error:")} docker-compose.yml has no \`build:\` section. Run ${oe.default.bold("spree eject")} first to switch to a build-from-source stack.
377
+ `),process.exit(1)),e.resetBundle){if(!e.yes){let i=await Ve({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=P();r.start("Wiping bundle_cache volume...");try{await X(["down"],t.projectDir,{stdio:"ignore"});let n=`${await Kv(t.projectDir)}_bundle_cache`;await Yv(n,t.projectDir)?(await re("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(`
378
+ ${oe.default.bold("Rebuilding dev image...")}
379
+ `),await X(["build","web","worker"],t.projectDir,{stdio:"inherit"}),W([`Image rebuilt. Start the stack with ${oe.default.bold("spree dev")}.`,e.resetBundle?`On next boot, gems will re-seed into a fresh ${oe.default.dim("bundle_cache")} volume.`:""].filter(Boolean).join(`
380
+ `),"Build complete")}function Wv(e,t){let r=mt.join(e,"backend"),i=mt.join(r,"Dockerfile");if(!Jt.existsSync(i))throw new Error("No backend/Dockerfile found. Is this a create-spree-app project?");let n=t??`${mt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}-spree:latest`,s=["build",r,"-f",i,"-t",n],o=mt.join(e,"apps","dashboard");if(!Jt.existsSync(mt.join(o,"package.json")))return{args:s,imageTag:n,dashboard:"stock-or-none"};if(!Jt.readFileSync(i,"utf-8").includes("DASHBOARD_SOURCE"))return{args:s,imageTag:n,dashboard:"unsupported-dockerfile"};let a=Jt.mkdtempSync(mt.join(zv.tmpdir(),"spree-dashboard-src-"));return Jt.cpSync(o,a,{recursive:!0,filter:c=>{let d=mt.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 Hv(e,t){let r;try{r=Wv(e,t)}catch(i){console.error(`
381
+ ${oe.default.red("Error:")} ${i instanceof Error?i.message:String(i)}
382
+ `),process.exit(1)}r.dashboard==="custom"?b.info(`Including your dashboard from ${oe.default.bold("apps/dashboard/")} (built in-image).`):r.dashboard==="unsupported-dockerfile"&&b.warn(`${oe.default.bold("apps/dashboard/")} exists, but ${oe.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(`
383
+ ${oe.default.bold(`Building production image ${r.imageTag}...`)}
384
+ `);try{await re("docker",r.args,{cwd:e,stdio:"inherit"})}finally{r.stagedDashboardDir&&Jt.rmSync(r.stagedDashboardDir,{recursive:!0,force:!0})}W([`Run it: ${oe.default.cyan(`docker run --rm -p 3000:3000 ${r.imageTag}`)}`,`Push it: ${oe.default.cyan(`docker tag ${r.imageTag} <registry>/<repo> && docker push <registry>/<repo>`)}`,r.dashboard!=="unsupported-dockerfile"?`Dashboard: served at ${oe.default.bold("/dashboard")} when the image includes one.`:""].filter(Boolean).join(`
385
+ `),"Production image built")}async function Kv(e){try{let{stdout:t}=await re("docker",["compose","config","--format","json"],{cwd:e}),r=JSON.parse(t);if(r.name)return r.name}catch{}return mt.basename(e).toLowerCase().replace(/[^a-z0-9_-]/g,"")}async function Yv(e,t){try{return await re("docker",["volume","inspect",e],{cwd:t,stdio:"ignore"}),!0}catch{return!1}}function Hm(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 Km=["/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 Ym=["bash","zsh","fish"],Xv=["eq","not_eq","cont","not_cont","start","end","in","not_in","gt","gteq","lt","lteq","null","not_null","present","blank"],Zv=["get","post","patch","delete","endpoints","schema","status"],Qv=["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 eS(e){let[t,r,...i]=e,n=e[e.length-1]??"",s=e[e.length-2]??"";if(e.length<=1)return kn(["api","auth",...tS],n);if((s==="-q"||s==="--query")&&n.includes("_")&&!n.includes("=")){let o=n.slice(0,n.lastIndexOf("_")+1);return Xv.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 kn(Qv,o).map(c=>a+c)}if(t==="api"){if(e.length===2)return kn(Zv,n);if(["get","post","patch","delete","schema"].includes(r)&&i.length<=1)return kn(Km,n)}return[]}var tS=["api-key","dev","console","migrate"];function kn(e,t){return t?e.filter(r=>r.startsWith(t)):e}function rS(e){return e==="fish"?`# spree fish completion \u2014 eval "$(spree completion fish)"
369
386
  function __spree_complete
370
387
  set -l tokens (commandline -opc) (commandline -ct)
371
388
  spree __complete $tokens[2..-1]
@@ -384,37 +401,42 @@ _spree() {
384
401
  COMPREPLY=( $(spree __complete "\${words[@]}") )
385
402
  }
386
403
  complete -F _spree spree
387
- `}function Om(e){e.command("completion <shell>").description("Output a shell completion script (bash, zsh, or fish)").action(t=>{if(!Tm.includes(t)){process.stderr.write(`Unsupported shell "${t}". Choose one of: ${Tm.join(", ")}.
388
- `),process.exitCode=2;return}process.stdout.write(kv(t))}),e.command("__complete",{hidden:!0}).allowUnknownOption().argument("[words...]").action(t=>{for(let r of xv(t??[]))process.stdout.write(`${r}
389
- `)})}function Im(e){e.command("console").description("Open Rails console").action(async()=>{let t=g();await rt(["bin/rails","console"],t.projectDir,{edgeHint:"then open the console"})})}var ke=G(X(),1);var vv=["bin/rails","db:drop","db:create","spree:install:migrations","db:migrate","db:seed"];function Rm(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=g(),i=s=>{F(s.join(`
390
- `)),process.exit(1)};if(Se(r.projectDir)&&i(["This is a monorepo edge project (SPREE_PATH set in .env).",`Reset the dev database from the monorepo root with ${ke.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 pt({message:"This will drop the spree_development database. Continue?",initialValue:!1});(K(s)||!s)&&(F("Cancelled."),process.exit(0))}let n;try{let[s,o]=await Promise.all([_t("web",r.projectDir),_t("worker",r.projectDir)]);n=s||o}catch(s){return i(["Could not inspect the Docker stack from this directory.",` ${ke.default.dim(String(s.message).split(`
391
- `)[0])}`,"",`Run ${ke.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=B();s.start("Stopping web + worker to release database connections..."),await H(["stop","web","worker"],r.projectDir),s.stop("Stopped web + worker.")}try{await Mo(vv,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 ${ke.default.bold("5433")}.`,"Disconnect it, then re-run `spree db:reset`.",...n?["",`Bring the stack back up with ${ke.default.bold("spree dev")}.`]:[]]),s}C.success("Database reset."),n&&Y(`Bring the stack back up with ${ke.default.bold("spree dev")}.`,"Done")}),e.command("db:console").description("Open a psql session against the dev database").action(async()=>{let t=g(),r;try{r=await _t("postgres",t.projectDir)}catch(i){F(["Could not inspect the Docker stack from this directory.",` ${ke.default.dim(String(i.message).split(`
392
- `)[0])}`,"",`Run ${ke.default.bold("spree db:console")} from your project root, and make sure Docker is running.`].join(`
393
- `)),process.exit(1)}r||(F(["Postgres is not running.",`Start the stack with ${ke.default.bold("spree dev")}, then re-run ${ke.default.bold("spree db:console")}.`].join(`
394
- `)),process.exit(1)),await D(["psql","-U","postgres","spree_development"],t.projectDir,{service:"postgres"})})}import qv from"fs";import Sv from"path";var Oe=G(X(),1);function jm(e){e.command("dev").description("Run the app in the foreground \u2014 streams web + worker logs; Ctrl+C stops them").action(async()=>{let t=g();Se(t.projectDir)&&(F(["This project uses SPREE_PATH for monorepo development.",`Use ${Oe.default.bold("pnpm server:dev")} from the monorepo root instead of ${Oe.default.bold("spree dev")}.`,"It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source."].join(`
395
- `)),process.exit(1)),Y(["",Oe.default.bold("Admin Dashboard"),` ${Oe.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${Er}`,` Password: ${Pr}`,"",Oe.default.bold("Store API"),` ${Oe.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,""].join(`
396
- `),"Spree Commerce"),C.info(`Starting services \u2014 web + worker logs stream below. ${Oe.default.bold("Ctrl+C")} stops them (databases keep running; ${Oe.default.bold("spree stop")} shuts everything down).
397
- `);let r=()=>{};process.on("SIGINT",r);let i;try{if(await tt(t.projectDir),Or(t.projectDir)){let s=Sv.join(t.projectDir,"backend/app/assets/builds/spree/admin/application.css");if(!qv.existsSync(s)){let o=B();o.start("Compiling admin dashboard stylesheets...");try{await rn(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),C.info("Watching admin dashboard stylesheets \u2014 edits recompile live.")}catch{}}i=await H(["up","web","worker"],t.projectDir,{stdio:"inherit",reject:!1})}finally{process.off("SIGINT",r)}let n=i.exitCode??0;n!==0&&n!==130&&(F(`docker compose exited with code ${n} \u2014 see the output above.`),process.exit(n)),Za(`Web + worker stopped. Databases keep running \u2014 ${Oe.default.bold("spree stop")} shuts everything down.`)})}import wr from"fs";import zo from"path";var oe=G(X(),1);function Dm(e){e.command("eject").description("Switch to the dev compose: bind-mount ./backend with hot reload").action(async()=>{let t=g(),r=zo.join(t.projectDir,"backend");wr.existsSync(r)||(console.error(`
398
- ${oe.default.red("Error:")} No backend/ directory found.
399
- `),process.exit(1));let i=zo.join(t.projectDir,"docker-compose.dev.yml");wr.existsSync(i)||(console.error(`
400
- ${oe.default.red("Error:")} No docker-compose.dev.yml found.
401
- `),process.exit(1));let n=wr.readFileSync(i,"utf-8");n.includes("- .:/rails")&&(n=n.replace("- .:/rails","- ./backend:/rails"),wr.writeFileSync(i,n)),wr.writeFileSync(zo.join(t.projectDir,"docker-compose.yml"),n),console.log(`
402
- ${oe.default.bold("Switching to dev compose (bind-mounts ./backend)...")}
403
- `),await tt(t.projectDir),await H(["up","-d"],t.projectDir,{stdio:"inherit"}),console.log(`
404
- ${oe.default.bold("Preparing the development database...")}
405
- `),await D(["bin/rails","db:prepare"],t.projectDir,{tty:!1}),console.log(`
406
- ${oe.default.bold("Building admin dashboard stylesheets...")}
407
- `),await rn(t.projectDir),Y([`Backend is now bind-mounted from ${oe.default.bold("./backend")} \u2014 edits are live.`,"",`The dev stack uses its own ${oe.default.bold("spree_development")} database (just`,`created and seeded). Load demo products with ${oe.default.bold("spree sample-data")}.`,"","You can now customize:",` ${oe.default.dim("backend/app/")} \u2014 models, controllers, services (instant reload)`,` ${oe.default.dim("backend/config/")} \u2014 Rails configuration (instant reload)`,` ${oe.default.dim("backend/Gemfile")} \u2014 add gems via ${oe.default.bold("spree bundle add <gem>")}`,"",`Rebuild only on Dockerfile / .ruby-version changes: ${oe.default.bold("spree build")}`].join(`
408
- `),"Ejected!")})}function Lm(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=g();await D(t,r.projectDir)})}var $v=new Set(["migration","controller","scaffold","scaffold_controller","mailer","job","channel","helper","resource","integration_test","system_test","task","generator","benchmark"]);function Mm(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=g(),n=t.includes(":")||$v.has(t)?t:`spree:${t}`;await D(["bin/rails","g",n,...r],i.projectDir)})}import Vo from"fs";import{platform as Cv}from"os";import Av from"path";var Ie=G(X(),1);var Ev=3e3,Fm=12e4;function Bm(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=>{let r=g();C.step("Pulling latest images..."),await H(["pull"],r.projectDir,{stdio:"inherit"});let i=B();i.start("Starting Docker services..."),await tt(r.projectDir,{stdio:"ignore"}),await H(["up","-d"],r.projectDir),i.stop("Docker services started."),i.start("Waiting for Spree to be ready..."),await Pv(r.port),i.stop("Spree is ready."),i.start("Seeding database..."),await ee("db:seed",r.projectDir),i.stop("Database seeded."),i.start("Configuring API keys...");let n=await Tv(r.projectDir);Iv(r.projectDir,n);let s=await Ov(r.projectDir,r.port);i.stop("API keys configured."),t.sampleData&&(i.start("Loading sample data..."),await ee("spree:load_sample_data",r.projectDir),i.stop("Sample data loaded.")),i.start("Indexing products for search..."),await ee("spree:search:reindex",r.projectDir),i.stop("Search index ready."),Y(["",Ie.default.bold("Admin Dashboard"),` ${Ie.default.cyan(`http://localhost:${r.port}/admin`)}`,` Email: ${Er}`,` Password: ${Pr}`,"",Ie.default.bold("Store API"),` ${Ie.default.cyan(`http://localhost:${r.port}/api/v3/store`)}`,` Publishable key: ${Ie.default.cyan(n)}`,"",Ie.default.bold("Admin API"),` ${Ie.default.cyan(`http://localhost:${r.port}/api/v3/admin`)}`,` Secret key: ${Ie.default.cyan(s)}`,` ${Ie.default.dim("Saved to .spree/credentials.json")}`,""].join(`
409
- `),"Your Spree store is ready!"),t.open&&await Rv(`http://localhost:${r.port}/admin`),C.info(`Streaming logs (Ctrl+C to stop)...
410
- `),await nn("web",r.projectDir)})}async function Pv(e){let t=`http://localhost:${e}/up`,r=Date.now();for(;Date.now()-r<Fm;){try{if((await fetch(t)).ok)return}catch{}await new Promise(i=>setTimeout(i,Ev))}throw new Error(`Spree did not become healthy within ${Fm/1e3}s`)}async function Tv(e){let t=await ee("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 Ov(e,t){let{token:r}=await No(e,t,!0);return r}function Iv(e,t){let r=Av.join(e,"apps","storefront",".env.local");if(!Vo.existsSync(r))return;let i=Vo.readFileSync(r,"utf-8");Vo.writeFileSync(r,i.replace(/SPREE_PUBLISHABLE_KEY=.*/,`SPREE_PUBLISHABLE_KEY=${t}`))}async function Rv(e){let t=Cv(),r=t==="darwin"?"open":t==="win32"?"start":"xdg-open";try{await tn(`${r} ${e}`,{stdio:"ignore"})}catch{}}function Um(e){e.command("logs").description("Stream service logs").argument("[service]","service name (web or worker)","web").action(async t=>{let r=g();await nn(t,r.projectDir)})}var un=G(X(),1);function Nm(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=g();console.log(`
411
- ${un.default.bold("\u2192 Installing pending Spree migrations from gems...")}`),await D(["bin/rails","spree:install:migrations"],r.projectDir),console.log(`
412
- ${un.default.bold("\u2192 Running db:migrate...")}`),await D(["bin/rails","db:migrate",...t],r.projectDir),Y(`Run ${un.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=g();await D(["bin/rails","db:rollback",...t],r.projectDir)}),e.command("migrate:status").description("Show migration status (`bin/rails db:migrate:status`)").action(async()=>{let t=g();await D(["bin/rails","db:migrate:status"],t.projectDir)})}import{platform as jv}from"os";function Gm(e){e.command("open").description("Open the admin dashboard in the browser").action(async()=>{let r=`http://localhost:${g().port}/admin`,i=jv();await tn(`${i==="darwin"?"open":i==="win32"?"start":"xdg-open"} ${r}`)})}function zm(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=g();await D(["bin/rails",...t],r.projectDir)})}function Vm(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=g();await D(["bin/rake",...t],r.projectDir)})}function Wm(e){e.command("restart").description("Restart web + worker in place (does not reload Gemfile or compose changes)").action(async()=>{let t=g(),r=B();r.start("Restarting web + worker...");try{await H(["restart","web","worker"],t.projectDir),r.stop("Services restarted.")}catch(i){throw r.stop("Restart failed."),i}})}function Hm(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=g();await D(["bin/rails","routes",...t],r.projectDir)})}function Km(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=g();await rt(["bundle","exec","rspec",...t],r.projectDir,{env:{RAILS_ENV:"test"},edgeHint:"then re-run spree rspec"})})}function Ym(e){e.command("sample-data").description("Load sample data (products, categories, images)").action(async()=>{let t=g(),r=B();r.start("Loading sample data..."),await ee("spree:load_sample_data",t.projectDir),r.stop("Sample data loaded.")})}function Jm(e){e.command("seed").description("Seed the database").action(async()=>{let t=g(),r=B();r.start("Seeding database..."),await ee("db:seed",t.projectDir),r.stop("Database seeded.")})}function Xm(e){e.command("shell").alias("bash").description("Open an interactive bash shell inside the web container").action(async()=>{let t=g();await rt(["bash"],t.projectDir,{edgeHint:"then open the shell"})})}function Qm(e){e.command("stop").description("Stop services").action(async()=>{let t=g(),r=B();r.start("Stopping services..."),await H(["stop"],t.projectDir),r.stop("Services stopped.")})}function Zm(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=g();await D(["bin/rake",`spree:${t}`,...r],i.projectDir)})}function eh(e){e.command("update").description("Pull latest image and recreate containers").action(async()=>{let t=g();C.step("Pulling latest images..."),await H(["pull"],t.projectDir,{stdio:"inherit"});let r=B();r.start("Recreating containers..."),await tt(t.projectDir,{stdio:"ignore"}),await H(["up","-d"],t.projectDir),r.stop("Containers recreated."),C.success("Update complete! Migrations will run automatically on startup."),C.info("Run `spree logs` to follow the startup progress.")})}import th from"fs";import Dv from"path";var ne=G(X(),1);function rh(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=g();await Lv(r.projectDir),t.plan||t.step||(await Mv(r.projectDir,t),await Bv(r.projectDir,t)),await Uv(r.projectDir,t),t.plan||Gv(r.projectDir)})}async function Lv(e){let t=i=>{F(i.join(`
413
- `)),process.exit(1)};Se(e)&&t(["This is a monorepo edge project (SPREE_PATH set in .env).",`Run the upgrade from the monorepo root with ${ne.default.bold("pnpm server:*")} \u2014 the`,"project-local docker-compose.yml is not the running config here."]);let r;try{r=await _t("web",e)}catch(i){return t(["Could not inspect the Docker stack from this directory.",` ${ne.default.dim(String(i.message).split(`
414
- `)[0])}`,"",`Run ${ne.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 ${ne.default.bold("spree:upgrade")} rake against your live`,`database, so the stack must be up. Start it with ${ne.default.bold("spree dev")}, then`,"re-run `spree upgrade`."])}async function Mv(e,t){if(!t.yes){let i=await pt({message:"Run `bundle update` to bump Spree gems?",initialValue:!0});if(K(i)&&(F("Upgrade aborted."),process.exit(0)),!i){C.info("Skipping `bundle update`.");return}}let r=await Fv(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.');C.step(ne.default.bold(`bundle update ${r.join(" ")}`)),await D(["bundle","update",...r],e)}async function Fv(e){try{let{stdout:t}=await pe("docker",["compose","exec","-T","web","sh","-c","bundle list --name-only | grep '^spree'"],{cwd:e});return t.split(`
404
+ `}function Jm(e){e.command("completion <shell>").description("Output a shell completion script (bash, zsh, or fish)").action(t=>{if(!Ym.includes(t)){process.stderr.write(`Unsupported shell "${t}". Choose one of: ${Ym.join(", ")}.
405
+ `),process.exitCode=2;return}process.stdout.write(rS(t))}),e.command("__complete",{hidden:!0}).allowUnknownOption().argument("[words...]").action(t=>{for(let r of eS(t??[]))process.stdout.write(`${r}
406
+ `)})}function Xm(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 Ce=U(Y(),1);var iS=["bin/rails","db:drop","db:create","spree:install:migrations","db:migrate","db:seed"];function Zm(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(`
407
+ `)),process.exit(1)};if(je(r.projectDir)&&i(["This is a monorepo edge project (SPREE_PATH set in .env).",`Reset the dev database from the monorepo root with ${Ce.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 Ve({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([qt("web",r.projectDir),qt("worker",r.projectDir)]);n=s||o}catch(s){return i(["Could not inspect the Docker stack from this directory.",` ${Ce.default.dim(String(s.message).split(`
408
+ `)[0])}`,"",`Run ${Ce.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=P();s.start("Stopping web + worker to release database connections..."),await X(["stop","web","worker"],r.projectDir),s.stop("Stopped web + worker.")}try{await Zo(iS,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 ${Ce.default.bold("5433")}.`,"Disconnect it, then re-run `spree db:reset`.",...n?["",`Bring the stack back up with ${Ce.default.bold("spree dev")}.`]:[]]),s}b.success("Database reset."),n&&W(`Bring the stack back up with ${Ce.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 qt("postgres",t.projectDir)}catch(i){O(["Could not inspect the Docker stack from this directory.",` ${Ce.default.dim(String(i.message).split(`
409
+ `)[0])}`,"",`Run ${Ce.default.bold("spree db:console")} from your project root, and make sure Docker is running.`].join(`
410
+ `)),process.exit(1)}r||(O(["Postgres is not running.",`Start the stack with ${Ce.default.bold("spree dev")}, then re-run ${Ce.default.bold("spree db:console")}.`].join(`
411
+ `)),process.exit(1)),await F(["psql","-U","postgres","spree_development"],t.projectDir,{service:"postgres"})})}import nS from"fs";import sS from"path";var Me=U(Y(),1);function Qm(e){e.command("dev").description("Run the app in the foreground \u2014 streams web + worker logs; Ctrl+C stops them").action(async()=>{let t=_();je(t.projectDir)&&(O(["This project uses SPREE_PATH for monorepo development.",`Use ${Me.default.bold("pnpm server:dev")} from the monorepo root instead of ${Me.default.bold("spree dev")}.`,"It loads the edge compose overlay and sets SPREE_PATH so the Spree gems resolve to the monorepo source."].join(`
412
+ `)),process.exit(1)),W(["",Me.default.bold("Admin Dashboard"),` ${Me.default.cyan(`http://localhost:${t.port}/admin`)}`,` Email: ${dn}`,` Password: ${un}`,"",Me.default.bold("Store API"),` ${Me.default.cyan(`http://localhost:${t.port}/api/v3/store`)}`,""].join(`
413
+ `),"Spree Commerce"),b.info(`Starting services \u2014 web + worker logs stream below. ${Me.default.bold("Ctrl+C")} stops them (databases keep running; ${Me.default.bold("spree stop")} shuts everything down).
414
+ `);let r=()=>{};process.on("SIGINT",r);let i;try{if(await dt(t.projectDir),mn(t.projectDir)){let s=sS.join(t.projectDir,"backend/app/assets/builds/spree/admin/application.css");if(!nS.existsSync(s)){let o=P();o.start("Compiling admin dashboard stylesheets...");try{await yn(t.projectDir),o.stop("Admin dashboard stylesheets compiled.")}catch{o.stop("Could not compile admin dashboard stylesheets \u2014 admin pages may 500.")}}try{await Sm(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)),Ct(`Web + worker stopped. Databases keep running \u2014 ${Me.default.bold("spree stop")} shuts everything down.`)})}import Ir from"fs";import na from"path";var me=U(Y(),1);function eh(e){e.command("eject").description("Switch to the dev compose: bind-mount ./backend with hot reload").action(async()=>{let t=_(),r=na.join(t.projectDir,"backend");Ir.existsSync(r)||(console.error(`
415
+ ${me.default.red("Error:")} No backend/ directory found.
416
+ `),process.exit(1));let i=na.join(t.projectDir,"docker-compose.dev.yml");Ir.existsSync(i)||(console.error(`
417
+ ${me.default.red("Error:")} No docker-compose.dev.yml found.
418
+ `),process.exit(1));let n=Ir.readFileSync(i,"utf-8");n.includes("- .:/rails")&&(n=n.replace("- .:/rails","- ./backend:/rails"),Ir.writeFileSync(i,n)),Ir.writeFileSync(na.join(t.projectDir,"docker-compose.yml"),n),console.log(`
419
+ ${me.default.bold("Switching to dev compose (bind-mounts ./backend)...")}
420
+ `),await dt(t.projectDir),await X(["up","-d"],t.projectDir,{stdio:"inherit"}),console.log(`
421
+ ${me.default.bold("Preparing the development database...")}
422
+ `),await F(["bin/rails","db:prepare"],t.projectDir,{tty:!1}),console.log(`
423
+ ${me.default.bold("Building admin dashboard stylesheets...")}
424
+ `),await yn(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(`
425
+ `),"Ejected!")})}function th(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 oS=new Set(["migration","controller","scaffold","scaffold_controller","mailer","job","channel","helper","resource","integration_test","system_test","task","generator","benchmark"]);function rh(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(":")||oS.has(t)?t:`spree:${t}`;await F(["bin/rails","g",n,...r],i.projectDir)})}import sa from"fs";import{platform as aS}from"os";import cS from"path";var Fe=U(Y(),1);var pS=3e3,ih=12e4;function nh(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=>{let r=_();b.step("Pulling latest images..."),await X(["pull"],r.projectDir,{stdio:"inherit"});let i=P();i.start("Starting Docker services..."),await dt(r.projectDir,{stdio:"ignore"}),await X(["up","-d"],r.projectDir),i.stop("Docker services started."),i.start("Waiting for Spree to be ready..."),await dS(r.port),i.stop("Spree is ready."),i.start("Seeding database..."),await ie("db:seed",r.projectDir),i.stop("Database seeded."),i.start("Configuring API keys...");let n=await uS(r.projectDir);mS(r.projectDir,n);let s=await lS(r.projectDir,r.port);i.stop("API keys configured."),t.sampleData&&(i.start("Loading sample data..."),await ie("spree:load_sample_data",r.projectDir),i.stop("Sample data loaded.")),i.start("Indexing products for search..."),await ie("spree:search:reindex",r.projectDir),i.stop("Search index ready."),W(["",Fe.default.bold("Admin Dashboard"),` ${Fe.default.cyan(`http://localhost:${r.port}/admin`)}`,` Email: ${dn}`,` Password: ${un}`,"",Fe.default.bold("Store API"),` ${Fe.default.cyan(`http://localhost:${r.port}/api/v3/store`)}`,` Publishable key: ${Fe.default.cyan(n)}`,"",Fe.default.bold("Admin API"),` ${Fe.default.cyan(`http://localhost:${r.port}/api/v3/admin`)}`,` Secret key: ${Fe.default.cyan(s)}`,` ${Fe.default.dim("Saved to .spree/credentials.json")}`,""].join(`
426
+ `),"Your Spree store is ready!"),t.open&&await hS(`http://localhost:${r.port}/admin`),b.info(`Streaming logs (Ctrl+C to stop)...
427
+ `),await fn("web",r.projectDir)})}async function dS(e){let t=`http://localhost:${e}/up`,r=Date.now();for(;Date.now()-r<ih;){try{if((await fetch(t)).ok)return}catch{}await new Promise(i=>setTimeout(i,pS))}throw new Error(`Spree did not become healthy within ${ih/1e3}s`)}async function uS(e){let t=await ie("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 lS(e,t){let{token:r}=await ra(e,t,!0);return r}function mS(e,t){let r=cS.join(e,"apps","storefront",".env.local");if(!sa.existsSync(r))return;let i=sa.readFileSync(r,"utf-8");sa.writeFileSync(r,i.replace(/SPREE_PUBLISHABLE_KEY=.*/,`SPREE_PUBLISHABLE_KEY=${t}`))}async function hS(e){let t=aS(),r=t==="darwin"?"open":t==="win32"?"start":"xdg-open";try{await at(`${r} ${e}`,{stdio:"ignore"})}catch{}}function sh(e){e.command("logs").description("Stream service logs").argument("[service]","service name (web or worker)","web").action(async t=>{let r=_();await fn(t,r.projectDir)})}var vn=U(Y(),1);function oh(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(`
428
+ ${vn.default.bold("\u2192 Installing pending Spree migrations from gems...")}`),await F(["bin/rails","spree:install:migrations"],r.projectDir),console.log(`
429
+ ${vn.default.bold("\u2192 Running db:migrate...")}`),await F(["bin/rails","db:migrate",...t],r.projectDir),W(`Run ${vn.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 yS}from"os";function ah(e){e.command("open").description("Open the admin dashboard in the browser").action(async()=>{let r=`http://localhost:${_().port}/admin`,i=yS();await at(`${i==="darwin"?"open":i==="win32"?"start":"xdg-open"} ${r}`)})}import aa from"fs";import Zt from"path";import{fileURLToPath as fS}from"url";var z=U(Y(),1);import et from"fs";import Sn from"path";function ph(e){let{src:t,dst:r,vars:i,skip:n,force:s}=e;if(!et.existsSync(t))throw new Error(`Template source not found: ${t}`);if(et.existsSync(r)){if(et.readdirSync(r).length>0&&!s)throw new Error(`Destination ${r} is not empty. Pass force=true to overwrite.`)}else et.mkdirSync(r,{recursive:!0});dh(t,r,"",i,n)}function dh(e,t,r,i,n){let s=Sn.join(e,r);for(let o of et.readdirSync(s,{withFileTypes:!0})){let a=r?`${r}/${o.name}`:o.name;if(n?.(a))continue;let c=uh(oa(o.name,i)),d=Sn.join(e,a);if(o.isDirectory()){let h=r?`${ch(r,i)}/${c}`:c,f=Sn.join(t,h);et.mkdirSync(f,{recursive:!0}),dh(e,t,a,i,n);continue}let p=c.endsWith(".tt"),u=p?c.slice(0,-3):c,l=r?`${ch(r,i)}/${u}`:u,m=Sn.join(t,l);if(p){let h=et.readFileSync(d,"utf8");et.writeFileSync(m,oa(h,i))}else et.copyFileSync(d,m)}}function oa(e,t){return e.replace(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,(r,i)=>Object.hasOwn(t,i)?t[i]:r)}function ch(e,t){return e.split("/").map(r=>uh(oa(r,t))).join("/")}function uh(e){if(e.includes("/")||e.includes("\\")||e==="..")throw new Error(`Template variable produced an unsafe path segment: "${e}"`);return e}var gS="../../templates/plugin",qn=["MIT","Apache-2.0","BSD-3-Clause"];function mh(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: ${qn.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)=>{Xr(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=Zt.resolve(process.cwd(),n.name);aa.existsSync(s)&&aa.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=wS(n),a=qS(),c=P();c.start(`Scaffolding ${z.default.cyan(n.name)}...`);try{ph({src:a,dst:s,vars:o,skip:xS(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 kS(s,n):b.info(z.default.dim("Skipping dependency install \u2014 run them yourself when ready.")),vS(n,s,i.install),Ct("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 ue({message:"Plugin name",placeholder:"brands",validate:r});if(D(i))return i;let n=`spree_${i.replace(/-/g,"_")}`,s=await Xt({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:()=>ue({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=SS(s),a=await Xt({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:()=>ue({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 Xt({flag:"--npm-scope",flagValue:t.npmScope,fallback:"",yes:t.yes,validate:c,prompt:()=>ue({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 lh("user.name"):void 0,u=await Xt({flag:"--author",flagValue:t.author,fallback:p,yes:t.yes,validate:g=>g?void 0:"Required",prompt:()=>ue({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 lh("user.email"):void 0,h=await Xt({flag:"--author-email",flagValue:t.authorEmail,fallback:m,yes:t.yes,validate:l,prompt:()=>ue({message:"Author email",placeholder:"jane@example.com",initialValue:m??"",validate:l})});if(D(h))return h;let f=g=>g&&qn.includes(g)?void 0:`Must be one of: ${qn.join(", ")}`,x=await Xt({flag:"--license",flagValue:t.license,fallback:"MIT",yes:t.yes,validate:f,prompt:()=>Qr({message:"License",options:qn.map(g=>({value:g,label:g})),initialValue:"MIT"})});if(D(x))return x;let w=t.dashboard===!1?!1:t.yes||await bS("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 bS(e,t){return await Ve({message:e,initialValue:t})}async function Xt(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 lh(e){try{let{stdout:t}=await at(`git config --get ${e}`);return t.trim()||void 0}catch{return}}function wS(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 xS(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 kS(e,t){let r=P();if(t.includeDashboard){r.start("Running pnpm install...");try{await at("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 at("bundle install",{cwd:Zt.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 vS(e,t,r){let i=[""];i.push(z.default.bold("Next steps")),i.push(` ${z.default.dim("cd")} ${Zt.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(`
430
+ `),"Your plugin is scaffolded.")}function SS(e){return e.split(/[_-]/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function qS(){let e=Zt.dirname(fS(import.meta.url)),t=[Zt.resolve(e,gS),Zt.resolve(e,"templates/plugin")];for(let r of t)if(aa.existsSync(r))return r;throw new Error(`Plugin template not found. Looked in:
431
+ ${t.join(`
432
+ `)}
433
+
434
+ Reinstall @spree/cli to fix.`)}function hh(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 yh(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 fh(e){e.command("restart").description("Restart web + worker in place (does not reload Gemfile or compose changes)").action(async()=>{let t=_(),r=P();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 gh(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 _h(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 bh(e){e.command("sample-data").description("Load sample data (products, categories, images)").action(async()=>{let t=_(),r=P();r.start("Loading sample data..."),await ie("spree:load_sample_data",t.projectDir),r.stop("Sample data loaded.")})}function wh(e){e.command("seed").description("Seed the database").action(async()=>{let t=_(),r=P();r.start("Seeding database..."),await ie("db:seed",t.projectDir),r.stop("Database seeded.")})}function xh(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 kh(e){e.command("stop").description("Stop services").action(async()=>{let t=_(),r=P();r.start("Stopping services..."),await X(["stop"],t.projectDir),r.stop("Services stopped.")})}function vh(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 Sh(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=P();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 qh from"fs";import $S from"path";var pe=U(Y(),1);function $h(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 AS(r.projectDir),t.plan||t.step||(await CS(r.projectDir,t),await PS(r.projectDir,t)),await TS(r.projectDir,t),t.plan||RS(r.projectDir)})}async function AS(e){let t=i=>{O(i.join(`
435
+ `)),process.exit(1)};je(e)&&t(["This is a monorepo edge project (SPREE_PATH set in .env).",`Run the upgrade from the monorepo root with ${pe.default.bold("pnpm server:*")} \u2014 the`,"project-local docker-compose.yml is not the running config here."]);let r;try{r=await qt("web",e)}catch(i){return t(["Could not inspect the Docker stack from this directory.",` ${pe.default.dim(String(i.message).split(`
436
+ `)[0])}`,"",`Run ${pe.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 ${pe.default.bold("spree:upgrade")} rake against your live`,`database, so the stack must be up. Start it with ${pe.default.bold("spree dev")}, then`,"re-run `spree upgrade`."])}async function CS(e,t){if(!t.yes){let i=await Ve({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 ES(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(pe.default.bold(`bundle update ${r.join(" ")}`)),await F(["bundle","update",...r],e)}async function ES(e){try{let{stdout:t}=await re("docker",["compose","exec","-T","web","sh","-c","bundle list --name-only | grep '^spree'"],{cwd:e});return t.split(`
415
437
  `).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()?`
416
438
 
417
- ${r.stderr.trim()}`:""))}}async function Bv(e,t){if(!t.yes){let r=await pt({message:"Install + run pending migrations?",initialValue:!0});if(K(r)&&(F("Upgrade aborted."),process.exit(0)),!r){C.info("Skipping migrations.");return}}C.step(ne.default.bold("spree:install:migrations + db:migrate")),await D(["bin/rails","spree:install:migrations","db:migrate"],e)}async function Uv(e,t){let r={};t.plan&&(r.DRY_RUN="1"),t.step&&(r.STEP=t.step),t.to&&(r.TO=t.to),C.step(ne.default.bold("spree:upgrade")),await D(["bin/rake","spree:upgrade"],e,{env:r})}function Nv(e){let t="Update @spree/sdk in any storefront or integration consuming the API",r=Dv.join(e,"apps","storefront","package.json");if(!th.existsSync(r))return t;try{let i=JSON.parse(th.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 Gv(e){Y([`The manifest only ran ${ne.default.bold("rake-automatable")} steps.`,"","Don't forget the manual parts from the upgrade doc:",` ${ne.default.dim("- Schedule Spree::StockReservations::ExpireJob (cron)")}`,` ${ne.default.dim(`- ${Nv(e)}`)}`,` ${ne.default.dim("- Review behavior changes (cart, availability, payment-method types)")}`,` ${ne.default.dim("- Audit custom decorators against renamed APIs")}`,"",`Full checklist: ${ne.default.cyan("https://spreecommerce.org/docs/developer/upgrades")}`].join(`
418
- `),"Next steps")}var ih=G(X(),1);function nh(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=g(),n=r.email,s=r.password;if(!n){let a=await dt({message:"Admin email:",placeholder:"admin@example.com",validate(c){if(!c)return"Email is required";if(!c.includes("@"))return"Invalid email"}});K(a)&&(F("Cancelled."),process.exit(0)),n=a}if(!s){let a=await Vr({message:"Admin password:",validate(c){if(!c||c.length<6)return"Password must be at least 6 characters"}});K(a)&&(F("Cancelled."),process.exit(0)),s=a}let o=B();o.start("Creating admin user..."),await ee("spree:cli:create_admin",i.projectDir,{EMAIL:n,PASSWORD:s}),o.stop("Admin user created."),C.success(`Email: ${ih.default.cyan(n)}`)})}import{createRequire as zv}from"module";var Vv=zv(import.meta.url),sh=Vv("../package.json").version;var I=new oa().name("spree").description("CLI for managing Spree Commerce projects").version(sh).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)});Bm(I);jm(I);Qm(I);Wm(I);eh(I);Um(I);Dm(I);Am(I);Mm(I);Nm(I);Rm(I);Hm(I);rh(I);Lm(I);zm(I);Em(I);Vm(I);Zm(I);Km(I);Im(I);Xm(I);nh(I);Sm(I);Gm(I);Jm(I);Ym(I);vm(I);Cm(I);Om(I);async function Wv(){try{await I.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(`
419
- ${oh.default.red("Error:")} ${r}
420
- `),process.exit(t)}}Wv();
439
+ ${r.stderr.trim()}`:""))}}async function PS(e,t){if(!t.yes){let r=await Ve({message:"Install + run pending migrations?",initialValue:!0});if(D(r)&&(O("Upgrade aborted."),process.exit(0)),!r){b.info("Skipping migrations.");return}}b.step(pe.default.bold("spree:install:migrations + db:migrate")),await F(["bin/rails","spree:install:migrations","db:migrate"],e)}async function TS(e,t){let r={};t.plan&&(r.DRY_RUN="1"),t.step&&(r.STEP=t.step),t.to&&(r.TO=t.to),b.step(pe.default.bold("spree:upgrade")),await F(["bin/rake","spree:upgrade"],e,{env:r})}function IS(e){let t="Update @spree/sdk in any storefront or integration consuming the API",r=$S.join(e,"apps","storefront","package.json");if(!qh.existsSync(r))return t;try{let i=JSON.parse(qh.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 RS(e){W([`The manifest only ran ${pe.default.bold("rake-automatable")} steps.`,"","Don't forget the manual parts from the upgrade doc:",` ${pe.default.dim("- Schedule Spree::StockReservations::ExpireJob (cron)")}`,` ${pe.default.dim(`- ${IS(e)}`)}`,` ${pe.default.dim("- Review behavior changes (cart, availability, payment-method types)")}`,` ${pe.default.dim("- Audit custom decorators against renamed APIs")}`,"",`Full checklist: ${pe.default.cyan("https://spreecommerce.org/docs/developer/upgrades")}`].join(`
440
+ `),"Next steps")}var Ah=U(Y(),1);function Ch(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 ue({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 Zr({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=P();o.start("Creating admin user..."),await ie("spree:cli:create_admin",i.projectDir,{EMAIL:n,PASSWORD:s}),o.stop("Admin user created."),b.success(`Email: ${Ah.default.cyan(n)}`)})}import{createRequire as OS}from"module";var jS=OS(import.meta.url),Eh=jS("../package.json").version;var T=new ka().name("spree").description("CLI for managing Spree Commerce projects").version(Eh).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)});nh(T);em(T);Qm(T);kh(T);fh(T);Sh(T);sh(T);eh(T);Wm(T);rh(T);oh(T);Zm(T);gh(T);$h(T);th(T);hh(T);Hm(T);yh(T);vh(T);_h(T);Xm(T);xh(T);Ch(T);Gm(T);ah(T);wh(T);bh(T);mh(T);Um(T);Vm(T);Jm(T);async function DS(){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(`
441
+ ${Ph.default.red("Error:")} ${r}
442
+ `),process.exit(t)}}DS();