storybook 9.0.0-alpha.1 → 9.0.0-alpha.11

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 (267) hide show
  1. package/README.md +31 -29
  2. package/assets/browser/favicon.svg +1 -0
  3. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  4. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  5. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  6. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  7. package/assets/docs/addon-controls-args-annotated.png +0 -0
  8. package/assets/docs/addon-controls-args-background-color.png +0 -0
  9. package/assets/docs/addon-controls-args-background-string.png +0 -0
  10. package/assets/docs/addon-controls-args-docs.png +0 -0
  11. package/assets/docs/addon-controls-args-logging.png +0 -0
  12. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  13. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  14. package/assets/docs/addon-controls-args-reflow.png +0 -0
  15. package/assets/docs/addon-controls-args-template.png +0 -0
  16. package/assets/docs/addon-controls-expanded.png +0 -0
  17. package/assets/docs/addon-controls-hero.gif +0 -0
  18. package/assets/docs/addon-controls-install.png +0 -0
  19. package/assets/docs/hero.gif +0 -0
  20. package/assets/docs/message-reference.png +0 -0
  21. package/assets/docs/viewport.png +0 -0
  22. package/assets/server/addon.tsconfig.json +6 -0
  23. package/assets/server/base-preview-body.html +119 -0
  24. package/assets/server/base-preview-head.html +451 -0
  25. package/assets/server/template.ejs +87 -0
  26. package/bin/index.cjs +1 -1
  27. package/dist/actions/decorator.d.ts +6 -0
  28. package/dist/actions/decorator.js +139 -0
  29. package/dist/actions/index.cjs +127 -0
  30. package/dist/actions/index.d.ts +105 -0
  31. package/dist/actions/index.js +112 -0
  32. package/dist/actions/manager.js +1196 -0
  33. package/dist/actions/preview.cjs +165 -0
  34. package/dist/actions/preview.d.ts +55 -0
  35. package/dist/actions/preview.js +156 -0
  36. package/dist/babel/index.cjs +54034 -0
  37. package/dist/babel/index.d.ts +7488 -0
  38. package/dist/babel/index.js +54044 -0
  39. package/dist/bin/index.cjs +118 -0
  40. package/dist/bin/index.js +112 -0
  41. package/dist/builder-manager/index.cjs +2140 -0
  42. package/dist/builder-manager/index.d.ts +19 -0
  43. package/dist/builder-manager/index.js +2162 -0
  44. package/dist/channels/index.cjs +1913 -0
  45. package/dist/channels/index.d.ts +108 -0
  46. package/dist/channels/index.js +1881 -0
  47. package/dist/cli/bin/index.cjs +2687 -0
  48. package/dist/cli/bin/index.d.ts +2 -0
  49. package/dist/cli/bin/index.js +2707 -0
  50. package/dist/cli/index.cjs +17327 -0
  51. package/dist/cli/index.d.ts +209 -0
  52. package/dist/cli/index.js +17349 -0
  53. package/dist/client-logger/index.cjs +80 -0
  54. package/dist/client-logger/index.d.ts +29 -0
  55. package/dist/client-logger/index.js +64 -0
  56. package/dist/common/index.cjs +20568 -0
  57. package/dist/common/index.d.ts +948 -0
  58. package/dist/common/index.js +20653 -0
  59. package/dist/component-testing/index.cjs +23 -0
  60. package/dist/component-testing/index.d.ts +3 -0
  61. package/dist/component-testing/index.js +5 -0
  62. package/dist/component-testing/manager.css +170 -0
  63. package/dist/component-testing/manager.js +3099 -0
  64. package/dist/component-testing/preview.cjs +40 -0
  65. package/dist/component-testing/preview.d.ts +5 -0
  66. package/dist/component-testing/preview.js +25 -0
  67. package/dist/components/index.cjs +27925 -0
  68. package/dist/components/index.d.ts +1423 -0
  69. package/dist/components/index.js +24674 -0
  70. package/dist/controls/decorator.d.ts +5 -0
  71. package/dist/controls/decorator.js +8 -0
  72. package/dist/controls/index.cjs +26 -0
  73. package/dist/controls/index.d.ts +39 -0
  74. package/dist/controls/index.js +6 -0
  75. package/dist/controls/manager.js +5545 -0
  76. package/dist/controls/preview.cjs +26 -0
  77. package/dist/controls/preview.d.ts +55 -0
  78. package/dist/controls/preview.js +9 -0
  79. package/dist/core-events/index.cjs +167 -0
  80. package/dist/core-events/index.d.ts +426 -0
  81. package/dist/core-events/index.js +149 -0
  82. package/dist/core-server/index.cjs +38183 -0
  83. package/dist/core-server/index.d.ts +720 -0
  84. package/dist/core-server/index.js +38272 -0
  85. package/dist/core-server/presets/common-manager.js +20 -0
  86. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  87. package/dist/core-server/presets/common-override-preset.js +4829 -0
  88. package/dist/core-server/presets/common-preset.cjs +10231 -0
  89. package/dist/core-server/presets/common-preset.js +10309 -0
  90. package/dist/csf/index.cjs +179 -0
  91. package/dist/csf/index.d.ts +750 -0
  92. package/dist/csf/index.js +172 -0
  93. package/dist/csf-tools/index.cjs +1422 -0
  94. package/dist/csf-tools/index.d.ts +250 -0
  95. package/dist/csf-tools/index.js +1439 -0
  96. package/dist/docs-tools/index.cjs +2891 -0
  97. package/dist/docs-tools/index.d.ts +162 -0
  98. package/dist/docs-tools/index.js +2876 -0
  99. package/dist/index.cjs +17 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.js +2 -7
  102. package/dist/instrumenter/index.cjs +3492 -0
  103. package/dist/instrumenter/index.d.ts +104 -0
  104. package/dist/instrumenter/index.js +4964 -0
  105. package/dist/manager/globals-module-info.cjs +817 -0
  106. package/dist/manager/globals-module-info.d.ts +36 -0
  107. package/dist/manager/globals-module-info.js +804 -0
  108. package/dist/manager/globals-runtime.js +83389 -0
  109. package/dist/manager/globals.cjs +47 -0
  110. package/dist/manager/globals.d.ts +24 -0
  111. package/dist/manager/globals.js +34 -0
  112. package/dist/manager/runtime.js +12323 -0
  113. package/dist/manager-api/index.cjs +11074 -0
  114. package/dist/manager-api/index.d.ts +1512 -0
  115. package/dist/manager-api/index.js +4835 -0
  116. package/dist/manager-errors.d.ts +89 -0
  117. package/dist/manager-errors.js +99 -0
  118. package/dist/node-logger/index.cjs +1642 -0
  119. package/dist/node-logger/index.d.ts +117 -0
  120. package/dist/node-logger/index.js +1652 -0
  121. package/dist/preview/globals.cjs +38 -0
  122. package/dist/preview/globals.d.ts +15 -0
  123. package/dist/preview/globals.js +25 -0
  124. package/dist/preview/runtime.js +44921 -0
  125. package/dist/preview-api/index.cjs +5227 -0
  126. package/dist/preview-api/index.d.ts +1093 -0
  127. package/dist/preview-api/index.js +5295 -0
  128. package/dist/preview-errors.cjs +503 -0
  129. package/dist/preview-errors.d.ts +212 -0
  130. package/dist/preview-errors.js +449 -0
  131. package/dist/router/index.cjs +3296 -0
  132. package/dist/router/index.d.ts +385 -0
  133. package/dist/router/index.js +1843 -0
  134. package/dist/server-errors.cjs +727 -0
  135. package/dist/server-errors.d.ts +296 -0
  136. package/dist/server-errors.js +728 -0
  137. package/dist/telemetry/index.cjs +2756 -0
  138. package/dist/telemetry/index.d.ts +133 -0
  139. package/dist/telemetry/index.js +2797 -0
  140. package/dist/test/index.cjs +35685 -0
  141. package/dist/test/index.d.ts +186 -0
  142. package/dist/test/index.js +33751 -0
  143. package/dist/test/preview.cjs +15869 -0
  144. package/dist/test/preview.d.ts +54 -0
  145. package/dist/test/preview.js +14440 -0
  146. package/dist/test/spy.cjs +257 -0
  147. package/dist/test/spy.d.ts +66 -0
  148. package/dist/test/spy.js +239 -0
  149. package/dist/theming/create.cjs +232 -0
  150. package/dist/theming/create.d.ts +50 -0
  151. package/dist/theming/create.js +216 -0
  152. package/dist/theming/index.cjs +2665 -0
  153. package/dist/theming/index.d.ts +11939 -0
  154. package/dist/theming/index.js +2485 -0
  155. package/dist/types/index.cjs +27 -0
  156. package/dist/types/index.d.ts +2795 -0
  157. package/dist/types/index.js +7 -0
  158. package/dist/viewport/index.cjs +310 -0
  159. package/dist/viewport/index.d.ts +320 -0
  160. package/dist/viewport/index.js +290 -0
  161. package/dist/viewport/manager.js +400 -0
  162. package/dist/viewport/preview.cjs +35 -0
  163. package/dist/viewport/preview.d.ts +69 -0
  164. package/dist/viewport/preview.js +19 -0
  165. package/package.json +539 -209
  166. package/.eslintrc.cjs +0 -31
  167. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  168. package/core/babel/index.cjs +0 -1
  169. package/core/babel/index.d.ts +0 -2
  170. package/core/babel/index.js +0 -1
  171. package/core/builder-manager/index.cjs +0 -1
  172. package/core/builder-manager/index.d.ts +0 -2
  173. package/core/builder-manager/index.js +0 -1
  174. package/core/channels/index.cjs +0 -1
  175. package/core/channels/index.d.ts +0 -2
  176. package/core/channels/index.js +0 -1
  177. package/core/cli/bin/index.cjs +0 -1
  178. package/core/cli/bin/index.d.ts +0 -2
  179. package/core/cli/bin/index.js +0 -1
  180. package/core/cli/index.cjs +0 -1
  181. package/core/cli/index.d.ts +0 -2
  182. package/core/cli/index.js +0 -1
  183. package/core/client-logger/index.cjs +0 -1
  184. package/core/client-logger/index.d.ts +0 -2
  185. package/core/client-logger/index.js +0 -1
  186. package/core/common/index.cjs +0 -1
  187. package/core/common/index.d.ts +0 -2
  188. package/core/common/index.js +0 -1
  189. package/core/components/index.cjs +0 -1
  190. package/core/components/index.d.ts +0 -2
  191. package/core/components/index.js +0 -1
  192. package/core/core-events/index.cjs +0 -1
  193. package/core/core-events/index.d.ts +0 -2
  194. package/core/core-events/index.js +0 -1
  195. package/core/core-server/index.cjs +0 -1
  196. package/core/core-server/index.d.ts +0 -2
  197. package/core/core-server/index.js +0 -1
  198. package/core/core-server/presets/common-manager.js +0 -1
  199. package/core/core-server/presets/common-override-preset.cjs +0 -1
  200. package/core/core-server/presets/common-override-preset.js +0 -1
  201. package/core/core-server/presets/common-preset.cjs +0 -1
  202. package/core/core-server/presets/common-preset.js +0 -1
  203. package/core/csf/index.cjs +0 -1
  204. package/core/csf/index.d.ts +0 -2
  205. package/core/csf/index.js +0 -1
  206. package/core/csf-tools/index.cjs +0 -1
  207. package/core/csf-tools/index.d.ts +0 -2
  208. package/core/csf-tools/index.js +0 -1
  209. package/core/docs-tools/index.cjs +0 -1
  210. package/core/docs-tools/index.d.ts +0 -2
  211. package/core/docs-tools/index.js +0 -1
  212. package/core/index.cjs +0 -1
  213. package/core/index.d.ts +0 -2
  214. package/core/index.js +0 -1
  215. package/core/manager/globals-module-info.cjs +0 -1
  216. package/core/manager/globals-module-info.d.ts +0 -2
  217. package/core/manager/globals-module-info.js +0 -1
  218. package/core/manager/globals-runtime.js +0 -1
  219. package/core/manager/globals.cjs +0 -1
  220. package/core/manager/globals.d.ts +0 -2
  221. package/core/manager/globals.js +0 -1
  222. package/core/manager-api/index.cjs +0 -1
  223. package/core/manager-api/index.d.ts +0 -2
  224. package/core/manager-api/index.js +0 -1
  225. package/core/manager-errors.d.ts +0 -2
  226. package/core/manager-errors.js +0 -1
  227. package/core/node-logger/index.cjs +0 -1
  228. package/core/node-logger/index.d.ts +0 -2
  229. package/core/node-logger/index.js +0 -1
  230. package/core/preview/globals.cjs +0 -1
  231. package/core/preview/globals.d.ts +0 -2
  232. package/core/preview/globals.js +0 -1
  233. package/core/preview/runtime.js +0 -1
  234. package/core/preview-api/index.cjs +0 -1
  235. package/core/preview-api/index.d.ts +0 -2
  236. package/core/preview-api/index.js +0 -1
  237. package/core/preview-errors.cjs +0 -1
  238. package/core/preview-errors.d.ts +0 -2
  239. package/core/preview-errors.js +0 -1
  240. package/core/router/index.cjs +0 -1
  241. package/core/router/index.d.ts +0 -2
  242. package/core/router/index.js +0 -1
  243. package/core/server-errors.cjs +0 -1
  244. package/core/server-errors.d.ts +0 -2
  245. package/core/server-errors.js +0 -1
  246. package/core/telemetry/index.cjs +0 -1
  247. package/core/telemetry/index.d.ts +0 -2
  248. package/core/telemetry/index.js +0 -1
  249. package/core/theming/create.cjs +0 -1
  250. package/core/theming/create.d.ts +0 -2
  251. package/core/theming/create.js +0 -1
  252. package/core/theming/index.cjs +0 -1
  253. package/core/theming/index.d.ts +0 -2
  254. package/core/theming/index.js +0 -1
  255. package/core/types/index.cjs +0 -1
  256. package/core/types/index.d.ts +0 -2
  257. package/core/types/index.js +0 -1
  258. package/core.cjs +0 -0
  259. package/core.d.ts +0 -0
  260. package/core.js +0 -1
  261. package/dist/chunk-OWLSIX54.js +0 -8
  262. package/dist/core-path.cjs +0 -1
  263. package/dist/core-path.d.ts +0 -3
  264. package/dist/core-path.js +0 -9
  265. package/dist/proxy.cjs +0 -1
  266. package/dist/proxy.d.ts +0 -2
  267. package/dist/proxy.js +0 -9
@@ -0,0 +1,2707 @@
1
+ import ESM_COMPAT_Module from "node:module";
2
+ import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
3
+ import { dirname as ESM_COMPAT_dirname } from 'node:path';
4
+ const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
5
+ const __dirname = ESM_COMPAT_dirname(__filename);
6
+ const require = ESM_COMPAT_Module.createRequire(import.meta.url);
7
+ var Ve = Object.create;
8
+ var N = Object.defineProperty;
9
+ var He = Object.getOwnPropertyDescriptor;
10
+ var De = Object.getOwnPropertyNames;
11
+ var Pe = Object.getPrototypeOf, Ie = Object.prototype.hasOwnProperty;
12
+ var d = (n, e) => N(n, "name", { value: e, configurable: !0 }), C = /* @__PURE__ */ ((n) => typeof require < "u" ? require : typeof Proxy < "\
13
+ u" ? new Proxy(n, {
14
+ get: (e, t) => (typeof require < "u" ? require : e)[t]
15
+ }) : n)(function(n) {
16
+ if (typeof require < "u") return require.apply(this, arguments);
17
+ throw Error('Dynamic require of "' + n + '" is not supported');
18
+ });
19
+ var b = (n, e) => () => (e || n((e = { exports: {} }).exports, e), e.exports);
20
+ var Ne = (n, e, t, i) => {
21
+ if (e && typeof e == "object" || typeof e == "function")
22
+ for (let s of De(e))
23
+ !Ie.call(n, s) && s !== t && N(n, s, { get: () => e[s], enumerable: !(i = He(e, s)) || i.enumerable });
24
+ return n;
25
+ };
26
+ var $ = (n, e, t) => (t = n != null ? Ve(Pe(n)) : {}, Ne(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ e || !n || !n.__esModule ? N(t, "default", { value: n, enumerable: !0 }) : t,
32
+ n
33
+ ));
34
+
35
+ // ../node_modules/commander/lib/error.js
36
+ var j = b((F) => {
37
+ var q = class extends Error {
38
+ static {
39
+ d(this, "CommanderError");
40
+ }
41
+ /**
42
+ * Constructs the CommanderError class
43
+ * @param {number} exitCode suggested exit code which could be used with process.exit
44
+ * @param {string} code an id string representing the error
45
+ * @param {string} message human-readable description of the error
46
+ */
47
+ constructor(e, t, i) {
48
+ super(i), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name, this.code = t, this.exitCode = e, this.nestedError =
49
+ void 0;
50
+ }
51
+ }, T = class extends q {
52
+ static {
53
+ d(this, "InvalidArgumentError");
54
+ }
55
+ /**
56
+ * Constructs the InvalidArgumentError class
57
+ * @param {string} [message] explanation of why argument is invalid
58
+ */
59
+ constructor(e) {
60
+ super(1, "commander.invalidArgument", e), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name;
61
+ }
62
+ };
63
+ F.CommanderError = q;
64
+ F.InvalidArgumentError = T;
65
+ });
66
+
67
+ // ../node_modules/commander/lib/argument.js
68
+ var V = b((M) => {
69
+ var { InvalidArgumentError: Te } = j(), B = class {
70
+ static {
71
+ d(this, "Argument");
72
+ }
73
+ /**
74
+ * Initialize a new command argument with the given name and description.
75
+ * The default is that the argument is required, and you can explicitly
76
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
77
+ *
78
+ * @param {string} name
79
+ * @param {string} [description]
80
+ */
81
+ constructor(e, t) {
82
+ switch (this.description = t || "", this.variadic = !1, this.parseArg = void 0, this.defaultValue = void 0, this.defaultValueDescription =
83
+ void 0, this.argChoices = void 0, e[0]) {
84
+ case "<":
85
+ this.required = !0, this._name = e.slice(1, -1);
86
+ break;
87
+ case "[":
88
+ this.required = !1, this._name = e.slice(1, -1);
89
+ break;
90
+ default:
91
+ this.required = !0, this._name = e;
92
+ break;
93
+ }
94
+ this._name.length > 3 && this._name.slice(-3) === "..." && (this.variadic = !0, this._name = this._name.slice(0, -3));
95
+ }
96
+ /**
97
+ * Return argument name.
98
+ *
99
+ * @return {string}
100
+ */
101
+ name() {
102
+ return this._name;
103
+ }
104
+ /**
105
+ * @package
106
+ */
107
+ _concatValue(e, t) {
108
+ return t === this.defaultValue || !Array.isArray(t) ? [e] : t.concat(e);
109
+ }
110
+ /**
111
+ * Set the default value, and optionally supply the description to be displayed in the help.
112
+ *
113
+ * @param {*} value
114
+ * @param {string} [description]
115
+ * @return {Argument}
116
+ */
117
+ default(e, t) {
118
+ return this.defaultValue = e, this.defaultValueDescription = t, this;
119
+ }
120
+ /**
121
+ * Set the custom handler for processing CLI command arguments into argument values.
122
+ *
123
+ * @param {Function} [fn]
124
+ * @return {Argument}
125
+ */
126
+ argParser(e) {
127
+ return this.parseArg = e, this;
128
+ }
129
+ /**
130
+ * Only allow argument value to be one of choices.
131
+ *
132
+ * @param {string[]} values
133
+ * @return {Argument}
134
+ */
135
+ choices(e) {
136
+ return this.argChoices = e.slice(), this.parseArg = (t, i) => {
137
+ if (!this.argChoices.includes(t))
138
+ throw new Te(
139
+ `Allowed choices are ${this.argChoices.join(", ")}.`
140
+ );
141
+ return this.variadic ? this._concatValue(t, i) : t;
142
+ }, this;
143
+ }
144
+ /**
145
+ * Make argument required.
146
+ *
147
+ * @returns {Argument}
148
+ */
149
+ argRequired() {
150
+ return this.required = !0, this;
151
+ }
152
+ /**
153
+ * Make argument optional.
154
+ *
155
+ * @returns {Argument}
156
+ */
157
+ argOptional() {
158
+ return this.required = !1, this;
159
+ }
160
+ };
161
+ function Fe(n) {
162
+ let e = n.name() + (n.variadic === !0 ? "..." : "");
163
+ return n.required ? "<" + e + ">" : "[" + e + "]";
164
+ }
165
+ d(Fe, "humanReadableArgName");
166
+ M.Argument = B;
167
+ M.humanReadableArgName = Fe;
168
+ });
169
+
170
+ // ../node_modules/commander/lib/help.js
171
+ var W = b((ae) => {
172
+ var { humanReadableArgName: Be } = V(), L = class {
173
+ static {
174
+ d(this, "Help");
175
+ }
176
+ constructor() {
177
+ this.helpWidth = void 0, this.sortSubcommands = !1, this.sortOptions = !1, this.showGlobalOptions = !1;
178
+ }
179
+ /**
180
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
181
+ *
182
+ * @param {Command} cmd
183
+ * @returns {Command[]}
184
+ */
185
+ visibleCommands(e) {
186
+ let t = e.commands.filter((s) => !s._hidden), i = e._getHelpCommand();
187
+ return i && !i._hidden && t.push(i), this.sortSubcommands && t.sort((s, r) => s.name().localeCompare(r.name())), t;
188
+ }
189
+ /**
190
+ * Compare options for sort.
191
+ *
192
+ * @param {Option} a
193
+ * @param {Option} b
194
+ * @returns {number}
195
+ */
196
+ compareOptions(e, t) {
197
+ let i = /* @__PURE__ */ d((s) => s.short ? s.short.replace(/^-/, "") : s.long.replace(/^--/, ""), "getSortKey");
198
+ return i(e).localeCompare(i(t));
199
+ }
200
+ /**
201
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
202
+ *
203
+ * @param {Command} cmd
204
+ * @returns {Option[]}
205
+ */
206
+ visibleOptions(e) {
207
+ let t = e.options.filter((s) => !s.hidden), i = e._getHelpOption();
208
+ if (i && !i.hidden) {
209
+ let s = i.short && e._findOption(i.short), r = i.long && e._findOption(i.long);
210
+ !s && !r ? t.push(i) : i.long && !r ? t.push(
211
+ e.createOption(i.long, i.description)
212
+ ) : i.short && !s && t.push(
213
+ e.createOption(i.short, i.description)
214
+ );
215
+ }
216
+ return this.sortOptions && t.sort(this.compareOptions), t;
217
+ }
218
+ /**
219
+ * Get an array of the visible global options. (Not including help.)
220
+ *
221
+ * @param {Command} cmd
222
+ * @returns {Option[]}
223
+ */
224
+ visibleGlobalOptions(e) {
225
+ if (!this.showGlobalOptions) return [];
226
+ let t = [];
227
+ for (let i = e.parent; i; i = i.parent) {
228
+ let s = i.options.filter(
229
+ (r) => !r.hidden
230
+ );
231
+ t.push(...s);
232
+ }
233
+ return this.sortOptions && t.sort(this.compareOptions), t;
234
+ }
235
+ /**
236
+ * Get an array of the arguments if any have a description.
237
+ *
238
+ * @param {Command} cmd
239
+ * @returns {Argument[]}
240
+ */
241
+ visibleArguments(e) {
242
+ return e._argsDescription && e.registeredArguments.forEach((t) => {
243
+ t.description = t.description || e._argsDescription[t.name()] || "";
244
+ }), e.registeredArguments.find((t) => t.description) ? e.registeredArguments : [];
245
+ }
246
+ /**
247
+ * Get the command term to show in the list of subcommands.
248
+ *
249
+ * @param {Command} cmd
250
+ * @returns {string}
251
+ */
252
+ subcommandTerm(e) {
253
+ let t = e.registeredArguments.map((i) => Be(i)).join(" ");
254
+ return e._name + (e._aliases[0] ? "|" + e._aliases[0] : "") + (e.options.length ? " [options]" : "") + // simplistic check for non-help option
255
+ (t ? " " + t : "");
256
+ }
257
+ /**
258
+ * Get the option term to show in the list of options.
259
+ *
260
+ * @param {Option} option
261
+ * @returns {string}
262
+ */
263
+ optionTerm(e) {
264
+ return e.flags;
265
+ }
266
+ /**
267
+ * Get the argument term to show in the list of arguments.
268
+ *
269
+ * @param {Argument} argument
270
+ * @returns {string}
271
+ */
272
+ argumentTerm(e) {
273
+ return e.name();
274
+ }
275
+ /**
276
+ * Get the longest command term length.
277
+ *
278
+ * @param {Command} cmd
279
+ * @param {Help} helper
280
+ * @returns {number}
281
+ */
282
+ longestSubcommandTermLength(e, t) {
283
+ return t.visibleCommands(e).reduce((i, s) => Math.max(i, t.subcommandTerm(s).length), 0);
284
+ }
285
+ /**
286
+ * Get the longest option term length.
287
+ *
288
+ * @param {Command} cmd
289
+ * @param {Help} helper
290
+ * @returns {number}
291
+ */
292
+ longestOptionTermLength(e, t) {
293
+ return t.visibleOptions(e).reduce((i, s) => Math.max(i, t.optionTerm(s).length), 0);
294
+ }
295
+ /**
296
+ * Get the longest global option term length.
297
+ *
298
+ * @param {Command} cmd
299
+ * @param {Help} helper
300
+ * @returns {number}
301
+ */
302
+ longestGlobalOptionTermLength(e, t) {
303
+ return t.visibleGlobalOptions(e).reduce((i, s) => Math.max(i, t.optionTerm(s).length), 0);
304
+ }
305
+ /**
306
+ * Get the longest argument term length.
307
+ *
308
+ * @param {Command} cmd
309
+ * @param {Help} helper
310
+ * @returns {number}
311
+ */
312
+ longestArgumentTermLength(e, t) {
313
+ return t.visibleArguments(e).reduce((i, s) => Math.max(i, t.argumentTerm(s).length), 0);
314
+ }
315
+ /**
316
+ * Get the command usage to be displayed at the top of the built-in help.
317
+ *
318
+ * @param {Command} cmd
319
+ * @returns {string}
320
+ */
321
+ commandUsage(e) {
322
+ let t = e._name;
323
+ e._aliases[0] && (t = t + "|" + e._aliases[0]);
324
+ let i = "";
325
+ for (let s = e.parent; s; s = s.parent)
326
+ i = s.name() + " " + i;
327
+ return i + t + " " + e.usage();
328
+ }
329
+ /**
330
+ * Get the description for the command.
331
+ *
332
+ * @param {Command} cmd
333
+ * @returns {string}
334
+ */
335
+ commandDescription(e) {
336
+ return e.description();
337
+ }
338
+ /**
339
+ * Get the subcommand summary to show in the list of subcommands.
340
+ * (Fallback to description for backwards compatibility.)
341
+ *
342
+ * @param {Command} cmd
343
+ * @returns {string}
344
+ */
345
+ subcommandDescription(e) {
346
+ return e.summary() || e.description();
347
+ }
348
+ /**
349
+ * Get the option description to show in the list of options.
350
+ *
351
+ * @param {Option} option
352
+ * @return {string}
353
+ */
354
+ optionDescription(e) {
355
+ let t = [];
356
+ return e.argChoices && t.push(
357
+ // use stringify to match the display of the default value
358
+ `choices: ${e.argChoices.map((i) => JSON.stringify(i)).join(", ")}`
359
+ ), e.defaultValue !== void 0 && (e.required || e.optional || e.isBoolean() && typeof e.defaultValue == "boolean") && t.push(
360
+ `default: ${e.defaultValueDescription || JSON.stringify(e.defaultValue)}`
361
+ ), e.presetArg !== void 0 && e.optional && t.push(`preset: ${JSON.stringify(e.presetArg)}`), e.envVar !== void 0 && t.push(`env: ${e.envVar}`),
362
+ t.length > 0 ? `${e.description} (${t.join(", ")})` : e.description;
363
+ }
364
+ /**
365
+ * Get the argument description to show in the list of arguments.
366
+ *
367
+ * @param {Argument} argument
368
+ * @return {string}
369
+ */
370
+ argumentDescription(e) {
371
+ let t = [];
372
+ if (e.argChoices && t.push(
373
+ // use stringify to match the display of the default value
374
+ `choices: ${e.argChoices.map((i) => JSON.stringify(i)).join(", ")}`
375
+ ), e.defaultValue !== void 0 && t.push(
376
+ `default: ${e.defaultValueDescription || JSON.stringify(e.defaultValue)}`
377
+ ), t.length > 0) {
378
+ let i = `(${t.join(", ")})`;
379
+ return e.description ? `${e.description} ${i}` : i;
380
+ }
381
+ return e.description;
382
+ }
383
+ /**
384
+ * Generate the built-in help text.
385
+ *
386
+ * @param {Command} cmd
387
+ * @param {Help} helper
388
+ * @returns {string}
389
+ */
390
+ formatHelp(e, t) {
391
+ let i = t.padWidth(e, t), s = t.helpWidth || 80, r = 2, o = 2;
392
+ function l(f, y) {
393
+ if (y) {
394
+ let I = `${f.padEnd(i + o)}${y}`;
395
+ return t.wrap(
396
+ I,
397
+ s - r,
398
+ i + o
399
+ );
400
+ }
401
+ return f;
402
+ }
403
+ d(l, "formatItem");
404
+ function a(f) {
405
+ return f.join(`
406
+ `).replace(/^/gm, " ".repeat(r));
407
+ }
408
+ d(a, "formatList");
409
+ let c = [`Usage: ${t.commandUsage(e)}`, ""], p = t.commandDescription(e);
410
+ p.length > 0 && (c = c.concat([
411
+ t.wrap(p, s, 0),
412
+ ""
413
+ ]));
414
+ let u = t.visibleArguments(e).map((f) => l(
415
+ t.argumentTerm(f),
416
+ t.argumentDescription(f)
417
+ ));
418
+ u.length > 0 && (c = c.concat(["Arguments:", a(u), ""]));
419
+ let m = t.visibleOptions(e).map((f) => l(
420
+ t.optionTerm(f),
421
+ t.optionDescription(f)
422
+ ));
423
+ if (m.length > 0 && (c = c.concat(["Options:", a(m), ""])), this.showGlobalOptions) {
424
+ let f = t.visibleGlobalOptions(e).map((y) => l(
425
+ t.optionTerm(y),
426
+ t.optionDescription(y)
427
+ ));
428
+ f.length > 0 && (c = c.concat([
429
+ "Global Options:",
430
+ a(f),
431
+ ""
432
+ ]));
433
+ }
434
+ let x = t.visibleCommands(e).map((f) => l(
435
+ t.subcommandTerm(f),
436
+ t.subcommandDescription(f)
437
+ ));
438
+ return x.length > 0 && (c = c.concat(["Commands:", a(x), ""])), c.join(`
439
+ `);
440
+ }
441
+ /**
442
+ * Calculate the pad width from the maximum term length.
443
+ *
444
+ * @param {Command} cmd
445
+ * @param {Help} helper
446
+ * @returns {number}
447
+ */
448
+ padWidth(e, t) {
449
+ return Math.max(
450
+ t.longestOptionTermLength(e, t),
451
+ t.longestGlobalOptionTermLength(e, t),
452
+ t.longestSubcommandTermLength(e, t),
453
+ t.longestArgumentTermLength(e, t)
454
+ );
455
+ }
456
+ /**
457
+ * Wrap the given string to width characters per line, with lines after the first indented.
458
+ * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
459
+ *
460
+ * @param {string} str
461
+ * @param {number} width
462
+ * @param {number} indent
463
+ * @param {number} [minColumnWidth=40]
464
+ * @return {string}
465
+ *
466
+ */
467
+ wrap(e, t, i, s = 40) {
468
+ let r = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF", o = new RegExp(`[\\n][${r}]+`);
469
+ if (e.match(o)) return e;
470
+ let l = t - i;
471
+ if (l < s) return e;
472
+ let a = e.slice(0, i), c = e.slice(i).replace(`\r
473
+ `, `
474
+ `), p = " ".repeat(i), m = "\\s\u200B", x = new RegExp(
475
+ `
476
+ |.{1,${l - 1}}([${m}]|$)|[^${m}]+?([${m}]|$)`,
477
+ "g"
478
+ ), f = c.match(x) || [];
479
+ return a + f.map((y, I) => y === `
480
+ ` ? "" : (I > 0 ? p : "") + y.trimEnd()).join(`
481
+ `);
482
+ }
483
+ };
484
+ ae.Help = L;
485
+ });
486
+
487
+ // ../node_modules/commander/lib/option.js
488
+ var J = b((U) => {
489
+ var { InvalidArgumentError: Me } = j(), R = class {
490
+ static {
491
+ d(this, "Option");
492
+ }
493
+ /**
494
+ * Initialize a new `Option` with the given `flags` and `description`.
495
+ *
496
+ * @param {string} flags
497
+ * @param {string} [description]
498
+ */
499
+ constructor(e, t) {
500
+ this.flags = e, this.description = t || "", this.required = e.includes("<"), this.optional = e.includes("["), this.variadic = /\w\.\.\.[>\]]$/.
501
+ test(e), this.mandatory = !1;
502
+ let i = We(e);
503
+ this.short = i.shortFlag, this.long = i.longFlag, this.negate = !1, this.long && (this.negate = this.long.startsWith("--no-")), this.defaultValue =
504
+ void 0, this.defaultValueDescription = void 0, this.presetArg = void 0, this.envVar = void 0, this.parseArg = void 0, this.hidden = !1,
505
+ this.argChoices = void 0, this.conflictsWith = [], this.implied = void 0;
506
+ }
507
+ /**
508
+ * Set the default value, and optionally supply the description to be displayed in the help.
509
+ *
510
+ * @param {*} value
511
+ * @param {string} [description]
512
+ * @return {Option}
513
+ */
514
+ default(e, t) {
515
+ return this.defaultValue = e, this.defaultValueDescription = t, this;
516
+ }
517
+ /**
518
+ * Preset to use when option used without option-argument, especially optional but also boolean and negated.
519
+ * The custom processing (parseArg) is called.
520
+ *
521
+ * @example
522
+ * new Option('--color').default('GREYSCALE').preset('RGB');
523
+ * new Option('--donate [amount]').preset('20').argParser(parseFloat);
524
+ *
525
+ * @param {*} arg
526
+ * @return {Option}
527
+ */
528
+ preset(e) {
529
+ return this.presetArg = e, this;
530
+ }
531
+ /**
532
+ * Add option name(s) that conflict with this option.
533
+ * An error will be displayed if conflicting options are found during parsing.
534
+ *
535
+ * @example
536
+ * new Option('--rgb').conflicts('cmyk');
537
+ * new Option('--js').conflicts(['ts', 'jsx']);
538
+ *
539
+ * @param {(string | string[])} names
540
+ * @return {Option}
541
+ */
542
+ conflicts(e) {
543
+ return this.conflictsWith = this.conflictsWith.concat(e), this;
544
+ }
545
+ /**
546
+ * Specify implied option values for when this option is set and the implied options are not.
547
+ *
548
+ * The custom processing (parseArg) is not called on the implied values.
549
+ *
550
+ * @example
551
+ * program
552
+ * .addOption(new Option('--log', 'write logging information to file'))
553
+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
554
+ *
555
+ * @param {object} impliedOptionValues
556
+ * @return {Option}
557
+ */
558
+ implies(e) {
559
+ let t = e;
560
+ return typeof e == "string" && (t = { [e]: !0 }), this.implied = Object.assign(this.implied || {}, t), this;
561
+ }
562
+ /**
563
+ * Set environment variable to check for option value.
564
+ *
565
+ * An environment variable is only used if when processed the current option value is
566
+ * undefined, or the source of the current value is 'default' or 'config' or 'env'.
567
+ *
568
+ * @param {string} name
569
+ * @return {Option}
570
+ */
571
+ env(e) {
572
+ return this.envVar = e, this;
573
+ }
574
+ /**
575
+ * Set the custom handler for processing CLI option arguments into option values.
576
+ *
577
+ * @param {Function} [fn]
578
+ * @return {Option}
579
+ */
580
+ argParser(e) {
581
+ return this.parseArg = e, this;
582
+ }
583
+ /**
584
+ * Whether the option is mandatory and must have a value after parsing.
585
+ *
586
+ * @param {boolean} [mandatory=true]
587
+ * @return {Option}
588
+ */
589
+ makeOptionMandatory(e = !0) {
590
+ return this.mandatory = !!e, this;
591
+ }
592
+ /**
593
+ * Hide option in help.
594
+ *
595
+ * @param {boolean} [hide=true]
596
+ * @return {Option}
597
+ */
598
+ hideHelp(e = !0) {
599
+ return this.hidden = !!e, this;
600
+ }
601
+ /**
602
+ * @package
603
+ */
604
+ _concatValue(e, t) {
605
+ return t === this.defaultValue || !Array.isArray(t) ? [e] : t.concat(e);
606
+ }
607
+ /**
608
+ * Only allow option value to be one of choices.
609
+ *
610
+ * @param {string[]} values
611
+ * @return {Option}
612
+ */
613
+ choices(e) {
614
+ return this.argChoices = e.slice(), this.parseArg = (t, i) => {
615
+ if (!this.argChoices.includes(t))
616
+ throw new Me(
617
+ `Allowed choices are ${this.argChoices.join(", ")}.`
618
+ );
619
+ return this.variadic ? this._concatValue(t, i) : t;
620
+ }, this;
621
+ }
622
+ /**
623
+ * Return option name.
624
+ *
625
+ * @return {string}
626
+ */
627
+ name() {
628
+ return this.long ? this.long.replace(/^--/, "") : this.short.replace(/^-/, "");
629
+ }
630
+ /**
631
+ * Return option name, in a camelcase format that can be used
632
+ * as a object attribute key.
633
+ *
634
+ * @return {string}
635
+ */
636
+ attributeName() {
637
+ return Le(this.name().replace(/^no-/, ""));
638
+ }
639
+ /**
640
+ * Check if `arg` matches the short or long flag.
641
+ *
642
+ * @param {string} arg
643
+ * @return {boolean}
644
+ * @package
645
+ */
646
+ is(e) {
647
+ return this.short === e || this.long === e;
648
+ }
649
+ /**
650
+ * Return whether a boolean option.
651
+ *
652
+ * Options are one of boolean, negated, required argument, or optional argument.
653
+ *
654
+ * @return {boolean}
655
+ * @package
656
+ */
657
+ isBoolean() {
658
+ return !this.required && !this.optional && !this.negate;
659
+ }
660
+ }, G = class {
661
+ static {
662
+ d(this, "DualOptions");
663
+ }
664
+ /**
665
+ * @param {Option[]} options
666
+ */
667
+ constructor(e) {
668
+ this.positiveOptions = /* @__PURE__ */ new Map(), this.negativeOptions = /* @__PURE__ */ new Map(), this.dualOptions = /* @__PURE__ */ new Set(),
669
+ e.forEach((t) => {
670
+ t.negate ? this.negativeOptions.set(t.attributeName(), t) : this.positiveOptions.set(t.attributeName(), t);
671
+ }), this.negativeOptions.forEach((t, i) => {
672
+ this.positiveOptions.has(i) && this.dualOptions.add(i);
673
+ });
674
+ }
675
+ /**
676
+ * Did the value come from the option, and not from possible matching dual option?
677
+ *
678
+ * @param {*} value
679
+ * @param {Option} option
680
+ * @returns {boolean}
681
+ */
682
+ valueFromOption(e, t) {
683
+ let i = t.attributeName();
684
+ if (!this.dualOptions.has(i)) return !0;
685
+ let s = this.negativeOptions.get(i).presetArg, r = s !== void 0 ? s : !1;
686
+ return t.negate === (r === e);
687
+ }
688
+ };
689
+ function Le(n) {
690
+ return n.split("-").reduce((e, t) => e + t[0].toUpperCase() + t.slice(1));
691
+ }
692
+ d(Le, "camelcase");
693
+ function We(n) {
694
+ let e, t, i = n.split(/[ |,]+/);
695
+ return i.length > 1 && !/^[[<]/.test(i[1]) && (e = i.shift()), t = i.shift(), !e && /^-[^-]$/.test(t) && (e = t, t = void 0), { shortFlag: e,
696
+ longFlag: t };
697
+ }
698
+ d(We, "splitOptionFlags");
699
+ U.Option = R;
700
+ U.DualOptions = G;
701
+ });
702
+
703
+ // ../node_modules/commander/lib/suggestSimilar.js
704
+ var de = b((le) => {
705
+ function Re(n, e) {
706
+ if (Math.abs(n.length - e.length) > 3)
707
+ return Math.max(n.length, e.length);
708
+ let t = [];
709
+ for (let i = 0; i <= n.length; i++)
710
+ t[i] = [i];
711
+ for (let i = 0; i <= e.length; i++)
712
+ t[0][i] = i;
713
+ for (let i = 1; i <= e.length; i++)
714
+ for (let s = 1; s <= n.length; s++) {
715
+ let r = 1;
716
+ n[s - 1] === e[i - 1] ? r = 0 : r = 1, t[s][i] = Math.min(
717
+ t[s - 1][i] + 1,
718
+ // deletion
719
+ t[s][i - 1] + 1,
720
+ // insertion
721
+ t[s - 1][i - 1] + r
722
+ // substitution
723
+ ), s > 1 && i > 1 && n[s - 1] === e[i - 2] && n[s - 2] === e[i - 1] && (t[s][i] = Math.min(t[s][i], t[s - 2][i - 2] + 1));
724
+ }
725
+ return t[n.length][e.length];
726
+ }
727
+ d(Re, "editDistance");
728
+ function Ge(n, e) {
729
+ if (!e || e.length === 0) return "";
730
+ e = Array.from(new Set(e));
731
+ let t = n.startsWith("--");
732
+ t && (n = n.slice(2), e = e.map((o) => o.slice(2)));
733
+ let i = [], s = 3, r = 0.4;
734
+ return e.forEach((o) => {
735
+ if (o.length <= 1) return;
736
+ let l = Re(n, o), a = Math.max(n.length, o.length);
737
+ (a - l) / a > r && (l < s ? (s = l, i = [o]) : l === s && i.push(o));
738
+ }), i.sort((o, l) => o.localeCompare(l)), t && (i = i.map((o) => `--${o}`)), i.length > 1 ? `
739
+ (Did you mean one of ${i.join(", ")}?)` : i.length === 1 ? `
740
+ (Did you mean ${i[0]}?)` : "";
741
+ }
742
+ d(Ge, "suggestSimilar");
743
+ le.suggestSimilar = Ge;
744
+ });
745
+
746
+ // ../node_modules/commander/lib/command.js
747
+ var me = b((he) => {
748
+ var Ue = C("node:events").EventEmitter, Y = C("node:child_process"), _ = C("node:path"), z = C("node:fs"), h = C("node:process"), { Argument: Je,
749
+ humanReadableArgName: Ye } = V(), { CommanderError: K } = j(), { Help: ze } = W(), { Option: ce, DualOptions: Ke } = J(), { suggestSimilar: pe } = de(),
750
+ Q = class n extends Ue {
751
+ static {
752
+ d(this, "Command");
753
+ }
754
+ /**
755
+ * Initialize a new `Command`.
756
+ *
757
+ * @param {string} [name]
758
+ */
759
+ constructor(e) {
760
+ super(), this.commands = [], this.options = [], this.parent = null, this._allowUnknownOption = !1, this._allowExcessArguments = !0, this.
761
+ registeredArguments = [], this._args = this.registeredArguments, this.args = [], this.rawArgs = [], this.processedArgs = [], this._scriptPath =
762
+ null, this._name = e || "", this._optionValues = {}, this._optionValueSources = {}, this._storeOptionsAsProperties = !1, this._actionHandler =
763
+ null, this._executableHandler = !1, this._executableFile = null, this._executableDir = null, this._defaultCommandName = null, this._exitCallback =
764
+ null, this._aliases = [], this._combineFlagAndOptionalValue = !0, this._description = "", this._summary = "", this._argsDescription = void 0,
765
+ this._enablePositionalOptions = !1, this._passThroughOptions = !1, this._lifeCycleHooks = {}, this._showHelpAfterError = !1, this._showSuggestionAfterError =
766
+ !0, this._outputConfiguration = {
767
+ writeOut: /* @__PURE__ */ d((t) => h.stdout.write(t), "writeOut"),
768
+ writeErr: /* @__PURE__ */ d((t) => h.stderr.write(t), "writeErr"),
769
+ getOutHelpWidth: /* @__PURE__ */ d(() => h.stdout.isTTY ? h.stdout.columns : void 0, "getOutHelpWidth"),
770
+ getErrHelpWidth: /* @__PURE__ */ d(() => h.stderr.isTTY ? h.stderr.columns : void 0, "getErrHelpWidth"),
771
+ outputError: /* @__PURE__ */ d((t, i) => i(t), "outputError")
772
+ }, this._hidden = !1, this._helpOption = void 0, this._addImplicitHelpCommand = void 0, this._helpCommand = void 0, this._helpConfiguration =
773
+ {};
774
+ }
775
+ /**
776
+ * Copy settings that are useful to have in common across root command and subcommands.
777
+ *
778
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
779
+ *
780
+ * @param {Command} sourceCommand
781
+ * @return {Command} `this` command for chaining
782
+ */
783
+ copyInheritedSettings(e) {
784
+ return this._outputConfiguration = e._outputConfiguration, this._helpOption = e._helpOption, this._helpCommand = e._helpCommand, this.
785
+ _helpConfiguration = e._helpConfiguration, this._exitCallback = e._exitCallback, this._storeOptionsAsProperties = e._storeOptionsAsProperties,
786
+ this._combineFlagAndOptionalValue = e._combineFlagAndOptionalValue, this._allowExcessArguments = e._allowExcessArguments, this._enablePositionalOptions =
787
+ e._enablePositionalOptions, this._showHelpAfterError = e._showHelpAfterError, this._showSuggestionAfterError = e._showSuggestionAfterError,
788
+ this;
789
+ }
790
+ /**
791
+ * @returns {Command[]}
792
+ * @private
793
+ */
794
+ _getCommandAndAncestors() {
795
+ let e = [];
796
+ for (let t = this; t; t = t.parent)
797
+ e.push(t);
798
+ return e;
799
+ }
800
+ /**
801
+ * Define a command.
802
+ *
803
+ * There are two styles of command: pay attention to where to put the description.
804
+ *
805
+ * @example
806
+ * // Command implemented using action handler (description is supplied separately to `.command`)
807
+ * program
808
+ * .command('clone <source> [destination]')
809
+ * .description('clone a repository into a newly created directory')
810
+ * .action((source, destination) => {
811
+ * console.log('clone command called');
812
+ * });
813
+ *
814
+ * // Command implemented using separate executable file (description is second parameter to `.command`)
815
+ * program
816
+ * .command('start <service>', 'start named service')
817
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
818
+ *
819
+ * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
820
+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
821
+ * @param {object} [execOpts] - configuration options (for executable)
822
+ * @return {Command} returns new command for action handler, or `this` for executable command
823
+ */
824
+ command(e, t, i) {
825
+ let s = t, r = i;
826
+ typeof s == "object" && s !== null && (r = s, s = null), r = r || {};
827
+ let [, o, l] = e.match(/([^ ]+) *(.*)/), a = this.createCommand(o);
828
+ return s && (a.description(s), a._executableHandler = !0), r.isDefault && (this._defaultCommandName = a._name), a._hidden = !!(r.noHelp ||
829
+ r.hidden), a._executableFile = r.executableFile || null, l && a.arguments(l), this._registerCommand(a), a.parent = this, a.copyInheritedSettings(
830
+ this), s ? this : a;
831
+ }
832
+ /**
833
+ * Factory routine to create a new unattached command.
834
+ *
835
+ * See .command() for creating an attached subcommand, which uses this routine to
836
+ * create the command. You can override createCommand to customise subcommands.
837
+ *
838
+ * @param {string} [name]
839
+ * @return {Command} new command
840
+ */
841
+ createCommand(e) {
842
+ return new n(e);
843
+ }
844
+ /**
845
+ * You can customise the help with a subclass of Help by overriding createHelp,
846
+ * or by overriding Help properties using configureHelp().
847
+ *
848
+ * @return {Help}
849
+ */
850
+ createHelp() {
851
+ return Object.assign(new ze(), this.configureHelp());
852
+ }
853
+ /**
854
+ * You can customise the help by overriding Help properties using configureHelp(),
855
+ * or with a subclass of Help by overriding createHelp().
856
+ *
857
+ * @param {object} [configuration] - configuration options
858
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
859
+ */
860
+ configureHelp(e) {
861
+ return e === void 0 ? this._helpConfiguration : (this._helpConfiguration = e, this);
862
+ }
863
+ /**
864
+ * The default output goes to stdout and stderr. You can customise this for special
865
+ * applications. You can also customise the display of errors by overriding outputError.
866
+ *
867
+ * The configuration properties are all functions:
868
+ *
869
+ * // functions to change where being written, stdout and stderr
870
+ * writeOut(str)
871
+ * writeErr(str)
872
+ * // matching functions to specify width for wrapping help
873
+ * getOutHelpWidth()
874
+ * getErrHelpWidth()
875
+ * // functions based on what is being written out
876
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
877
+ *
878
+ * @param {object} [configuration] - configuration options
879
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
880
+ */
881
+ configureOutput(e) {
882
+ return e === void 0 ? this._outputConfiguration : (Object.assign(this._outputConfiguration, e), this);
883
+ }
884
+ /**
885
+ * Display the help or a custom message after an error occurs.
886
+ *
887
+ * @param {(boolean|string)} [displayHelp]
888
+ * @return {Command} `this` command for chaining
889
+ */
890
+ showHelpAfterError(e = !0) {
891
+ return typeof e != "string" && (e = !!e), this._showHelpAfterError = e, this;
892
+ }
893
+ /**
894
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
895
+ *
896
+ * @param {boolean} [displaySuggestion]
897
+ * @return {Command} `this` command for chaining
898
+ */
899
+ showSuggestionAfterError(e = !0) {
900
+ return this._showSuggestionAfterError = !!e, this;
901
+ }
902
+ /**
903
+ * Add a prepared subcommand.
904
+ *
905
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
906
+ *
907
+ * @param {Command} cmd - new subcommand
908
+ * @param {object} [opts] - configuration options
909
+ * @return {Command} `this` command for chaining
910
+ */
911
+ addCommand(e, t) {
912
+ if (!e._name)
913
+ throw new Error(`Command passed to .addCommand() must have a name
914
+ - specify the name in Command constructor or using .name()`);
915
+ return t = t || {}, t.isDefault && (this._defaultCommandName = e._name), (t.noHelp || t.hidden) && (e._hidden = !0), this._registerCommand(
916
+ e), e.parent = this, e._checkForBrokenPassThrough(), this;
917
+ }
918
+ /**
919
+ * Factory routine to create a new unattached argument.
920
+ *
921
+ * See .argument() for creating an attached argument, which uses this routine to
922
+ * create the argument. You can override createArgument to return a custom argument.
923
+ *
924
+ * @param {string} name
925
+ * @param {string} [description]
926
+ * @return {Argument} new argument
927
+ */
928
+ createArgument(e, t) {
929
+ return new Je(e, t);
930
+ }
931
+ /**
932
+ * Define argument syntax for command.
933
+ *
934
+ * The default is that the argument is required, and you can explicitly
935
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
936
+ *
937
+ * @example
938
+ * program.argument('<input-file>');
939
+ * program.argument('[output-file]');
940
+ *
941
+ * @param {string} name
942
+ * @param {string} [description]
943
+ * @param {(Function|*)} [fn] - custom argument processing function
944
+ * @param {*} [defaultValue]
945
+ * @return {Command} `this` command for chaining
946
+ */
947
+ argument(e, t, i, s) {
948
+ let r = this.createArgument(e, t);
949
+ return typeof i == "function" ? r.default(s).argParser(i) : r.default(i), this.addArgument(r), this;
950
+ }
951
+ /**
952
+ * Define argument syntax for command, adding multiple at once (without descriptions).
953
+ *
954
+ * See also .argument().
955
+ *
956
+ * @example
957
+ * program.arguments('<cmd> [env]');
958
+ *
959
+ * @param {string} names
960
+ * @return {Command} `this` command for chaining
961
+ */
962
+ arguments(e) {
963
+ return e.trim().split(/ +/).forEach((t) => {
964
+ this.argument(t);
965
+ }), this;
966
+ }
967
+ /**
968
+ * Define argument syntax for command, adding a prepared argument.
969
+ *
970
+ * @param {Argument} argument
971
+ * @return {Command} `this` command for chaining
972
+ */
973
+ addArgument(e) {
974
+ let t = this.registeredArguments.slice(-1)[0];
975
+ if (t && t.variadic)
976
+ throw new Error(
977
+ `only the last argument can be variadic '${t.name()}'`
978
+ );
979
+ if (e.required && e.defaultValue !== void 0 && e.parseArg === void 0)
980
+ throw new Error(
981
+ `a default value for a required argument is never used: '${e.name()}'`
982
+ );
983
+ return this.registeredArguments.push(e), this;
984
+ }
985
+ /**
986
+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
987
+ *
988
+ * @example
989
+ * program.helpCommand('help [cmd]');
990
+ * program.helpCommand('help [cmd]', 'show help');
991
+ * program.helpCommand(false); // suppress default help command
992
+ * program.helpCommand(true); // add help command even if no subcommands
993
+ *
994
+ * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
995
+ * @param {string} [description] - custom description
996
+ * @return {Command} `this` command for chaining
997
+ */
998
+ helpCommand(e, t) {
999
+ if (typeof e == "boolean")
1000
+ return this._addImplicitHelpCommand = e, this;
1001
+ e = e ?? "help [command]";
1002
+ let [, i, s] = e.match(/([^ ]+) *(.*)/), r = t ?? "display help for command", o = this.createCommand(i);
1003
+ return o.helpOption(!1), s && o.arguments(s), r && o.description(r), this._addImplicitHelpCommand = !0, this._helpCommand = o, this;
1004
+ }
1005
+ /**
1006
+ * Add prepared custom help command.
1007
+ *
1008
+ * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
1009
+ * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
1010
+ * @return {Command} `this` command for chaining
1011
+ */
1012
+ addHelpCommand(e, t) {
1013
+ return typeof e != "object" ? (this.helpCommand(e, t), this) : (this._addImplicitHelpCommand = !0, this._helpCommand = e, this);
1014
+ }
1015
+ /**
1016
+ * Lazy create help command.
1017
+ *
1018
+ * @return {(Command|null)}
1019
+ * @package
1020
+ */
1021
+ _getHelpCommand() {
1022
+ return this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")) ? (this._helpCommand ===
1023
+ void 0 && this.helpCommand(void 0, void 0), this._helpCommand) : null;
1024
+ }
1025
+ /**
1026
+ * Add hook for life cycle event.
1027
+ *
1028
+ * @param {string} event
1029
+ * @param {Function} listener
1030
+ * @return {Command} `this` command for chaining
1031
+ */
1032
+ hook(e, t) {
1033
+ let i = ["preSubcommand", "preAction", "postAction"];
1034
+ if (!i.includes(e))
1035
+ throw new Error(`Unexpected value for event passed to hook : '${e}'.
1036
+ Expecting one of '${i.join("', '")}'`);
1037
+ return this._lifeCycleHooks[e] ? this._lifeCycleHooks[e].push(t) : this._lifeCycleHooks[e] = [t], this;
1038
+ }
1039
+ /**
1040
+ * Register callback to use as replacement for calling process.exit.
1041
+ *
1042
+ * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
1043
+ * @return {Command} `this` command for chaining
1044
+ */
1045
+ exitOverride(e) {
1046
+ return e ? this._exitCallback = e : this._exitCallback = (t) => {
1047
+ if (t.code !== "commander.executeSubCommandAsync")
1048
+ throw t;
1049
+ }, this;
1050
+ }
1051
+ /**
1052
+ * Call process.exit, and _exitCallback if defined.
1053
+ *
1054
+ * @param {number} exitCode exit code for using with process.exit
1055
+ * @param {string} code an id string representing the error
1056
+ * @param {string} message human-readable description of the error
1057
+ * @return never
1058
+ * @private
1059
+ */
1060
+ _exit(e, t, i) {
1061
+ this._exitCallback && this._exitCallback(new K(e, t, i)), h.exit(e);
1062
+ }
1063
+ /**
1064
+ * Register callback `fn` for the command.
1065
+ *
1066
+ * @example
1067
+ * program
1068
+ * .command('serve')
1069
+ * .description('start service')
1070
+ * .action(function() {
1071
+ * // do work here
1072
+ * });
1073
+ *
1074
+ * @param {Function} fn
1075
+ * @return {Command} `this` command for chaining
1076
+ */
1077
+ action(e) {
1078
+ let t = /* @__PURE__ */ d((i) => {
1079
+ let s = this.registeredArguments.length, r = i.slice(0, s);
1080
+ return this._storeOptionsAsProperties ? r[s] = this : r[s] = this.opts(), r.push(this), e.apply(this, r);
1081
+ }, "listener");
1082
+ return this._actionHandler = t, this;
1083
+ }
1084
+ /**
1085
+ * Factory routine to create a new unattached option.
1086
+ *
1087
+ * See .option() for creating an attached option, which uses this routine to
1088
+ * create the option. You can override createOption to return a custom option.
1089
+ *
1090
+ * @param {string} flags
1091
+ * @param {string} [description]
1092
+ * @return {Option} new option
1093
+ */
1094
+ createOption(e, t) {
1095
+ return new ce(e, t);
1096
+ }
1097
+ /**
1098
+ * Wrap parseArgs to catch 'commander.invalidArgument'.
1099
+ *
1100
+ * @param {(Option | Argument)} target
1101
+ * @param {string} value
1102
+ * @param {*} previous
1103
+ * @param {string} invalidArgumentMessage
1104
+ * @private
1105
+ */
1106
+ _callParseArg(e, t, i, s) {
1107
+ try {
1108
+ return e.parseArg(t, i);
1109
+ } catch (r) {
1110
+ if (r.code === "commander.invalidArgument") {
1111
+ let o = `${s} ${r.message}`;
1112
+ this.error(o, { exitCode: r.exitCode, code: r.code });
1113
+ }
1114
+ throw r;
1115
+ }
1116
+ }
1117
+ /**
1118
+ * Check for option flag conflicts.
1119
+ * Register option if no conflicts found, or throw on conflict.
1120
+ *
1121
+ * @param {Option} option
1122
+ * @private
1123
+ */
1124
+ _registerOption(e) {
1125
+ let t = e.short && this._findOption(e.short) || e.long && this._findOption(e.long);
1126
+ if (t) {
1127
+ let i = e.long && this._findOption(e.long) ? e.long : e.short;
1128
+ throw new Error(`Cannot add option '${e.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${i}'
1129
+ - already used by option '${t.flags}'`);
1130
+ }
1131
+ this.options.push(e);
1132
+ }
1133
+ /**
1134
+ * Check for command name and alias conflicts with existing commands.
1135
+ * Register command if no conflicts found, or throw on conflict.
1136
+ *
1137
+ * @param {Command} command
1138
+ * @private
1139
+ */
1140
+ _registerCommand(e) {
1141
+ let t = /* @__PURE__ */ d((s) => [s.name()].concat(s.aliases()), "knownBy"), i = t(e).find(
1142
+ (s) => this._findCommand(s)
1143
+ );
1144
+ if (i) {
1145
+ let s = t(this._findCommand(i)).join("|"), r = t(e).join("|");
1146
+ throw new Error(
1147
+ `cannot add command '${r}' as already have command '${s}'`
1148
+ );
1149
+ }
1150
+ this.commands.push(e);
1151
+ }
1152
+ /**
1153
+ * Add an option.
1154
+ *
1155
+ * @param {Option} option
1156
+ * @return {Command} `this` command for chaining
1157
+ */
1158
+ addOption(e) {
1159
+ this._registerOption(e);
1160
+ let t = e.name(), i = e.attributeName();
1161
+ if (e.negate) {
1162
+ let r = e.long.replace(/^--no-/, "--");
1163
+ this._findOption(r) || this.setOptionValueWithSource(
1164
+ i,
1165
+ e.defaultValue === void 0 ? !0 : e.defaultValue,
1166
+ "default"
1167
+ );
1168
+ } else e.defaultValue !== void 0 && this.setOptionValueWithSource(i, e.defaultValue, "default");
1169
+ let s = /* @__PURE__ */ d((r, o, l) => {
1170
+ r == null && e.presetArg !== void 0 && (r = e.presetArg);
1171
+ let a = this.getOptionValue(i);
1172
+ r !== null && e.parseArg ? r = this._callParseArg(e, r, a, o) : r !== null && e.variadic && (r = e._concatValue(r, a)), r == null &&
1173
+ (e.negate ? r = !1 : e.isBoolean() || e.optional ? r = !0 : r = ""), this.setOptionValueWithSource(i, r, l);
1174
+ }, "handleOptionValue");
1175
+ return this.on("option:" + t, (r) => {
1176
+ let o = `error: option '${e.flags}' argument '${r}' is invalid.`;
1177
+ s(r, o, "cli");
1178
+ }), e.envVar && this.on("optionEnv:" + t, (r) => {
1179
+ let o = `error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;
1180
+ s(r, o, "env");
1181
+ }), this;
1182
+ }
1183
+ /**
1184
+ * Internal implementation shared by .option() and .requiredOption()
1185
+ *
1186
+ * @return {Command} `this` command for chaining
1187
+ * @private
1188
+ */
1189
+ _optionEx(e, t, i, s, r) {
1190
+ if (typeof t == "object" && t instanceof ce)
1191
+ throw new Error(
1192
+ "To add an Option object use addOption() instead of option() or requiredOption()"
1193
+ );
1194
+ let o = this.createOption(t, i);
1195
+ if (o.makeOptionMandatory(!!e.mandatory), typeof s == "function")
1196
+ o.default(r).argParser(s);
1197
+ else if (s instanceof RegExp) {
1198
+ let l = s;
1199
+ s = /* @__PURE__ */ d((a, c) => {
1200
+ let p = l.exec(a);
1201
+ return p ? p[0] : c;
1202
+ }, "fn"), o.default(r).argParser(s);
1203
+ } else
1204
+ o.default(s);
1205
+ return this.addOption(o);
1206
+ }
1207
+ /**
1208
+ * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
1209
+ *
1210
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
1211
+ * option-argument is indicated by `<>` and an optional option-argument by `[]`.
1212
+ *
1213
+ * See the README for more details, and see also addOption() and requiredOption().
1214
+ *
1215
+ * @example
1216
+ * program
1217
+ * .option('-p, --pepper', 'add pepper')
1218
+ * .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
1219
+ * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
1220
+ * .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
1221
+ *
1222
+ * @param {string} flags
1223
+ * @param {string} [description]
1224
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1225
+ * @param {*} [defaultValue]
1226
+ * @return {Command} `this` command for chaining
1227
+ */
1228
+ option(e, t, i, s) {
1229
+ return this._optionEx({}, e, t, i, s);
1230
+ }
1231
+ /**
1232
+ * Add a required option which must have a value after parsing. This usually means
1233
+ * the option must be specified on the command line. (Otherwise the same as .option().)
1234
+ *
1235
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1236
+ *
1237
+ * @param {string} flags
1238
+ * @param {string} [description]
1239
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
1240
+ * @param {*} [defaultValue]
1241
+ * @return {Command} `this` command for chaining
1242
+ */
1243
+ requiredOption(e, t, i, s) {
1244
+ return this._optionEx(
1245
+ { mandatory: !0 },
1246
+ e,
1247
+ t,
1248
+ i,
1249
+ s
1250
+ );
1251
+ }
1252
+ /**
1253
+ * Alter parsing of short flags with optional values.
1254
+ *
1255
+ * @example
1256
+ * // for `.option('-f,--flag [value]'):
1257
+ * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1258
+ * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1259
+ *
1260
+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
1261
+ * @return {Command} `this` command for chaining
1262
+ */
1263
+ combineFlagAndOptionalValue(e = !0) {
1264
+ return this._combineFlagAndOptionalValue = !!e, this;
1265
+ }
1266
+ /**
1267
+ * Allow unknown options on the command line.
1268
+ *
1269
+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
1270
+ * @return {Command} `this` command for chaining
1271
+ */
1272
+ allowUnknownOption(e = !0) {
1273
+ return this._allowUnknownOption = !!e, this;
1274
+ }
1275
+ /**
1276
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1277
+ *
1278
+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
1279
+ * @return {Command} `this` command for chaining
1280
+ */
1281
+ allowExcessArguments(e = !0) {
1282
+ return this._allowExcessArguments = !!e, this;
1283
+ }
1284
+ /**
1285
+ * Enable positional options. Positional means global options are specified before subcommands which lets
1286
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1287
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
1288
+ *
1289
+ * @param {boolean} [positional]
1290
+ * @return {Command} `this` command for chaining
1291
+ */
1292
+ enablePositionalOptions(e = !0) {
1293
+ return this._enablePositionalOptions = !!e, this;
1294
+ }
1295
+ /**
1296
+ * Pass through options that come after command-arguments rather than treat them as command-options,
1297
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
1298
+ * positional options to have been enabled on the program (parent commands).
1299
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
1300
+ *
1301
+ * @param {boolean} [passThrough] for unknown options.
1302
+ * @return {Command} `this` command for chaining
1303
+ */
1304
+ passThroughOptions(e = !0) {
1305
+ return this._passThroughOptions = !!e, this._checkForBrokenPassThrough(), this;
1306
+ }
1307
+ /**
1308
+ * @private
1309
+ */
1310
+ _checkForBrokenPassThrough() {
1311
+ if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions)
1312
+ throw new Error(
1313
+ `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
1314
+ );
1315
+ }
1316
+ /**
1317
+ * Whether to store option values as properties on command object,
1318
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
1319
+ *
1320
+ * @param {boolean} [storeAsProperties=true]
1321
+ * @return {Command} `this` command for chaining
1322
+ */
1323
+ storeOptionsAsProperties(e = !0) {
1324
+ if (this.options.length)
1325
+ throw new Error("call .storeOptionsAsProperties() before adding options");
1326
+ if (Object.keys(this._optionValues).length)
1327
+ throw new Error(
1328
+ "call .storeOptionsAsProperties() before setting option values"
1329
+ );
1330
+ return this._storeOptionsAsProperties = !!e, this;
1331
+ }
1332
+ /**
1333
+ * Retrieve option value.
1334
+ *
1335
+ * @param {string} key
1336
+ * @return {object} value
1337
+ */
1338
+ getOptionValue(e) {
1339
+ return this._storeOptionsAsProperties ? this[e] : this._optionValues[e];
1340
+ }
1341
+ /**
1342
+ * Store option value.
1343
+ *
1344
+ * @param {string} key
1345
+ * @param {object} value
1346
+ * @return {Command} `this` command for chaining
1347
+ */
1348
+ setOptionValue(e, t) {
1349
+ return this.setOptionValueWithSource(e, t, void 0);
1350
+ }
1351
+ /**
1352
+ * Store option value and where the value came from.
1353
+ *
1354
+ * @param {string} key
1355
+ * @param {object} value
1356
+ * @param {string} source - expected values are default/config/env/cli/implied
1357
+ * @return {Command} `this` command for chaining
1358
+ */
1359
+ setOptionValueWithSource(e, t, i) {
1360
+ return this._storeOptionsAsProperties ? this[e] = t : this._optionValues[e] = t, this._optionValueSources[e] = i, this;
1361
+ }
1362
+ /**
1363
+ * Get source of option value.
1364
+ * Expected values are default | config | env | cli | implied
1365
+ *
1366
+ * @param {string} key
1367
+ * @return {string}
1368
+ */
1369
+ getOptionValueSource(e) {
1370
+ return this._optionValueSources[e];
1371
+ }
1372
+ /**
1373
+ * Get source of option value. See also .optsWithGlobals().
1374
+ * Expected values are default | config | env | cli | implied
1375
+ *
1376
+ * @param {string} key
1377
+ * @return {string}
1378
+ */
1379
+ getOptionValueSourceWithGlobals(e) {
1380
+ let t;
1381
+ return this._getCommandAndAncestors().forEach((i) => {
1382
+ i.getOptionValueSource(e) !== void 0 && (t = i.getOptionValueSource(e));
1383
+ }), t;
1384
+ }
1385
+ /**
1386
+ * Get user arguments from implied or explicit arguments.
1387
+ * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
1388
+ *
1389
+ * @private
1390
+ */
1391
+ _prepareUserArgs(e, t) {
1392
+ if (e !== void 0 && !Array.isArray(e))
1393
+ throw new Error("first parameter to parse must be array or undefined");
1394
+ if (t = t || {}, e === void 0 && t.from === void 0) {
1395
+ h.versions?.electron && (t.from = "electron");
1396
+ let s = h.execArgv ?? [];
1397
+ (s.includes("-e") || s.includes("--eval") || s.includes("-p") || s.includes("--print")) && (t.from = "eval");
1398
+ }
1399
+ e === void 0 && (e = h.argv), this.rawArgs = e.slice();
1400
+ let i;
1401
+ switch (t.from) {
1402
+ case void 0:
1403
+ case "node":
1404
+ this._scriptPath = e[1], i = e.slice(2);
1405
+ break;
1406
+ case "electron":
1407
+ h.defaultApp ? (this._scriptPath = e[1], i = e.slice(2)) : i = e.slice(1);
1408
+ break;
1409
+ case "user":
1410
+ i = e.slice(0);
1411
+ break;
1412
+ case "eval":
1413
+ i = e.slice(1);
1414
+ break;
1415
+ default:
1416
+ throw new Error(
1417
+ `unexpected parse option { from: '${t.from}' }`
1418
+ );
1419
+ }
1420
+ return !this._name && this._scriptPath && this.nameFromFilename(this._scriptPath), this._name = this._name || "program", i;
1421
+ }
1422
+ /**
1423
+ * Parse `argv`, setting options and invoking commands when defined.
1424
+ *
1425
+ * Use parseAsync instead of parse if any of your action handlers are async.
1426
+ *
1427
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1428
+ *
1429
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1430
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1431
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1432
+ * - `'user'`: just user arguments
1433
+ *
1434
+ * @example
1435
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
1436
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
1437
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1438
+ *
1439
+ * @param {string[]} [argv] - optional, defaults to process.argv
1440
+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
1441
+ * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
1442
+ * @return {Command} `this` command for chaining
1443
+ */
1444
+ parse(e, t) {
1445
+ let i = this._prepareUserArgs(e, t);
1446
+ return this._parseCommand([], i), this;
1447
+ }
1448
+ /**
1449
+ * Parse `argv`, setting options and invoking commands when defined.
1450
+ *
1451
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
1452
+ *
1453
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
1454
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
1455
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
1456
+ * - `'user'`: just user arguments
1457
+ *
1458
+ * @example
1459
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
1460
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
1461
+ * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
1462
+ *
1463
+ * @param {string[]} [argv]
1464
+ * @param {object} [parseOptions]
1465
+ * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
1466
+ * @return {Promise}
1467
+ */
1468
+ async parseAsync(e, t) {
1469
+ let i = this._prepareUserArgs(e, t);
1470
+ return await this._parseCommand([], i), this;
1471
+ }
1472
+ /**
1473
+ * Execute a sub-command executable.
1474
+ *
1475
+ * @private
1476
+ */
1477
+ _executeSubCommand(e, t) {
1478
+ t = t.slice();
1479
+ let i = !1, s = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1480
+ function r(p, u) {
1481
+ let m = _.resolve(p, u);
1482
+ if (z.existsSync(m)) return m;
1483
+ if (s.includes(_.extname(u))) return;
1484
+ let x = s.find(
1485
+ (f) => z.existsSync(`${m}${f}`)
1486
+ );
1487
+ if (x) return `${m}${x}`;
1488
+ }
1489
+ d(r, "findFile"), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
1490
+ let o = e._executableFile || `${this._name}-${e._name}`, l = this._executableDir || "";
1491
+ if (this._scriptPath) {
1492
+ let p;
1493
+ try {
1494
+ p = z.realpathSync(this._scriptPath);
1495
+ } catch {
1496
+ p = this._scriptPath;
1497
+ }
1498
+ l = _.resolve(
1499
+ _.dirname(p),
1500
+ l
1501
+ );
1502
+ }
1503
+ if (l) {
1504
+ let p = r(l, o);
1505
+ if (!p && !e._executableFile && this._scriptPath) {
1506
+ let u = _.basename(
1507
+ this._scriptPath,
1508
+ _.extname(this._scriptPath)
1509
+ );
1510
+ u !== this._name && (p = r(
1511
+ l,
1512
+ `${u}-${e._name}`
1513
+ ));
1514
+ }
1515
+ o = p || o;
1516
+ }
1517
+ i = s.includes(_.extname(o));
1518
+ let a;
1519
+ h.platform !== "win32" ? i ? (t.unshift(o), t = ue(h.execArgv).concat(t), a = Y.spawn(h.argv[0], t, { stdio: "inherit" })) : a = Y.spawn(
1520
+ o, t, { stdio: "inherit" }) : (t.unshift(o), t = ue(h.execArgv).concat(t), a = Y.spawn(h.execPath, t, { stdio: "inherit" })), a.killed ||
1521
+ ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"].forEach((u) => {
1522
+ h.on(u, () => {
1523
+ a.killed === !1 && a.exitCode === null && a.kill(u);
1524
+ });
1525
+ });
1526
+ let c = this._exitCallback;
1527
+ a.on("close", (p) => {
1528
+ p = p ?? 1, c ? c(
1529
+ new K(
1530
+ p,
1531
+ "commander.executeSubCommandAsync",
1532
+ "(close)"
1533
+ )
1534
+ ) : h.exit(p);
1535
+ }), a.on("error", (p) => {
1536
+ if (p.code === "ENOENT") {
1537
+ let u = l ? `searched for local subcommand relative to directory '${l}'` : "no directory for search for local subcommand, use .exe\
1538
+ cutableDir() to supply a custom directory", m = `'${o}' does not exist
1539
+ - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\
1540
+
1541
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
1542
+ - ${u}`;
1543
+ throw new Error(m);
1544
+ } else if (p.code === "EACCES")
1545
+ throw new Error(`'${o}' not executable`);
1546
+ if (!c)
1547
+ h.exit(1);
1548
+ else {
1549
+ let u = new K(
1550
+ 1,
1551
+ "commander.executeSubCommandAsync",
1552
+ "(error)"
1553
+ );
1554
+ u.nestedError = p, c(u);
1555
+ }
1556
+ }), this.runningCommand = a;
1557
+ }
1558
+ /**
1559
+ * @private
1560
+ */
1561
+ _dispatchSubcommand(e, t, i) {
1562
+ let s = this._findCommand(e);
1563
+ s || this.help({ error: !0 });
1564
+ let r;
1565
+ return r = this._chainOrCallSubCommandHook(
1566
+ r,
1567
+ s,
1568
+ "preSubcommand"
1569
+ ), r = this._chainOrCall(r, () => {
1570
+ if (s._executableHandler)
1571
+ this._executeSubCommand(s, t.concat(i));
1572
+ else
1573
+ return s._parseCommand(t, i);
1574
+ }), r;
1575
+ }
1576
+ /**
1577
+ * Invoke help directly if possible, or dispatch if necessary.
1578
+ * e.g. help foo
1579
+ *
1580
+ * @private
1581
+ */
1582
+ _dispatchHelpCommand(e) {
1583
+ e || this.help();
1584
+ let t = this._findCommand(e);
1585
+ return t && !t._executableHandler && t.help(), this._dispatchSubcommand(
1586
+ e,
1587
+ [],
1588
+ [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
1589
+ );
1590
+ }
1591
+ /**
1592
+ * Check this.args against expected this.registeredArguments.
1593
+ *
1594
+ * @private
1595
+ */
1596
+ _checkNumberOfArguments() {
1597
+ this.registeredArguments.forEach((e, t) => {
1598
+ e.required && this.args[t] == null && this.missingArgument(e.name());
1599
+ }), !(this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) && this.args.length >
1600
+ this.registeredArguments.length && this._excessArguments(this.args);
1601
+ }
1602
+ /**
1603
+ * Process this.args using this.registeredArguments and save as this.processedArgs!
1604
+ *
1605
+ * @private
1606
+ */
1607
+ _processArguments() {
1608
+ let e = /* @__PURE__ */ d((i, s, r) => {
1609
+ let o = s;
1610
+ if (s !== null && i.parseArg) {
1611
+ let l = `error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;
1612
+ o = this._callParseArg(
1613
+ i,
1614
+ s,
1615
+ r,
1616
+ l
1617
+ );
1618
+ }
1619
+ return o;
1620
+ }, "myParseArg");
1621
+ this._checkNumberOfArguments();
1622
+ let t = [];
1623
+ this.registeredArguments.forEach((i, s) => {
1624
+ let r = i.defaultValue;
1625
+ i.variadic ? s < this.args.length ? (r = this.args.slice(s), i.parseArg && (r = r.reduce((o, l) => e(i, l, o), i.defaultValue))) : r ===
1626
+ void 0 && (r = []) : s < this.args.length && (r = this.args[s], i.parseArg && (r = e(i, r, i.defaultValue))), t[s] = r;
1627
+ }), this.processedArgs = t;
1628
+ }
1629
+ /**
1630
+ * Once we have a promise we chain, but call synchronously until then.
1631
+ *
1632
+ * @param {(Promise|undefined)} promise
1633
+ * @param {Function} fn
1634
+ * @return {(Promise|undefined)}
1635
+ * @private
1636
+ */
1637
+ _chainOrCall(e, t) {
1638
+ return e && e.then && typeof e.then == "function" ? e.then(() => t()) : t();
1639
+ }
1640
+ /**
1641
+ *
1642
+ * @param {(Promise|undefined)} promise
1643
+ * @param {string} event
1644
+ * @return {(Promise|undefined)}
1645
+ * @private
1646
+ */
1647
+ _chainOrCallHooks(e, t) {
1648
+ let i = e, s = [];
1649
+ return this._getCommandAndAncestors().reverse().filter((r) => r._lifeCycleHooks[t] !== void 0).forEach((r) => {
1650
+ r._lifeCycleHooks[t].forEach((o) => {
1651
+ s.push({ hookedCommand: r, callback: o });
1652
+ });
1653
+ }), t === "postAction" && s.reverse(), s.forEach((r) => {
1654
+ i = this._chainOrCall(i, () => r.callback(r.hookedCommand, this));
1655
+ }), i;
1656
+ }
1657
+ /**
1658
+ *
1659
+ * @param {(Promise|undefined)} promise
1660
+ * @param {Command} subCommand
1661
+ * @param {string} event
1662
+ * @return {(Promise|undefined)}
1663
+ * @private
1664
+ */
1665
+ _chainOrCallSubCommandHook(e, t, i) {
1666
+ let s = e;
1667
+ return this._lifeCycleHooks[i] !== void 0 && this._lifeCycleHooks[i].forEach((r) => {
1668
+ s = this._chainOrCall(s, () => r(this, t));
1669
+ }), s;
1670
+ }
1671
+ /**
1672
+ * Process arguments in context of this command.
1673
+ * Returns action result, in case it is a promise.
1674
+ *
1675
+ * @private
1676
+ */
1677
+ _parseCommand(e, t) {
1678
+ let i = this.parseOptions(t);
1679
+ if (this._parseOptionsEnv(), this._parseOptionsImplied(), e = e.concat(i.operands), t = i.unknown, this.args = e.concat(t), e && this.
1680
+ _findCommand(e[0]))
1681
+ return this._dispatchSubcommand(e[0], e.slice(1), t);
1682
+ if (this._getHelpCommand() && e[0] === this._getHelpCommand().name())
1683
+ return this._dispatchHelpCommand(e[1]);
1684
+ if (this._defaultCommandName)
1685
+ return this._outputHelpIfRequested(t), this._dispatchSubcommand(
1686
+ this._defaultCommandName,
1687
+ e,
1688
+ t
1689
+ );
1690
+ this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName && this.help({ error: !0 }), this.
1691
+ _outputHelpIfRequested(i.unknown), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
1692
+ let s = /* @__PURE__ */ d(() => {
1693
+ i.unknown.length > 0 && this.unknownOption(i.unknown[0]);
1694
+ }, "checkForUnknownOptions"), r = `command:${this.name()}`;
1695
+ if (this._actionHandler) {
1696
+ s(), this._processArguments();
1697
+ let o;
1698
+ return o = this._chainOrCallHooks(o, "preAction"), o = this._chainOrCall(
1699
+ o,
1700
+ () => this._actionHandler(this.processedArgs)
1701
+ ), this.parent && (o = this._chainOrCall(o, () => {
1702
+ this.parent.emit(r, e, t);
1703
+ })), o = this._chainOrCallHooks(o, "postAction"), o;
1704
+ }
1705
+ if (this.parent && this.parent.listenerCount(r))
1706
+ s(), this._processArguments(), this.parent.emit(r, e, t);
1707
+ else if (e.length) {
1708
+ if (this._findCommand("*"))
1709
+ return this._dispatchSubcommand("*", e, t);
1710
+ this.listenerCount("command:*") ? this.emit("command:*", e, t) : this.commands.length ? this.unknownCommand() : (s(), this._processArguments());
1711
+ } else this.commands.length ? (s(), this.help({ error: !0 })) : (s(), this._processArguments());
1712
+ }
1713
+ /**
1714
+ * Find matching command.
1715
+ *
1716
+ * @private
1717
+ * @return {Command | undefined}
1718
+ */
1719
+ _findCommand(e) {
1720
+ if (e)
1721
+ return this.commands.find(
1722
+ (t) => t._name === e || t._aliases.includes(e)
1723
+ );
1724
+ }
1725
+ /**
1726
+ * Return an option matching `arg` if any.
1727
+ *
1728
+ * @param {string} arg
1729
+ * @return {Option}
1730
+ * @package
1731
+ */
1732
+ _findOption(e) {
1733
+ return this.options.find((t) => t.is(e));
1734
+ }
1735
+ /**
1736
+ * Display an error message if a mandatory option does not have a value.
1737
+ * Called after checking for help flags in leaf subcommand.
1738
+ *
1739
+ * @private
1740
+ */
1741
+ _checkForMissingMandatoryOptions() {
1742
+ this._getCommandAndAncestors().forEach((e) => {
1743
+ e.options.forEach((t) => {
1744
+ t.mandatory && e.getOptionValue(t.attributeName()) === void 0 && e.missingMandatoryOptionValue(t);
1745
+ });
1746
+ });
1747
+ }
1748
+ /**
1749
+ * Display an error message if conflicting options are used together in this.
1750
+ *
1751
+ * @private
1752
+ */
1753
+ _checkForConflictingLocalOptions() {
1754
+ let e = this.options.filter((i) => {
1755
+ let s = i.attributeName();
1756
+ return this.getOptionValue(s) === void 0 ? !1 : this.getOptionValueSource(s) !== "default";
1757
+ });
1758
+ e.filter(
1759
+ (i) => i.conflictsWith.length > 0
1760
+ ).forEach((i) => {
1761
+ let s = e.find(
1762
+ (r) => i.conflictsWith.includes(r.attributeName())
1763
+ );
1764
+ s && this._conflictingOption(i, s);
1765
+ });
1766
+ }
1767
+ /**
1768
+ * Display an error message if conflicting options are used together.
1769
+ * Called after checking for help flags in leaf subcommand.
1770
+ *
1771
+ * @private
1772
+ */
1773
+ _checkForConflictingOptions() {
1774
+ this._getCommandAndAncestors().forEach((e) => {
1775
+ e._checkForConflictingLocalOptions();
1776
+ });
1777
+ }
1778
+ /**
1779
+ * Parse options from `argv` removing known options,
1780
+ * and return argv split into operands and unknown arguments.
1781
+ *
1782
+ * Examples:
1783
+ *
1784
+ * argv => operands, unknown
1785
+ * --known kkk op => [op], []
1786
+ * op --known kkk => [op], []
1787
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
1788
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
1789
+ *
1790
+ * @param {string[]} argv
1791
+ * @return {{operands: string[], unknown: string[]}}
1792
+ */
1793
+ parseOptions(e) {
1794
+ let t = [], i = [], s = t, r = e.slice();
1795
+ function o(a) {
1796
+ return a.length > 1 && a[0] === "-";
1797
+ }
1798
+ d(o, "maybeOption");
1799
+ let l = null;
1800
+ for (; r.length; ) {
1801
+ let a = r.shift();
1802
+ if (a === "--") {
1803
+ s === i && s.push(a), s.push(...r);
1804
+ break;
1805
+ }
1806
+ if (l && !o(a)) {
1807
+ this.emit(`option:${l.name()}`, a);
1808
+ continue;
1809
+ }
1810
+ if (l = null, o(a)) {
1811
+ let c = this._findOption(a);
1812
+ if (c) {
1813
+ if (c.required) {
1814
+ let p = r.shift();
1815
+ p === void 0 && this.optionMissingArgument(c), this.emit(`option:${c.name()}`, p);
1816
+ } else if (c.optional) {
1817
+ let p = null;
1818
+ r.length > 0 && !o(r[0]) && (p = r.shift()), this.emit(`option:${c.name()}`, p);
1819
+ } else
1820
+ this.emit(`option:${c.name()}`);
1821
+ l = c.variadic ? c : null;
1822
+ continue;
1823
+ }
1824
+ }
1825
+ if (a.length > 2 && a[0] === "-" && a[1] !== "-") {
1826
+ let c = this._findOption(`-${a[1]}`);
1827
+ if (c) {
1828
+ c.required || c.optional && this._combineFlagAndOptionalValue ? this.emit(`option:${c.name()}`, a.slice(2)) : (this.emit(`option\
1829
+ :${c.name()}`), r.unshift(`-${a.slice(2)}`));
1830
+ continue;
1831
+ }
1832
+ }
1833
+ if (/^--[^=]+=/.test(a)) {
1834
+ let c = a.indexOf("="), p = this._findOption(a.slice(0, c));
1835
+ if (p && (p.required || p.optional)) {
1836
+ this.emit(`option:${p.name()}`, a.slice(c + 1));
1837
+ continue;
1838
+ }
1839
+ }
1840
+ if (o(a) && (s = i), (this._enablePositionalOptions || this._passThroughOptions) && t.length === 0 && i.length === 0) {
1841
+ if (this._findCommand(a)) {
1842
+ t.push(a), r.length > 0 && i.push(...r);
1843
+ break;
1844
+ } else if (this._getHelpCommand() && a === this._getHelpCommand().name()) {
1845
+ t.push(a), r.length > 0 && t.push(...r);
1846
+ break;
1847
+ } else if (this._defaultCommandName) {
1848
+ i.push(a), r.length > 0 && i.push(...r);
1849
+ break;
1850
+ }
1851
+ }
1852
+ if (this._passThroughOptions) {
1853
+ s.push(a), r.length > 0 && s.push(...r);
1854
+ break;
1855
+ }
1856
+ s.push(a);
1857
+ }
1858
+ return { operands: t, unknown: i };
1859
+ }
1860
+ /**
1861
+ * Return an object containing local option values as key-value pairs.
1862
+ *
1863
+ * @return {object}
1864
+ */
1865
+ opts() {
1866
+ if (this._storeOptionsAsProperties) {
1867
+ let e = {}, t = this.options.length;
1868
+ for (let i = 0; i < t; i++) {
1869
+ let s = this.options[i].attributeName();
1870
+ e[s] = s === this._versionOptionName ? this._version : this[s];
1871
+ }
1872
+ return e;
1873
+ }
1874
+ return this._optionValues;
1875
+ }
1876
+ /**
1877
+ * Return an object containing merged local and global option values as key-value pairs.
1878
+ *
1879
+ * @return {object}
1880
+ */
1881
+ optsWithGlobals() {
1882
+ return this._getCommandAndAncestors().reduce(
1883
+ (e, t) => Object.assign(e, t.opts()),
1884
+ {}
1885
+ );
1886
+ }
1887
+ /**
1888
+ * Display error message and exit (or call exitOverride).
1889
+ *
1890
+ * @param {string} message
1891
+ * @param {object} [errorOptions]
1892
+ * @param {string} [errorOptions.code] - an id string representing the error
1893
+ * @param {number} [errorOptions.exitCode] - used with process.exit
1894
+ */
1895
+ error(e, t) {
1896
+ this._outputConfiguration.outputError(
1897
+ `${e}
1898
+ `,
1899
+ this._outputConfiguration.writeErr
1900
+ ), typeof this._showHelpAfterError == "string" ? this._outputConfiguration.writeErr(`${this._showHelpAfterError}
1901
+ `) : this._showHelpAfterError && (this._outputConfiguration.writeErr(`
1902
+ `), this.outputHelp({ error: !0 }));
1903
+ let i = t || {}, s = i.exitCode || 1, r = i.code || "commander.error";
1904
+ this._exit(s, r, e);
1905
+ }
1906
+ /**
1907
+ * Apply any option related environment variables, if option does
1908
+ * not have a value from cli or client code.
1909
+ *
1910
+ * @private
1911
+ */
1912
+ _parseOptionsEnv() {
1913
+ this.options.forEach((e) => {
1914
+ if (e.envVar && e.envVar in h.env) {
1915
+ let t = e.attributeName();
1916
+ (this.getOptionValue(t) === void 0 || ["default", "config", "env"].includes(
1917
+ this.getOptionValueSource(t)
1918
+ )) && (e.required || e.optional ? this.emit(`optionEnv:${e.name()}`, h.env[e.envVar]) : this.emit(`optionEnv:${e.name()}`));
1919
+ }
1920
+ });
1921
+ }
1922
+ /**
1923
+ * Apply any implied option values, if option is undefined or default value.
1924
+ *
1925
+ * @private
1926
+ */
1927
+ _parseOptionsImplied() {
1928
+ let e = new Ke(this.options), t = /* @__PURE__ */ d((i) => this.getOptionValue(i) !== void 0 && !["default", "implied"].includes(this.
1929
+ getOptionValueSource(i)), "hasCustomOptionValue");
1930
+ this.options.filter(
1931
+ (i) => i.implied !== void 0 && t(i.attributeName()) && e.valueFromOption(
1932
+ this.getOptionValue(i.attributeName()),
1933
+ i
1934
+ )
1935
+ ).forEach((i) => {
1936
+ Object.keys(i.implied).filter((s) => !t(s)).forEach((s) => {
1937
+ this.setOptionValueWithSource(
1938
+ s,
1939
+ i.implied[s],
1940
+ "implied"
1941
+ );
1942
+ });
1943
+ });
1944
+ }
1945
+ /**
1946
+ * Argument `name` is missing.
1947
+ *
1948
+ * @param {string} name
1949
+ * @private
1950
+ */
1951
+ missingArgument(e) {
1952
+ let t = `error: missing required argument '${e}'`;
1953
+ this.error(t, { code: "commander.missingArgument" });
1954
+ }
1955
+ /**
1956
+ * `Option` is missing an argument.
1957
+ *
1958
+ * @param {Option} option
1959
+ * @private
1960
+ */
1961
+ optionMissingArgument(e) {
1962
+ let t = `error: option '${e.flags}' argument missing`;
1963
+ this.error(t, { code: "commander.optionMissingArgument" });
1964
+ }
1965
+ /**
1966
+ * `Option` does not have a value, and is a mandatory option.
1967
+ *
1968
+ * @param {Option} option
1969
+ * @private
1970
+ */
1971
+ missingMandatoryOptionValue(e) {
1972
+ let t = `error: required option '${e.flags}' not specified`;
1973
+ this.error(t, { code: "commander.missingMandatoryOptionValue" });
1974
+ }
1975
+ /**
1976
+ * `Option` conflicts with another option.
1977
+ *
1978
+ * @param {Option} option
1979
+ * @param {Option} conflictingOption
1980
+ * @private
1981
+ */
1982
+ _conflictingOption(e, t) {
1983
+ let i = /* @__PURE__ */ d((o) => {
1984
+ let l = o.attributeName(), a = this.getOptionValue(l), c = this.options.find(
1985
+ (u) => u.negate && l === u.attributeName()
1986
+ ), p = this.options.find(
1987
+ (u) => !u.negate && l === u.attributeName()
1988
+ );
1989
+ return c && (c.presetArg === void 0 && a === !1 || c.presetArg !== void 0 && a === c.presetArg) ? c : p || o;
1990
+ }, "findBestOptionFromValue"), s = /* @__PURE__ */ d((o) => {
1991
+ let l = i(o), a = l.attributeName();
1992
+ return this.getOptionValueSource(a) === "env" ? `environment variable '${l.envVar}'` : `option '${l.flags}'`;
1993
+ }, "getErrorMessage"), r = `error: ${s(e)} cannot be used with ${s(t)}`;
1994
+ this.error(r, { code: "commander.conflictingOption" });
1995
+ }
1996
+ /**
1997
+ * Unknown option `flag`.
1998
+ *
1999
+ * @param {string} flag
2000
+ * @private
2001
+ */
2002
+ unknownOption(e) {
2003
+ if (this._allowUnknownOption) return;
2004
+ let t = "";
2005
+ if (e.startsWith("--") && this._showSuggestionAfterError) {
2006
+ let s = [], r = this;
2007
+ do {
2008
+ let o = r.createHelp().visibleOptions(r).filter((l) => l.long).map((l) => l.long);
2009
+ s = s.concat(o), r = r.parent;
2010
+ } while (r && !r._enablePositionalOptions);
2011
+ t = pe(e, s);
2012
+ }
2013
+ let i = `error: unknown option '${e}'${t}`;
2014
+ this.error(i, { code: "commander.unknownOption" });
2015
+ }
2016
+ /**
2017
+ * Excess arguments, more than expected.
2018
+ *
2019
+ * @param {string[]} receivedArgs
2020
+ * @private
2021
+ */
2022
+ _excessArguments(e) {
2023
+ if (this._allowExcessArguments) return;
2024
+ let t = this.registeredArguments.length, i = t === 1 ? "" : "s", r = `error: too many arguments${this.parent ? ` for '${this.name()}'` :
2025
+ ""}. Expected ${t} argument${i} but got ${e.length}.`;
2026
+ this.error(r, { code: "commander.excessArguments" });
2027
+ }
2028
+ /**
2029
+ * Unknown command.
2030
+ *
2031
+ * @private
2032
+ */
2033
+ unknownCommand() {
2034
+ let e = this.args[0], t = "";
2035
+ if (this._showSuggestionAfterError) {
2036
+ let s = [];
2037
+ this.createHelp().visibleCommands(this).forEach((r) => {
2038
+ s.push(r.name()), r.alias() && s.push(r.alias());
2039
+ }), t = pe(e, s);
2040
+ }
2041
+ let i = `error: unknown command '${e}'${t}`;
2042
+ this.error(i, { code: "commander.unknownCommand" });
2043
+ }
2044
+ /**
2045
+ * Get or set the program version.
2046
+ *
2047
+ * This method auto-registers the "-V, --version" option which will print the version number.
2048
+ *
2049
+ * You can optionally supply the flags and description to override the defaults.
2050
+ *
2051
+ * @param {string} [str]
2052
+ * @param {string} [flags]
2053
+ * @param {string} [description]
2054
+ * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2055
+ */
2056
+ version(e, t, i) {
2057
+ if (e === void 0) return this._version;
2058
+ this._version = e, t = t || "-V, --version", i = i || "output the version number";
2059
+ let s = this.createOption(t, i);
2060
+ return this._versionOptionName = s.attributeName(), this._registerOption(s), this.on("option:" + s.name(), () => {
2061
+ this._outputConfiguration.writeOut(`${e}
2062
+ `), this._exit(0, "commander.version", e);
2063
+ }), this;
2064
+ }
2065
+ /**
2066
+ * Set the description.
2067
+ *
2068
+ * @param {string} [str]
2069
+ * @param {object} [argsDescription]
2070
+ * @return {(string|Command)}
2071
+ */
2072
+ description(e, t) {
2073
+ return e === void 0 && t === void 0 ? this._description : (this._description = e, t && (this._argsDescription = t), this);
2074
+ }
2075
+ /**
2076
+ * Set the summary. Used when listed as subcommand of parent.
2077
+ *
2078
+ * @param {string} [str]
2079
+ * @return {(string|Command)}
2080
+ */
2081
+ summary(e) {
2082
+ return e === void 0 ? this._summary : (this._summary = e, this);
2083
+ }
2084
+ /**
2085
+ * Set an alias for the command.
2086
+ *
2087
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
2088
+ *
2089
+ * @param {string} [alias]
2090
+ * @return {(string|Command)}
2091
+ */
2092
+ alias(e) {
2093
+ if (e === void 0) return this._aliases[0];
2094
+ let t = this;
2095
+ if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler && (t = this.commands[this.commands.length -
2096
+ 1]), e === t._name)
2097
+ throw new Error("Command alias can't be the same as its name");
2098
+ let i = this.parent?._findCommand(e);
2099
+ if (i) {
2100
+ let s = [i.name()].concat(i.aliases()).join("|");
2101
+ throw new Error(
2102
+ `cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`
2103
+ );
2104
+ }
2105
+ return t._aliases.push(e), this;
2106
+ }
2107
+ /**
2108
+ * Set aliases for the command.
2109
+ *
2110
+ * Only the first alias is shown in the auto-generated help.
2111
+ *
2112
+ * @param {string[]} [aliases]
2113
+ * @return {(string[]|Command)}
2114
+ */
2115
+ aliases(e) {
2116
+ return e === void 0 ? this._aliases : (e.forEach((t) => this.alias(t)), this);
2117
+ }
2118
+ /**
2119
+ * Set / get the command usage `str`.
2120
+ *
2121
+ * @param {string} [str]
2122
+ * @return {(string|Command)}
2123
+ */
2124
+ usage(e) {
2125
+ if (e === void 0) {
2126
+ if (this._usage) return this._usage;
2127
+ let t = this.registeredArguments.map((i) => Ye(i));
2128
+ return [].concat(
2129
+ this.options.length || this._helpOption !== null ? "[options]" : [],
2130
+ this.commands.length ? "[command]" : [],
2131
+ this.registeredArguments.length ? t : []
2132
+ ).join(" ");
2133
+ }
2134
+ return this._usage = e, this;
2135
+ }
2136
+ /**
2137
+ * Get or set the name of the command.
2138
+ *
2139
+ * @param {string} [str]
2140
+ * @return {(string|Command)}
2141
+ */
2142
+ name(e) {
2143
+ return e === void 0 ? this._name : (this._name = e, this);
2144
+ }
2145
+ /**
2146
+ * Set the name of the command from script filename, such as process.argv[1],
2147
+ * or require.main.filename, or __filename.
2148
+ *
2149
+ * (Used internally and public although not documented in README.)
2150
+ *
2151
+ * @example
2152
+ * program.nameFromFilename(require.main.filename);
2153
+ *
2154
+ * @param {string} filename
2155
+ * @return {Command}
2156
+ */
2157
+ nameFromFilename(e) {
2158
+ return this._name = _.basename(e, _.extname(e)), this;
2159
+ }
2160
+ /**
2161
+ * Get or set the directory for searching for executable subcommands of this command.
2162
+ *
2163
+ * @example
2164
+ * program.executableDir(__dirname);
2165
+ * // or
2166
+ * program.executableDir('subcommands');
2167
+ *
2168
+ * @param {string} [path]
2169
+ * @return {(string|null|Command)}
2170
+ */
2171
+ executableDir(e) {
2172
+ return e === void 0 ? this._executableDir : (this._executableDir = e, this);
2173
+ }
2174
+ /**
2175
+ * Return program help documentation.
2176
+ *
2177
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
2178
+ * @return {string}
2179
+ */
2180
+ helpInformation(e) {
2181
+ let t = this.createHelp();
2182
+ return t.helpWidth === void 0 && (t.helpWidth = e && e.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.
2183
+ getOutHelpWidth()), t.formatHelp(this, t);
2184
+ }
2185
+ /**
2186
+ * @private
2187
+ */
2188
+ _getHelpContext(e) {
2189
+ e = e || {};
2190
+ let t = { error: !!e.error }, i;
2191
+ return t.error ? i = /* @__PURE__ */ d((s) => this._outputConfiguration.writeErr(s), "write") : i = /* @__PURE__ */ d((s) => this._outputConfiguration.
2192
+ writeOut(s), "write"), t.write = e.write || i, t.command = this, t;
2193
+ }
2194
+ /**
2195
+ * Output help information for this command.
2196
+ *
2197
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2198
+ *
2199
+ * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2200
+ */
2201
+ outputHelp(e) {
2202
+ let t;
2203
+ typeof e == "function" && (t = e, e = void 0);
2204
+ let i = this._getHelpContext(e);
2205
+ this._getCommandAndAncestors().reverse().forEach((r) => r.emit("beforeAllHelp", i)), this.emit("beforeHelp", i);
2206
+ let s = this.helpInformation(i);
2207
+ if (t && (s = t(s), typeof s != "string" && !Buffer.isBuffer(s)))
2208
+ throw new Error("outputHelp callback must return a string or a Buffer");
2209
+ i.write(s), this._getHelpOption()?.long && this.emit(this._getHelpOption().long), this.emit("afterHelp", i), this._getCommandAndAncestors().
2210
+ forEach(
2211
+ (r) => r.emit("afterAllHelp", i)
2212
+ );
2213
+ }
2214
+ /**
2215
+ * You can pass in flags and a description to customise the built-in help option.
2216
+ * Pass in false to disable the built-in help option.
2217
+ *
2218
+ * @example
2219
+ * program.helpOption('-?, --help' 'show help'); // customise
2220
+ * program.helpOption(false); // disable
2221
+ *
2222
+ * @param {(string | boolean)} flags
2223
+ * @param {string} [description]
2224
+ * @return {Command} `this` command for chaining
2225
+ */
2226
+ helpOption(e, t) {
2227
+ return typeof e == "boolean" ? (e ? this._helpOption = this._helpOption ?? void 0 : this._helpOption = null, this) : (e = e ?? "-h, --\
2228
+ help", t = t ?? "display help for command", this._helpOption = this.createOption(e, t), this);
2229
+ }
2230
+ /**
2231
+ * Lazy create help option.
2232
+ * Returns null if has been disabled with .helpOption(false).
2233
+ *
2234
+ * @returns {(Option | null)} the help option
2235
+ * @package
2236
+ */
2237
+ _getHelpOption() {
2238
+ return this._helpOption === void 0 && this.helpOption(void 0, void 0), this._helpOption;
2239
+ }
2240
+ /**
2241
+ * Supply your own option to use for the built-in help option.
2242
+ * This is an alternative to using helpOption() to customise the flags and description etc.
2243
+ *
2244
+ * @param {Option} option
2245
+ * @return {Command} `this` command for chaining
2246
+ */
2247
+ addHelpOption(e) {
2248
+ return this._helpOption = e, this;
2249
+ }
2250
+ /**
2251
+ * Output help information and exit.
2252
+ *
2253
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
2254
+ *
2255
+ * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
2256
+ */
2257
+ help(e) {
2258
+ this.outputHelp(e);
2259
+ let t = h.exitCode || 0;
2260
+ t === 0 && e && typeof e != "function" && e.error && (t = 1), this._exit(t, "commander.help", "(outputHelp)");
2261
+ }
2262
+ /**
2263
+ * Add additional text to be displayed with the built-in help.
2264
+ *
2265
+ * Position is 'before' or 'after' to affect just this command,
2266
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
2267
+ *
2268
+ * @param {string} position - before or after built-in help
2269
+ * @param {(string | Function)} text - string to add, or a function returning a string
2270
+ * @return {Command} `this` command for chaining
2271
+ */
2272
+ addHelpText(e, t) {
2273
+ let i = ["beforeAll", "before", "after", "afterAll"];
2274
+ if (!i.includes(e))
2275
+ throw new Error(`Unexpected value for position to addHelpText.
2276
+ Expecting one of '${i.join("', '")}'`);
2277
+ let s = `${e}Help`;
2278
+ return this.on(s, (r) => {
2279
+ let o;
2280
+ typeof t == "function" ? o = t({ error: r.error, command: r.command }) : o = t, o && r.write(`${o}
2281
+ `);
2282
+ }), this;
2283
+ }
2284
+ /**
2285
+ * Output help information if help flags specified
2286
+ *
2287
+ * @param {Array} args - array of options to search for help flags
2288
+ * @private
2289
+ */
2290
+ _outputHelpIfRequested(e) {
2291
+ let t = this._getHelpOption();
2292
+ t && e.find((s) => t.is(s)) && (this.outputHelp(), this._exit(0, "commander.helpDisplayed", "(outputHelp)"));
2293
+ }
2294
+ };
2295
+ function ue(n) {
2296
+ return n.map((e) => {
2297
+ if (!e.startsWith("--inspect"))
2298
+ return e;
2299
+ let t, i = "127.0.0.1", s = "9229", r;
2300
+ return (r = e.match(/^(--inspect(-brk)?)$/)) !== null ? t = r[1] : (r = e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null ? (t =
2301
+ r[1], /^\d+$/.test(r[3]) ? s = r[3] : i = r[3]) : (r = e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null && (t = r[1], i =
2302
+ r[3], s = r[4]), t && s !== "0" ? `${t}=${i}:${parseInt(s) + 1}` : e;
2303
+ });
2304
+ }
2305
+ d(ue, "incrementNodeInspectorPort");
2306
+ he.Command = Q;
2307
+ });
2308
+
2309
+ // ../node_modules/commander/index.js
2310
+ var xe = b((g) => {
2311
+ var { Argument: fe } = V(), { Command: X } = me(), { CommanderError: Qe, InvalidArgumentError: ge } = j(), { Help: Xe } = W(), { Option: be } = J();
2312
+ g.program = new X();
2313
+ g.createCommand = (n) => new X(n);
2314
+ g.createOption = (n, e) => new be(n, e);
2315
+ g.createArgument = (n, e) => new fe(n, e);
2316
+ g.Command = X;
2317
+ g.Option = be;
2318
+ g.Argument = fe;
2319
+ g.Help = Xe;
2320
+ g.CommanderError = Qe;
2321
+ g.InvalidArgumentError = ge;
2322
+ g.InvalidOptionArgumentError = ge;
2323
+ });
2324
+
2325
+ // ../node_modules/walk-up-path/dist/cjs/index.js
2326
+ var ye = b((H) => {
2327
+ "use strict";
2328
+ Object.defineProperty(H, "__esModule", { value: !0 });
2329
+ H.walkUp = void 0;
2330
+ var _e = C("path"), Ze = /* @__PURE__ */ d(function* (n) {
2331
+ for (n = (0, _e.resolve)(n); n; ) {
2332
+ yield n;
2333
+ let e = (0, _e.dirname)(n);
2334
+ if (e === n)
2335
+ break;
2336
+ n = e;
2337
+ }
2338
+ }, "walkUp");
2339
+ H.walkUp = Ze;
2340
+ });
2341
+
2342
+ // ../node_modules/picocolors/picocolors.js
2343
+ var je = b((zt, te) => {
2344
+ var P = process || {}, Oe = P.argv || [], D = P.env || {}, nt = !(D.NO_COLOR || Oe.includes("--no-color")) && (!!D.FORCE_COLOR || Oe.includes(
2345
+ "--color") || P.platform === "win32" || (P.stdout || {}).isTTY && D.TERM !== "dumb" || !!D.CI), ot = /* @__PURE__ */ d((n, e, t = n) => (i) => {
2346
+ let s = "" + i, r = s.indexOf(e, n.length);
2347
+ return ~r ? n + at(s, e, t, r) + e : n + s + e;
2348
+ }, "formatter"), at = /* @__PURE__ */ d((n, e, t, i) => {
2349
+ let s = "", r = 0;
2350
+ do
2351
+ s += n.substring(r, i) + t, r = i + e.length, i = n.indexOf(e, r);
2352
+ while (~i);
2353
+ return s + n.substring(r);
2354
+ }, "replaceClose"), Ce = /* @__PURE__ */ d((n = nt) => {
2355
+ let e = n ? ot : () => String;
2356
+ return {
2357
+ isColorSupported: n,
2358
+ reset: e("\x1B[0m", "\x1B[0m"),
2359
+ bold: e("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
2360
+ dim: e("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
2361
+ italic: e("\x1B[3m", "\x1B[23m"),
2362
+ underline: e("\x1B[4m", "\x1B[24m"),
2363
+ inverse: e("\x1B[7m", "\x1B[27m"),
2364
+ hidden: e("\x1B[8m", "\x1B[28m"),
2365
+ strikethrough: e("\x1B[9m", "\x1B[29m"),
2366
+ black: e("\x1B[30m", "\x1B[39m"),
2367
+ red: e("\x1B[31m", "\x1B[39m"),
2368
+ green: e("\x1B[32m", "\x1B[39m"),
2369
+ yellow: e("\x1B[33m", "\x1B[39m"),
2370
+ blue: e("\x1B[34m", "\x1B[39m"),
2371
+ magenta: e("\x1B[35m", "\x1B[39m"),
2372
+ cyan: e("\x1B[36m", "\x1B[39m"),
2373
+ white: e("\x1B[37m", "\x1B[39m"),
2374
+ gray: e("\x1B[90m", "\x1B[39m"),
2375
+ bgBlack: e("\x1B[40m", "\x1B[49m"),
2376
+ bgRed: e("\x1B[41m", "\x1B[49m"),
2377
+ bgGreen: e("\x1B[42m", "\x1B[49m"),
2378
+ bgYellow: e("\x1B[43m", "\x1B[49m"),
2379
+ bgBlue: e("\x1B[44m", "\x1B[49m"),
2380
+ bgMagenta: e("\x1B[45m", "\x1B[49m"),
2381
+ bgCyan: e("\x1B[46m", "\x1B[49m"),
2382
+ bgWhite: e("\x1B[47m", "\x1B[49m"),
2383
+ blackBright: e("\x1B[90m", "\x1B[39m"),
2384
+ redBright: e("\x1B[91m", "\x1B[39m"),
2385
+ greenBright: e("\x1B[92m", "\x1B[39m"),
2386
+ yellowBright: e("\x1B[93m", "\x1B[39m"),
2387
+ blueBright: e("\x1B[94m", "\x1B[39m"),
2388
+ magentaBright: e("\x1B[95m", "\x1B[39m"),
2389
+ cyanBright: e("\x1B[96m", "\x1B[39m"),
2390
+ whiteBright: e("\x1B[97m", "\x1B[39m"),
2391
+ bgBlackBright: e("\x1B[100m", "\x1B[49m"),
2392
+ bgRedBright: e("\x1B[101m", "\x1B[49m"),
2393
+ bgGreenBright: e("\x1B[102m", "\x1B[49m"),
2394
+ bgYellowBright: e("\x1B[103m", "\x1B[49m"),
2395
+ bgBlueBright: e("\x1B[104m", "\x1B[49m"),
2396
+ bgMagentaBright: e("\x1B[105m", "\x1B[49m"),
2397
+ bgCyanBright: e("\x1B[106m", "\x1B[49m"),
2398
+ bgWhiteBright: e("\x1B[107m", "\x1B[49m")
2399
+ };
2400
+ }, "createColors");
2401
+ te.exports = Ce();
2402
+ te.exports.createColors = Ce;
2403
+ });
2404
+
2405
+ // ../node_modules/ts-dedent/dist/index.js
2406
+ var $e = b((k) => {
2407
+ "use strict";
2408
+ Object.defineProperty(k, "__esModule", { value: !0 });
2409
+ k.dedent = void 0;
2410
+ function Se(n) {
2411
+ for (var e = [], t = 1; t < arguments.length; t++)
2412
+ e[t - 1] = arguments[t];
2413
+ var i = Array.from(typeof n == "string" ? [n] : n);
2414
+ i[i.length - 1] = i[i.length - 1].replace(/\r?\n([\t ]*)$/, "");
2415
+ var s = i.reduce(function(l, a) {
2416
+ var c = a.match(/\n([\t ]+|(?!\s).)/g);
2417
+ return c ? l.concat(c.map(function(p) {
2418
+ var u, m;
2419
+ return (m = (u = p.match(/[\t ]/g)) === null || u === void 0 ? void 0 : u.length) !== null && m !== void 0 ? m : 0;
2420
+ })) : l;
2421
+ }, []);
2422
+ if (s.length) {
2423
+ var r = new RegExp(`
2424
+ [ ]{` + Math.min.apply(Math, s) + "}", "g");
2425
+ i = i.map(function(l) {
2426
+ return l.replace(r, `
2427
+ `);
2428
+ });
2429
+ }
2430
+ i[0] = i[0].replace(/^\r?\n/, "");
2431
+ var o = i[0];
2432
+ return e.forEach(function(l, a) {
2433
+ var c = o.match(/(?:^|\n)( *)$/), p = c ? c[1] : "", u = l;
2434
+ typeof l == "string" && l.includes(`
2435
+ `) && (u = String(l).split(`
2436
+ `).map(function(m, x) {
2437
+ return x === 0 ? m : "" + p + m;
2438
+ }).join(`
2439
+ `)), o += u + i[a + 1];
2440
+ }), o;
2441
+ }
2442
+ d(Se, "dedent");
2443
+ k.dedent = Se;
2444
+ k.default = Se;
2445
+ });
2446
+
2447
+ // src/cli/bin/index.ts
2448
+ var A = $(xe(), 1);
2449
+ import { getEnvConfig as re, parseList as vt, versions as wt } from "storybook/internal/common";
2450
+ import { logger as ne } from "storybook/internal/node-logger";
2451
+ import { addToGlobalContext as Ot } from "storybook/internal/telemetry";
2452
+
2453
+ // ../node_modules/fd-package-json/dist/esm/main.js
2454
+ var ve = $(ye(), 1);
2455
+ import { resolve as et } from "node:path";
2456
+ import { stat as tt, readFile as it } from "node:fs/promises";
2457
+ import { statSync as Wt, readFileSync as Rt } from "node:fs";
2458
+ async function st(n) {
2459
+ try {
2460
+ return (await tt(n)).isFile();
2461
+ } catch {
2462
+ return !1;
2463
+ }
2464
+ }
2465
+ d(st, "fileExists");
2466
+ async function rt(n) {
2467
+ for (let e of (0, ve.walkUp)(n)) {
2468
+ let t = et(e, "package.json");
2469
+ if (await st(t))
2470
+ return t;
2471
+ }
2472
+ return null;
2473
+ }
2474
+ d(rt, "findPackagePath");
2475
+ async function v(n) {
2476
+ let e = await rt(n);
2477
+ if (!e)
2478
+ return null;
2479
+ try {
2480
+ let t = await it(e, { encoding: "utf8" });
2481
+ return JSON.parse(t);
2482
+ } catch {
2483
+ return null;
2484
+ }
2485
+ }
2486
+ d(v, "findPackage");
2487
+
2488
+ // node_modules/leven/index.js
2489
+ var Z = [], we = [];
2490
+ function ee(n, e) {
2491
+ if (n === e)
2492
+ return 0;
2493
+ let t = n;
2494
+ n.length > e.length && (n = e, e = t);
2495
+ let i = n.length, s = e.length;
2496
+ for (; i > 0 && n.charCodeAt(~-i) === e.charCodeAt(~-s); )
2497
+ i--, s--;
2498
+ let r = 0;
2499
+ for (; r < i && n.charCodeAt(r) === e.charCodeAt(r); )
2500
+ r++;
2501
+ if (i -= r, s -= r, i === 0)
2502
+ return s;
2503
+ let o, l, a, c, p = 0, u = 0;
2504
+ for (; p < i; )
2505
+ we[p] = n.charCodeAt(r + p), Z[p] = ++p;
2506
+ for (; u < s; )
2507
+ for (o = e.charCodeAt(r + u), a = u++, l = u, p = 0; p < i; p++)
2508
+ c = o === we[p] ? a : a + 1, a = Z[p], l = Z[p] = a > l ? c > l ? l + 1 : c : c > a ? a + 1 : c;
2509
+ return l;
2510
+ }
2511
+ d(ee, "leven");
2512
+
2513
+ // src/cli/bin/index.ts
2514
+ var E = $(je(), 1);
2515
+
2516
+ // ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
2517
+ var lt = process.env.NODE_ENV === "production", ie = "Invariant failed";
2518
+ function w(n, e) {
2519
+ if (!n) {
2520
+ if (lt)
2521
+ throw new Error(ie);
2522
+ var t = typeof e == "function" ? e() : e, i = t ? "".concat(ie, ": ").concat(t) : ie;
2523
+ throw new Error(i);
2524
+ }
2525
+ }
2526
+ d(w, "invariant");
2527
+
2528
+ // package.json
2529
+ var ke = "9.0.0-alpha.11";
2530
+
2531
+ // src/cli/build.ts
2532
+ import { cache as ct } from "storybook/internal/common";
2533
+ import { buildStaticStandalone as pt, withTelemetry as ut } from "storybook/internal/core-server";
2534
+ var Ae = /* @__PURE__ */ d(async (n) => {
2535
+ let e = await v(__dirname);
2536
+ w(e, "Failed to find the closest package.json file.");
2537
+ let t = {
2538
+ ...n,
2539
+ configDir: n.configDir || "./.storybook",
2540
+ outputDir: n.outputDir || "./storybook-static",
2541
+ ignorePreview: !!n.previewUrl && !n.forceBuildPreview,
2542
+ configType: "PRODUCTION",
2543
+ cache: ct,
2544
+ packageJson: e
2545
+ };
2546
+ await ut(
2547
+ "build",
2548
+ { cliOptions: n, presetOptions: t },
2549
+ () => pt(t)
2550
+ );
2551
+ }, "build");
2552
+
2553
+ // src/cli/buildIndex.ts
2554
+ import { cache as ht } from "storybook/internal/common";
2555
+ import { buildIndexStandalone as mt, withTelemetry as ft } from "storybook/internal/core-server";
2556
+ var Ee = /* @__PURE__ */ d(async (n) => {
2557
+ let e = {
2558
+ ...n,
2559
+ configDir: n.configDir || ".storybook",
2560
+ outputFile: n.outputFile || "index.json",
2561
+ ignorePreview: !0,
2562
+ configType: "PRODUCTION",
2563
+ cache: ht,
2564
+ packageJson: n.packageJson
2565
+ }, t = {
2566
+ ...e,
2567
+ corePresets: [],
2568
+ overridePresets: []
2569
+ };
2570
+ await ft("index", { cliOptions: n, presetOptions: t }, () => mt(e));
2571
+ }, "buildIndex");
2572
+
2573
+ // src/cli/dev.ts
2574
+ import { cache as gt } from "storybook/internal/common";
2575
+ import { buildDevStandalone as bt, withTelemetry as xt } from "storybook/internal/core-server";
2576
+ import { logger as O, instance as _t } from "storybook/internal/node-logger";
2577
+ var se = $($e(), 1);
2578
+ function yt(n) {
2579
+ _t.heading = "", n instanceof Error ? n.error ? O.error(n.error) : n.stats && n.stats.compilation.errors ? n.stats.compilation.errors.forEach(
2580
+ (e) => O.plain(e)) : O.error(n) : n.compilation?.errors && n.compilation.errors.forEach((e) => O.plain(e)), O.line(), O.warn(
2581
+ n.close ? se.dedent`
2582
+ FATAL broken build!, will close the process,
2583
+ Fix the error below and restart storybook.
2584
+ ` : se.dedent`
2585
+ Broken build, fix the error above.
2586
+ You may need to refresh the browser.
2587
+ `
2588
+ ), O.line();
2589
+ }
2590
+ d(yt, "printError");
2591
+ var qe = /* @__PURE__ */ d(async (n) => {
2592
+ let { env: e } = process;
2593
+ e.NODE_ENV = e.NODE_ENV || "development";
2594
+ let t = await v(__dirname);
2595
+ w(t, "Failed to find the closest package.json file.");
2596
+ let i = {
2597
+ ...n,
2598
+ configDir: n.configDir || "./.storybook",
2599
+ configType: "DEVELOPMENT",
2600
+ ignorePreview: !!n.previewUrl && !n.forceBuildPreview,
2601
+ cache: gt,
2602
+ packageJson: t
2603
+ };
2604
+ await xt(
2605
+ "dev",
2606
+ {
2607
+ cliOptions: n,
2608
+ presetOptions: i,
2609
+ printError: yt
2610
+ },
2611
+ () => bt(i)
2612
+ );
2613
+ }, "dev");
2614
+
2615
+ // src/cli/bin/index.ts
2616
+ Ot("cliVersion", wt.storybook);
2617
+ var S = console, oe = /* @__PURE__ */ d((n) => A.program.command(n).option(
2618
+ "--disable-telemetry",
2619
+ "Disable sending telemetry data",
2620
+ // default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true
2621
+ process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== "false"
2622
+ ).option("--debug", "Get more logs in debug mode", !1).option("--enable-crash-reports", "Enable sending crash reports to telemetry data"), "\
2623
+ command");
2624
+ oe("dev").option("-p, --port <number>", "Port to run Storybook", (n) => parseInt(n, 10)).option("-h, --host <string>", "Host to run Storyboo\
2625
+ k").option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option(
2626
+ "--https",
2627
+ "Serve Storybook over HTTPS. Note: You must provide your own certificate information."
2628
+ ).option(
2629
+ "--ssl-ca <ca>",
2630
+ "Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",
2631
+ vt
2632
+ ).option("--ssl-cert <cert>", "Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>", "Provide an SSL key. (Require\
2633
+ d with --https)").option("--smoke-test", "Exit after successful start").option("--ci", "CI mode (skip interactive prompts, don't open browse\
2634
+ r)").option("--no-open", "Do not open Storybook automatically in the browser").option("--loglevel <level>", "Control level of logging during\
2635
+ build").option("--quiet", "Suppress verbose build output").option("--no-version-updates", "Suppress update check", !0).option("--debug-webp\
2636
+ ack", "Display final webpack configurations for debugging purposes").option(
2637
+ "--webpack-stats-json [directory]",
2638
+ "Write Webpack stats JSON to disk (synonym for `--stats-json`)"
2639
+ ).option("--stats-json [directory]", "Write stats JSON to disk").option(
2640
+ "--preview-url <string>",
2641
+ "Disables the default storybook preview and lets your use your own"
2642
+ ).option("--force-build-preview", "Build the preview iframe even if you are using --preview-url").option("--docs", "Build a documentation-on\
2643
+ ly site using addon-docs").option("--exact-port", "Exit early if the desired port is not available").option(
2644
+ "--initial-path [path]",
2645
+ "URL path to be appended when visiting Storybook for the first time"
2646
+ ).action(async (n) => {
2647
+ ne.setLevel(n.loglevel);
2648
+ let e = await v(__dirname);
2649
+ w(e, "Failed to find the closest package.json file."), S.log(E.default.bold(`${e.name} v${e.version}`) + E.default.reset(`
2650
+ `)), re(n, {
2651
+ port: "SBCONFIG_PORT",
2652
+ host: "SBCONFIG_HOSTNAME",
2653
+ staticDir: "SBCONFIG_STATIC_DIR",
2654
+ configDir: "SBCONFIG_CONFIG_DIR",
2655
+ ci: "CI"
2656
+ }), parseInt(`${n.port}`, 10) && (n.port = parseInt(`${n.port}`, 10)), await qe({ ...n, packageJson: e }).catch(() => process.exit(1));
2657
+ });
2658
+ oe("build").option("-o, --output-dir <dir-name>", "Directory where to store built files").option("-c, --config-dir <dir-name>", "Directory w\
2659
+ here to load Storybook configurations from").option("--quiet", "Suppress verbose build output").option("--loglevel <level>", "Control level \
2660
+ of logging during build").option("--debug-webpack", "Display final webpack configurations for debugging purposes").option(
2661
+ "--webpack-stats-json [directory]",
2662
+ "Write Webpack stats JSON to disk (synonym for `--stats-json`)"
2663
+ ).option("--stats-json [directory]", "Write stats JSON to disk").option(
2664
+ "--preview-url <string>",
2665
+ "Disables the default storybook preview and lets your use your own"
2666
+ ).option("--force-build-preview", "Build the preview iframe even if you are using --preview-url").option("--docs", "Build a documentation-on\
2667
+ ly site using addon-docs").option("--test", "Build stories optimized for testing purposes.").action(async (n) => {
2668
+ let { env: e } = process;
2669
+ e.NODE_ENV = e.NODE_ENV || "production";
2670
+ let t = await v(__dirname);
2671
+ w(t, "Failed to find the closest package.json file."), ne.setLevel(n.loglevel), S.log(E.default.bold(`${t.name} v${t.version}
2672
+ `)), re(n, {
2673
+ staticDir: "SBCONFIG_STATIC_DIR",
2674
+ outputDir: "SBCONFIG_OUTPUT_DIR",
2675
+ configDir: "SBCONFIG_CONFIG_DIR"
2676
+ }), await Ae({
2677
+ ...n,
2678
+ packageJson: t,
2679
+ test: !!n.test || process.env.SB_TESTBUILD === "true"
2680
+ }).catch(() => process.exit(1));
2681
+ });
2682
+ oe("index").option("-o, --output-file <file-name>", "JSON file to output index").option("-c, --config-dir <dir-name>", "Directory where to l\
2683
+ oad Storybook configurations from").option("--quiet", "Suppress verbose build output").option("--loglevel <level>", "Control level of loggin\
2684
+ g during build").action(async (n) => {
2685
+ let { env: e } = process;
2686
+ e.NODE_ENV = e.NODE_ENV || "production";
2687
+ let t = await v(__dirname);
2688
+ w(t, "Failed to find the closest package.json file."), ne.setLevel(n.loglevel), S.log(E.default.bold(`${t.name} v${t.version}
2689
+ `)), re(n, {
2690
+ configDir: "SBCONFIG_CONFIG_DIR",
2691
+ outputFile: "SBCONFIG_OUTPUT_FILE"
2692
+ }), await Ee({
2693
+ ...n,
2694
+ packageJson: t
2695
+ }).catch(() => process.exit(1));
2696
+ });
2697
+ A.program.on("command:*", ([n]) => {
2698
+ S.error(
2699
+ ` Invalid command: %s.
2700
+ See --help for a list of available commands.`,
2701
+ n
2702
+ );
2703
+ let t = A.program.commands.map((i) => i.name()).find((i) => ee(i, n) < 3);
2704
+ t && S.info(`
2705
+ Did you mean ${t}?`), process.exit(1);
2706
+ });
2707
+ A.program.usage("<command> [options]").version(String(ke)).parse(process.argv);