@storm-software/k8s-tools 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/executors.json +9 -0
  4. package/generators.json +14 -0
  5. package/index.js +4109 -0
  6. package/meta.json +1 -0
  7. package/package.json +71 -0
  8. package/packages/build-tools/src/build/index.d.ts +3 -0
  9. package/packages/build-tools/src/build/rolldown.d.ts +20 -0
  10. package/packages/build-tools/src/build/ts-build.d.ts +20 -0
  11. package/packages/build-tools/src/build/unbuild.d.ts +20 -0
  12. package/packages/build-tools/src/cli/index.d.ts +2 -0
  13. package/packages/build-tools/src/config/browser-config.d.ts +2 -0
  14. package/packages/build-tools/src/config/default-config.d.ts +2 -0
  15. package/packages/build-tools/src/config/get-config.d.ts +2 -0
  16. package/packages/build-tools/src/config/get-rolldown-config.d.ts +6 -0
  17. package/packages/build-tools/src/config/get-unbuild-config.d.ts +6 -0
  18. package/packages/build-tools/src/config/index.d.ts +7 -0
  19. package/packages/build-tools/src/config/neutral-config.d.ts +2 -0
  20. package/packages/build-tools/src/config/node-config.d.ts +3 -0
  21. package/packages/build-tools/src/index.d.ts +6 -0
  22. package/packages/build-tools/src/plugins/analyze-plugin.d.ts +4 -0
  23. package/packages/build-tools/src/plugins/index.d.ts +4 -0
  24. package/packages/build-tools/src/plugins/swc-plugin.d.ts +2 -0
  25. package/packages/build-tools/src/plugins/ts-resolve.d.ts +6 -0
  26. package/packages/build-tools/src/plugins/type-definitions.d.ts +7 -0
  27. package/packages/build-tools/src/types.d.ts +213 -0
  28. package/packages/build-tools/src/utils/apply-default-options.d.ts +6 -0
  29. package/packages/build-tools/src/utils/generate-package-json.d.ts +7 -0
  30. package/packages/build-tools/src/utils/get-entry-points.d.ts +3 -0
  31. package/packages/build-tools/src/utils/get-file-banner.d.ts +8 -0
  32. package/packages/build-tools/src/utils/get-project-deps.d.ts +5 -0
  33. package/packages/build-tools/src/utils/index.d.ts +7 -0
  34. package/packages/build-tools/src/utils/out-extension.d.ts +8 -0
  35. package/packages/build-tools/src/utils/run-tsup-build.d.ts +3 -0
  36. package/packages/build-tools/src/utils/task-graph.d.ts +6 -0
  37. package/packages/config/src/constants.d.ts +3 -0
  38. package/packages/config/src/define-config.d.ts +174 -0
  39. package/packages/config/src/index.d.ts +12 -0
  40. package/packages/config/src/schema.d.ts +1915 -0
  41. package/packages/config/src/types.d.ts +23 -0
  42. package/packages/config-tools/src/config-file/get-config-file.d.ts +16 -0
  43. package/packages/config-tools/src/config-file/index.d.ts +1 -0
  44. package/packages/config-tools/src/create-storm-config.d.ts +26 -0
  45. package/packages/config-tools/src/env/get-env.d.ts +15 -0
  46. package/packages/config-tools/src/env/index.d.ts +2 -0
  47. package/packages/config-tools/src/env/set-env.d.ts +14 -0
  48. package/packages/config-tools/src/index.d.ts +13 -0
  49. package/packages/config-tools/src/types.d.ts +33 -0
  50. package/packages/config-tools/src/utilities/apply-workspace-tokens.d.ts +4 -0
  51. package/packages/config-tools/src/utilities/chalk.d.ts +23 -0
  52. package/packages/config-tools/src/utilities/correct-paths.d.ts +1 -0
  53. package/packages/config-tools/src/utilities/file-path-utils.d.ts +2 -0
  54. package/packages/config-tools/src/utilities/find-up.d.ts +4 -0
  55. package/packages/config-tools/src/utilities/find-workspace-root.d.ts +14 -0
  56. package/packages/config-tools/src/utilities/get-default-config.d.ts +15 -0
  57. package/packages/config-tools/src/utilities/get-log-level.d.ts +15 -0
  58. package/packages/config-tools/src/utilities/index.d.ts +10 -0
  59. package/packages/config-tools/src/utilities/logger.d.ts +74 -0
  60. package/packages/config-tools/src/utilities/process-handler.d.ts +4 -0
  61. package/packages/config-tools/src/utilities/run.d.ts +18 -0
  62. package/packages/k8s-tools/index.d.ts +1 -0
  63. package/packages/k8s-tools/src/executors/helm-package/executor.d.ts +8 -0
  64. package/packages/k8s-tools/src/executors/index.d.ts +1 -0
  65. package/packages/k8s-tools/src/generators/helm-chart/generator.d.ts +5 -0
  66. package/packages/k8s-tools/src/generators/helm-dependency/generator.d.ts +5 -0
  67. package/packages/k8s-tools/src/generators/index.d.ts +2 -0
  68. package/packages/k8s-tools/src/index.d.ts +2 -0
  69. package/packages/k8s-tools/src/types.d.ts +28 -0
  70. package/packages/k8s-tools/src/utils/client.d.ts +26 -0
  71. package/packages/k8s-tools/src/utils/ensure-init.d.ts +9 -0
  72. package/packages/k8s-tools/src/utils/prettier.d.ts +9 -0
  73. package/packages/workspace-tools/index.d.ts +32 -0
  74. package/packages/workspace-tools/src/base/base-executor.d.ts +7 -0
  75. package/packages/workspace-tools/src/base/base-generator.d.ts +4 -0
  76. package/packages/workspace-tools/src/base/index.d.ts +3 -0
  77. package/packages/workspace-tools/src/base/typescript-library-generator.d.ts +8 -0
  78. package/packages/workspace-tools/src/executors/cargo-publish/executor.d.ts +6 -0
  79. package/packages/workspace-tools/src/executors/clean-package/constants.d.ts +4 -0
  80. package/packages/workspace-tools/src/executors/clean-package/executor.d.ts +8 -0
  81. package/packages/workspace-tools/src/executors/clean-package/types.d.ts +8 -0
  82. package/packages/workspace-tools/src/executors/clean-package/utils.d.ts +4 -0
  83. package/packages/workspace-tools/src/executors/npm-publish/executor.d.ts +6 -0
  84. package/packages/workspace-tools/src/executors/rolldown/executor.d.ts +9 -0
  85. package/packages/workspace-tools/src/executors/size-limit/executor.d.ts +8 -0
  86. package/packages/workspace-tools/src/executors/tsup/executor.d.ts +8 -0
  87. package/packages/workspace-tools/src/executors/tsup-browser/executor.d.ts +8 -0
  88. package/packages/workspace-tools/src/executors/tsup-neutral/executor.d.ts +8 -0
  89. package/packages/workspace-tools/src/executors/tsup-node/executor.d.ts +8 -0
  90. package/packages/workspace-tools/src/executors/typia/executor.d.ts +8 -0
  91. package/packages/workspace-tools/src/executors/unbuild/executor.d.ts +9 -0
  92. package/packages/workspace-tools/src/generators/config-schema/generator.d.ts +13 -0
  93. package/packages/workspace-tools/src/generators/init/init.d.ts +4 -0
  94. package/packages/workspace-tools/src/generators/node-library/generator.d.ts +5 -0
  95. package/packages/workspace-tools/src/generators/preset/generator.d.ts +5 -0
  96. package/packages/workspace-tools/src/generators/release-version/generator.d.ts +13 -0
  97. package/packages/workspace-tools/src/utils/apply-workspace-tokens.d.ts +8 -0
  98. package/packages/workspace-tools/src/utils/cargo.d.ts +26 -0
  99. package/packages/workspace-tools/src/utils/create-cli-options.d.ts +1 -0
  100. package/packages/workspace-tools/src/utils/get-project-configurations.d.ts +13 -0
  101. package/packages/workspace-tools/src/utils/index.d.ts +9 -0
  102. package/packages/workspace-tools/src/utils/lock-file.d.ts +23 -0
  103. package/packages/workspace-tools/src/utils/project-tags.d.ts +30 -0
  104. package/packages/workspace-tools/src/utils/toml.d.ts +167 -0
  105. package/packages/workspace-tools/src/utils/typia-transform.d.ts +2 -0
  106. package/packages/workspace-tools/src/utils/versions.d.ts +18 -0
  107. package/src/executors/helm-package/executor.js +1244 -0
  108. package/src/executors/helm-package/schema.d.ts +29 -0
  109. package/src/executors/helm-package/schema.json +112 -0
  110. package/src/generators/helm-chart/files/chart/.helmignore +23 -0
  111. package/src/generators/helm-chart/files/chart/Chart.yaml.template +6 -0
  112. package/src/generators/helm-chart/files/chart/templates/NOTES.txt +22 -0
  113. package/src/generators/helm-chart/files/chart/templates/_helpers.yaml +62 -0
  114. package/src/generators/helm-chart/files/chart/templates/deployment.yaml +68 -0
  115. package/src/generators/helm-chart/files/chart/templates/hpa.yaml +32 -0
  116. package/src/generators/helm-chart/files/chart/templates/ingress.yaml +61 -0
  117. package/src/generators/helm-chart/files/chart/templates/service.yaml +13 -0
  118. package/src/generators/helm-chart/files/chart/templates/serviceaccount.yaml +13 -0
  119. package/src/generators/helm-chart/files/chart/templates/test/test-connection.yaml +15 -0
  120. package/src/generators/helm-chart/files/chart/values.yaml +111 -0
  121. package/src/generators/helm-chart/generator.js +131 -0
  122. package/src/generators/helm-chart/schema.d.ts +11 -0
  123. package/src/generators/helm-chart/schema.json +48 -0
  124. package/src/generators/helm-dependency/generator.js +2805 -0
  125. package/src/generators/helm-dependency/schema.d.ts +15 -0
  126. package/src/generators/helm-dependency/schema.json +71 -0
package/index.js ADDED
@@ -0,0 +1,4109 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var __decorateClass = (decorators, target, key, kind) => {
32
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
33
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
34
+ if (decorator = decorators[i])
35
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
36
+ if (kind && result) __defProp(target, key, result);
37
+ return result;
38
+ };
39
+
40
+ // node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io-util.js
41
+ var require_io_util = __commonJS({
42
+ "node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io-util.js"(exports2) {
43
+ "use strict";
44
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
45
+ if (k2 === void 0) k2 = k;
46
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
47
+ return m[k];
48
+ } });
49
+ } : function(o, m, k, k2) {
50
+ if (k2 === void 0) k2 = k;
51
+ o[k2] = m[k];
52
+ });
53
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
54
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
55
+ } : function(o, v) {
56
+ o["default"] = v;
57
+ });
58
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
59
+ if (mod && mod.__esModule) return mod;
60
+ var result = {};
61
+ if (mod != null) {
62
+ for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
63
+ }
64
+ __setModuleDefault(result, mod);
65
+ return result;
66
+ };
67
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
68
+ function adopt(value) {
69
+ return value instanceof P ? value : new P(function(resolve) {
70
+ resolve(value);
71
+ });
72
+ }
73
+ return new (P || (P = Promise))(function(resolve, reject) {
74
+ function fulfilled(value) {
75
+ try {
76
+ step(generator.next(value));
77
+ } catch (e) {
78
+ reject(e);
79
+ }
80
+ }
81
+ function rejected(value) {
82
+ try {
83
+ step(generator["throw"](value));
84
+ } catch (e) {
85
+ reject(e);
86
+ }
87
+ }
88
+ function step(result) {
89
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
90
+ }
91
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
92
+ });
93
+ };
94
+ var _a;
95
+ Object.defineProperty(exports2, "__esModule", { value: true });
96
+ exports2.getCmdPath = exports2.tryGetExecutablePath = exports2.isRooted = exports2.isDirectory = exports2.exists = exports2.READONLY = exports2.UV_FS_O_EXLOCK = exports2.IS_WINDOWS = exports2.unlink = exports2.symlink = exports2.stat = exports2.rmdir = exports2.rm = exports2.rename = exports2.readlink = exports2.readdir = exports2.open = exports2.mkdir = exports2.lstat = exports2.copyFile = exports2.chmod = void 0;
97
+ var fs = __importStar(require("fs"));
98
+ var path = __importStar(require("path"));
99
+ _a = fs.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.readlink = _a.readlink, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
100
+ exports2.IS_WINDOWS = process.platform === "win32";
101
+ exports2.UV_FS_O_EXLOCK = 268435456;
102
+ exports2.READONLY = fs.constants.O_RDONLY;
103
+ function exists(fsPath) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ try {
106
+ yield exports2.stat(fsPath);
107
+ } catch (err) {
108
+ if (err.code === "ENOENT") {
109
+ return false;
110
+ }
111
+ throw err;
112
+ }
113
+ return true;
114
+ });
115
+ }
116
+ exports2.exists = exists;
117
+ function isDirectory(fsPath, useStat = false) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const stats = useStat ? yield exports2.stat(fsPath) : yield exports2.lstat(fsPath);
120
+ return stats.isDirectory();
121
+ });
122
+ }
123
+ exports2.isDirectory = isDirectory;
124
+ function isRooted(p) {
125
+ p = normalizeSeparators(p);
126
+ if (!p) {
127
+ throw new Error('isRooted() parameter "p" cannot be empty');
128
+ }
129
+ if (exports2.IS_WINDOWS) {
130
+ return p.startsWith("\\") || /^[A-Z]:/i.test(p);
131
+ }
132
+ return p.startsWith("/");
133
+ }
134
+ exports2.isRooted = isRooted;
135
+ function tryGetExecutablePath(filePath, extensions) {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ let stats = void 0;
138
+ try {
139
+ stats = yield exports2.stat(filePath);
140
+ } catch (err) {
141
+ if (err.code !== "ENOENT") {
142
+ console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
143
+ }
144
+ }
145
+ if (stats && stats.isFile()) {
146
+ if (exports2.IS_WINDOWS) {
147
+ const upperExt = path.extname(filePath).toUpperCase();
148
+ if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) {
149
+ return filePath;
150
+ }
151
+ } else {
152
+ if (isUnixExecutable(stats)) {
153
+ return filePath;
154
+ }
155
+ }
156
+ }
157
+ const originalFilePath = filePath;
158
+ for (const extension of extensions) {
159
+ filePath = originalFilePath + extension;
160
+ stats = void 0;
161
+ try {
162
+ stats = yield exports2.stat(filePath);
163
+ } catch (err) {
164
+ if (err.code !== "ENOENT") {
165
+ console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
166
+ }
167
+ }
168
+ if (stats && stats.isFile()) {
169
+ if (exports2.IS_WINDOWS) {
170
+ try {
171
+ const directory = path.dirname(filePath);
172
+ const upperName = path.basename(filePath).toUpperCase();
173
+ for (const actualName of yield exports2.readdir(directory)) {
174
+ if (upperName === actualName.toUpperCase()) {
175
+ filePath = path.join(directory, actualName);
176
+ break;
177
+ }
178
+ }
179
+ } catch (err) {
180
+ console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
181
+ }
182
+ return filePath;
183
+ } else {
184
+ if (isUnixExecutable(stats)) {
185
+ return filePath;
186
+ }
187
+ }
188
+ }
189
+ }
190
+ return "";
191
+ });
192
+ }
193
+ exports2.tryGetExecutablePath = tryGetExecutablePath;
194
+ function normalizeSeparators(p) {
195
+ p = p || "";
196
+ if (exports2.IS_WINDOWS) {
197
+ p = p.replace(/\//g, "\\");
198
+ return p.replace(/\\\\+/g, "\\");
199
+ }
200
+ return p.replace(/\/\/+/g, "/");
201
+ }
202
+ function isUnixExecutable(stats) {
203
+ return (stats.mode & 1) > 0 || (stats.mode & 8) > 0 && stats.gid === process.getgid() || (stats.mode & 64) > 0 && stats.uid === process.getuid();
204
+ }
205
+ function getCmdPath() {
206
+ var _a2;
207
+ return (_a2 = process.env["COMSPEC"]) !== null && _a2 !== void 0 ? _a2 : `cmd.exe`;
208
+ }
209
+ exports2.getCmdPath = getCmdPath;
210
+ }
211
+ });
212
+
213
+ // node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io.js
214
+ var require_io = __commonJS({
215
+ "node_modules/.pnpm/@actions+io@1.1.3/node_modules/@actions/io/lib/io.js"(exports2) {
216
+ "use strict";
217
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
218
+ if (k2 === void 0) k2 = k;
219
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
220
+ return m[k];
221
+ } });
222
+ } : function(o, m, k, k2) {
223
+ if (k2 === void 0) k2 = k;
224
+ o[k2] = m[k];
225
+ });
226
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
227
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
228
+ } : function(o, v) {
229
+ o["default"] = v;
230
+ });
231
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
232
+ if (mod && mod.__esModule) return mod;
233
+ var result = {};
234
+ if (mod != null) {
235
+ for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
236
+ }
237
+ __setModuleDefault(result, mod);
238
+ return result;
239
+ };
240
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
241
+ function adopt(value) {
242
+ return value instanceof P ? value : new P(function(resolve) {
243
+ resolve(value);
244
+ });
245
+ }
246
+ return new (P || (P = Promise))(function(resolve, reject) {
247
+ function fulfilled(value) {
248
+ try {
249
+ step(generator.next(value));
250
+ } catch (e) {
251
+ reject(e);
252
+ }
253
+ }
254
+ function rejected(value) {
255
+ try {
256
+ step(generator["throw"](value));
257
+ } catch (e) {
258
+ reject(e);
259
+ }
260
+ }
261
+ function step(result) {
262
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
263
+ }
264
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
265
+ });
266
+ };
267
+ Object.defineProperty(exports2, "__esModule", { value: true });
268
+ exports2.findInPath = exports2.which = exports2.mkdirP = exports2.rmRF = exports2.mv = exports2.cp = void 0;
269
+ var assert_1 = require("assert");
270
+ var path = __importStar(require("path"));
271
+ var ioUtil = __importStar(require_io_util());
272
+ function cp(source, dest, options = {}) {
273
+ return __awaiter(this, void 0, void 0, function* () {
274
+ const { force, recursive, copySourceDirectory } = readCopyOptions(options);
275
+ const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
276
+ if (destStat && destStat.isFile() && !force) {
277
+ return;
278
+ }
279
+ const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path.join(dest, path.basename(source)) : dest;
280
+ if (!(yield ioUtil.exists(source))) {
281
+ throw new Error(`no such file or directory: ${source}`);
282
+ }
283
+ const sourceStat = yield ioUtil.stat(source);
284
+ if (sourceStat.isDirectory()) {
285
+ if (!recursive) {
286
+ throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
287
+ } else {
288
+ yield cpDirRecursive(source, newDest, 0, force);
289
+ }
290
+ } else {
291
+ if (path.relative(source, newDest) === "") {
292
+ throw new Error(`'${newDest}' and '${source}' are the same file`);
293
+ }
294
+ yield copyFile(source, newDest, force);
295
+ }
296
+ });
297
+ }
298
+ exports2.cp = cp;
299
+ function mv(source, dest, options = {}) {
300
+ return __awaiter(this, void 0, void 0, function* () {
301
+ if (yield ioUtil.exists(dest)) {
302
+ let destExists = true;
303
+ if (yield ioUtil.isDirectory(dest)) {
304
+ dest = path.join(dest, path.basename(source));
305
+ destExists = yield ioUtil.exists(dest);
306
+ }
307
+ if (destExists) {
308
+ if (options.force == null || options.force) {
309
+ yield rmRF(dest);
310
+ } else {
311
+ throw new Error("Destination already exists");
312
+ }
313
+ }
314
+ }
315
+ yield mkdirP(path.dirname(dest));
316
+ yield ioUtil.rename(source, dest);
317
+ });
318
+ }
319
+ exports2.mv = mv;
320
+ function rmRF(inputPath) {
321
+ return __awaiter(this, void 0, void 0, function* () {
322
+ if (ioUtil.IS_WINDOWS) {
323
+ if (/[*"<>|]/.test(inputPath)) {
324
+ throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
325
+ }
326
+ }
327
+ try {
328
+ yield ioUtil.rm(inputPath, {
329
+ force: true,
330
+ maxRetries: 3,
331
+ recursive: true,
332
+ retryDelay: 300
333
+ });
334
+ } catch (err) {
335
+ throw new Error(`File was unable to be removed ${err}`);
336
+ }
337
+ });
338
+ }
339
+ exports2.rmRF = rmRF;
340
+ function mkdirP(fsPath) {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ assert_1.ok(fsPath, "a path argument must be provided");
343
+ yield ioUtil.mkdir(fsPath, { recursive: true });
344
+ });
345
+ }
346
+ exports2.mkdirP = mkdirP;
347
+ function which(tool, check) {
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ if (!tool) {
350
+ throw new Error("parameter 'tool' is required");
351
+ }
352
+ if (check) {
353
+ const result = yield which(tool, false);
354
+ if (!result) {
355
+ if (ioUtil.IS_WINDOWS) {
356
+ throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
357
+ } else {
358
+ throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
359
+ }
360
+ }
361
+ return result;
362
+ }
363
+ const matches = yield findInPath(tool);
364
+ if (matches && matches.length > 0) {
365
+ return matches[0];
366
+ }
367
+ return "";
368
+ });
369
+ }
370
+ exports2.which = which;
371
+ function findInPath(tool) {
372
+ return __awaiter(this, void 0, void 0, function* () {
373
+ if (!tool) {
374
+ throw new Error("parameter 'tool' is required");
375
+ }
376
+ const extensions = [];
377
+ if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) {
378
+ for (const extension of process.env["PATHEXT"].split(path.delimiter)) {
379
+ if (extension) {
380
+ extensions.push(extension);
381
+ }
382
+ }
383
+ }
384
+ if (ioUtil.isRooted(tool)) {
385
+ const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
386
+ if (filePath) {
387
+ return [filePath];
388
+ }
389
+ return [];
390
+ }
391
+ if (tool.includes(path.sep)) {
392
+ return [];
393
+ }
394
+ const directories = [];
395
+ if (process.env.PATH) {
396
+ for (const p of process.env.PATH.split(path.delimiter)) {
397
+ if (p) {
398
+ directories.push(p);
399
+ }
400
+ }
401
+ }
402
+ const matches = [];
403
+ for (const directory of directories) {
404
+ const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
405
+ if (filePath) {
406
+ matches.push(filePath);
407
+ }
408
+ }
409
+ return matches;
410
+ });
411
+ }
412
+ exports2.findInPath = findInPath;
413
+ function readCopyOptions(options) {
414
+ const force = options.force == null ? true : options.force;
415
+ const recursive = Boolean(options.recursive);
416
+ const copySourceDirectory = options.copySourceDirectory == null ? true : Boolean(options.copySourceDirectory);
417
+ return { force, recursive, copySourceDirectory };
418
+ }
419
+ function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
420
+ return __awaiter(this, void 0, void 0, function* () {
421
+ if (currentDepth >= 255)
422
+ return;
423
+ currentDepth++;
424
+ yield mkdirP(destDir);
425
+ const files = yield ioUtil.readdir(sourceDir);
426
+ for (const fileName of files) {
427
+ const srcFile = `${sourceDir}/${fileName}`;
428
+ const destFile = `${destDir}/${fileName}`;
429
+ const srcFileStat = yield ioUtil.lstat(srcFile);
430
+ if (srcFileStat.isDirectory()) {
431
+ yield cpDirRecursive(srcFile, destFile, currentDepth, force);
432
+ } else {
433
+ yield copyFile(srcFile, destFile, force);
434
+ }
435
+ }
436
+ yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
437
+ });
438
+ }
439
+ function copyFile(srcFile, destFile, force) {
440
+ return __awaiter(this, void 0, void 0, function* () {
441
+ if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
442
+ try {
443
+ yield ioUtil.lstat(destFile);
444
+ yield ioUtil.unlink(destFile);
445
+ } catch (e) {
446
+ if (e.code === "EPERM") {
447
+ yield ioUtil.chmod(destFile, "0666");
448
+ yield ioUtil.unlink(destFile);
449
+ }
450
+ }
451
+ const symlinkFull = yield ioUtil.readlink(srcFile);
452
+ yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? "junction" : null);
453
+ } else if (!(yield ioUtil.exists(destFile)) || force) {
454
+ yield ioUtil.copyFile(srcFile, destFile);
455
+ }
456
+ });
457
+ }
458
+ }
459
+ });
460
+
461
+ // node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js
462
+ var require_toolrunner = __commonJS({
463
+ "node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js"(exports2) {
464
+ "use strict";
465
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
466
+ if (k2 === void 0) k2 = k;
467
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
468
+ return m[k];
469
+ } });
470
+ } : function(o, m, k, k2) {
471
+ if (k2 === void 0) k2 = k;
472
+ o[k2] = m[k];
473
+ });
474
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
475
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
476
+ } : function(o, v) {
477
+ o["default"] = v;
478
+ });
479
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
480
+ if (mod && mod.__esModule) return mod;
481
+ var result = {};
482
+ if (mod != null) {
483
+ for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
484
+ }
485
+ __setModuleDefault(result, mod);
486
+ return result;
487
+ };
488
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
489
+ function adopt(value) {
490
+ return value instanceof P ? value : new P(function(resolve) {
491
+ resolve(value);
492
+ });
493
+ }
494
+ return new (P || (P = Promise))(function(resolve, reject) {
495
+ function fulfilled(value) {
496
+ try {
497
+ step(generator.next(value));
498
+ } catch (e) {
499
+ reject(e);
500
+ }
501
+ }
502
+ function rejected(value) {
503
+ try {
504
+ step(generator["throw"](value));
505
+ } catch (e) {
506
+ reject(e);
507
+ }
508
+ }
509
+ function step(result) {
510
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
511
+ }
512
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
513
+ });
514
+ };
515
+ Object.defineProperty(exports2, "__esModule", { value: true });
516
+ exports2.argStringToArray = exports2.ToolRunner = void 0;
517
+ var os = __importStar(require("os"));
518
+ var events = __importStar(require("events"));
519
+ var child = __importStar(require("child_process"));
520
+ var path = __importStar(require("path"));
521
+ var io = __importStar(require_io());
522
+ var ioUtil = __importStar(require_io_util());
523
+ var timers_1 = require("timers");
524
+ var IS_WINDOWS = process.platform === "win32";
525
+ var ToolRunner = class extends events.EventEmitter {
526
+ constructor(toolPath, args, options) {
527
+ super();
528
+ if (!toolPath) {
529
+ throw new Error("Parameter 'toolPath' cannot be null or empty.");
530
+ }
531
+ this.toolPath = toolPath;
532
+ this.args = args || [];
533
+ this.options = options || {};
534
+ }
535
+ _debug(message) {
536
+ if (this.options.listeners && this.options.listeners.debug) {
537
+ this.options.listeners.debug(message);
538
+ }
539
+ }
540
+ _getCommandString(options, noPrefix) {
541
+ const toolPath = this._getSpawnFileName();
542
+ const args = this._getSpawnArgs(options);
543
+ let cmd = noPrefix ? "" : "[command]";
544
+ if (IS_WINDOWS) {
545
+ if (this._isCmdFile()) {
546
+ cmd += toolPath;
547
+ for (const a of args) {
548
+ cmd += ` ${a}`;
549
+ }
550
+ } else if (options.windowsVerbatimArguments) {
551
+ cmd += `"${toolPath}"`;
552
+ for (const a of args) {
553
+ cmd += ` ${a}`;
554
+ }
555
+ } else {
556
+ cmd += this._windowsQuoteCmdArg(toolPath);
557
+ for (const a of args) {
558
+ cmd += ` ${this._windowsQuoteCmdArg(a)}`;
559
+ }
560
+ }
561
+ } else {
562
+ cmd += toolPath;
563
+ for (const a of args) {
564
+ cmd += ` ${a}`;
565
+ }
566
+ }
567
+ return cmd;
568
+ }
569
+ _processLineBuffer(data, strBuffer, onLine) {
570
+ try {
571
+ let s = strBuffer + data.toString();
572
+ let n = s.indexOf(os.EOL);
573
+ while (n > -1) {
574
+ const line = s.substring(0, n);
575
+ onLine(line);
576
+ s = s.substring(n + os.EOL.length);
577
+ n = s.indexOf(os.EOL);
578
+ }
579
+ return s;
580
+ } catch (err) {
581
+ this._debug(`error processing line. Failed with error ${err}`);
582
+ return "";
583
+ }
584
+ }
585
+ _getSpawnFileName() {
586
+ if (IS_WINDOWS) {
587
+ if (this._isCmdFile()) {
588
+ return process.env["COMSPEC"] || "cmd.exe";
589
+ }
590
+ }
591
+ return this.toolPath;
592
+ }
593
+ _getSpawnArgs(options) {
594
+ if (IS_WINDOWS) {
595
+ if (this._isCmdFile()) {
596
+ let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
597
+ for (const a of this.args) {
598
+ argline += " ";
599
+ argline += options.windowsVerbatimArguments ? a : this._windowsQuoteCmdArg(a);
600
+ }
601
+ argline += '"';
602
+ return [argline];
603
+ }
604
+ }
605
+ return this.args;
606
+ }
607
+ _endsWith(str2, end) {
608
+ return str2.endsWith(end);
609
+ }
610
+ _isCmdFile() {
611
+ const upperToolPath = this.toolPath.toUpperCase();
612
+ return this._endsWith(upperToolPath, ".CMD") || this._endsWith(upperToolPath, ".BAT");
613
+ }
614
+ _windowsQuoteCmdArg(arg) {
615
+ if (!this._isCmdFile()) {
616
+ return this._uvQuoteCmdArg(arg);
617
+ }
618
+ if (!arg) {
619
+ return '""';
620
+ }
621
+ const cmdSpecialChars = [
622
+ " ",
623
+ " ",
624
+ "&",
625
+ "(",
626
+ ")",
627
+ "[",
628
+ "]",
629
+ "{",
630
+ "}",
631
+ "^",
632
+ "=",
633
+ ";",
634
+ "!",
635
+ "'",
636
+ "+",
637
+ ",",
638
+ "`",
639
+ "~",
640
+ "|",
641
+ "<",
642
+ ">",
643
+ '"'
644
+ ];
645
+ let needsQuotes = false;
646
+ for (const char of arg) {
647
+ if (cmdSpecialChars.some((x) => x === char)) {
648
+ needsQuotes = true;
649
+ break;
650
+ }
651
+ }
652
+ if (!needsQuotes) {
653
+ return arg;
654
+ }
655
+ let reverse = '"';
656
+ let quoteHit = true;
657
+ for (let i = arg.length; i > 0; i--) {
658
+ reverse += arg[i - 1];
659
+ if (quoteHit && arg[i - 1] === "\\") {
660
+ reverse += "\\";
661
+ } else if (arg[i - 1] === '"') {
662
+ quoteHit = true;
663
+ reverse += '"';
664
+ } else {
665
+ quoteHit = false;
666
+ }
667
+ }
668
+ reverse += '"';
669
+ return reverse.split("").reverse().join("");
670
+ }
671
+ _uvQuoteCmdArg(arg) {
672
+ if (!arg) {
673
+ return '""';
674
+ }
675
+ if (!arg.includes(" ") && !arg.includes(" ") && !arg.includes('"')) {
676
+ return arg;
677
+ }
678
+ if (!arg.includes('"') && !arg.includes("\\")) {
679
+ return `"${arg}"`;
680
+ }
681
+ let reverse = '"';
682
+ let quoteHit = true;
683
+ for (let i = arg.length; i > 0; i--) {
684
+ reverse += arg[i - 1];
685
+ if (quoteHit && arg[i - 1] === "\\") {
686
+ reverse += "\\";
687
+ } else if (arg[i - 1] === '"') {
688
+ quoteHit = true;
689
+ reverse += "\\";
690
+ } else {
691
+ quoteHit = false;
692
+ }
693
+ }
694
+ reverse += '"';
695
+ return reverse.split("").reverse().join("");
696
+ }
697
+ _cloneExecOptions(options) {
698
+ options = options || {};
699
+ const result = {
700
+ cwd: options.cwd || process.cwd(),
701
+ env: options.env || process.env,
702
+ silent: options.silent || false,
703
+ windowsVerbatimArguments: options.windowsVerbatimArguments || false,
704
+ failOnStdErr: options.failOnStdErr || false,
705
+ ignoreReturnCode: options.ignoreReturnCode || false,
706
+ delay: options.delay || 1e4
707
+ };
708
+ result.outStream = options.outStream || process.stdout;
709
+ result.errStream = options.errStream || process.stderr;
710
+ return result;
711
+ }
712
+ _getSpawnOptions(options, toolPath) {
713
+ options = options || {};
714
+ const result = {};
715
+ result.cwd = options.cwd;
716
+ result.env = options.env;
717
+ result["windowsVerbatimArguments"] = options.windowsVerbatimArguments || this._isCmdFile();
718
+ if (options.windowsVerbatimArguments) {
719
+ result.argv0 = `"${toolPath}"`;
720
+ }
721
+ return result;
722
+ }
723
+ /**
724
+ * Exec a tool.
725
+ * Output will be streamed to the live console.
726
+ * Returns promise with return code
727
+ *
728
+ * @param tool path to tool to exec
729
+ * @param options optional exec options. See ExecOptions
730
+ * @returns number
731
+ */
732
+ exec() {
733
+ return __awaiter(this, void 0, void 0, function* () {
734
+ if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) {
735
+ this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
736
+ }
737
+ this.toolPath = yield io.which(this.toolPath, true);
738
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
739
+ this._debug(`exec tool: ${this.toolPath}`);
740
+ this._debug("arguments:");
741
+ for (const arg of this.args) {
742
+ this._debug(` ${arg}`);
743
+ }
744
+ const optionsNonNull = this._cloneExecOptions(this.options);
745
+ if (!optionsNonNull.silent && optionsNonNull.outStream) {
746
+ optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
747
+ }
748
+ const state = new ExecState(optionsNonNull, this.toolPath);
749
+ state.on("debug", (message) => {
750
+ this._debug(message);
751
+ });
752
+ if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
753
+ return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
754
+ }
755
+ const fileName = this._getSpawnFileName();
756
+ const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
757
+ let stdbuffer = "";
758
+ if (cp.stdout) {
759
+ cp.stdout.on("data", (data) => {
760
+ if (this.options.listeners && this.options.listeners.stdout) {
761
+ this.options.listeners.stdout(data);
762
+ }
763
+ if (!optionsNonNull.silent && optionsNonNull.outStream) {
764
+ optionsNonNull.outStream.write(data);
765
+ }
766
+ stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
767
+ if (this.options.listeners && this.options.listeners.stdline) {
768
+ this.options.listeners.stdline(line);
769
+ }
770
+ });
771
+ });
772
+ }
773
+ let errbuffer = "";
774
+ if (cp.stderr) {
775
+ cp.stderr.on("data", (data) => {
776
+ state.processStderr = true;
777
+ if (this.options.listeners && this.options.listeners.stderr) {
778
+ this.options.listeners.stderr(data);
779
+ }
780
+ if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) {
781
+ const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
782
+ s.write(data);
783
+ }
784
+ errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
785
+ if (this.options.listeners && this.options.listeners.errline) {
786
+ this.options.listeners.errline(line);
787
+ }
788
+ });
789
+ });
790
+ }
791
+ cp.on("error", (err) => {
792
+ state.processError = err.message;
793
+ state.processExited = true;
794
+ state.processClosed = true;
795
+ state.CheckComplete();
796
+ });
797
+ cp.on("exit", (code) => {
798
+ state.processExitCode = code;
799
+ state.processExited = true;
800
+ this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
801
+ state.CheckComplete();
802
+ });
803
+ cp.on("close", (code) => {
804
+ state.processExitCode = code;
805
+ state.processExited = true;
806
+ state.processClosed = true;
807
+ this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
808
+ state.CheckComplete();
809
+ });
810
+ state.on("done", (error, exitCode) => {
811
+ if (stdbuffer.length > 0) {
812
+ this.emit("stdline", stdbuffer);
813
+ }
814
+ if (errbuffer.length > 0) {
815
+ this.emit("errline", errbuffer);
816
+ }
817
+ cp.removeAllListeners();
818
+ if (error) {
819
+ reject(error);
820
+ } else {
821
+ resolve(exitCode);
822
+ }
823
+ });
824
+ if (this.options.input) {
825
+ if (!cp.stdin) {
826
+ throw new Error("child process missing stdin");
827
+ }
828
+ cp.stdin.end(this.options.input);
829
+ }
830
+ }));
831
+ });
832
+ }
833
+ };
834
+ exports2.ToolRunner = ToolRunner;
835
+ function argStringToArray(argString) {
836
+ const args = [];
837
+ let inQuotes = false;
838
+ let escaped = false;
839
+ let arg = "";
840
+ function append(c) {
841
+ if (escaped && c !== '"') {
842
+ arg += "\\";
843
+ }
844
+ arg += c;
845
+ escaped = false;
846
+ }
847
+ for (let i = 0; i < argString.length; i++) {
848
+ const c = argString.charAt(i);
849
+ if (c === '"') {
850
+ if (!escaped) {
851
+ inQuotes = !inQuotes;
852
+ } else {
853
+ append(c);
854
+ }
855
+ continue;
856
+ }
857
+ if (c === "\\" && escaped) {
858
+ append(c);
859
+ continue;
860
+ }
861
+ if (c === "\\" && inQuotes) {
862
+ escaped = true;
863
+ continue;
864
+ }
865
+ if (c === " " && !inQuotes) {
866
+ if (arg.length > 0) {
867
+ args.push(arg);
868
+ arg = "";
869
+ }
870
+ continue;
871
+ }
872
+ append(c);
873
+ }
874
+ if (arg.length > 0) {
875
+ args.push(arg.trim());
876
+ }
877
+ return args;
878
+ }
879
+ exports2.argStringToArray = argStringToArray;
880
+ var ExecState = class _ExecState extends events.EventEmitter {
881
+ constructor(options, toolPath) {
882
+ super();
883
+ this.processClosed = false;
884
+ this.processError = "";
885
+ this.processExitCode = 0;
886
+ this.processExited = false;
887
+ this.processStderr = false;
888
+ this.delay = 1e4;
889
+ this.done = false;
890
+ this.timeout = null;
891
+ if (!toolPath) {
892
+ throw new Error("toolPath must not be empty");
893
+ }
894
+ this.options = options;
895
+ this.toolPath = toolPath;
896
+ if (options.delay) {
897
+ this.delay = options.delay;
898
+ }
899
+ }
900
+ CheckComplete() {
901
+ if (this.done) {
902
+ return;
903
+ }
904
+ if (this.processClosed) {
905
+ this._setResult();
906
+ } else if (this.processExited) {
907
+ this.timeout = timers_1.setTimeout(_ExecState.HandleTimeout, this.delay, this);
908
+ }
909
+ }
910
+ _debug(message) {
911
+ this.emit("debug", message);
912
+ }
913
+ _setResult() {
914
+ let error;
915
+ if (this.processExited) {
916
+ if (this.processError) {
917
+ error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
918
+ } else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
919
+ error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
920
+ } else if (this.processStderr && this.options.failOnStdErr) {
921
+ error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
922
+ }
923
+ }
924
+ if (this.timeout) {
925
+ clearTimeout(this.timeout);
926
+ this.timeout = null;
927
+ }
928
+ this.done = true;
929
+ this.emit("done", error, this.processExitCode);
930
+ }
931
+ static HandleTimeout(state) {
932
+ if (state.done) {
933
+ return;
934
+ }
935
+ if (!state.processClosed && state.processExited) {
936
+ const message = `The STDIO streams did not close within ${state.delay / 1e3} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
937
+ state._debug(message);
938
+ }
939
+ state._setResult();
940
+ }
941
+ };
942
+ }
943
+ });
944
+
945
+ // node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/exec.js
946
+ var require_exec = __commonJS({
947
+ "node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/exec.js"(exports2) {
948
+ "use strict";
949
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
950
+ if (k2 === void 0) k2 = k;
951
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
952
+ return m[k];
953
+ } });
954
+ } : function(o, m, k, k2) {
955
+ if (k2 === void 0) k2 = k;
956
+ o[k2] = m[k];
957
+ });
958
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
959
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
960
+ } : function(o, v) {
961
+ o["default"] = v;
962
+ });
963
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
964
+ if (mod && mod.__esModule) return mod;
965
+ var result = {};
966
+ if (mod != null) {
967
+ for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
968
+ }
969
+ __setModuleDefault(result, mod);
970
+ return result;
971
+ };
972
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
973
+ function adopt(value) {
974
+ return value instanceof P ? value : new P(function(resolve) {
975
+ resolve(value);
976
+ });
977
+ }
978
+ return new (P || (P = Promise))(function(resolve, reject) {
979
+ function fulfilled(value) {
980
+ try {
981
+ step(generator.next(value));
982
+ } catch (e) {
983
+ reject(e);
984
+ }
985
+ }
986
+ function rejected(value) {
987
+ try {
988
+ step(generator["throw"](value));
989
+ } catch (e) {
990
+ reject(e);
991
+ }
992
+ }
993
+ function step(result) {
994
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
995
+ }
996
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
997
+ });
998
+ };
999
+ Object.defineProperty(exports2, "__esModule", { value: true });
1000
+ exports2.getExecOutput = exports2.exec = void 0;
1001
+ var string_decoder_1 = require("string_decoder");
1002
+ var tr = __importStar(require_toolrunner());
1003
+ function exec(commandLine, args, options) {
1004
+ return __awaiter(this, void 0, void 0, function* () {
1005
+ const commandArgs = tr.argStringToArray(commandLine);
1006
+ if (commandArgs.length === 0) {
1007
+ throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
1008
+ }
1009
+ const toolPath = commandArgs[0];
1010
+ args = commandArgs.slice(1).concat(args || []);
1011
+ const runner = new tr.ToolRunner(toolPath, args, options);
1012
+ return runner.exec();
1013
+ });
1014
+ }
1015
+ exports2.exec = exec;
1016
+ function getExecOutput2(commandLine, args, options) {
1017
+ var _a, _b;
1018
+ return __awaiter(this, void 0, void 0, function* () {
1019
+ let stdout = "";
1020
+ let stderr = "";
1021
+ const stdoutDecoder = new string_decoder_1.StringDecoder("utf8");
1022
+ const stderrDecoder = new string_decoder_1.StringDecoder("utf8");
1023
+ const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
1024
+ const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
1025
+ const stdErrListener = (data) => {
1026
+ stderr += stderrDecoder.write(data);
1027
+ if (originalStdErrListener) {
1028
+ originalStdErrListener(data);
1029
+ }
1030
+ };
1031
+ const stdOutListener = (data) => {
1032
+ stdout += stdoutDecoder.write(data);
1033
+ if (originalStdoutListener) {
1034
+ originalStdoutListener(data);
1035
+ }
1036
+ };
1037
+ const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
1038
+ const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
1039
+ stdout += stdoutDecoder.end();
1040
+ stderr += stderrDecoder.end();
1041
+ return {
1042
+ exitCode,
1043
+ stdout,
1044
+ stderr
1045
+ };
1046
+ });
1047
+ }
1048
+ exports2.getExecOutput = getExecOutput2;
1049
+ }
1050
+ });
1051
+
1052
+ // packages/k8s-tools/index.ts
1053
+ var k8s_tools_exports = {};
1054
+ __export(k8s_tools_exports, {
1055
+ helmChartGenerator: () => helmChartGenerator,
1056
+ helmChartSchematic: () => helmChartSchematic,
1057
+ helmDependencyGenerator: () => helmDependencyGenerator,
1058
+ helmDependencySchematic: () => helmDependencySchematic,
1059
+ serveExecutor: () => serveExecutor
1060
+ });
1061
+ module.exports = __toCommonJS(k8s_tools_exports);
1062
+
1063
+ // packages/k8s-tools/src/executors/helm-package/executor.ts
1064
+ var import_workspace_tools = require("@storm-software/workspace-tools");
1065
+
1066
+ // packages/k8s-tools/src/utils/client.ts
1067
+ var import_exec = __toESM(require_exec());
1068
+
1069
+ // packages/k8s-tools/src/types.ts
1070
+ var AbstractHelmClient = class {
1071
+ initialized = false;
1072
+ async initialize() {
1073
+ throw new Error("Method not implemented.");
1074
+ }
1075
+ };
1076
+
1077
+ // packages/k8s-tools/src/utils/ensure-init.ts
1078
+ var ensureInitialized = (target, propertyKey, descriptor) => {
1079
+ const originalMethod = descriptor.value;
1080
+ descriptor.value = async function(...arguments_) {
1081
+ const self = this;
1082
+ if (self.initialized === void 0 || typeof self.initialize !== "function") {
1083
+ throw new TypeError(
1084
+ `The ensureInitialized decorator can only be applied in classes with an 'initialized' property and 'initialize' method.`
1085
+ );
1086
+ }
1087
+ if (!self.initialized) {
1088
+ await self.initialize();
1089
+ }
1090
+ return originalMethod.apply(this, arguments_);
1091
+ };
1092
+ return descriptor;
1093
+ };
1094
+
1095
+ // packages/k8s-tools/src/utils/client.ts
1096
+ var HelmClient = class extends AbstractHelmClient {
1097
+ async package(options) {
1098
+ let chartPath = void 0;
1099
+ await (0, import_exec.getExecOutput)("helm", [
1100
+ "package",
1101
+ options.chartFolder,
1102
+ "-d",
1103
+ options.outputFolder
1104
+ ]).then((output) => {
1105
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1106
+ throw new Error(`Failed to package chart: ${output.stderr}`);
1107
+ }
1108
+ const stdout = output.stdout;
1109
+ const match = stdout.match(
1110
+ /Successfully packaged chart and saved it to: (.+)/
1111
+ );
1112
+ if (!match) {
1113
+ throw new Error("Failed to parse chart path from helm output");
1114
+ }
1115
+ chartPath = match[1]?.trim();
1116
+ });
1117
+ return chartPath;
1118
+ }
1119
+ async push(options) {
1120
+ await (0, import_exec.getExecOutput)("helm", [
1121
+ "push",
1122
+ options.chartPath,
1123
+ options.remote
1124
+ ]).then((output) => {
1125
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1126
+ throw new Error(`Failed to push chart: ${output.stderr}`);
1127
+ }
1128
+ });
1129
+ }
1130
+ async dependencyUpdate(chartFolder) {
1131
+ await (0, import_exec.getExecOutput)("helm", ["dependency", "update", chartFolder]).then(
1132
+ (output) => {
1133
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1134
+ throw new Error(
1135
+ `Failed to update chart dependencies: ${output.stderr}`
1136
+ );
1137
+ }
1138
+ }
1139
+ );
1140
+ }
1141
+ async dependencyBuild(chartFolder) {
1142
+ await (0, import_exec.getExecOutput)("helm", ["dependency", "build", chartFolder]).then(
1143
+ (output) => {
1144
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1145
+ throw new Error(
1146
+ `Failed to build chart dependencies: ${output.stderr}`
1147
+ );
1148
+ }
1149
+ }
1150
+ );
1151
+ }
1152
+ async addRepository(name, url) {
1153
+ await (0, import_exec.getExecOutput)("helm", ["repo", "add", name, url]).then((output) => {
1154
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1155
+ throw new Error(`Failed to add repository: ${output.stderr}`);
1156
+ }
1157
+ });
1158
+ }
1159
+ /**
1160
+ * Initialize Helm
1161
+ *
1162
+ * @returns {Promise<void>}
1163
+ */
1164
+ async initialize() {
1165
+ if (this.initialized) {
1166
+ return;
1167
+ }
1168
+ await (0, import_exec.getExecOutput)("helm", ["version"]).then((output) => {
1169
+ if (output.stderr.length > 0 && output.exitCode !== 0) {
1170
+ throw new Error(`Helm is not installed: ${output.stderr}`);
1171
+ }
1172
+ this.initialized = true;
1173
+ });
1174
+ }
1175
+ };
1176
+ __decorateClass([
1177
+ ensureInitialized
1178
+ ], HelmClient.prototype, "package", 1);
1179
+ __decorateClass([
1180
+ ensureInitialized
1181
+ ], HelmClient.prototype, "push", 1);
1182
+ __decorateClass([
1183
+ ensureInitialized
1184
+ ], HelmClient.prototype, "dependencyUpdate", 1);
1185
+ __decorateClass([
1186
+ ensureInitialized
1187
+ ], HelmClient.prototype, "dependencyBuild", 1);
1188
+ __decorateClass([
1189
+ ensureInitialized
1190
+ ], HelmClient.prototype, "addRepository", 1);
1191
+ var createHelmClient = () => {
1192
+ return new HelmClient();
1193
+ };
1194
+
1195
+ // packages/k8s-tools/src/executors/helm-package/executor.ts
1196
+ async function serveExecutor(options, context, config) {
1197
+ const { writeWarning } = await import("@storm-software/config-tools");
1198
+ if (!context?.projectName || !context?.projectsConfigurations?.projects?.[context.projectName]?.root) {
1199
+ throw new Error("Nx executor context was invalid");
1200
+ }
1201
+ const helm = createHelmClient();
1202
+ if (options.dependencies?.repositories) {
1203
+ for (const repository of options.dependencies.repositories) {
1204
+ if (repository.name && repository.url) {
1205
+ await helm.addRepository(repository.name, repository.url);
1206
+ } else {
1207
+ throw new Error("Repository name and url are required");
1208
+ }
1209
+ }
1210
+ }
1211
+ if (options.dependencies?.update) {
1212
+ await helm.dependencyUpdate(options.chartFolder);
1213
+ }
1214
+ if (options.dependencies?.build) {
1215
+ await helm.dependencyBuild(options.chartFolder);
1216
+ }
1217
+ const chartPath = await helm.package({
1218
+ chartFolder: options.chartFolder,
1219
+ outputFolder: options.outputFolder
1220
+ });
1221
+ if (options.push && chartPath && options.remote) {
1222
+ await helm.push({
1223
+ chartPath,
1224
+ remote: options.remote
1225
+ });
1226
+ } else {
1227
+ writeWarning(`Chart packaged at: ${chartPath}`, config);
1228
+ }
1229
+ return {
1230
+ success: true
1231
+ };
1232
+ }
1233
+ var executor_default = (0, import_workspace_tools.withRunExecutor)(
1234
+ "Helm Chart Package executor",
1235
+ serveExecutor,
1236
+ {
1237
+ skipReadingConfig: false,
1238
+ hooks: {
1239
+ applyDefaultOptions: (options) => {
1240
+ options.port ??= 4500;
1241
+ return options;
1242
+ }
1243
+ }
1244
+ }
1245
+ );
1246
+
1247
+ // packages/k8s-tools/src/generators/helm-chart/generator.ts
1248
+ var import_devkit = require("@nx/devkit");
1249
+ var import_path = require("path");
1250
+ async function helmChartGenerator(tree, options) {
1251
+ const {
1252
+ getStopwatch,
1253
+ writeDebug,
1254
+ writeError,
1255
+ writeFatal,
1256
+ writeInfo,
1257
+ writeTrace,
1258
+ findWorkspaceRoot,
1259
+ loadStormConfig
1260
+ } = await import("@storm-software/config-tools");
1261
+ const stopwatch = getStopwatch("Storm Helm Chart generator");
1262
+ let config;
1263
+ try {
1264
+ writeInfo(`\u26A1 Running the Storm Helm Chart generator...
1265
+
1266
+ `, config);
1267
+ const workspaceRoot = findWorkspaceRoot();
1268
+ writeDebug(
1269
+ `Loading the Storm Config from environment variables and storm.json file...
1270
+ - workspaceRoot: ${workspaceRoot}`,
1271
+ config
1272
+ );
1273
+ config = await loadStormConfig(workspaceRoot);
1274
+ writeTrace(
1275
+ `Loaded Storm config into env:
1276
+ ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
1277
+ config
1278
+ );
1279
+ const tasks = [];
1280
+ tasks.push(async () => {
1281
+ const project = (0, import_devkit.readProjectConfiguration)(tree, options.project);
1282
+ if (project.targets?.["helm-package"]) {
1283
+ throw new Error(
1284
+ `Project ${options.project} already has a helm target. Please remove it before running this command.`
1285
+ );
1286
+ }
1287
+ (0, import_devkit.updateProjectConfiguration)(tree, options.project, {
1288
+ ...project,
1289
+ targets: {
1290
+ ...project.targets,
1291
+ "helm-package": {
1292
+ executor: "@storm-software/k8s-tools:helm-package",
1293
+ outputs: ["{options.outputFolder}"],
1294
+ options: {
1295
+ chartFolder: `${project.root}/${options.chartFolder}`,
1296
+ outputFolder: "{workspaceRoot}/dist/charts/{projectRoot}",
1297
+ push: false,
1298
+ remote: "oci://localhost:5000/helm-charts",
1299
+ dependencies: {
1300
+ update: true,
1301
+ build: true,
1302
+ repositories: []
1303
+ }
1304
+ }
1305
+ }
1306
+ }
1307
+ });
1308
+ (0, import_devkit.generateFiles)(
1309
+ tree,
1310
+ (0, import_path.join)(__dirname, "files", "chart"),
1311
+ (0, import_path.join)(project.root, options.chartFolder ?? ""),
1312
+ options
1313
+ );
1314
+ if (options.format) {
1315
+ await (0, import_devkit.formatFiles)(tree);
1316
+ }
1317
+ });
1318
+ return (0, import_devkit.runTasksInSerial)(...tasks);
1319
+ } catch (error) {
1320
+ return () => {
1321
+ writeFatal(
1322
+ "A fatal error occurred while running the generator - the process was forced to terminate",
1323
+ config
1324
+ );
1325
+ writeError(
1326
+ `An exception was thrown in the generator's process
1327
+ - Details: ${error.message}
1328
+ - Stacktrace: ${error.stack}`,
1329
+ config
1330
+ );
1331
+ };
1332
+ } finally {
1333
+ stopwatch();
1334
+ }
1335
+ }
1336
+ var helmChartSchematic = (0, import_devkit.convertNxGenerator)(helmChartGenerator);
1337
+
1338
+ // packages/k8s-tools/src/generators/helm-dependency/generator.ts
1339
+ var import_devkit2 = require("@nx/devkit");
1340
+
1341
+ // node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
1342
+ function isNothing(subject) {
1343
+ return typeof subject === "undefined" || subject === null;
1344
+ }
1345
+ function isObject(subject) {
1346
+ return typeof subject === "object" && subject !== null;
1347
+ }
1348
+ function toArray(sequence) {
1349
+ if (Array.isArray(sequence)) return sequence;
1350
+ else if (isNothing(sequence)) return [];
1351
+ return [sequence];
1352
+ }
1353
+ function extend(target, source) {
1354
+ var index, length, key, sourceKeys;
1355
+ if (source) {
1356
+ sourceKeys = Object.keys(source);
1357
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
1358
+ key = sourceKeys[index];
1359
+ target[key] = source[key];
1360
+ }
1361
+ }
1362
+ return target;
1363
+ }
1364
+ function repeat(string, count) {
1365
+ var result = "", cycle;
1366
+ for (cycle = 0; cycle < count; cycle += 1) {
1367
+ result += string;
1368
+ }
1369
+ return result;
1370
+ }
1371
+ function isNegativeZero(number) {
1372
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
1373
+ }
1374
+ var isNothing_1 = isNothing;
1375
+ var isObject_1 = isObject;
1376
+ var toArray_1 = toArray;
1377
+ var repeat_1 = repeat;
1378
+ var isNegativeZero_1 = isNegativeZero;
1379
+ var extend_1 = extend;
1380
+ var common = {
1381
+ isNothing: isNothing_1,
1382
+ isObject: isObject_1,
1383
+ toArray: toArray_1,
1384
+ repeat: repeat_1,
1385
+ isNegativeZero: isNegativeZero_1,
1386
+ extend: extend_1
1387
+ };
1388
+ function formatError(exception2, compact) {
1389
+ var where = "", message = exception2.reason || "(unknown reason)";
1390
+ if (!exception2.mark) return message;
1391
+ if (exception2.mark.name) {
1392
+ where += 'in "' + exception2.mark.name + '" ';
1393
+ }
1394
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
1395
+ if (!compact && exception2.mark.snippet) {
1396
+ where += "\n\n" + exception2.mark.snippet;
1397
+ }
1398
+ return message + " " + where;
1399
+ }
1400
+ function YAMLException$1(reason, mark) {
1401
+ Error.call(this);
1402
+ this.name = "YAMLException";
1403
+ this.reason = reason;
1404
+ this.mark = mark;
1405
+ this.message = formatError(this, false);
1406
+ if (Error.captureStackTrace) {
1407
+ Error.captureStackTrace(this, this.constructor);
1408
+ } else {
1409
+ this.stack = new Error().stack || "";
1410
+ }
1411
+ }
1412
+ YAMLException$1.prototype = Object.create(Error.prototype);
1413
+ YAMLException$1.prototype.constructor = YAMLException$1;
1414
+ YAMLException$1.prototype.toString = function toString(compact) {
1415
+ return this.name + ": " + formatError(this, compact);
1416
+ };
1417
+ var exception = YAMLException$1;
1418
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
1419
+ var head = "";
1420
+ var tail = "";
1421
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
1422
+ if (position - lineStart > maxHalfLength) {
1423
+ head = " ... ";
1424
+ lineStart = position - maxHalfLength + head.length;
1425
+ }
1426
+ if (lineEnd - position > maxHalfLength) {
1427
+ tail = " ...";
1428
+ lineEnd = position + maxHalfLength - tail.length;
1429
+ }
1430
+ return {
1431
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
1432
+ pos: position - lineStart + head.length
1433
+ // relative position
1434
+ };
1435
+ }
1436
+ function padStart(string, max) {
1437
+ return common.repeat(" ", max - string.length) + string;
1438
+ }
1439
+ function makeSnippet(mark, options) {
1440
+ options = Object.create(options || null);
1441
+ if (!mark.buffer) return null;
1442
+ if (!options.maxLength) options.maxLength = 79;
1443
+ if (typeof options.indent !== "number") options.indent = 1;
1444
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
1445
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
1446
+ var re = /\r?\n|\r|\0/g;
1447
+ var lineStarts = [0];
1448
+ var lineEnds = [];
1449
+ var match;
1450
+ var foundLineNo = -1;
1451
+ while (match = re.exec(mark.buffer)) {
1452
+ lineEnds.push(match.index);
1453
+ lineStarts.push(match.index + match[0].length);
1454
+ if (mark.position <= match.index && foundLineNo < 0) {
1455
+ foundLineNo = lineStarts.length - 2;
1456
+ }
1457
+ }
1458
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
1459
+ var result = "", i, line;
1460
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
1461
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
1462
+ for (i = 1; i <= options.linesBefore; i++) {
1463
+ if (foundLineNo - i < 0) break;
1464
+ line = getLine(
1465
+ mark.buffer,
1466
+ lineStarts[foundLineNo - i],
1467
+ lineEnds[foundLineNo - i],
1468
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
1469
+ maxLineLength
1470
+ );
1471
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
1472
+ }
1473
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
1474
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
1475
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
1476
+ for (i = 1; i <= options.linesAfter; i++) {
1477
+ if (foundLineNo + i >= lineEnds.length) break;
1478
+ line = getLine(
1479
+ mark.buffer,
1480
+ lineStarts[foundLineNo + i],
1481
+ lineEnds[foundLineNo + i],
1482
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
1483
+ maxLineLength
1484
+ );
1485
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
1486
+ }
1487
+ return result.replace(/\n$/, "");
1488
+ }
1489
+ var snippet = makeSnippet;
1490
+ var TYPE_CONSTRUCTOR_OPTIONS = [
1491
+ "kind",
1492
+ "multi",
1493
+ "resolve",
1494
+ "construct",
1495
+ "instanceOf",
1496
+ "predicate",
1497
+ "represent",
1498
+ "representName",
1499
+ "defaultStyle",
1500
+ "styleAliases"
1501
+ ];
1502
+ var YAML_NODE_KINDS = [
1503
+ "scalar",
1504
+ "sequence",
1505
+ "mapping"
1506
+ ];
1507
+ function compileStyleAliases(map2) {
1508
+ var result = {};
1509
+ if (map2 !== null) {
1510
+ Object.keys(map2).forEach(function(style) {
1511
+ map2[style].forEach(function(alias) {
1512
+ result[String(alias)] = style;
1513
+ });
1514
+ });
1515
+ }
1516
+ return result;
1517
+ }
1518
+ function Type$1(tag, options) {
1519
+ options = options || {};
1520
+ Object.keys(options).forEach(function(name) {
1521
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
1522
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
1523
+ }
1524
+ });
1525
+ this.options = options;
1526
+ this.tag = tag;
1527
+ this.kind = options["kind"] || null;
1528
+ this.resolve = options["resolve"] || function() {
1529
+ return true;
1530
+ };
1531
+ this.construct = options["construct"] || function(data) {
1532
+ return data;
1533
+ };
1534
+ this.instanceOf = options["instanceOf"] || null;
1535
+ this.predicate = options["predicate"] || null;
1536
+ this.represent = options["represent"] || null;
1537
+ this.representName = options["representName"] || null;
1538
+ this.defaultStyle = options["defaultStyle"] || null;
1539
+ this.multi = options["multi"] || false;
1540
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
1541
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
1542
+ throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
1543
+ }
1544
+ }
1545
+ var type = Type$1;
1546
+ function compileList(schema2, name) {
1547
+ var result = [];
1548
+ schema2[name].forEach(function(currentType) {
1549
+ var newIndex = result.length;
1550
+ result.forEach(function(previousType, previousIndex) {
1551
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
1552
+ newIndex = previousIndex;
1553
+ }
1554
+ });
1555
+ result[newIndex] = currentType;
1556
+ });
1557
+ return result;
1558
+ }
1559
+ function compileMap() {
1560
+ var result = {
1561
+ scalar: {},
1562
+ sequence: {},
1563
+ mapping: {},
1564
+ fallback: {},
1565
+ multi: {
1566
+ scalar: [],
1567
+ sequence: [],
1568
+ mapping: [],
1569
+ fallback: []
1570
+ }
1571
+ }, index, length;
1572
+ function collectType(type2) {
1573
+ if (type2.multi) {
1574
+ result.multi[type2.kind].push(type2);
1575
+ result.multi["fallback"].push(type2);
1576
+ } else {
1577
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
1578
+ }
1579
+ }
1580
+ for (index = 0, length = arguments.length; index < length; index += 1) {
1581
+ arguments[index].forEach(collectType);
1582
+ }
1583
+ return result;
1584
+ }
1585
+ function Schema$1(definition) {
1586
+ return this.extend(definition);
1587
+ }
1588
+ Schema$1.prototype.extend = function extend2(definition) {
1589
+ var implicit = [];
1590
+ var explicit = [];
1591
+ if (definition instanceof type) {
1592
+ explicit.push(definition);
1593
+ } else if (Array.isArray(definition)) {
1594
+ explicit = explicit.concat(definition);
1595
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
1596
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
1597
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
1598
+ } else {
1599
+ throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
1600
+ }
1601
+ implicit.forEach(function(type$1) {
1602
+ if (!(type$1 instanceof type)) {
1603
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
1604
+ }
1605
+ if (type$1.loadKind && type$1.loadKind !== "scalar") {
1606
+ throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
1607
+ }
1608
+ if (type$1.multi) {
1609
+ throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
1610
+ }
1611
+ });
1612
+ explicit.forEach(function(type$1) {
1613
+ if (!(type$1 instanceof type)) {
1614
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
1615
+ }
1616
+ });
1617
+ var result = Object.create(Schema$1.prototype);
1618
+ result.implicit = (this.implicit || []).concat(implicit);
1619
+ result.explicit = (this.explicit || []).concat(explicit);
1620
+ result.compiledImplicit = compileList(result, "implicit");
1621
+ result.compiledExplicit = compileList(result, "explicit");
1622
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
1623
+ return result;
1624
+ };
1625
+ var schema = Schema$1;
1626
+ var str = new type("tag:yaml.org,2002:str", {
1627
+ kind: "scalar",
1628
+ construct: function(data) {
1629
+ return data !== null ? data : "";
1630
+ }
1631
+ });
1632
+ var seq = new type("tag:yaml.org,2002:seq", {
1633
+ kind: "sequence",
1634
+ construct: function(data) {
1635
+ return data !== null ? data : [];
1636
+ }
1637
+ });
1638
+ var map = new type("tag:yaml.org,2002:map", {
1639
+ kind: "mapping",
1640
+ construct: function(data) {
1641
+ return data !== null ? data : {};
1642
+ }
1643
+ });
1644
+ var failsafe = new schema({
1645
+ explicit: [
1646
+ str,
1647
+ seq,
1648
+ map
1649
+ ]
1650
+ });
1651
+ function resolveYamlNull(data) {
1652
+ if (data === null) return true;
1653
+ var max = data.length;
1654
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
1655
+ }
1656
+ function constructYamlNull() {
1657
+ return null;
1658
+ }
1659
+ function isNull(object) {
1660
+ return object === null;
1661
+ }
1662
+ var _null = new type("tag:yaml.org,2002:null", {
1663
+ kind: "scalar",
1664
+ resolve: resolveYamlNull,
1665
+ construct: constructYamlNull,
1666
+ predicate: isNull,
1667
+ represent: {
1668
+ canonical: function() {
1669
+ return "~";
1670
+ },
1671
+ lowercase: function() {
1672
+ return "null";
1673
+ },
1674
+ uppercase: function() {
1675
+ return "NULL";
1676
+ },
1677
+ camelcase: function() {
1678
+ return "Null";
1679
+ },
1680
+ empty: function() {
1681
+ return "";
1682
+ }
1683
+ },
1684
+ defaultStyle: "lowercase"
1685
+ });
1686
+ function resolveYamlBoolean(data) {
1687
+ if (data === null) return false;
1688
+ var max = data.length;
1689
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
1690
+ }
1691
+ function constructYamlBoolean(data) {
1692
+ return data === "true" || data === "True" || data === "TRUE";
1693
+ }
1694
+ function isBoolean(object) {
1695
+ return Object.prototype.toString.call(object) === "[object Boolean]";
1696
+ }
1697
+ var bool = new type("tag:yaml.org,2002:bool", {
1698
+ kind: "scalar",
1699
+ resolve: resolveYamlBoolean,
1700
+ construct: constructYamlBoolean,
1701
+ predicate: isBoolean,
1702
+ represent: {
1703
+ lowercase: function(object) {
1704
+ return object ? "true" : "false";
1705
+ },
1706
+ uppercase: function(object) {
1707
+ return object ? "TRUE" : "FALSE";
1708
+ },
1709
+ camelcase: function(object) {
1710
+ return object ? "True" : "False";
1711
+ }
1712
+ },
1713
+ defaultStyle: "lowercase"
1714
+ });
1715
+ function isHexCode(c) {
1716
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
1717
+ }
1718
+ function isOctCode(c) {
1719
+ return 48 <= c && c <= 55;
1720
+ }
1721
+ function isDecCode(c) {
1722
+ return 48 <= c && c <= 57;
1723
+ }
1724
+ function resolveYamlInteger(data) {
1725
+ if (data === null) return false;
1726
+ var max = data.length, index = 0, hasDigits = false, ch;
1727
+ if (!max) return false;
1728
+ ch = data[index];
1729
+ if (ch === "-" || ch === "+") {
1730
+ ch = data[++index];
1731
+ }
1732
+ if (ch === "0") {
1733
+ if (index + 1 === max) return true;
1734
+ ch = data[++index];
1735
+ if (ch === "b") {
1736
+ index++;
1737
+ for (; index < max; index++) {
1738
+ ch = data[index];
1739
+ if (ch === "_") continue;
1740
+ if (ch !== "0" && ch !== "1") return false;
1741
+ hasDigits = true;
1742
+ }
1743
+ return hasDigits && ch !== "_";
1744
+ }
1745
+ if (ch === "x") {
1746
+ index++;
1747
+ for (; index < max; index++) {
1748
+ ch = data[index];
1749
+ if (ch === "_") continue;
1750
+ if (!isHexCode(data.charCodeAt(index))) return false;
1751
+ hasDigits = true;
1752
+ }
1753
+ return hasDigits && ch !== "_";
1754
+ }
1755
+ if (ch === "o") {
1756
+ index++;
1757
+ for (; index < max; index++) {
1758
+ ch = data[index];
1759
+ if (ch === "_") continue;
1760
+ if (!isOctCode(data.charCodeAt(index))) return false;
1761
+ hasDigits = true;
1762
+ }
1763
+ return hasDigits && ch !== "_";
1764
+ }
1765
+ }
1766
+ if (ch === "_") return false;
1767
+ for (; index < max; index++) {
1768
+ ch = data[index];
1769
+ if (ch === "_") continue;
1770
+ if (!isDecCode(data.charCodeAt(index))) {
1771
+ return false;
1772
+ }
1773
+ hasDigits = true;
1774
+ }
1775
+ if (!hasDigits || ch === "_") return false;
1776
+ return true;
1777
+ }
1778
+ function constructYamlInteger(data) {
1779
+ var value = data, sign = 1, ch;
1780
+ if (value.indexOf("_") !== -1) {
1781
+ value = value.replace(/_/g, "");
1782
+ }
1783
+ ch = value[0];
1784
+ if (ch === "-" || ch === "+") {
1785
+ if (ch === "-") sign = -1;
1786
+ value = value.slice(1);
1787
+ ch = value[0];
1788
+ }
1789
+ if (value === "0") return 0;
1790
+ if (ch === "0") {
1791
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
1792
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
1793
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
1794
+ }
1795
+ return sign * parseInt(value, 10);
1796
+ }
1797
+ function isInteger(object) {
1798
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
1799
+ }
1800
+ var int = new type("tag:yaml.org,2002:int", {
1801
+ kind: "scalar",
1802
+ resolve: resolveYamlInteger,
1803
+ construct: constructYamlInteger,
1804
+ predicate: isInteger,
1805
+ represent: {
1806
+ binary: function(obj) {
1807
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
1808
+ },
1809
+ octal: function(obj) {
1810
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
1811
+ },
1812
+ decimal: function(obj) {
1813
+ return obj.toString(10);
1814
+ },
1815
+ /* eslint-disable max-len */
1816
+ hexadecimal: function(obj) {
1817
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
1818
+ }
1819
+ },
1820
+ defaultStyle: "decimal",
1821
+ styleAliases: {
1822
+ binary: [2, "bin"],
1823
+ octal: [8, "oct"],
1824
+ decimal: [10, "dec"],
1825
+ hexadecimal: [16, "hex"]
1826
+ }
1827
+ });
1828
+ var YAML_FLOAT_PATTERN = new RegExp(
1829
+ // 2.5e4, 2.5 and integers
1830
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
1831
+ );
1832
+ function resolveYamlFloat(data) {
1833
+ if (data === null) return false;
1834
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
1835
+ // Probably should update regexp & check speed
1836
+ data[data.length - 1] === "_") {
1837
+ return false;
1838
+ }
1839
+ return true;
1840
+ }
1841
+ function constructYamlFloat(data) {
1842
+ var value, sign;
1843
+ value = data.replace(/_/g, "").toLowerCase();
1844
+ sign = value[0] === "-" ? -1 : 1;
1845
+ if ("+-".indexOf(value[0]) >= 0) {
1846
+ value = value.slice(1);
1847
+ }
1848
+ if (value === ".inf") {
1849
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
1850
+ } else if (value === ".nan") {
1851
+ return NaN;
1852
+ }
1853
+ return sign * parseFloat(value, 10);
1854
+ }
1855
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
1856
+ function representYamlFloat(object, style) {
1857
+ var res;
1858
+ if (isNaN(object)) {
1859
+ switch (style) {
1860
+ case "lowercase":
1861
+ return ".nan";
1862
+ case "uppercase":
1863
+ return ".NAN";
1864
+ case "camelcase":
1865
+ return ".NaN";
1866
+ }
1867
+ } else if (Number.POSITIVE_INFINITY === object) {
1868
+ switch (style) {
1869
+ case "lowercase":
1870
+ return ".inf";
1871
+ case "uppercase":
1872
+ return ".INF";
1873
+ case "camelcase":
1874
+ return ".Inf";
1875
+ }
1876
+ } else if (Number.NEGATIVE_INFINITY === object) {
1877
+ switch (style) {
1878
+ case "lowercase":
1879
+ return "-.inf";
1880
+ case "uppercase":
1881
+ return "-.INF";
1882
+ case "camelcase":
1883
+ return "-.Inf";
1884
+ }
1885
+ } else if (common.isNegativeZero(object)) {
1886
+ return "-0.0";
1887
+ }
1888
+ res = object.toString(10);
1889
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
1890
+ }
1891
+ function isFloat(object) {
1892
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
1893
+ }
1894
+ var float = new type("tag:yaml.org,2002:float", {
1895
+ kind: "scalar",
1896
+ resolve: resolveYamlFloat,
1897
+ construct: constructYamlFloat,
1898
+ predicate: isFloat,
1899
+ represent: representYamlFloat,
1900
+ defaultStyle: "lowercase"
1901
+ });
1902
+ var json = failsafe.extend({
1903
+ implicit: [
1904
+ _null,
1905
+ bool,
1906
+ int,
1907
+ float
1908
+ ]
1909
+ });
1910
+ var core = json;
1911
+ var YAML_DATE_REGEXP = new RegExp(
1912
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
1913
+ );
1914
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
1915
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
1916
+ );
1917
+ function resolveYamlTimestamp(data) {
1918
+ if (data === null) return false;
1919
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
1920
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
1921
+ return false;
1922
+ }
1923
+ function constructYamlTimestamp(data) {
1924
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
1925
+ match = YAML_DATE_REGEXP.exec(data);
1926
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
1927
+ if (match === null) throw new Error("Date resolve error");
1928
+ year = +match[1];
1929
+ month = +match[2] - 1;
1930
+ day = +match[3];
1931
+ if (!match[4]) {
1932
+ return new Date(Date.UTC(year, month, day));
1933
+ }
1934
+ hour = +match[4];
1935
+ minute = +match[5];
1936
+ second = +match[6];
1937
+ if (match[7]) {
1938
+ fraction = match[7].slice(0, 3);
1939
+ while (fraction.length < 3) {
1940
+ fraction += "0";
1941
+ }
1942
+ fraction = +fraction;
1943
+ }
1944
+ if (match[9]) {
1945
+ tz_hour = +match[10];
1946
+ tz_minute = +(match[11] || 0);
1947
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
1948
+ if (match[9] === "-") delta = -delta;
1949
+ }
1950
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1951
+ if (delta) date.setTime(date.getTime() - delta);
1952
+ return date;
1953
+ }
1954
+ function representYamlTimestamp(object) {
1955
+ return object.toISOString();
1956
+ }
1957
+ var timestamp = new type("tag:yaml.org,2002:timestamp", {
1958
+ kind: "scalar",
1959
+ resolve: resolveYamlTimestamp,
1960
+ construct: constructYamlTimestamp,
1961
+ instanceOf: Date,
1962
+ represent: representYamlTimestamp
1963
+ });
1964
+ function resolveYamlMerge(data) {
1965
+ return data === "<<" || data === null;
1966
+ }
1967
+ var merge = new type("tag:yaml.org,2002:merge", {
1968
+ kind: "scalar",
1969
+ resolve: resolveYamlMerge
1970
+ });
1971
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
1972
+ function resolveYamlBinary(data) {
1973
+ if (data === null) return false;
1974
+ var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
1975
+ for (idx = 0; idx < max; idx++) {
1976
+ code = map2.indexOf(data.charAt(idx));
1977
+ if (code > 64) continue;
1978
+ if (code < 0) return false;
1979
+ bitlen += 6;
1980
+ }
1981
+ return bitlen % 8 === 0;
1982
+ }
1983
+ function constructYamlBinary(data) {
1984
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
1985
+ for (idx = 0; idx < max; idx++) {
1986
+ if (idx % 4 === 0 && idx) {
1987
+ result.push(bits >> 16 & 255);
1988
+ result.push(bits >> 8 & 255);
1989
+ result.push(bits & 255);
1990
+ }
1991
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
1992
+ }
1993
+ tailbits = max % 4 * 6;
1994
+ if (tailbits === 0) {
1995
+ result.push(bits >> 16 & 255);
1996
+ result.push(bits >> 8 & 255);
1997
+ result.push(bits & 255);
1998
+ } else if (tailbits === 18) {
1999
+ result.push(bits >> 10 & 255);
2000
+ result.push(bits >> 2 & 255);
2001
+ } else if (tailbits === 12) {
2002
+ result.push(bits >> 4 & 255);
2003
+ }
2004
+ return new Uint8Array(result);
2005
+ }
2006
+ function representYamlBinary(object) {
2007
+ var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
2008
+ for (idx = 0; idx < max; idx++) {
2009
+ if (idx % 3 === 0 && idx) {
2010
+ result += map2[bits >> 18 & 63];
2011
+ result += map2[bits >> 12 & 63];
2012
+ result += map2[bits >> 6 & 63];
2013
+ result += map2[bits & 63];
2014
+ }
2015
+ bits = (bits << 8) + object[idx];
2016
+ }
2017
+ tail = max % 3;
2018
+ if (tail === 0) {
2019
+ result += map2[bits >> 18 & 63];
2020
+ result += map2[bits >> 12 & 63];
2021
+ result += map2[bits >> 6 & 63];
2022
+ result += map2[bits & 63];
2023
+ } else if (tail === 2) {
2024
+ result += map2[bits >> 10 & 63];
2025
+ result += map2[bits >> 4 & 63];
2026
+ result += map2[bits << 2 & 63];
2027
+ result += map2[64];
2028
+ } else if (tail === 1) {
2029
+ result += map2[bits >> 2 & 63];
2030
+ result += map2[bits << 4 & 63];
2031
+ result += map2[64];
2032
+ result += map2[64];
2033
+ }
2034
+ return result;
2035
+ }
2036
+ function isBinary(obj) {
2037
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
2038
+ }
2039
+ var binary = new type("tag:yaml.org,2002:binary", {
2040
+ kind: "scalar",
2041
+ resolve: resolveYamlBinary,
2042
+ construct: constructYamlBinary,
2043
+ predicate: isBinary,
2044
+ represent: representYamlBinary
2045
+ });
2046
+ var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
2047
+ var _toString$2 = Object.prototype.toString;
2048
+ function resolveYamlOmap(data) {
2049
+ if (data === null) return true;
2050
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
2051
+ for (index = 0, length = object.length; index < length; index += 1) {
2052
+ pair = object[index];
2053
+ pairHasKey = false;
2054
+ if (_toString$2.call(pair) !== "[object Object]") return false;
2055
+ for (pairKey in pair) {
2056
+ if (_hasOwnProperty$3.call(pair, pairKey)) {
2057
+ if (!pairHasKey) pairHasKey = true;
2058
+ else return false;
2059
+ }
2060
+ }
2061
+ if (!pairHasKey) return false;
2062
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
2063
+ else return false;
2064
+ }
2065
+ return true;
2066
+ }
2067
+ function constructYamlOmap(data) {
2068
+ return data !== null ? data : [];
2069
+ }
2070
+ var omap = new type("tag:yaml.org,2002:omap", {
2071
+ kind: "sequence",
2072
+ resolve: resolveYamlOmap,
2073
+ construct: constructYamlOmap
2074
+ });
2075
+ var _toString$1 = Object.prototype.toString;
2076
+ function resolveYamlPairs(data) {
2077
+ if (data === null) return true;
2078
+ var index, length, pair, keys, result, object = data;
2079
+ result = new Array(object.length);
2080
+ for (index = 0, length = object.length; index < length; index += 1) {
2081
+ pair = object[index];
2082
+ if (_toString$1.call(pair) !== "[object Object]") return false;
2083
+ keys = Object.keys(pair);
2084
+ if (keys.length !== 1) return false;
2085
+ result[index] = [keys[0], pair[keys[0]]];
2086
+ }
2087
+ return true;
2088
+ }
2089
+ function constructYamlPairs(data) {
2090
+ if (data === null) return [];
2091
+ var index, length, pair, keys, result, object = data;
2092
+ result = new Array(object.length);
2093
+ for (index = 0, length = object.length; index < length; index += 1) {
2094
+ pair = object[index];
2095
+ keys = Object.keys(pair);
2096
+ result[index] = [keys[0], pair[keys[0]]];
2097
+ }
2098
+ return result;
2099
+ }
2100
+ var pairs = new type("tag:yaml.org,2002:pairs", {
2101
+ kind: "sequence",
2102
+ resolve: resolveYamlPairs,
2103
+ construct: constructYamlPairs
2104
+ });
2105
+ var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
2106
+ function resolveYamlSet(data) {
2107
+ if (data === null) return true;
2108
+ var key, object = data;
2109
+ for (key in object) {
2110
+ if (_hasOwnProperty$2.call(object, key)) {
2111
+ if (object[key] !== null) return false;
2112
+ }
2113
+ }
2114
+ return true;
2115
+ }
2116
+ function constructYamlSet(data) {
2117
+ return data !== null ? data : {};
2118
+ }
2119
+ var set = new type("tag:yaml.org,2002:set", {
2120
+ kind: "mapping",
2121
+ resolve: resolveYamlSet,
2122
+ construct: constructYamlSet
2123
+ });
2124
+ var _default = core.extend({
2125
+ implicit: [
2126
+ timestamp,
2127
+ merge
2128
+ ],
2129
+ explicit: [
2130
+ binary,
2131
+ omap,
2132
+ pairs,
2133
+ set
2134
+ ]
2135
+ });
2136
+ var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
2137
+ var CONTEXT_FLOW_IN = 1;
2138
+ var CONTEXT_FLOW_OUT = 2;
2139
+ var CONTEXT_BLOCK_IN = 3;
2140
+ var CONTEXT_BLOCK_OUT = 4;
2141
+ var CHOMPING_CLIP = 1;
2142
+ var CHOMPING_STRIP = 2;
2143
+ var CHOMPING_KEEP = 3;
2144
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
2145
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
2146
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
2147
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
2148
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
2149
+ function _class(obj) {
2150
+ return Object.prototype.toString.call(obj);
2151
+ }
2152
+ function is_EOL(c) {
2153
+ return c === 10 || c === 13;
2154
+ }
2155
+ function is_WHITE_SPACE(c) {
2156
+ return c === 9 || c === 32;
2157
+ }
2158
+ function is_WS_OR_EOL(c) {
2159
+ return c === 9 || c === 32 || c === 10 || c === 13;
2160
+ }
2161
+ function is_FLOW_INDICATOR(c) {
2162
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
2163
+ }
2164
+ function fromHexCode(c) {
2165
+ var lc;
2166
+ if (48 <= c && c <= 57) {
2167
+ return c - 48;
2168
+ }
2169
+ lc = c | 32;
2170
+ if (97 <= lc && lc <= 102) {
2171
+ return lc - 97 + 10;
2172
+ }
2173
+ return -1;
2174
+ }
2175
+ function escapedHexLen(c) {
2176
+ if (c === 120) {
2177
+ return 2;
2178
+ }
2179
+ if (c === 117) {
2180
+ return 4;
2181
+ }
2182
+ if (c === 85) {
2183
+ return 8;
2184
+ }
2185
+ return 0;
2186
+ }
2187
+ function fromDecimalCode(c) {
2188
+ if (48 <= c && c <= 57) {
2189
+ return c - 48;
2190
+ }
2191
+ return -1;
2192
+ }
2193
+ function simpleEscapeSequence(c) {
2194
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
2195
+ }
2196
+ function charFromCodepoint(c) {
2197
+ if (c <= 65535) {
2198
+ return String.fromCharCode(c);
2199
+ }
2200
+ return String.fromCharCode(
2201
+ (c - 65536 >> 10) + 55296,
2202
+ (c - 65536 & 1023) + 56320
2203
+ );
2204
+ }
2205
+ var simpleEscapeCheck = new Array(256);
2206
+ var simpleEscapeMap = new Array(256);
2207
+ for (i = 0; i < 256; i++) {
2208
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
2209
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
2210
+ }
2211
+ var i;
2212
+ function State$1(input, options) {
2213
+ this.input = input;
2214
+ this.filename = options["filename"] || null;
2215
+ this.schema = options["schema"] || _default;
2216
+ this.onWarning = options["onWarning"] || null;
2217
+ this.legacy = options["legacy"] || false;
2218
+ this.json = options["json"] || false;
2219
+ this.listener = options["listener"] || null;
2220
+ this.implicitTypes = this.schema.compiledImplicit;
2221
+ this.typeMap = this.schema.compiledTypeMap;
2222
+ this.length = input.length;
2223
+ this.position = 0;
2224
+ this.line = 0;
2225
+ this.lineStart = 0;
2226
+ this.lineIndent = 0;
2227
+ this.firstTabInLine = -1;
2228
+ this.documents = [];
2229
+ }
2230
+ function generateError(state, message) {
2231
+ var mark = {
2232
+ name: state.filename,
2233
+ buffer: state.input.slice(0, -1),
2234
+ // omit trailing \0
2235
+ position: state.position,
2236
+ line: state.line,
2237
+ column: state.position - state.lineStart
2238
+ };
2239
+ mark.snippet = snippet(mark);
2240
+ return new exception(message, mark);
2241
+ }
2242
+ function throwError(state, message) {
2243
+ throw generateError(state, message);
2244
+ }
2245
+ function throwWarning(state, message) {
2246
+ if (state.onWarning) {
2247
+ state.onWarning.call(null, generateError(state, message));
2248
+ }
2249
+ }
2250
+ var directiveHandlers = {
2251
+ YAML: function handleYamlDirective(state, name, args) {
2252
+ var match, major, minor;
2253
+ if (state.version !== null) {
2254
+ throwError(state, "duplication of %YAML directive");
2255
+ }
2256
+ if (args.length !== 1) {
2257
+ throwError(state, "YAML directive accepts exactly one argument");
2258
+ }
2259
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
2260
+ if (match === null) {
2261
+ throwError(state, "ill-formed argument of the YAML directive");
2262
+ }
2263
+ major = parseInt(match[1], 10);
2264
+ minor = parseInt(match[2], 10);
2265
+ if (major !== 1) {
2266
+ throwError(state, "unacceptable YAML version of the document");
2267
+ }
2268
+ state.version = args[0];
2269
+ state.checkLineBreaks = minor < 2;
2270
+ if (minor !== 1 && minor !== 2) {
2271
+ throwWarning(state, "unsupported YAML version of the document");
2272
+ }
2273
+ },
2274
+ TAG: function handleTagDirective(state, name, args) {
2275
+ var handle, prefix;
2276
+ if (args.length !== 2) {
2277
+ throwError(state, "TAG directive accepts exactly two arguments");
2278
+ }
2279
+ handle = args[0];
2280
+ prefix = args[1];
2281
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
2282
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
2283
+ }
2284
+ if (_hasOwnProperty$1.call(state.tagMap, handle)) {
2285
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
2286
+ }
2287
+ if (!PATTERN_TAG_URI.test(prefix)) {
2288
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
2289
+ }
2290
+ try {
2291
+ prefix = decodeURIComponent(prefix);
2292
+ } catch (err) {
2293
+ throwError(state, "tag prefix is malformed: " + prefix);
2294
+ }
2295
+ state.tagMap[handle] = prefix;
2296
+ }
2297
+ };
2298
+ function captureSegment(state, start, end, checkJson) {
2299
+ var _position, _length, _character, _result;
2300
+ if (start < end) {
2301
+ _result = state.input.slice(start, end);
2302
+ if (checkJson) {
2303
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
2304
+ _character = _result.charCodeAt(_position);
2305
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
2306
+ throwError(state, "expected valid JSON character");
2307
+ }
2308
+ }
2309
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
2310
+ throwError(state, "the stream contains non-printable characters");
2311
+ }
2312
+ state.result += _result;
2313
+ }
2314
+ }
2315
+ function mergeMappings(state, destination, source, overridableKeys) {
2316
+ var sourceKeys, key, index, quantity;
2317
+ if (!common.isObject(source)) {
2318
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
2319
+ }
2320
+ sourceKeys = Object.keys(source);
2321
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
2322
+ key = sourceKeys[index];
2323
+ if (!_hasOwnProperty$1.call(destination, key)) {
2324
+ destination[key] = source[key];
2325
+ overridableKeys[key] = true;
2326
+ }
2327
+ }
2328
+ }
2329
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
2330
+ var index, quantity;
2331
+ if (Array.isArray(keyNode)) {
2332
+ keyNode = Array.prototype.slice.call(keyNode);
2333
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
2334
+ if (Array.isArray(keyNode[index])) {
2335
+ throwError(state, "nested arrays are not supported inside keys");
2336
+ }
2337
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
2338
+ keyNode[index] = "[object Object]";
2339
+ }
2340
+ }
2341
+ }
2342
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
2343
+ keyNode = "[object Object]";
2344
+ }
2345
+ keyNode = String(keyNode);
2346
+ if (_result === null) {
2347
+ _result = {};
2348
+ }
2349
+ if (keyTag === "tag:yaml.org,2002:merge") {
2350
+ if (Array.isArray(valueNode)) {
2351
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
2352
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
2353
+ }
2354
+ } else {
2355
+ mergeMappings(state, _result, valueNode, overridableKeys);
2356
+ }
2357
+ } else {
2358
+ if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
2359
+ state.line = startLine || state.line;
2360
+ state.lineStart = startLineStart || state.lineStart;
2361
+ state.position = startPos || state.position;
2362
+ throwError(state, "duplicated mapping key");
2363
+ }
2364
+ if (keyNode === "__proto__") {
2365
+ Object.defineProperty(_result, keyNode, {
2366
+ configurable: true,
2367
+ enumerable: true,
2368
+ writable: true,
2369
+ value: valueNode
2370
+ });
2371
+ } else {
2372
+ _result[keyNode] = valueNode;
2373
+ }
2374
+ delete overridableKeys[keyNode];
2375
+ }
2376
+ return _result;
2377
+ }
2378
+ function readLineBreak(state) {
2379
+ var ch;
2380
+ ch = state.input.charCodeAt(state.position);
2381
+ if (ch === 10) {
2382
+ state.position++;
2383
+ } else if (ch === 13) {
2384
+ state.position++;
2385
+ if (state.input.charCodeAt(state.position) === 10) {
2386
+ state.position++;
2387
+ }
2388
+ } else {
2389
+ throwError(state, "a line break is expected");
2390
+ }
2391
+ state.line += 1;
2392
+ state.lineStart = state.position;
2393
+ state.firstTabInLine = -1;
2394
+ }
2395
+ function skipSeparationSpace(state, allowComments, checkIndent) {
2396
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
2397
+ while (ch !== 0) {
2398
+ while (is_WHITE_SPACE(ch)) {
2399
+ if (ch === 9 && state.firstTabInLine === -1) {
2400
+ state.firstTabInLine = state.position;
2401
+ }
2402
+ ch = state.input.charCodeAt(++state.position);
2403
+ }
2404
+ if (allowComments && ch === 35) {
2405
+ do {
2406
+ ch = state.input.charCodeAt(++state.position);
2407
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
2408
+ }
2409
+ if (is_EOL(ch)) {
2410
+ readLineBreak(state);
2411
+ ch = state.input.charCodeAt(state.position);
2412
+ lineBreaks++;
2413
+ state.lineIndent = 0;
2414
+ while (ch === 32) {
2415
+ state.lineIndent++;
2416
+ ch = state.input.charCodeAt(++state.position);
2417
+ }
2418
+ } else {
2419
+ break;
2420
+ }
2421
+ }
2422
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
2423
+ throwWarning(state, "deficient indentation");
2424
+ }
2425
+ return lineBreaks;
2426
+ }
2427
+ function testDocumentSeparator(state) {
2428
+ var _position = state.position, ch;
2429
+ ch = state.input.charCodeAt(_position);
2430
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
2431
+ _position += 3;
2432
+ ch = state.input.charCodeAt(_position);
2433
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
2434
+ return true;
2435
+ }
2436
+ }
2437
+ return false;
2438
+ }
2439
+ function writeFoldedLines(state, count) {
2440
+ if (count === 1) {
2441
+ state.result += " ";
2442
+ } else if (count > 1) {
2443
+ state.result += common.repeat("\n", count - 1);
2444
+ }
2445
+ }
2446
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
2447
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
2448
+ ch = state.input.charCodeAt(state.position);
2449
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
2450
+ return false;
2451
+ }
2452
+ if (ch === 63 || ch === 45) {
2453
+ following = state.input.charCodeAt(state.position + 1);
2454
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
2455
+ return false;
2456
+ }
2457
+ }
2458
+ state.kind = "scalar";
2459
+ state.result = "";
2460
+ captureStart = captureEnd = state.position;
2461
+ hasPendingContent = false;
2462
+ while (ch !== 0) {
2463
+ if (ch === 58) {
2464
+ following = state.input.charCodeAt(state.position + 1);
2465
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
2466
+ break;
2467
+ }
2468
+ } else if (ch === 35) {
2469
+ preceding = state.input.charCodeAt(state.position - 1);
2470
+ if (is_WS_OR_EOL(preceding)) {
2471
+ break;
2472
+ }
2473
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
2474
+ break;
2475
+ } else if (is_EOL(ch)) {
2476
+ _line = state.line;
2477
+ _lineStart = state.lineStart;
2478
+ _lineIndent = state.lineIndent;
2479
+ skipSeparationSpace(state, false, -1);
2480
+ if (state.lineIndent >= nodeIndent) {
2481
+ hasPendingContent = true;
2482
+ ch = state.input.charCodeAt(state.position);
2483
+ continue;
2484
+ } else {
2485
+ state.position = captureEnd;
2486
+ state.line = _line;
2487
+ state.lineStart = _lineStart;
2488
+ state.lineIndent = _lineIndent;
2489
+ break;
2490
+ }
2491
+ }
2492
+ if (hasPendingContent) {
2493
+ captureSegment(state, captureStart, captureEnd, false);
2494
+ writeFoldedLines(state, state.line - _line);
2495
+ captureStart = captureEnd = state.position;
2496
+ hasPendingContent = false;
2497
+ }
2498
+ if (!is_WHITE_SPACE(ch)) {
2499
+ captureEnd = state.position + 1;
2500
+ }
2501
+ ch = state.input.charCodeAt(++state.position);
2502
+ }
2503
+ captureSegment(state, captureStart, captureEnd, false);
2504
+ if (state.result) {
2505
+ return true;
2506
+ }
2507
+ state.kind = _kind;
2508
+ state.result = _result;
2509
+ return false;
2510
+ }
2511
+ function readSingleQuotedScalar(state, nodeIndent) {
2512
+ var ch, captureStart, captureEnd;
2513
+ ch = state.input.charCodeAt(state.position);
2514
+ if (ch !== 39) {
2515
+ return false;
2516
+ }
2517
+ state.kind = "scalar";
2518
+ state.result = "";
2519
+ state.position++;
2520
+ captureStart = captureEnd = state.position;
2521
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2522
+ if (ch === 39) {
2523
+ captureSegment(state, captureStart, state.position, true);
2524
+ ch = state.input.charCodeAt(++state.position);
2525
+ if (ch === 39) {
2526
+ captureStart = state.position;
2527
+ state.position++;
2528
+ captureEnd = state.position;
2529
+ } else {
2530
+ return true;
2531
+ }
2532
+ } else if (is_EOL(ch)) {
2533
+ captureSegment(state, captureStart, captureEnd, true);
2534
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
2535
+ captureStart = captureEnd = state.position;
2536
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
2537
+ throwError(state, "unexpected end of the document within a single quoted scalar");
2538
+ } else {
2539
+ state.position++;
2540
+ captureEnd = state.position;
2541
+ }
2542
+ }
2543
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
2544
+ }
2545
+ function readDoubleQuotedScalar(state, nodeIndent) {
2546
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
2547
+ ch = state.input.charCodeAt(state.position);
2548
+ if (ch !== 34) {
2549
+ return false;
2550
+ }
2551
+ state.kind = "scalar";
2552
+ state.result = "";
2553
+ state.position++;
2554
+ captureStart = captureEnd = state.position;
2555
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2556
+ if (ch === 34) {
2557
+ captureSegment(state, captureStart, state.position, true);
2558
+ state.position++;
2559
+ return true;
2560
+ } else if (ch === 92) {
2561
+ captureSegment(state, captureStart, state.position, true);
2562
+ ch = state.input.charCodeAt(++state.position);
2563
+ if (is_EOL(ch)) {
2564
+ skipSeparationSpace(state, false, nodeIndent);
2565
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
2566
+ state.result += simpleEscapeMap[ch];
2567
+ state.position++;
2568
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
2569
+ hexLength = tmp;
2570
+ hexResult = 0;
2571
+ for (; hexLength > 0; hexLength--) {
2572
+ ch = state.input.charCodeAt(++state.position);
2573
+ if ((tmp = fromHexCode(ch)) >= 0) {
2574
+ hexResult = (hexResult << 4) + tmp;
2575
+ } else {
2576
+ throwError(state, "expected hexadecimal character");
2577
+ }
2578
+ }
2579
+ state.result += charFromCodepoint(hexResult);
2580
+ state.position++;
2581
+ } else {
2582
+ throwError(state, "unknown escape sequence");
2583
+ }
2584
+ captureStart = captureEnd = state.position;
2585
+ } else if (is_EOL(ch)) {
2586
+ captureSegment(state, captureStart, captureEnd, true);
2587
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
2588
+ captureStart = captureEnd = state.position;
2589
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
2590
+ throwError(state, "unexpected end of the document within a double quoted scalar");
2591
+ } else {
2592
+ state.position++;
2593
+ captureEnd = state.position;
2594
+ }
2595
+ }
2596
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
2597
+ }
2598
+ function readFlowCollection(state, nodeIndent) {
2599
+ var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
2600
+ ch = state.input.charCodeAt(state.position);
2601
+ if (ch === 91) {
2602
+ terminator = 93;
2603
+ isMapping = false;
2604
+ _result = [];
2605
+ } else if (ch === 123) {
2606
+ terminator = 125;
2607
+ isMapping = true;
2608
+ _result = {};
2609
+ } else {
2610
+ return false;
2611
+ }
2612
+ if (state.anchor !== null) {
2613
+ state.anchorMap[state.anchor] = _result;
2614
+ }
2615
+ ch = state.input.charCodeAt(++state.position);
2616
+ while (ch !== 0) {
2617
+ skipSeparationSpace(state, true, nodeIndent);
2618
+ ch = state.input.charCodeAt(state.position);
2619
+ if (ch === terminator) {
2620
+ state.position++;
2621
+ state.tag = _tag;
2622
+ state.anchor = _anchor;
2623
+ state.kind = isMapping ? "mapping" : "sequence";
2624
+ state.result = _result;
2625
+ return true;
2626
+ } else if (!readNext) {
2627
+ throwError(state, "missed comma between flow collection entries");
2628
+ } else if (ch === 44) {
2629
+ throwError(state, "expected the node content, but found ','");
2630
+ }
2631
+ keyTag = keyNode = valueNode = null;
2632
+ isPair = isExplicitPair = false;
2633
+ if (ch === 63) {
2634
+ following = state.input.charCodeAt(state.position + 1);
2635
+ if (is_WS_OR_EOL(following)) {
2636
+ isPair = isExplicitPair = true;
2637
+ state.position++;
2638
+ skipSeparationSpace(state, true, nodeIndent);
2639
+ }
2640
+ }
2641
+ _line = state.line;
2642
+ _lineStart = state.lineStart;
2643
+ _pos = state.position;
2644
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2645
+ keyTag = state.tag;
2646
+ keyNode = state.result;
2647
+ skipSeparationSpace(state, true, nodeIndent);
2648
+ ch = state.input.charCodeAt(state.position);
2649
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
2650
+ isPair = true;
2651
+ ch = state.input.charCodeAt(++state.position);
2652
+ skipSeparationSpace(state, true, nodeIndent);
2653
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2654
+ valueNode = state.result;
2655
+ }
2656
+ if (isMapping) {
2657
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
2658
+ } else if (isPair) {
2659
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
2660
+ } else {
2661
+ _result.push(keyNode);
2662
+ }
2663
+ skipSeparationSpace(state, true, nodeIndent);
2664
+ ch = state.input.charCodeAt(state.position);
2665
+ if (ch === 44) {
2666
+ readNext = true;
2667
+ ch = state.input.charCodeAt(++state.position);
2668
+ } else {
2669
+ readNext = false;
2670
+ }
2671
+ }
2672
+ throwError(state, "unexpected end of the stream within a flow collection");
2673
+ }
2674
+ function readBlockScalar(state, nodeIndent) {
2675
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
2676
+ ch = state.input.charCodeAt(state.position);
2677
+ if (ch === 124) {
2678
+ folding = false;
2679
+ } else if (ch === 62) {
2680
+ folding = true;
2681
+ } else {
2682
+ return false;
2683
+ }
2684
+ state.kind = "scalar";
2685
+ state.result = "";
2686
+ while (ch !== 0) {
2687
+ ch = state.input.charCodeAt(++state.position);
2688
+ if (ch === 43 || ch === 45) {
2689
+ if (CHOMPING_CLIP === chomping) {
2690
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
2691
+ } else {
2692
+ throwError(state, "repeat of a chomping mode identifier");
2693
+ }
2694
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
2695
+ if (tmp === 0) {
2696
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
2697
+ } else if (!detectedIndent) {
2698
+ textIndent = nodeIndent + tmp - 1;
2699
+ detectedIndent = true;
2700
+ } else {
2701
+ throwError(state, "repeat of an indentation width identifier");
2702
+ }
2703
+ } else {
2704
+ break;
2705
+ }
2706
+ }
2707
+ if (is_WHITE_SPACE(ch)) {
2708
+ do {
2709
+ ch = state.input.charCodeAt(++state.position);
2710
+ } while (is_WHITE_SPACE(ch));
2711
+ if (ch === 35) {
2712
+ do {
2713
+ ch = state.input.charCodeAt(++state.position);
2714
+ } while (!is_EOL(ch) && ch !== 0);
2715
+ }
2716
+ }
2717
+ while (ch !== 0) {
2718
+ readLineBreak(state);
2719
+ state.lineIndent = 0;
2720
+ ch = state.input.charCodeAt(state.position);
2721
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
2722
+ state.lineIndent++;
2723
+ ch = state.input.charCodeAt(++state.position);
2724
+ }
2725
+ if (!detectedIndent && state.lineIndent > textIndent) {
2726
+ textIndent = state.lineIndent;
2727
+ }
2728
+ if (is_EOL(ch)) {
2729
+ emptyLines++;
2730
+ continue;
2731
+ }
2732
+ if (state.lineIndent < textIndent) {
2733
+ if (chomping === CHOMPING_KEEP) {
2734
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2735
+ } else if (chomping === CHOMPING_CLIP) {
2736
+ if (didReadContent) {
2737
+ state.result += "\n";
2738
+ }
2739
+ }
2740
+ break;
2741
+ }
2742
+ if (folding) {
2743
+ if (is_WHITE_SPACE(ch)) {
2744
+ atMoreIndented = true;
2745
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2746
+ } else if (atMoreIndented) {
2747
+ atMoreIndented = false;
2748
+ state.result += common.repeat("\n", emptyLines + 1);
2749
+ } else if (emptyLines === 0) {
2750
+ if (didReadContent) {
2751
+ state.result += " ";
2752
+ }
2753
+ } else {
2754
+ state.result += common.repeat("\n", emptyLines);
2755
+ }
2756
+ } else {
2757
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2758
+ }
2759
+ didReadContent = true;
2760
+ detectedIndent = true;
2761
+ emptyLines = 0;
2762
+ captureStart = state.position;
2763
+ while (!is_EOL(ch) && ch !== 0) {
2764
+ ch = state.input.charCodeAt(++state.position);
2765
+ }
2766
+ captureSegment(state, captureStart, state.position, false);
2767
+ }
2768
+ return true;
2769
+ }
2770
+ function readBlockSequence(state, nodeIndent) {
2771
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
2772
+ if (state.firstTabInLine !== -1) return false;
2773
+ if (state.anchor !== null) {
2774
+ state.anchorMap[state.anchor] = _result;
2775
+ }
2776
+ ch = state.input.charCodeAt(state.position);
2777
+ while (ch !== 0) {
2778
+ if (state.firstTabInLine !== -1) {
2779
+ state.position = state.firstTabInLine;
2780
+ throwError(state, "tab characters must not be used in indentation");
2781
+ }
2782
+ if (ch !== 45) {
2783
+ break;
2784
+ }
2785
+ following = state.input.charCodeAt(state.position + 1);
2786
+ if (!is_WS_OR_EOL(following)) {
2787
+ break;
2788
+ }
2789
+ detected = true;
2790
+ state.position++;
2791
+ if (skipSeparationSpace(state, true, -1)) {
2792
+ if (state.lineIndent <= nodeIndent) {
2793
+ _result.push(null);
2794
+ ch = state.input.charCodeAt(state.position);
2795
+ continue;
2796
+ }
2797
+ }
2798
+ _line = state.line;
2799
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
2800
+ _result.push(state.result);
2801
+ skipSeparationSpace(state, true, -1);
2802
+ ch = state.input.charCodeAt(state.position);
2803
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
2804
+ throwError(state, "bad indentation of a sequence entry");
2805
+ } else if (state.lineIndent < nodeIndent) {
2806
+ break;
2807
+ }
2808
+ }
2809
+ if (detected) {
2810
+ state.tag = _tag;
2811
+ state.anchor = _anchor;
2812
+ state.kind = "sequence";
2813
+ state.result = _result;
2814
+ return true;
2815
+ }
2816
+ return false;
2817
+ }
2818
+ function readBlockMapping(state, nodeIndent, flowIndent) {
2819
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
2820
+ if (state.firstTabInLine !== -1) return false;
2821
+ if (state.anchor !== null) {
2822
+ state.anchorMap[state.anchor] = _result;
2823
+ }
2824
+ ch = state.input.charCodeAt(state.position);
2825
+ while (ch !== 0) {
2826
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
2827
+ state.position = state.firstTabInLine;
2828
+ throwError(state, "tab characters must not be used in indentation");
2829
+ }
2830
+ following = state.input.charCodeAt(state.position + 1);
2831
+ _line = state.line;
2832
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
2833
+ if (ch === 63) {
2834
+ if (atExplicitKey) {
2835
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2836
+ keyTag = keyNode = valueNode = null;
2837
+ }
2838
+ detected = true;
2839
+ atExplicitKey = true;
2840
+ allowCompact = true;
2841
+ } else if (atExplicitKey) {
2842
+ atExplicitKey = false;
2843
+ allowCompact = true;
2844
+ } else {
2845
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
2846
+ }
2847
+ state.position += 1;
2848
+ ch = following;
2849
+ } else {
2850
+ _keyLine = state.line;
2851
+ _keyLineStart = state.lineStart;
2852
+ _keyPos = state.position;
2853
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
2854
+ break;
2855
+ }
2856
+ if (state.line === _line) {
2857
+ ch = state.input.charCodeAt(state.position);
2858
+ while (is_WHITE_SPACE(ch)) {
2859
+ ch = state.input.charCodeAt(++state.position);
2860
+ }
2861
+ if (ch === 58) {
2862
+ ch = state.input.charCodeAt(++state.position);
2863
+ if (!is_WS_OR_EOL(ch)) {
2864
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
2865
+ }
2866
+ if (atExplicitKey) {
2867
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2868
+ keyTag = keyNode = valueNode = null;
2869
+ }
2870
+ detected = true;
2871
+ atExplicitKey = false;
2872
+ allowCompact = false;
2873
+ keyTag = state.tag;
2874
+ keyNode = state.result;
2875
+ } else if (detected) {
2876
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
2877
+ } else {
2878
+ state.tag = _tag;
2879
+ state.anchor = _anchor;
2880
+ return true;
2881
+ }
2882
+ } else if (detected) {
2883
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
2884
+ } else {
2885
+ state.tag = _tag;
2886
+ state.anchor = _anchor;
2887
+ return true;
2888
+ }
2889
+ }
2890
+ if (state.line === _line || state.lineIndent > nodeIndent) {
2891
+ if (atExplicitKey) {
2892
+ _keyLine = state.line;
2893
+ _keyLineStart = state.lineStart;
2894
+ _keyPos = state.position;
2895
+ }
2896
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2897
+ if (atExplicitKey) {
2898
+ keyNode = state.result;
2899
+ } else {
2900
+ valueNode = state.result;
2901
+ }
2902
+ }
2903
+ if (!atExplicitKey) {
2904
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
2905
+ keyTag = keyNode = valueNode = null;
2906
+ }
2907
+ skipSeparationSpace(state, true, -1);
2908
+ ch = state.input.charCodeAt(state.position);
2909
+ }
2910
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
2911
+ throwError(state, "bad indentation of a mapping entry");
2912
+ } else if (state.lineIndent < nodeIndent) {
2913
+ break;
2914
+ }
2915
+ }
2916
+ if (atExplicitKey) {
2917
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2918
+ }
2919
+ if (detected) {
2920
+ state.tag = _tag;
2921
+ state.anchor = _anchor;
2922
+ state.kind = "mapping";
2923
+ state.result = _result;
2924
+ }
2925
+ return detected;
2926
+ }
2927
+ function readTagProperty(state) {
2928
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
2929
+ ch = state.input.charCodeAt(state.position);
2930
+ if (ch !== 33) return false;
2931
+ if (state.tag !== null) {
2932
+ throwError(state, "duplication of a tag property");
2933
+ }
2934
+ ch = state.input.charCodeAt(++state.position);
2935
+ if (ch === 60) {
2936
+ isVerbatim = true;
2937
+ ch = state.input.charCodeAt(++state.position);
2938
+ } else if (ch === 33) {
2939
+ isNamed = true;
2940
+ tagHandle = "!!";
2941
+ ch = state.input.charCodeAt(++state.position);
2942
+ } else {
2943
+ tagHandle = "!";
2944
+ }
2945
+ _position = state.position;
2946
+ if (isVerbatim) {
2947
+ do {
2948
+ ch = state.input.charCodeAt(++state.position);
2949
+ } while (ch !== 0 && ch !== 62);
2950
+ if (state.position < state.length) {
2951
+ tagName = state.input.slice(_position, state.position);
2952
+ ch = state.input.charCodeAt(++state.position);
2953
+ } else {
2954
+ throwError(state, "unexpected end of the stream within a verbatim tag");
2955
+ }
2956
+ } else {
2957
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2958
+ if (ch === 33) {
2959
+ if (!isNamed) {
2960
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
2961
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2962
+ throwError(state, "named tag handle cannot contain such characters");
2963
+ }
2964
+ isNamed = true;
2965
+ _position = state.position + 1;
2966
+ } else {
2967
+ throwError(state, "tag suffix cannot contain exclamation marks");
2968
+ }
2969
+ }
2970
+ ch = state.input.charCodeAt(++state.position);
2971
+ }
2972
+ tagName = state.input.slice(_position, state.position);
2973
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2974
+ throwError(state, "tag suffix cannot contain flow indicator characters");
2975
+ }
2976
+ }
2977
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2978
+ throwError(state, "tag name cannot contain such characters: " + tagName);
2979
+ }
2980
+ try {
2981
+ tagName = decodeURIComponent(tagName);
2982
+ } catch (err) {
2983
+ throwError(state, "tag name is malformed: " + tagName);
2984
+ }
2985
+ if (isVerbatim) {
2986
+ state.tag = tagName;
2987
+ } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
2988
+ state.tag = state.tagMap[tagHandle] + tagName;
2989
+ } else if (tagHandle === "!") {
2990
+ state.tag = "!" + tagName;
2991
+ } else if (tagHandle === "!!") {
2992
+ state.tag = "tag:yaml.org,2002:" + tagName;
2993
+ } else {
2994
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2995
+ }
2996
+ return true;
2997
+ }
2998
+ function readAnchorProperty(state) {
2999
+ var _position, ch;
3000
+ ch = state.input.charCodeAt(state.position);
3001
+ if (ch !== 38) return false;
3002
+ if (state.anchor !== null) {
3003
+ throwError(state, "duplication of an anchor property");
3004
+ }
3005
+ ch = state.input.charCodeAt(++state.position);
3006
+ _position = state.position;
3007
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
3008
+ ch = state.input.charCodeAt(++state.position);
3009
+ }
3010
+ if (state.position === _position) {
3011
+ throwError(state, "name of an anchor node must contain at least one character");
3012
+ }
3013
+ state.anchor = state.input.slice(_position, state.position);
3014
+ return true;
3015
+ }
3016
+ function readAlias(state) {
3017
+ var _position, alias, ch;
3018
+ ch = state.input.charCodeAt(state.position);
3019
+ if (ch !== 42) return false;
3020
+ ch = state.input.charCodeAt(++state.position);
3021
+ _position = state.position;
3022
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
3023
+ ch = state.input.charCodeAt(++state.position);
3024
+ }
3025
+ if (state.position === _position) {
3026
+ throwError(state, "name of an alias node must contain at least one character");
3027
+ }
3028
+ alias = state.input.slice(_position, state.position);
3029
+ if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
3030
+ throwError(state, 'unidentified alias "' + alias + '"');
3031
+ }
3032
+ state.result = state.anchorMap[alias];
3033
+ skipSeparationSpace(state, true, -1);
3034
+ return true;
3035
+ }
3036
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
3037
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
3038
+ if (state.listener !== null) {
3039
+ state.listener("open", state);
3040
+ }
3041
+ state.tag = null;
3042
+ state.anchor = null;
3043
+ state.kind = null;
3044
+ state.result = null;
3045
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
3046
+ if (allowToSeek) {
3047
+ if (skipSeparationSpace(state, true, -1)) {
3048
+ atNewLine = true;
3049
+ if (state.lineIndent > parentIndent) {
3050
+ indentStatus = 1;
3051
+ } else if (state.lineIndent === parentIndent) {
3052
+ indentStatus = 0;
3053
+ } else if (state.lineIndent < parentIndent) {
3054
+ indentStatus = -1;
3055
+ }
3056
+ }
3057
+ }
3058
+ if (indentStatus === 1) {
3059
+ while (readTagProperty(state) || readAnchorProperty(state)) {
3060
+ if (skipSeparationSpace(state, true, -1)) {
3061
+ atNewLine = true;
3062
+ allowBlockCollections = allowBlockStyles;
3063
+ if (state.lineIndent > parentIndent) {
3064
+ indentStatus = 1;
3065
+ } else if (state.lineIndent === parentIndent) {
3066
+ indentStatus = 0;
3067
+ } else if (state.lineIndent < parentIndent) {
3068
+ indentStatus = -1;
3069
+ }
3070
+ } else {
3071
+ allowBlockCollections = false;
3072
+ }
3073
+ }
3074
+ }
3075
+ if (allowBlockCollections) {
3076
+ allowBlockCollections = atNewLine || allowCompact;
3077
+ }
3078
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
3079
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
3080
+ flowIndent = parentIndent;
3081
+ } else {
3082
+ flowIndent = parentIndent + 1;
3083
+ }
3084
+ blockIndent = state.position - state.lineStart;
3085
+ if (indentStatus === 1) {
3086
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
3087
+ hasContent = true;
3088
+ } else {
3089
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
3090
+ hasContent = true;
3091
+ } else if (readAlias(state)) {
3092
+ hasContent = true;
3093
+ if (state.tag !== null || state.anchor !== null) {
3094
+ throwError(state, "alias node should not have any properties");
3095
+ }
3096
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
3097
+ hasContent = true;
3098
+ if (state.tag === null) {
3099
+ state.tag = "?";
3100
+ }
3101
+ }
3102
+ if (state.anchor !== null) {
3103
+ state.anchorMap[state.anchor] = state.result;
3104
+ }
3105
+ }
3106
+ } else if (indentStatus === 0) {
3107
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
3108
+ }
3109
+ }
3110
+ if (state.tag === null) {
3111
+ if (state.anchor !== null) {
3112
+ state.anchorMap[state.anchor] = state.result;
3113
+ }
3114
+ } else if (state.tag === "?") {
3115
+ if (state.result !== null && state.kind !== "scalar") {
3116
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
3117
+ }
3118
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
3119
+ type2 = state.implicitTypes[typeIndex];
3120
+ if (type2.resolve(state.result)) {
3121
+ state.result = type2.construct(state.result);
3122
+ state.tag = type2.tag;
3123
+ if (state.anchor !== null) {
3124
+ state.anchorMap[state.anchor] = state.result;
3125
+ }
3126
+ break;
3127
+ }
3128
+ }
3129
+ } else if (state.tag !== "!") {
3130
+ if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
3131
+ type2 = state.typeMap[state.kind || "fallback"][state.tag];
3132
+ } else {
3133
+ type2 = null;
3134
+ typeList = state.typeMap.multi[state.kind || "fallback"];
3135
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
3136
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
3137
+ type2 = typeList[typeIndex];
3138
+ break;
3139
+ }
3140
+ }
3141
+ }
3142
+ if (!type2) {
3143
+ throwError(state, "unknown tag !<" + state.tag + ">");
3144
+ }
3145
+ if (state.result !== null && type2.kind !== state.kind) {
3146
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
3147
+ }
3148
+ if (!type2.resolve(state.result, state.tag)) {
3149
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
3150
+ } else {
3151
+ state.result = type2.construct(state.result, state.tag);
3152
+ if (state.anchor !== null) {
3153
+ state.anchorMap[state.anchor] = state.result;
3154
+ }
3155
+ }
3156
+ }
3157
+ if (state.listener !== null) {
3158
+ state.listener("close", state);
3159
+ }
3160
+ return state.tag !== null || state.anchor !== null || hasContent;
3161
+ }
3162
+ function readDocument(state) {
3163
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
3164
+ state.version = null;
3165
+ state.checkLineBreaks = state.legacy;
3166
+ state.tagMap = /* @__PURE__ */ Object.create(null);
3167
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
3168
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
3169
+ skipSeparationSpace(state, true, -1);
3170
+ ch = state.input.charCodeAt(state.position);
3171
+ if (state.lineIndent > 0 || ch !== 37) {
3172
+ break;
3173
+ }
3174
+ hasDirectives = true;
3175
+ ch = state.input.charCodeAt(++state.position);
3176
+ _position = state.position;
3177
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
3178
+ ch = state.input.charCodeAt(++state.position);
3179
+ }
3180
+ directiveName = state.input.slice(_position, state.position);
3181
+ directiveArgs = [];
3182
+ if (directiveName.length < 1) {
3183
+ throwError(state, "directive name must not be less than one character in length");
3184
+ }
3185
+ while (ch !== 0) {
3186
+ while (is_WHITE_SPACE(ch)) {
3187
+ ch = state.input.charCodeAt(++state.position);
3188
+ }
3189
+ if (ch === 35) {
3190
+ do {
3191
+ ch = state.input.charCodeAt(++state.position);
3192
+ } while (ch !== 0 && !is_EOL(ch));
3193
+ break;
3194
+ }
3195
+ if (is_EOL(ch)) break;
3196
+ _position = state.position;
3197
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
3198
+ ch = state.input.charCodeAt(++state.position);
3199
+ }
3200
+ directiveArgs.push(state.input.slice(_position, state.position));
3201
+ }
3202
+ if (ch !== 0) readLineBreak(state);
3203
+ if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
3204
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
3205
+ } else {
3206
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
3207
+ }
3208
+ }
3209
+ skipSeparationSpace(state, true, -1);
3210
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
3211
+ state.position += 3;
3212
+ skipSeparationSpace(state, true, -1);
3213
+ } else if (hasDirectives) {
3214
+ throwError(state, "directives end mark is expected");
3215
+ }
3216
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
3217
+ skipSeparationSpace(state, true, -1);
3218
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
3219
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
3220
+ }
3221
+ state.documents.push(state.result);
3222
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
3223
+ if (state.input.charCodeAt(state.position) === 46) {
3224
+ state.position += 3;
3225
+ skipSeparationSpace(state, true, -1);
3226
+ }
3227
+ return;
3228
+ }
3229
+ if (state.position < state.length - 1) {
3230
+ throwError(state, "end of the stream or a document separator is expected");
3231
+ } else {
3232
+ return;
3233
+ }
3234
+ }
3235
+ function loadDocuments(input, options) {
3236
+ input = String(input);
3237
+ options = options || {};
3238
+ if (input.length !== 0) {
3239
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
3240
+ input += "\n";
3241
+ }
3242
+ if (input.charCodeAt(0) === 65279) {
3243
+ input = input.slice(1);
3244
+ }
3245
+ }
3246
+ var state = new State$1(input, options);
3247
+ var nullpos = input.indexOf("\0");
3248
+ if (nullpos !== -1) {
3249
+ state.position = nullpos;
3250
+ throwError(state, "null byte is not allowed in input");
3251
+ }
3252
+ state.input += "\0";
3253
+ while (state.input.charCodeAt(state.position) === 32) {
3254
+ state.lineIndent += 1;
3255
+ state.position += 1;
3256
+ }
3257
+ while (state.position < state.length - 1) {
3258
+ readDocument(state);
3259
+ }
3260
+ return state.documents;
3261
+ }
3262
+ function loadAll$1(input, iterator, options) {
3263
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
3264
+ options = iterator;
3265
+ iterator = null;
3266
+ }
3267
+ var documents = loadDocuments(input, options);
3268
+ if (typeof iterator !== "function") {
3269
+ return documents;
3270
+ }
3271
+ for (var index = 0, length = documents.length; index < length; index += 1) {
3272
+ iterator(documents[index]);
3273
+ }
3274
+ }
3275
+ function load$1(input, options) {
3276
+ var documents = loadDocuments(input, options);
3277
+ if (documents.length === 0) {
3278
+ return void 0;
3279
+ } else if (documents.length === 1) {
3280
+ return documents[0];
3281
+ }
3282
+ throw new exception("expected a single document in the stream, but found more");
3283
+ }
3284
+ var loadAll_1 = loadAll$1;
3285
+ var load_1 = load$1;
3286
+ var loader = {
3287
+ loadAll: loadAll_1,
3288
+ load: load_1
3289
+ };
3290
+ var _toString = Object.prototype.toString;
3291
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
3292
+ var CHAR_BOM = 65279;
3293
+ var CHAR_TAB = 9;
3294
+ var CHAR_LINE_FEED = 10;
3295
+ var CHAR_CARRIAGE_RETURN = 13;
3296
+ var CHAR_SPACE = 32;
3297
+ var CHAR_EXCLAMATION = 33;
3298
+ var CHAR_DOUBLE_QUOTE = 34;
3299
+ var CHAR_SHARP = 35;
3300
+ var CHAR_PERCENT = 37;
3301
+ var CHAR_AMPERSAND = 38;
3302
+ var CHAR_SINGLE_QUOTE = 39;
3303
+ var CHAR_ASTERISK = 42;
3304
+ var CHAR_COMMA = 44;
3305
+ var CHAR_MINUS = 45;
3306
+ var CHAR_COLON = 58;
3307
+ var CHAR_EQUALS = 61;
3308
+ var CHAR_GREATER_THAN = 62;
3309
+ var CHAR_QUESTION = 63;
3310
+ var CHAR_COMMERCIAL_AT = 64;
3311
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
3312
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
3313
+ var CHAR_GRAVE_ACCENT = 96;
3314
+ var CHAR_LEFT_CURLY_BRACKET = 123;
3315
+ var CHAR_VERTICAL_LINE = 124;
3316
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
3317
+ var ESCAPE_SEQUENCES = {};
3318
+ ESCAPE_SEQUENCES[0] = "\\0";
3319
+ ESCAPE_SEQUENCES[7] = "\\a";
3320
+ ESCAPE_SEQUENCES[8] = "\\b";
3321
+ ESCAPE_SEQUENCES[9] = "\\t";
3322
+ ESCAPE_SEQUENCES[10] = "\\n";
3323
+ ESCAPE_SEQUENCES[11] = "\\v";
3324
+ ESCAPE_SEQUENCES[12] = "\\f";
3325
+ ESCAPE_SEQUENCES[13] = "\\r";
3326
+ ESCAPE_SEQUENCES[27] = "\\e";
3327
+ ESCAPE_SEQUENCES[34] = '\\"';
3328
+ ESCAPE_SEQUENCES[92] = "\\\\";
3329
+ ESCAPE_SEQUENCES[133] = "\\N";
3330
+ ESCAPE_SEQUENCES[160] = "\\_";
3331
+ ESCAPE_SEQUENCES[8232] = "\\L";
3332
+ ESCAPE_SEQUENCES[8233] = "\\P";
3333
+ var DEPRECATED_BOOLEANS_SYNTAX = [
3334
+ "y",
3335
+ "Y",
3336
+ "yes",
3337
+ "Yes",
3338
+ "YES",
3339
+ "on",
3340
+ "On",
3341
+ "ON",
3342
+ "n",
3343
+ "N",
3344
+ "no",
3345
+ "No",
3346
+ "NO",
3347
+ "off",
3348
+ "Off",
3349
+ "OFF"
3350
+ ];
3351
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
3352
+ function compileStyleMap(schema2, map2) {
3353
+ var result, keys, index, length, tag, style, type2;
3354
+ if (map2 === null) return {};
3355
+ result = {};
3356
+ keys = Object.keys(map2);
3357
+ for (index = 0, length = keys.length; index < length; index += 1) {
3358
+ tag = keys[index];
3359
+ style = String(map2[tag]);
3360
+ if (tag.slice(0, 2) === "!!") {
3361
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
3362
+ }
3363
+ type2 = schema2.compiledTypeMap["fallback"][tag];
3364
+ if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
3365
+ style = type2.styleAliases[style];
3366
+ }
3367
+ result[tag] = style;
3368
+ }
3369
+ return result;
3370
+ }
3371
+ function encodeHex(character) {
3372
+ var string, handle, length;
3373
+ string = character.toString(16).toUpperCase();
3374
+ if (character <= 255) {
3375
+ handle = "x";
3376
+ length = 2;
3377
+ } else if (character <= 65535) {
3378
+ handle = "u";
3379
+ length = 4;
3380
+ } else if (character <= 4294967295) {
3381
+ handle = "U";
3382
+ length = 8;
3383
+ } else {
3384
+ throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
3385
+ }
3386
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
3387
+ }
3388
+ var QUOTING_TYPE_SINGLE = 1;
3389
+ var QUOTING_TYPE_DOUBLE = 2;
3390
+ function State(options) {
3391
+ this.schema = options["schema"] || _default;
3392
+ this.indent = Math.max(1, options["indent"] || 2);
3393
+ this.noArrayIndent = options["noArrayIndent"] || false;
3394
+ this.skipInvalid = options["skipInvalid"] || false;
3395
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
3396
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
3397
+ this.sortKeys = options["sortKeys"] || false;
3398
+ this.lineWidth = options["lineWidth"] || 80;
3399
+ this.noRefs = options["noRefs"] || false;
3400
+ this.noCompatMode = options["noCompatMode"] || false;
3401
+ this.condenseFlow = options["condenseFlow"] || false;
3402
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
3403
+ this.forceQuotes = options["forceQuotes"] || false;
3404
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
3405
+ this.implicitTypes = this.schema.compiledImplicit;
3406
+ this.explicitTypes = this.schema.compiledExplicit;
3407
+ this.tag = null;
3408
+ this.result = "";
3409
+ this.duplicates = [];
3410
+ this.usedDuplicates = null;
3411
+ }
3412
+ function indentString(string, spaces) {
3413
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
3414
+ while (position < length) {
3415
+ next = string.indexOf("\n", position);
3416
+ if (next === -1) {
3417
+ line = string.slice(position);
3418
+ position = length;
3419
+ } else {
3420
+ line = string.slice(position, next + 1);
3421
+ position = next + 1;
3422
+ }
3423
+ if (line.length && line !== "\n") result += ind;
3424
+ result += line;
3425
+ }
3426
+ return result;
3427
+ }
3428
+ function generateNextLine(state, level) {
3429
+ return "\n" + common.repeat(" ", state.indent * level);
3430
+ }
3431
+ function testImplicitResolving(state, str2) {
3432
+ var index, length, type2;
3433
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
3434
+ type2 = state.implicitTypes[index];
3435
+ if (type2.resolve(str2)) {
3436
+ return true;
3437
+ }
3438
+ }
3439
+ return false;
3440
+ }
3441
+ function isWhitespace(c) {
3442
+ return c === CHAR_SPACE || c === CHAR_TAB;
3443
+ }
3444
+ function isPrintable(c) {
3445
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
3446
+ }
3447
+ function isNsCharOrWhitespace(c) {
3448
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
3449
+ }
3450
+ function isPlainSafe(c, prev, inblock) {
3451
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
3452
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
3453
+ return (
3454
+ // ns-plain-safe
3455
+ (inblock ? (
3456
+ // c = flow-in
3457
+ cIsNsCharOrWhitespace
3458
+ ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
3459
+ );
3460
+ }
3461
+ function isPlainSafeFirst(c) {
3462
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
3463
+ }
3464
+ function isPlainSafeLast(c) {
3465
+ return !isWhitespace(c) && c !== CHAR_COLON;
3466
+ }
3467
+ function codePointAt(string, pos) {
3468
+ var first = string.charCodeAt(pos), second;
3469
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
3470
+ second = string.charCodeAt(pos + 1);
3471
+ if (second >= 56320 && second <= 57343) {
3472
+ return (first - 55296) * 1024 + second - 56320 + 65536;
3473
+ }
3474
+ }
3475
+ return first;
3476
+ }
3477
+ function needIndentIndicator(string) {
3478
+ var leadingSpaceRe = /^\n* /;
3479
+ return leadingSpaceRe.test(string);
3480
+ }
3481
+ var STYLE_PLAIN = 1;
3482
+ var STYLE_SINGLE = 2;
3483
+ var STYLE_LITERAL = 3;
3484
+ var STYLE_FOLDED = 4;
3485
+ var STYLE_DOUBLE = 5;
3486
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
3487
+ var i;
3488
+ var char = 0;
3489
+ var prevChar = null;
3490
+ var hasLineBreak = false;
3491
+ var hasFoldableLine = false;
3492
+ var shouldTrackWidth = lineWidth !== -1;
3493
+ var previousLineBreak = -1;
3494
+ var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
3495
+ if (singleLineOnly || forceQuotes) {
3496
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
3497
+ char = codePointAt(string, i);
3498
+ if (!isPrintable(char)) {
3499
+ return STYLE_DOUBLE;
3500
+ }
3501
+ plain = plain && isPlainSafe(char, prevChar, inblock);
3502
+ prevChar = char;
3503
+ }
3504
+ } else {
3505
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
3506
+ char = codePointAt(string, i);
3507
+ if (char === CHAR_LINE_FEED) {
3508
+ hasLineBreak = true;
3509
+ if (shouldTrackWidth) {
3510
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
3511
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
3512
+ previousLineBreak = i;
3513
+ }
3514
+ } else if (!isPrintable(char)) {
3515
+ return STYLE_DOUBLE;
3516
+ }
3517
+ plain = plain && isPlainSafe(char, prevChar, inblock);
3518
+ prevChar = char;
3519
+ }
3520
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
3521
+ }
3522
+ if (!hasLineBreak && !hasFoldableLine) {
3523
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
3524
+ return STYLE_PLAIN;
3525
+ }
3526
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
3527
+ }
3528
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
3529
+ return STYLE_DOUBLE;
3530
+ }
3531
+ if (!forceQuotes) {
3532
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
3533
+ }
3534
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
3535
+ }
3536
+ function writeScalar(state, string, level, iskey, inblock) {
3537
+ state.dump = function() {
3538
+ if (string.length === 0) {
3539
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
3540
+ }
3541
+ if (!state.noCompatMode) {
3542
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
3543
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
3544
+ }
3545
+ }
3546
+ var indent = state.indent * Math.max(1, level);
3547
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
3548
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
3549
+ function testAmbiguity(string2) {
3550
+ return testImplicitResolving(state, string2);
3551
+ }
3552
+ switch (chooseScalarStyle(
3553
+ string,
3554
+ singleLineOnly,
3555
+ state.indent,
3556
+ lineWidth,
3557
+ testAmbiguity,
3558
+ state.quotingType,
3559
+ state.forceQuotes && !iskey,
3560
+ inblock
3561
+ )) {
3562
+ case STYLE_PLAIN:
3563
+ return string;
3564
+ case STYLE_SINGLE:
3565
+ return "'" + string.replace(/'/g, "''") + "'";
3566
+ case STYLE_LITERAL:
3567
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
3568
+ case STYLE_FOLDED:
3569
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
3570
+ case STYLE_DOUBLE:
3571
+ return '"' + escapeString(string) + '"';
3572
+ default:
3573
+ throw new exception("impossible error: invalid scalar style");
3574
+ }
3575
+ }();
3576
+ }
3577
+ function blockHeader(string, indentPerLevel) {
3578
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
3579
+ var clip = string[string.length - 1] === "\n";
3580
+ var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
3581
+ var chomp = keep ? "+" : clip ? "" : "-";
3582
+ return indentIndicator + chomp + "\n";
3583
+ }
3584
+ function dropEndingNewline(string) {
3585
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
3586
+ }
3587
+ function foldString(string, width) {
3588
+ var lineRe = /(\n+)([^\n]*)/g;
3589
+ var result = function() {
3590
+ var nextLF = string.indexOf("\n");
3591
+ nextLF = nextLF !== -1 ? nextLF : string.length;
3592
+ lineRe.lastIndex = nextLF;
3593
+ return foldLine(string.slice(0, nextLF), width);
3594
+ }();
3595
+ var prevMoreIndented = string[0] === "\n" || string[0] === " ";
3596
+ var moreIndented;
3597
+ var match;
3598
+ while (match = lineRe.exec(string)) {
3599
+ var prefix = match[1], line = match[2];
3600
+ moreIndented = line[0] === " ";
3601
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
3602
+ prevMoreIndented = moreIndented;
3603
+ }
3604
+ return result;
3605
+ }
3606
+ function foldLine(line, width) {
3607
+ if (line === "" || line[0] === " ") return line;
3608
+ var breakRe = / [^ ]/g;
3609
+ var match;
3610
+ var start = 0, end, curr = 0, next = 0;
3611
+ var result = "";
3612
+ while (match = breakRe.exec(line)) {
3613
+ next = match.index;
3614
+ if (next - start > width) {
3615
+ end = curr > start ? curr : next;
3616
+ result += "\n" + line.slice(start, end);
3617
+ start = end + 1;
3618
+ }
3619
+ curr = next;
3620
+ }
3621
+ result += "\n";
3622
+ if (line.length - start > width && curr > start) {
3623
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
3624
+ } else {
3625
+ result += line.slice(start);
3626
+ }
3627
+ return result.slice(1);
3628
+ }
3629
+ function escapeString(string) {
3630
+ var result = "";
3631
+ var char = 0;
3632
+ var escapeSeq;
3633
+ for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
3634
+ char = codePointAt(string, i);
3635
+ escapeSeq = ESCAPE_SEQUENCES[char];
3636
+ if (!escapeSeq && isPrintable(char)) {
3637
+ result += string[i];
3638
+ if (char >= 65536) result += string[i + 1];
3639
+ } else {
3640
+ result += escapeSeq || encodeHex(char);
3641
+ }
3642
+ }
3643
+ return result;
3644
+ }
3645
+ function writeFlowSequence(state, level, object) {
3646
+ var _result = "", _tag = state.tag, index, length, value;
3647
+ for (index = 0, length = object.length; index < length; index += 1) {
3648
+ value = object[index];
3649
+ if (state.replacer) {
3650
+ value = state.replacer.call(object, String(index), value);
3651
+ }
3652
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
3653
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
3654
+ _result += state.dump;
3655
+ }
3656
+ }
3657
+ state.tag = _tag;
3658
+ state.dump = "[" + _result + "]";
3659
+ }
3660
+ function writeBlockSequence(state, level, object, compact) {
3661
+ var _result = "", _tag = state.tag, index, length, value;
3662
+ for (index = 0, length = object.length; index < length; index += 1) {
3663
+ value = object[index];
3664
+ if (state.replacer) {
3665
+ value = state.replacer.call(object, String(index), value);
3666
+ }
3667
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
3668
+ if (!compact || _result !== "") {
3669
+ _result += generateNextLine(state, level);
3670
+ }
3671
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3672
+ _result += "-";
3673
+ } else {
3674
+ _result += "- ";
3675
+ }
3676
+ _result += state.dump;
3677
+ }
3678
+ }
3679
+ state.tag = _tag;
3680
+ state.dump = _result || "[]";
3681
+ }
3682
+ function writeFlowMapping(state, level, object) {
3683
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
3684
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3685
+ pairBuffer = "";
3686
+ if (_result !== "") pairBuffer += ", ";
3687
+ if (state.condenseFlow) pairBuffer += '"';
3688
+ objectKey = objectKeyList[index];
3689
+ objectValue = object[objectKey];
3690
+ if (state.replacer) {
3691
+ objectValue = state.replacer.call(object, objectKey, objectValue);
3692
+ }
3693
+ if (!writeNode(state, level, objectKey, false, false)) {
3694
+ continue;
3695
+ }
3696
+ if (state.dump.length > 1024) pairBuffer += "? ";
3697
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
3698
+ if (!writeNode(state, level, objectValue, false, false)) {
3699
+ continue;
3700
+ }
3701
+ pairBuffer += state.dump;
3702
+ _result += pairBuffer;
3703
+ }
3704
+ state.tag = _tag;
3705
+ state.dump = "{" + _result + "}";
3706
+ }
3707
+ function writeBlockMapping(state, level, object, compact) {
3708
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
3709
+ if (state.sortKeys === true) {
3710
+ objectKeyList.sort();
3711
+ } else if (typeof state.sortKeys === "function") {
3712
+ objectKeyList.sort(state.sortKeys);
3713
+ } else if (state.sortKeys) {
3714
+ throw new exception("sortKeys must be a boolean or a function");
3715
+ }
3716
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3717
+ pairBuffer = "";
3718
+ if (!compact || _result !== "") {
3719
+ pairBuffer += generateNextLine(state, level);
3720
+ }
3721
+ objectKey = objectKeyList[index];
3722
+ objectValue = object[objectKey];
3723
+ if (state.replacer) {
3724
+ objectValue = state.replacer.call(object, objectKey, objectValue);
3725
+ }
3726
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
3727
+ continue;
3728
+ }
3729
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
3730
+ if (explicitPair) {
3731
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3732
+ pairBuffer += "?";
3733
+ } else {
3734
+ pairBuffer += "? ";
3735
+ }
3736
+ }
3737
+ pairBuffer += state.dump;
3738
+ if (explicitPair) {
3739
+ pairBuffer += generateNextLine(state, level);
3740
+ }
3741
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
3742
+ continue;
3743
+ }
3744
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3745
+ pairBuffer += ":";
3746
+ } else {
3747
+ pairBuffer += ": ";
3748
+ }
3749
+ pairBuffer += state.dump;
3750
+ _result += pairBuffer;
3751
+ }
3752
+ state.tag = _tag;
3753
+ state.dump = _result || "{}";
3754
+ }
3755
+ function detectType(state, object, explicit) {
3756
+ var _result, typeList, index, length, type2, style;
3757
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
3758
+ for (index = 0, length = typeList.length; index < length; index += 1) {
3759
+ type2 = typeList[index];
3760
+ if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
3761
+ if (explicit) {
3762
+ if (type2.multi && type2.representName) {
3763
+ state.tag = type2.representName(object);
3764
+ } else {
3765
+ state.tag = type2.tag;
3766
+ }
3767
+ } else {
3768
+ state.tag = "?";
3769
+ }
3770
+ if (type2.represent) {
3771
+ style = state.styleMap[type2.tag] || type2.defaultStyle;
3772
+ if (_toString.call(type2.represent) === "[object Function]") {
3773
+ _result = type2.represent(object, style);
3774
+ } else if (_hasOwnProperty.call(type2.represent, style)) {
3775
+ _result = type2.represent[style](object, style);
3776
+ } else {
3777
+ throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
3778
+ }
3779
+ state.dump = _result;
3780
+ }
3781
+ return true;
3782
+ }
3783
+ }
3784
+ return false;
3785
+ }
3786
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3787
+ state.tag = null;
3788
+ state.dump = object;
3789
+ if (!detectType(state, object, false)) {
3790
+ detectType(state, object, true);
3791
+ }
3792
+ var type2 = _toString.call(state.dump);
3793
+ var inblock = block;
3794
+ var tagStr;
3795
+ if (block) {
3796
+ block = state.flowLevel < 0 || state.flowLevel > level;
3797
+ }
3798
+ var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
3799
+ if (objectOrArray) {
3800
+ duplicateIndex = state.duplicates.indexOf(object);
3801
+ duplicate = duplicateIndex !== -1;
3802
+ }
3803
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
3804
+ compact = false;
3805
+ }
3806
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
3807
+ state.dump = "*ref_" + duplicateIndex;
3808
+ } else {
3809
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
3810
+ state.usedDuplicates[duplicateIndex] = true;
3811
+ }
3812
+ if (type2 === "[object Object]") {
3813
+ if (block && Object.keys(state.dump).length !== 0) {
3814
+ writeBlockMapping(state, level, state.dump, compact);
3815
+ if (duplicate) {
3816
+ state.dump = "&ref_" + duplicateIndex + state.dump;
3817
+ }
3818
+ } else {
3819
+ writeFlowMapping(state, level, state.dump);
3820
+ if (duplicate) {
3821
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3822
+ }
3823
+ }
3824
+ } else if (type2 === "[object Array]") {
3825
+ if (block && state.dump.length !== 0) {
3826
+ if (state.noArrayIndent && !isblockseq && level > 0) {
3827
+ writeBlockSequence(state, level - 1, state.dump, compact);
3828
+ } else {
3829
+ writeBlockSequence(state, level, state.dump, compact);
3830
+ }
3831
+ if (duplicate) {
3832
+ state.dump = "&ref_" + duplicateIndex + state.dump;
3833
+ }
3834
+ } else {
3835
+ writeFlowSequence(state, level, state.dump);
3836
+ if (duplicate) {
3837
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3838
+ }
3839
+ }
3840
+ } else if (type2 === "[object String]") {
3841
+ if (state.tag !== "?") {
3842
+ writeScalar(state, state.dump, level, iskey, inblock);
3843
+ }
3844
+ } else if (type2 === "[object Undefined]") {
3845
+ return false;
3846
+ } else {
3847
+ if (state.skipInvalid) return false;
3848
+ throw new exception("unacceptable kind of an object to dump " + type2);
3849
+ }
3850
+ if (state.tag !== null && state.tag !== "?") {
3851
+ tagStr = encodeURI(
3852
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
3853
+ ).replace(/!/g, "%21");
3854
+ if (state.tag[0] === "!") {
3855
+ tagStr = "!" + tagStr;
3856
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
3857
+ tagStr = "!!" + tagStr.slice(18);
3858
+ } else {
3859
+ tagStr = "!<" + tagStr + ">";
3860
+ }
3861
+ state.dump = tagStr + " " + state.dump;
3862
+ }
3863
+ }
3864
+ return true;
3865
+ }
3866
+ function getDuplicateReferences(object, state) {
3867
+ var objects = [], duplicatesIndexes = [], index, length;
3868
+ inspectNode(object, objects, duplicatesIndexes);
3869
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
3870
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
3871
+ }
3872
+ state.usedDuplicates = new Array(length);
3873
+ }
3874
+ function inspectNode(object, objects, duplicatesIndexes) {
3875
+ var objectKeyList, index, length;
3876
+ if (object !== null && typeof object === "object") {
3877
+ index = objects.indexOf(object);
3878
+ if (index !== -1) {
3879
+ if (duplicatesIndexes.indexOf(index) === -1) {
3880
+ duplicatesIndexes.push(index);
3881
+ }
3882
+ } else {
3883
+ objects.push(object);
3884
+ if (Array.isArray(object)) {
3885
+ for (index = 0, length = object.length; index < length; index += 1) {
3886
+ inspectNode(object[index], objects, duplicatesIndexes);
3887
+ }
3888
+ } else {
3889
+ objectKeyList = Object.keys(object);
3890
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3891
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
3892
+ }
3893
+ }
3894
+ }
3895
+ }
3896
+ }
3897
+ function dump$1(input, options) {
3898
+ options = options || {};
3899
+ var state = new State(options);
3900
+ if (!state.noRefs) getDuplicateReferences(input, state);
3901
+ var value = input;
3902
+ if (state.replacer) {
3903
+ value = state.replacer.call({ "": value }, "", value);
3904
+ }
3905
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
3906
+ return "";
3907
+ }
3908
+ var dump_1 = dump$1;
3909
+ var dumper = {
3910
+ dump: dump_1
3911
+ };
3912
+ function renamed(from, to) {
3913
+ return function() {
3914
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
3915
+ };
3916
+ }
3917
+ var Type = type;
3918
+ var Schema = schema;
3919
+ var FAILSAFE_SCHEMA = failsafe;
3920
+ var JSON_SCHEMA = json;
3921
+ var CORE_SCHEMA = core;
3922
+ var DEFAULT_SCHEMA = _default;
3923
+ var load = loader.load;
3924
+ var loadAll = loader.loadAll;
3925
+ var dump = dumper.dump;
3926
+ var YAMLException = exception;
3927
+ var types = {
3928
+ binary,
3929
+ float,
3930
+ map,
3931
+ null: _null,
3932
+ pairs,
3933
+ set,
3934
+ timestamp,
3935
+ bool,
3936
+ int,
3937
+ merge,
3938
+ omap,
3939
+ seq,
3940
+ str
3941
+ };
3942
+ var safeLoad = renamed("safeLoad", "load");
3943
+ var safeLoadAll = renamed("safeLoadAll", "loadAll");
3944
+ var safeDump = renamed("safeDump", "dump");
3945
+ var jsYaml = {
3946
+ Type,
3947
+ Schema,
3948
+ FAILSAFE_SCHEMA,
3949
+ JSON_SCHEMA,
3950
+ CORE_SCHEMA,
3951
+ DEFAULT_SCHEMA,
3952
+ load,
3953
+ loadAll,
3954
+ dump,
3955
+ YAMLException,
3956
+ types,
3957
+ safeLoad,
3958
+ safeLoadAll,
3959
+ safeDump
3960
+ };
3961
+ var js_yaml_default = jsYaml;
3962
+
3963
+ // packages/k8s-tools/src/generators/helm-dependency/generator.ts
3964
+ async function helmDependencyGenerator(tree, options) {
3965
+ const {
3966
+ getStopwatch,
3967
+ writeDebug,
3968
+ writeError,
3969
+ writeFatal,
3970
+ writeInfo,
3971
+ writeTrace,
3972
+ findWorkspaceRoot,
3973
+ loadStormConfig
3974
+ } = await import("@storm-software/config-tools");
3975
+ const stopwatch = getStopwatch("Storm Worker generator");
3976
+ let config;
3977
+ try {
3978
+ writeInfo(`\u26A1 Running the Storm Worker generator...
3979
+
3980
+ `, config);
3981
+ const workspaceRoot = findWorkspaceRoot();
3982
+ writeDebug(
3983
+ `Loading the Storm Config from environment variables and storm.json file...
3984
+ - workspaceRoot: ${workspaceRoot}`,
3985
+ config
3986
+ );
3987
+ config = await loadStormConfig(workspaceRoot);
3988
+ writeTrace(
3989
+ `Loaded Storm config into env:
3990
+ ${Object.keys(process.env).map((key) => ` - ${key}=${JSON.stringify(process.env[key])}`).join("\n")}`,
3991
+ config
3992
+ );
3993
+ const tasks = [];
3994
+ tasks.push(async () => {
3995
+ const project = (0, import_devkit2.readProjectConfiguration)(tree, options.project);
3996
+ if (!project.targets?.["helm-package"]) {
3997
+ throw new Error(
3998
+ `Project ${options.project} does not have a helm target. Please run the chart generator first.`
3999
+ );
4000
+ }
4001
+ (0, import_devkit2.updateProjectConfiguration)(
4002
+ tree,
4003
+ options.project,
4004
+ addDependencyToConfig(
4005
+ project,
4006
+ options.repositoryName,
4007
+ options.repository
4008
+ )
4009
+ );
4010
+ updateChartYaml(
4011
+ tree,
4012
+ project,
4013
+ options.chartName,
4014
+ options.chartVersion,
4015
+ options.repository
4016
+ );
4017
+ if (options.format) {
4018
+ await (0, import_devkit2.formatFiles)(tree);
4019
+ }
4020
+ });
4021
+ return (0, import_devkit2.runTasksInSerial)(...tasks);
4022
+ } catch (error) {
4023
+ return () => {
4024
+ writeFatal(
4025
+ "A fatal error occurred while running the generator - the process was forced to terminate",
4026
+ config
4027
+ );
4028
+ writeError(
4029
+ `An exception was thrown in the generator's process
4030
+ - Details: ${error.message}
4031
+ - Stacktrace: ${error.stack}`,
4032
+ config
4033
+ );
4034
+ };
4035
+ } finally {
4036
+ stopwatch();
4037
+ }
4038
+ }
4039
+ var helmDependencySchematic = (0, import_devkit2.convertNxGenerator)(
4040
+ helmDependencyGenerator
4041
+ );
4042
+ function addDependencyToConfig(project, name, url) {
4043
+ return {
4044
+ ...project,
4045
+ targets: {
4046
+ ...project.targets,
4047
+ helm: {
4048
+ ...project.targets?.["helm-package"],
4049
+ options: {
4050
+ ...project.targets?.["helm-package"]?.options,
4051
+ dependencies: {
4052
+ ...project.targets?.["helm-package"]?.options.dependencies,
4053
+ repositories: project.targets?.["helm-package"]?.options.dependencies.repositories ? [
4054
+ ...project.targets["helm-package"].options.dependencies.repositories,
4055
+ { name, url }
4056
+ ] : [{ name, url }]
4057
+ }
4058
+ }
4059
+ }
4060
+ }
4061
+ };
4062
+ }
4063
+ function updateChartYaml(tree, project, name, version, repository) {
4064
+ const chartFolder = project.targets?.["helm-package"]?.options.chartFolder;
4065
+ const chartPath = `${chartFolder}/Chart.yaml`;
4066
+ if (!tree.exists(chartPath)) {
4067
+ throw new Error("Chart.yaml not found");
4068
+ }
4069
+ try {
4070
+ const result = tree.read(chartPath, "utf8")?.toString();
4071
+ if (!result) {
4072
+ throw new Error("Failed to read Chart.yaml");
4073
+ }
4074
+ const chartContents = js_yaml_default.load(result);
4075
+ if (!chartContents.dependencies) {
4076
+ chartContents.dependencies = [];
4077
+ }
4078
+ const existingDependency = chartContents.dependencies.find(
4079
+ (dep) => dep.name === name
4080
+ );
4081
+ if (existingDependency) {
4082
+ existingDependency.version = version;
4083
+ existingDependency.repository = repository;
4084
+ } else {
4085
+ chartContents.dependencies.push({
4086
+ name,
4087
+ version,
4088
+ repository
4089
+ });
4090
+ tree.write(chartPath, js_yaml_default.dump(chartContents));
4091
+ }
4092
+ } catch (error) {
4093
+ console.error(error);
4094
+ throw new Error("Failed to parse Chart.yaml");
4095
+ }
4096
+ }
4097
+ // Annotate the CommonJS export names for ESM import in node:
4098
+ 0 && (module.exports = {
4099
+ helmChartGenerator,
4100
+ helmChartSchematic,
4101
+ helmDependencyGenerator,
4102
+ helmDependencySchematic,
4103
+ serveExecutor
4104
+ });
4105
+ /*! Bundled license information:
4106
+
4107
+ js-yaml/dist/js-yaml.mjs:
4108
+ (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
4109
+ */