@poe-platform/safe-bash 0.1.506 → 0.1.508

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 (39) hide show
  1. package/dist/safe-bash/chunks/chunk-3ISDVRIM.js +3821 -0
  2. package/dist/safe-bash/chunks/chunk-3ISDVRIM.js.map +7 -0
  3. package/dist/safe-bash/commands/node/index.d.ts +0 -1
  4. package/dist/safe-bash/commands/node/index.d.ts.map +1 -1
  5. package/dist/safe-bash/commands/node/index.js +0 -1
  6. package/dist/safe-bash/commands/node/index.js.map +1 -1
  7. package/dist/safe-bash/commands/xml/evaluate.d.ts +27 -0
  8. package/dist/safe-bash/commands/xml/evaluate.d.ts.map +1 -0
  9. package/dist/safe-bash/commands/xml/evaluate.js +208 -0
  10. package/dist/safe-bash/commands/xml/evaluate.js.map +1 -0
  11. package/dist/safe-bash/commands/xml/index.browser.js +11 -0
  12. package/dist/safe-bash/commands/xml/index.browser.js.map +7 -0
  13. package/dist/safe-bash/commands/xml/index.d.ts +7 -0
  14. package/dist/safe-bash/commands/xml/index.d.ts.map +1 -0
  15. package/dist/safe-bash/commands/xml/index.js +196 -0
  16. package/dist/safe-bash/commands/xml/index.js.map +1 -0
  17. package/dist/safe-bash/commands/xml/limits.d.ts +36 -0
  18. package/dist/safe-bash/commands/xml/limits.d.ts.map +1 -0
  19. package/dist/safe-bash/commands/xml/limits.js +55 -0
  20. package/dist/safe-bash/commands/xml/limits.js.map +1 -0
  21. package/dist/safe-bash/commands/xml/query.d.ts +21 -0
  22. package/dist/safe-bash/commands/xml/query.d.ts.map +1 -0
  23. package/dist/safe-bash/commands/xml/query.js +111 -0
  24. package/dist/safe-bash/commands/xml/query.js.map +1 -0
  25. package/dist/safe-bash/core.browser.js +990 -3879
  26. package/dist/safe-bash/core.browser.js.map +4 -4
  27. package/dist/safe-bash/core.d.ts +1 -0
  28. package/dist/safe-bash/core.d.ts.map +1 -1
  29. package/dist/safe-bash/core.js +1 -0
  30. package/dist/safe-bash/core.js.map +1 -1
  31. package/dist/safe-bash/node-unavailable.d.ts +2 -0
  32. package/dist/safe-bash/node-unavailable.d.ts.map +1 -0
  33. package/dist/safe-bash/node-unavailable.js +2 -0
  34. package/dist/safe-bash/node-unavailable.js.map +1 -0
  35. package/dist/safe-bash/plugins/composition.d.ts +2 -0
  36. package/dist/safe-bash/plugins/composition.d.ts.map +1 -1
  37. package/dist/safe-bash/plugins/composition.js +3 -1
  38. package/dist/safe-bash/plugins/composition.js.map +1 -1
  39. package/package.json +22 -2
@@ -0,0 +1,3821 @@
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 __esm = (fn, res, err) => function __init() {
8
+ if (err) throw err[0];
9
+ try {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ } catch (e) {
12
+ throw err = [e], e;
13
+ }
14
+ };
15
+ var __commonJS = (cb, mod) => function __require() {
16
+ try {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ } catch (e) {
19
+ throw mod = 0, e;
20
+ }
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") {
24
+ for (let key of __getOwnPropNames(from))
25
+ if (!__hasOwnProp.call(to, key) && key !== except)
26
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
+ mod
37
+ ));
38
+
39
+ // node_modules/base64-js/index.js
40
+ var require_base64_js = __commonJS({
41
+ "node_modules/base64-js/index.js"(exports) {
42
+ "use strict";
43
+ init_platform();
44
+ exports.byteLength = byteLength;
45
+ exports.toByteArray = toByteArray;
46
+ exports.fromByteArray = fromByteArray;
47
+ var lookup = [];
48
+ var revLookup = [];
49
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
50
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
51
+ for (i = 0, len = code.length; i < len; ++i) {
52
+ lookup[i] = code[i];
53
+ revLookup[code.charCodeAt(i)] = i;
54
+ }
55
+ var i;
56
+ var len;
57
+ revLookup["-".charCodeAt(0)] = 62;
58
+ revLookup["_".charCodeAt(0)] = 63;
59
+ function getLens(b64) {
60
+ var len2 = b64.length;
61
+ if (len2 % 4 > 0) {
62
+ throw new Error("Invalid string. Length must be a multiple of 4");
63
+ }
64
+ var validLen = b64.indexOf("=");
65
+ if (validLen === -1) validLen = len2;
66
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
67
+ return [validLen, placeHoldersLen];
68
+ }
69
+ function byteLength(b64) {
70
+ var lens = getLens(b64);
71
+ var validLen = lens[0];
72
+ var placeHoldersLen = lens[1];
73
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
74
+ }
75
+ function _byteLength(b64, validLen, placeHoldersLen) {
76
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
77
+ }
78
+ function toByteArray(b64) {
79
+ var tmp;
80
+ var lens = getLens(b64);
81
+ var validLen = lens[0];
82
+ var placeHoldersLen = lens[1];
83
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
84
+ var curByte = 0;
85
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
86
+ var i2;
87
+ for (i2 = 0; i2 < len2; i2 += 4) {
88
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
89
+ arr[curByte++] = tmp >> 16 & 255;
90
+ arr[curByte++] = tmp >> 8 & 255;
91
+ arr[curByte++] = tmp & 255;
92
+ }
93
+ if (placeHoldersLen === 2) {
94
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
95
+ arr[curByte++] = tmp & 255;
96
+ }
97
+ if (placeHoldersLen === 1) {
98
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
99
+ arr[curByte++] = tmp >> 8 & 255;
100
+ arr[curByte++] = tmp & 255;
101
+ }
102
+ return arr;
103
+ }
104
+ function tripletToBase64(num) {
105
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
106
+ }
107
+ function encodeChunk(uint8, start, end) {
108
+ var tmp;
109
+ var output2 = [];
110
+ for (var i2 = start; i2 < end; i2 += 3) {
111
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
112
+ output2.push(tripletToBase64(tmp));
113
+ }
114
+ return output2.join("");
115
+ }
116
+ function fromByteArray(uint8) {
117
+ var tmp;
118
+ var len2 = uint8.length;
119
+ var extraBytes = len2 % 3;
120
+ var parts2 = [];
121
+ var maxChunkLength = 16383;
122
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
123
+ parts2.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
124
+ }
125
+ if (extraBytes === 1) {
126
+ tmp = uint8[len2 - 1];
127
+ parts2.push(
128
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
129
+ );
130
+ } else if (extraBytes === 2) {
131
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
132
+ parts2.push(
133
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
134
+ );
135
+ }
136
+ return parts2.join("");
137
+ }
138
+ }
139
+ });
140
+
141
+ // node_modules/ieee754/index.js
142
+ var require_ieee754 = __commonJS({
143
+ "node_modules/ieee754/index.js"(exports) {
144
+ init_platform();
145
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
146
+ var e, m;
147
+ var eLen = nBytes * 8 - mLen - 1;
148
+ var eMax = (1 << eLen) - 1;
149
+ var eBias = eMax >> 1;
150
+ var nBits = -7;
151
+ var i = isLE ? nBytes - 1 : 0;
152
+ var d = isLE ? -1 : 1;
153
+ var s = buffer[offset + i];
154
+ i += d;
155
+ e = s & (1 << -nBits) - 1;
156
+ s >>= -nBits;
157
+ nBits += eLen;
158
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
159
+ }
160
+ m = e & (1 << -nBits) - 1;
161
+ e >>= -nBits;
162
+ nBits += mLen;
163
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
164
+ }
165
+ if (e === 0) {
166
+ e = 1 - eBias;
167
+ } else if (e === eMax) {
168
+ return m ? NaN : (s ? -1 : 1) * Infinity;
169
+ } else {
170
+ m = m + Math.pow(2, mLen);
171
+ e = e - eBias;
172
+ }
173
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
174
+ };
175
+ exports.write = function(buffer, value2, offset, isLE, mLen, nBytes) {
176
+ var e, m, c;
177
+ var eLen = nBytes * 8 - mLen - 1;
178
+ var eMax = (1 << eLen) - 1;
179
+ var eBias = eMax >> 1;
180
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
181
+ var i = isLE ? 0 : nBytes - 1;
182
+ var d = isLE ? 1 : -1;
183
+ var s = value2 < 0 || value2 === 0 && 1 / value2 < 0 ? 1 : 0;
184
+ value2 = Math.abs(value2);
185
+ if (isNaN(value2) || value2 === Infinity) {
186
+ m = isNaN(value2) ? 1 : 0;
187
+ e = eMax;
188
+ } else {
189
+ e = Math.floor(Math.log(value2) / Math.LN2);
190
+ if (value2 * (c = Math.pow(2, -e)) < 1) {
191
+ e--;
192
+ c *= 2;
193
+ }
194
+ if (e + eBias >= 1) {
195
+ value2 += rt / c;
196
+ } else {
197
+ value2 += rt * Math.pow(2, 1 - eBias);
198
+ }
199
+ if (value2 * c >= 2) {
200
+ e++;
201
+ c /= 2;
202
+ }
203
+ if (e + eBias >= eMax) {
204
+ m = 0;
205
+ e = eMax;
206
+ } else if (e + eBias >= 1) {
207
+ m = (value2 * c - 1) * Math.pow(2, mLen);
208
+ e = e + eBias;
209
+ } else {
210
+ m = value2 * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
211
+ e = 0;
212
+ }
213
+ }
214
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
215
+ }
216
+ e = e << mLen | m;
217
+ eLen += mLen;
218
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
219
+ }
220
+ buffer[offset + i - d] |= s * 128;
221
+ };
222
+ }
223
+ });
224
+
225
+ // node_modules/buffer/index.js
226
+ var require_buffer = __commonJS({
227
+ "node_modules/buffer/index.js"(exports) {
228
+ "use strict";
229
+ init_platform();
230
+ var base64 = require_base64_js();
231
+ var ieee754 = require_ieee754();
232
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
233
+ exports.Buffer = Buffer3;
234
+ exports.SlowBuffer = SlowBuffer;
235
+ exports.INSPECT_MAX_BYTES = 50;
236
+ var K_MAX_LENGTH = 2147483647;
237
+ exports.kMaxLength = K_MAX_LENGTH;
238
+ Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
239
+ if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
240
+ console.error(
241
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
242
+ );
243
+ }
244
+ function typedArraySupport() {
245
+ try {
246
+ const arr = new Uint8Array(1);
247
+ const proto = { foo: function() {
248
+ return 42;
249
+ } };
250
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
251
+ Object.setPrototypeOf(arr, proto);
252
+ return arr.foo() === 42;
253
+ } catch (e) {
254
+ return false;
255
+ }
256
+ }
257
+ Object.defineProperty(Buffer3.prototype, "parent", {
258
+ enumerable: true,
259
+ get: function() {
260
+ if (!Buffer3.isBuffer(this)) return void 0;
261
+ return this.buffer;
262
+ }
263
+ });
264
+ Object.defineProperty(Buffer3.prototype, "offset", {
265
+ enumerable: true,
266
+ get: function() {
267
+ if (!Buffer3.isBuffer(this)) return void 0;
268
+ return this.byteOffset;
269
+ }
270
+ });
271
+ function createBuffer(length) {
272
+ if (length > K_MAX_LENGTH) {
273
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
274
+ }
275
+ const buf = new Uint8Array(length);
276
+ Object.setPrototypeOf(buf, Buffer3.prototype);
277
+ return buf;
278
+ }
279
+ function Buffer3(arg, encodingOrOffset, length) {
280
+ if (typeof arg === "number") {
281
+ if (typeof encodingOrOffset === "string") {
282
+ throw new TypeError(
283
+ 'The "string" argument must be of type string. Received type number'
284
+ );
285
+ }
286
+ return allocUnsafe(arg);
287
+ }
288
+ return from(arg, encodingOrOffset, length);
289
+ }
290
+ Buffer3.poolSize = 8192;
291
+ function from(value2, encodingOrOffset, length) {
292
+ if (typeof value2 === "string") {
293
+ return fromString(value2, encodingOrOffset);
294
+ }
295
+ if (ArrayBuffer.isView(value2)) {
296
+ return fromArrayView(value2);
297
+ }
298
+ if (value2 == null) {
299
+ throw new TypeError(
300
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value2
301
+ );
302
+ }
303
+ if (isInstance(value2, ArrayBuffer) || value2 && isInstance(value2.buffer, ArrayBuffer)) {
304
+ return fromArrayBuffer(value2, encodingOrOffset, length);
305
+ }
306
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value2, SharedArrayBuffer) || value2 && isInstance(value2.buffer, SharedArrayBuffer))) {
307
+ return fromArrayBuffer(value2, encodingOrOffset, length);
308
+ }
309
+ if (typeof value2 === "number") {
310
+ throw new TypeError(
311
+ 'The "value" argument must not be of type number. Received type number'
312
+ );
313
+ }
314
+ const valueOf = value2.valueOf && value2.valueOf();
315
+ if (valueOf != null && valueOf !== value2) {
316
+ return Buffer3.from(valueOf, encodingOrOffset, length);
317
+ }
318
+ const b = fromObject(value2);
319
+ if (b) return b;
320
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value2[Symbol.toPrimitive] === "function") {
321
+ return Buffer3.from(value2[Symbol.toPrimitive]("string"), encodingOrOffset, length);
322
+ }
323
+ throw new TypeError(
324
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value2
325
+ );
326
+ }
327
+ Buffer3.from = function(value2, encodingOrOffset, length) {
328
+ return from(value2, encodingOrOffset, length);
329
+ };
330
+ Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
331
+ Object.setPrototypeOf(Buffer3, Uint8Array);
332
+ function assertSize(size) {
333
+ if (typeof size !== "number") {
334
+ throw new TypeError('"size" argument must be of type number');
335
+ } else if (size < 0) {
336
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
337
+ }
338
+ }
339
+ function alloc(size, fill, encoding) {
340
+ assertSize(size);
341
+ if (size <= 0) {
342
+ return createBuffer(size);
343
+ }
344
+ if (fill !== void 0) {
345
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
346
+ }
347
+ return createBuffer(size);
348
+ }
349
+ Buffer3.alloc = function(size, fill, encoding) {
350
+ return alloc(size, fill, encoding);
351
+ };
352
+ function allocUnsafe(size) {
353
+ assertSize(size);
354
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
355
+ }
356
+ Buffer3.allocUnsafe = function(size) {
357
+ return allocUnsafe(size);
358
+ };
359
+ Buffer3.allocUnsafeSlow = function(size) {
360
+ return allocUnsafe(size);
361
+ };
362
+ function fromString(string, encoding) {
363
+ if (typeof encoding !== "string" || encoding === "") {
364
+ encoding = "utf8";
365
+ }
366
+ if (!Buffer3.isEncoding(encoding)) {
367
+ throw new TypeError("Unknown encoding: " + encoding);
368
+ }
369
+ const length = byteLength(string, encoding) | 0;
370
+ let buf = createBuffer(length);
371
+ const actual = buf.write(string, encoding);
372
+ if (actual !== length) {
373
+ buf = buf.slice(0, actual);
374
+ }
375
+ return buf;
376
+ }
377
+ function fromArrayLike(array) {
378
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
379
+ const buf = createBuffer(length);
380
+ for (let i = 0; i < length; i += 1) {
381
+ buf[i] = array[i] & 255;
382
+ }
383
+ return buf;
384
+ }
385
+ function fromArrayView(arrayView) {
386
+ if (isInstance(arrayView, Uint8Array)) {
387
+ const copy = new Uint8Array(arrayView);
388
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
389
+ }
390
+ return fromArrayLike(arrayView);
391
+ }
392
+ function fromArrayBuffer(array, byteOffset, length) {
393
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
394
+ throw new RangeError('"offset" is outside of buffer bounds');
395
+ }
396
+ if (array.byteLength < byteOffset + (length || 0)) {
397
+ throw new RangeError('"length" is outside of buffer bounds');
398
+ }
399
+ let buf;
400
+ if (byteOffset === void 0 && length === void 0) {
401
+ buf = new Uint8Array(array);
402
+ } else if (length === void 0) {
403
+ buf = new Uint8Array(array, byteOffset);
404
+ } else {
405
+ buf = new Uint8Array(array, byteOffset, length);
406
+ }
407
+ Object.setPrototypeOf(buf, Buffer3.prototype);
408
+ return buf;
409
+ }
410
+ function fromObject(obj) {
411
+ if (Buffer3.isBuffer(obj)) {
412
+ const len = checked(obj.length) | 0;
413
+ const buf = createBuffer(len);
414
+ if (buf.length === 0) {
415
+ return buf;
416
+ }
417
+ obj.copy(buf, 0, 0, len);
418
+ return buf;
419
+ }
420
+ if (obj.length !== void 0) {
421
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
422
+ return createBuffer(0);
423
+ }
424
+ return fromArrayLike(obj);
425
+ }
426
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
427
+ return fromArrayLike(obj.data);
428
+ }
429
+ }
430
+ function checked(length) {
431
+ if (length >= K_MAX_LENGTH) {
432
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
433
+ }
434
+ return length | 0;
435
+ }
436
+ function SlowBuffer(length) {
437
+ if (+length != length) {
438
+ length = 0;
439
+ }
440
+ return Buffer3.alloc(+length);
441
+ }
442
+ Buffer3.isBuffer = function isBuffer(b) {
443
+ return b != null && b._isBuffer === true && b !== Buffer3.prototype;
444
+ };
445
+ Buffer3.compare = function compare(a, b) {
446
+ if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
447
+ if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
448
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
449
+ throw new TypeError(
450
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
451
+ );
452
+ }
453
+ if (a === b) return 0;
454
+ let x = a.length;
455
+ let y = b.length;
456
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
457
+ if (a[i] !== b[i]) {
458
+ x = a[i];
459
+ y = b[i];
460
+ break;
461
+ }
462
+ }
463
+ if (x < y) return -1;
464
+ if (y < x) return 1;
465
+ return 0;
466
+ };
467
+ Buffer3.isEncoding = function isEncoding(encoding) {
468
+ switch (String(encoding).toLowerCase()) {
469
+ case "hex":
470
+ case "utf8":
471
+ case "utf-8":
472
+ case "ascii":
473
+ case "latin1":
474
+ case "binary":
475
+ case "base64":
476
+ case "ucs2":
477
+ case "ucs-2":
478
+ case "utf16le":
479
+ case "utf-16le":
480
+ return true;
481
+ default:
482
+ return false;
483
+ }
484
+ };
485
+ Buffer3.concat = function concat(list, length) {
486
+ if (!Array.isArray(list)) {
487
+ throw new TypeError('"list" argument must be an Array of Buffers');
488
+ }
489
+ if (list.length === 0) {
490
+ return Buffer3.alloc(0);
491
+ }
492
+ let i;
493
+ if (length === void 0) {
494
+ length = 0;
495
+ for (i = 0; i < list.length; ++i) {
496
+ length += list[i].length;
497
+ }
498
+ }
499
+ const buffer = Buffer3.allocUnsafe(length);
500
+ let pos = 0;
501
+ for (i = 0; i < list.length; ++i) {
502
+ let buf = list[i];
503
+ if (isInstance(buf, Uint8Array)) {
504
+ if (pos + buf.length > buffer.length) {
505
+ if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
506
+ buf.copy(buffer, pos);
507
+ } else {
508
+ Uint8Array.prototype.set.call(
509
+ buffer,
510
+ buf,
511
+ pos
512
+ );
513
+ }
514
+ } else if (!Buffer3.isBuffer(buf)) {
515
+ throw new TypeError('"list" argument must be an Array of Buffers');
516
+ } else {
517
+ buf.copy(buffer, pos);
518
+ }
519
+ pos += buf.length;
520
+ }
521
+ return buffer;
522
+ };
523
+ function byteLength(string, encoding) {
524
+ if (Buffer3.isBuffer(string)) {
525
+ return string.length;
526
+ }
527
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
528
+ return string.byteLength;
529
+ }
530
+ if (typeof string !== "string") {
531
+ throw new TypeError(
532
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
533
+ );
534
+ }
535
+ const len = string.length;
536
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
537
+ if (!mustMatch && len === 0) return 0;
538
+ let loweredCase = false;
539
+ for (; ; ) {
540
+ switch (encoding) {
541
+ case "ascii":
542
+ case "latin1":
543
+ case "binary":
544
+ return len;
545
+ case "utf8":
546
+ case "utf-8":
547
+ return utf8ToBytes(string).length;
548
+ case "ucs2":
549
+ case "ucs-2":
550
+ case "utf16le":
551
+ case "utf-16le":
552
+ return len * 2;
553
+ case "hex":
554
+ return len >>> 1;
555
+ case "base64":
556
+ return base64ToBytes(string).length;
557
+ default:
558
+ if (loweredCase) {
559
+ return mustMatch ? -1 : utf8ToBytes(string).length;
560
+ }
561
+ encoding = ("" + encoding).toLowerCase();
562
+ loweredCase = true;
563
+ }
564
+ }
565
+ }
566
+ Buffer3.byteLength = byteLength;
567
+ function slowToString(encoding, start, end) {
568
+ let loweredCase = false;
569
+ if (start === void 0 || start < 0) {
570
+ start = 0;
571
+ }
572
+ if (start > this.length) {
573
+ return "";
574
+ }
575
+ if (end === void 0 || end > this.length) {
576
+ end = this.length;
577
+ }
578
+ if (end <= 0) {
579
+ return "";
580
+ }
581
+ end >>>= 0;
582
+ start >>>= 0;
583
+ if (end <= start) {
584
+ return "";
585
+ }
586
+ if (!encoding) encoding = "utf8";
587
+ while (true) {
588
+ switch (encoding) {
589
+ case "hex":
590
+ return hexSlice(this, start, end);
591
+ case "utf8":
592
+ case "utf-8":
593
+ return utf8Slice(this, start, end);
594
+ case "ascii":
595
+ return asciiSlice(this, start, end);
596
+ case "latin1":
597
+ case "binary":
598
+ return latin1Slice(this, start, end);
599
+ case "base64":
600
+ return base64Slice(this, start, end);
601
+ case "ucs2":
602
+ case "ucs-2":
603
+ case "utf16le":
604
+ case "utf-16le":
605
+ return utf16leSlice(this, start, end);
606
+ default:
607
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
608
+ encoding = (encoding + "").toLowerCase();
609
+ loweredCase = true;
610
+ }
611
+ }
612
+ }
613
+ Buffer3.prototype._isBuffer = true;
614
+ function swap(b, n, m) {
615
+ const i = b[n];
616
+ b[n] = b[m];
617
+ b[m] = i;
618
+ }
619
+ Buffer3.prototype.swap16 = function swap16() {
620
+ const len = this.length;
621
+ if (len % 2 !== 0) {
622
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
623
+ }
624
+ for (let i = 0; i < len; i += 2) {
625
+ swap(this, i, i + 1);
626
+ }
627
+ return this;
628
+ };
629
+ Buffer3.prototype.swap32 = function swap32() {
630
+ const len = this.length;
631
+ if (len % 4 !== 0) {
632
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
633
+ }
634
+ for (let i = 0; i < len; i += 4) {
635
+ swap(this, i, i + 3);
636
+ swap(this, i + 1, i + 2);
637
+ }
638
+ return this;
639
+ };
640
+ Buffer3.prototype.swap64 = function swap64() {
641
+ const len = this.length;
642
+ if (len % 8 !== 0) {
643
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
644
+ }
645
+ for (let i = 0; i < len; i += 8) {
646
+ swap(this, i, i + 7);
647
+ swap(this, i + 1, i + 6);
648
+ swap(this, i + 2, i + 5);
649
+ swap(this, i + 3, i + 4);
650
+ }
651
+ return this;
652
+ };
653
+ Buffer3.prototype.toString = function toString() {
654
+ const length = this.length;
655
+ if (length === 0) return "";
656
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
657
+ return slowToString.apply(this, arguments);
658
+ };
659
+ Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
660
+ Buffer3.prototype.equals = function equals(b) {
661
+ if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
662
+ if (this === b) return true;
663
+ return Buffer3.compare(this, b) === 0;
664
+ };
665
+ Buffer3.prototype.inspect = function inspect() {
666
+ let str = "";
667
+ const max = exports.INSPECT_MAX_BYTES;
668
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
669
+ if (this.length > max) str += " ... ";
670
+ return "<Buffer " + str + ">";
671
+ };
672
+ if (customInspectSymbol) {
673
+ Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
674
+ }
675
+ Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
676
+ if (isInstance(target, Uint8Array)) {
677
+ target = Buffer3.from(target, target.offset, target.byteLength);
678
+ }
679
+ if (!Buffer3.isBuffer(target)) {
680
+ throw new TypeError(
681
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
682
+ );
683
+ }
684
+ if (start === void 0) {
685
+ start = 0;
686
+ }
687
+ if (end === void 0) {
688
+ end = target ? target.length : 0;
689
+ }
690
+ if (thisStart === void 0) {
691
+ thisStart = 0;
692
+ }
693
+ if (thisEnd === void 0) {
694
+ thisEnd = this.length;
695
+ }
696
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
697
+ throw new RangeError("out of range index");
698
+ }
699
+ if (thisStart >= thisEnd && start >= end) {
700
+ return 0;
701
+ }
702
+ if (thisStart >= thisEnd) {
703
+ return -1;
704
+ }
705
+ if (start >= end) {
706
+ return 1;
707
+ }
708
+ start >>>= 0;
709
+ end >>>= 0;
710
+ thisStart >>>= 0;
711
+ thisEnd >>>= 0;
712
+ if (this === target) return 0;
713
+ let x = thisEnd - thisStart;
714
+ let y = end - start;
715
+ const len = Math.min(x, y);
716
+ const thisCopy = this.slice(thisStart, thisEnd);
717
+ const targetCopy = target.slice(start, end);
718
+ for (let i = 0; i < len; ++i) {
719
+ if (thisCopy[i] !== targetCopy[i]) {
720
+ x = thisCopy[i];
721
+ y = targetCopy[i];
722
+ break;
723
+ }
724
+ }
725
+ if (x < y) return -1;
726
+ if (y < x) return 1;
727
+ return 0;
728
+ };
729
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
730
+ if (buffer.length === 0) return -1;
731
+ if (typeof byteOffset === "string") {
732
+ encoding = byteOffset;
733
+ byteOffset = 0;
734
+ } else if (byteOffset > 2147483647) {
735
+ byteOffset = 2147483647;
736
+ } else if (byteOffset < -2147483648) {
737
+ byteOffset = -2147483648;
738
+ }
739
+ byteOffset = +byteOffset;
740
+ if (numberIsNaN(byteOffset)) {
741
+ byteOffset = dir ? 0 : buffer.length - 1;
742
+ }
743
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
744
+ if (byteOffset >= buffer.length) {
745
+ if (dir) return -1;
746
+ else byteOffset = buffer.length - 1;
747
+ } else if (byteOffset < 0) {
748
+ if (dir) byteOffset = 0;
749
+ else return -1;
750
+ }
751
+ if (typeof val === "string") {
752
+ val = Buffer3.from(val, encoding);
753
+ }
754
+ if (Buffer3.isBuffer(val)) {
755
+ if (val.length === 0) {
756
+ return -1;
757
+ }
758
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
759
+ } else if (typeof val === "number") {
760
+ val = val & 255;
761
+ if (typeof Uint8Array.prototype.indexOf === "function") {
762
+ if (dir) {
763
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
764
+ } else {
765
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
766
+ }
767
+ }
768
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
769
+ }
770
+ throw new TypeError("val must be string, number or Buffer");
771
+ }
772
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
773
+ let indexSize = 1;
774
+ let arrLength = arr.length;
775
+ let valLength = val.length;
776
+ if (encoding !== void 0) {
777
+ encoding = String(encoding).toLowerCase();
778
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
779
+ if (arr.length < 2 || val.length < 2) {
780
+ return -1;
781
+ }
782
+ indexSize = 2;
783
+ arrLength /= 2;
784
+ valLength /= 2;
785
+ byteOffset /= 2;
786
+ }
787
+ }
788
+ function read(buf, i2) {
789
+ if (indexSize === 1) {
790
+ return buf[i2];
791
+ } else {
792
+ return buf.readUInt16BE(i2 * indexSize);
793
+ }
794
+ }
795
+ let i;
796
+ if (dir) {
797
+ let foundIndex = -1;
798
+ for (i = byteOffset; i < arrLength; i++) {
799
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
800
+ if (foundIndex === -1) foundIndex = i;
801
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
802
+ } else {
803
+ if (foundIndex !== -1) i -= i - foundIndex;
804
+ foundIndex = -1;
805
+ }
806
+ }
807
+ } else {
808
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
809
+ for (i = byteOffset; i >= 0; i--) {
810
+ let found = true;
811
+ for (let j = 0; j < valLength; j++) {
812
+ if (read(arr, i + j) !== read(val, j)) {
813
+ found = false;
814
+ break;
815
+ }
816
+ }
817
+ if (found) return i;
818
+ }
819
+ }
820
+ return -1;
821
+ }
822
+ Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
823
+ return this.indexOf(val, byteOffset, encoding) !== -1;
824
+ };
825
+ Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
826
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
827
+ };
828
+ Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
829
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
830
+ };
831
+ function hexWrite(buf, string, offset, length) {
832
+ offset = Number(offset) || 0;
833
+ const remaining = buf.length - offset;
834
+ if (!length) {
835
+ length = remaining;
836
+ } else {
837
+ length = Number(length);
838
+ if (length > remaining) {
839
+ length = remaining;
840
+ }
841
+ }
842
+ const strLen = string.length;
843
+ if (length > strLen / 2) {
844
+ length = strLen / 2;
845
+ }
846
+ let i;
847
+ for (i = 0; i < length; ++i) {
848
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
849
+ if (numberIsNaN(parsed)) return i;
850
+ buf[offset + i] = parsed;
851
+ }
852
+ return i;
853
+ }
854
+ function utf8Write(buf, string, offset, length) {
855
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
856
+ }
857
+ function asciiWrite(buf, string, offset, length) {
858
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
859
+ }
860
+ function base64Write(buf, string, offset, length) {
861
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
862
+ }
863
+ function ucs2Write(buf, string, offset, length) {
864
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
865
+ }
866
+ Buffer3.prototype.write = function write(string, offset, length, encoding) {
867
+ if (offset === void 0) {
868
+ encoding = "utf8";
869
+ length = this.length;
870
+ offset = 0;
871
+ } else if (length === void 0 && typeof offset === "string") {
872
+ encoding = offset;
873
+ length = this.length;
874
+ offset = 0;
875
+ } else if (isFinite(offset)) {
876
+ offset = offset >>> 0;
877
+ if (isFinite(length)) {
878
+ length = length >>> 0;
879
+ if (encoding === void 0) encoding = "utf8";
880
+ } else {
881
+ encoding = length;
882
+ length = void 0;
883
+ }
884
+ } else {
885
+ throw new Error(
886
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
887
+ );
888
+ }
889
+ const remaining = this.length - offset;
890
+ if (length === void 0 || length > remaining) length = remaining;
891
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
892
+ throw new RangeError("Attempt to write outside buffer bounds");
893
+ }
894
+ if (!encoding) encoding = "utf8";
895
+ let loweredCase = false;
896
+ for (; ; ) {
897
+ switch (encoding) {
898
+ case "hex":
899
+ return hexWrite(this, string, offset, length);
900
+ case "utf8":
901
+ case "utf-8":
902
+ return utf8Write(this, string, offset, length);
903
+ case "ascii":
904
+ case "latin1":
905
+ case "binary":
906
+ return asciiWrite(this, string, offset, length);
907
+ case "base64":
908
+ return base64Write(this, string, offset, length);
909
+ case "ucs2":
910
+ case "ucs-2":
911
+ case "utf16le":
912
+ case "utf-16le":
913
+ return ucs2Write(this, string, offset, length);
914
+ default:
915
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
916
+ encoding = ("" + encoding).toLowerCase();
917
+ loweredCase = true;
918
+ }
919
+ }
920
+ };
921
+ Buffer3.prototype.toJSON = function toJSON() {
922
+ return {
923
+ type: "Buffer",
924
+ data: Array.prototype.slice.call(this._arr || this, 0)
925
+ };
926
+ };
927
+ function base64Slice(buf, start, end) {
928
+ if (start === 0 && end === buf.length) {
929
+ return base64.fromByteArray(buf);
930
+ } else {
931
+ return base64.fromByteArray(buf.slice(start, end));
932
+ }
933
+ }
934
+ function utf8Slice(buf, start, end) {
935
+ end = Math.min(buf.length, end);
936
+ const res = [];
937
+ let i = start;
938
+ while (i < end) {
939
+ const firstByte = buf[i];
940
+ let codePoint = null;
941
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
942
+ if (i + bytesPerSequence <= end) {
943
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
944
+ switch (bytesPerSequence) {
945
+ case 1:
946
+ if (firstByte < 128) {
947
+ codePoint = firstByte;
948
+ }
949
+ break;
950
+ case 2:
951
+ secondByte = buf[i + 1];
952
+ if ((secondByte & 192) === 128) {
953
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
954
+ if (tempCodePoint > 127) {
955
+ codePoint = tempCodePoint;
956
+ }
957
+ }
958
+ break;
959
+ case 3:
960
+ secondByte = buf[i + 1];
961
+ thirdByte = buf[i + 2];
962
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
963
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
964
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
965
+ codePoint = tempCodePoint;
966
+ }
967
+ }
968
+ break;
969
+ case 4:
970
+ secondByte = buf[i + 1];
971
+ thirdByte = buf[i + 2];
972
+ fourthByte = buf[i + 3];
973
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
974
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
975
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
976
+ codePoint = tempCodePoint;
977
+ }
978
+ }
979
+ }
980
+ }
981
+ if (codePoint === null) {
982
+ codePoint = 65533;
983
+ bytesPerSequence = 1;
984
+ } else if (codePoint > 65535) {
985
+ codePoint -= 65536;
986
+ res.push(codePoint >>> 10 & 1023 | 55296);
987
+ codePoint = 56320 | codePoint & 1023;
988
+ }
989
+ res.push(codePoint);
990
+ i += bytesPerSequence;
991
+ }
992
+ return decodeCodePointsArray(res);
993
+ }
994
+ var MAX_ARGUMENTS_LENGTH = 4096;
995
+ function decodeCodePointsArray(codePoints) {
996
+ const len = codePoints.length;
997
+ if (len <= MAX_ARGUMENTS_LENGTH) {
998
+ return String.fromCharCode.apply(String, codePoints);
999
+ }
1000
+ let res = "";
1001
+ let i = 0;
1002
+ while (i < len) {
1003
+ res += String.fromCharCode.apply(
1004
+ String,
1005
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1006
+ );
1007
+ }
1008
+ return res;
1009
+ }
1010
+ function asciiSlice(buf, start, end) {
1011
+ let ret = "";
1012
+ end = Math.min(buf.length, end);
1013
+ for (let i = start; i < end; ++i) {
1014
+ ret += String.fromCharCode(buf[i] & 127);
1015
+ }
1016
+ return ret;
1017
+ }
1018
+ function latin1Slice(buf, start, end) {
1019
+ let ret = "";
1020
+ end = Math.min(buf.length, end);
1021
+ for (let i = start; i < end; ++i) {
1022
+ ret += String.fromCharCode(buf[i]);
1023
+ }
1024
+ return ret;
1025
+ }
1026
+ function hexSlice(buf, start, end) {
1027
+ const len = buf.length;
1028
+ if (!start || start < 0) start = 0;
1029
+ if (!end || end < 0 || end > len) end = len;
1030
+ let out = "";
1031
+ for (let i = start; i < end; ++i) {
1032
+ out += hexSliceLookupTable[buf[i]];
1033
+ }
1034
+ return out;
1035
+ }
1036
+ function utf16leSlice(buf, start, end) {
1037
+ const bytes = buf.slice(start, end);
1038
+ let res = "";
1039
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1040
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1041
+ }
1042
+ return res;
1043
+ }
1044
+ Buffer3.prototype.slice = function slice(start, end) {
1045
+ const len = this.length;
1046
+ start = ~~start;
1047
+ end = end === void 0 ? len : ~~end;
1048
+ if (start < 0) {
1049
+ start += len;
1050
+ if (start < 0) start = 0;
1051
+ } else if (start > len) {
1052
+ start = len;
1053
+ }
1054
+ if (end < 0) {
1055
+ end += len;
1056
+ if (end < 0) end = 0;
1057
+ } else if (end > len) {
1058
+ end = len;
1059
+ }
1060
+ if (end < start) end = start;
1061
+ const newBuf = this.subarray(start, end);
1062
+ Object.setPrototypeOf(newBuf, Buffer3.prototype);
1063
+ return newBuf;
1064
+ };
1065
+ function checkOffset(offset, ext, length) {
1066
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1067
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1068
+ }
1069
+ Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1070
+ offset = offset >>> 0;
1071
+ byteLength2 = byteLength2 >>> 0;
1072
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1073
+ let val = this[offset];
1074
+ let mul = 1;
1075
+ let i = 0;
1076
+ while (++i < byteLength2 && (mul *= 256)) {
1077
+ val += this[offset + i] * mul;
1078
+ }
1079
+ return val;
1080
+ };
1081
+ Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1082
+ offset = offset >>> 0;
1083
+ byteLength2 = byteLength2 >>> 0;
1084
+ if (!noAssert) {
1085
+ checkOffset(offset, byteLength2, this.length);
1086
+ }
1087
+ let val = this[offset + --byteLength2];
1088
+ let mul = 1;
1089
+ while (byteLength2 > 0 && (mul *= 256)) {
1090
+ val += this[offset + --byteLength2] * mul;
1091
+ }
1092
+ return val;
1093
+ };
1094
+ Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1095
+ offset = offset >>> 0;
1096
+ if (!noAssert) checkOffset(offset, 1, this.length);
1097
+ return this[offset];
1098
+ };
1099
+ Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1100
+ offset = offset >>> 0;
1101
+ if (!noAssert) checkOffset(offset, 2, this.length);
1102
+ return this[offset] | this[offset + 1] << 8;
1103
+ };
1104
+ Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1105
+ offset = offset >>> 0;
1106
+ if (!noAssert) checkOffset(offset, 2, this.length);
1107
+ return this[offset] << 8 | this[offset + 1];
1108
+ };
1109
+ Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1110
+ offset = offset >>> 0;
1111
+ if (!noAssert) checkOffset(offset, 4, this.length);
1112
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1113
+ };
1114
+ Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1115
+ offset = offset >>> 0;
1116
+ if (!noAssert) checkOffset(offset, 4, this.length);
1117
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1118
+ };
1119
+ Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1120
+ offset = offset >>> 0;
1121
+ validateNumber(offset, "offset");
1122
+ const first = this[offset];
1123
+ const last = this[offset + 7];
1124
+ if (first === void 0 || last === void 0) {
1125
+ boundsError(offset, this.length - 8);
1126
+ }
1127
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1128
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1129
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1130
+ });
1131
+ Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1132
+ offset = offset >>> 0;
1133
+ validateNumber(offset, "offset");
1134
+ const first = this[offset];
1135
+ const last = this[offset + 7];
1136
+ if (first === void 0 || last === void 0) {
1137
+ boundsError(offset, this.length - 8);
1138
+ }
1139
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1140
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1141
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1142
+ });
1143
+ Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1144
+ offset = offset >>> 0;
1145
+ byteLength2 = byteLength2 >>> 0;
1146
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1147
+ let val = this[offset];
1148
+ let mul = 1;
1149
+ let i = 0;
1150
+ while (++i < byteLength2 && (mul *= 256)) {
1151
+ val += this[offset + i] * mul;
1152
+ }
1153
+ mul *= 128;
1154
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1155
+ return val;
1156
+ };
1157
+ Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1158
+ offset = offset >>> 0;
1159
+ byteLength2 = byteLength2 >>> 0;
1160
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1161
+ let i = byteLength2;
1162
+ let mul = 1;
1163
+ let val = this[offset + --i];
1164
+ while (i > 0 && (mul *= 256)) {
1165
+ val += this[offset + --i] * mul;
1166
+ }
1167
+ mul *= 128;
1168
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1169
+ return val;
1170
+ };
1171
+ Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
1172
+ offset = offset >>> 0;
1173
+ if (!noAssert) checkOffset(offset, 1, this.length);
1174
+ if (!(this[offset] & 128)) return this[offset];
1175
+ return (255 - this[offset] + 1) * -1;
1176
+ };
1177
+ Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1178
+ offset = offset >>> 0;
1179
+ if (!noAssert) checkOffset(offset, 2, this.length);
1180
+ const val = this[offset] | this[offset + 1] << 8;
1181
+ return val & 32768 ? val | 4294901760 : val;
1182
+ };
1183
+ Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1184
+ offset = offset >>> 0;
1185
+ if (!noAssert) checkOffset(offset, 2, this.length);
1186
+ const val = this[offset + 1] | this[offset] << 8;
1187
+ return val & 32768 ? val | 4294901760 : val;
1188
+ };
1189
+ Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1190
+ offset = offset >>> 0;
1191
+ if (!noAssert) checkOffset(offset, 4, this.length);
1192
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1193
+ };
1194
+ Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1195
+ offset = offset >>> 0;
1196
+ if (!noAssert) checkOffset(offset, 4, this.length);
1197
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1198
+ };
1199
+ Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1200
+ offset = offset >>> 0;
1201
+ validateNumber(offset, "offset");
1202
+ const first = this[offset];
1203
+ const last = this[offset + 7];
1204
+ if (first === void 0 || last === void 0) {
1205
+ boundsError(offset, this.length - 8);
1206
+ }
1207
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1208
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1209
+ });
1210
+ Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1211
+ offset = offset >>> 0;
1212
+ validateNumber(offset, "offset");
1213
+ const first = this[offset];
1214
+ const last = this[offset + 7];
1215
+ if (first === void 0 || last === void 0) {
1216
+ boundsError(offset, this.length - 8);
1217
+ }
1218
+ const val = (first << 24) + // Overflow
1219
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1220
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1221
+ });
1222
+ Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1223
+ offset = offset >>> 0;
1224
+ if (!noAssert) checkOffset(offset, 4, this.length);
1225
+ return ieee754.read(this, offset, true, 23, 4);
1226
+ };
1227
+ Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1228
+ offset = offset >>> 0;
1229
+ if (!noAssert) checkOffset(offset, 4, this.length);
1230
+ return ieee754.read(this, offset, false, 23, 4);
1231
+ };
1232
+ Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1233
+ offset = offset >>> 0;
1234
+ if (!noAssert) checkOffset(offset, 8, this.length);
1235
+ return ieee754.read(this, offset, true, 52, 8);
1236
+ };
1237
+ Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1238
+ offset = offset >>> 0;
1239
+ if (!noAssert) checkOffset(offset, 8, this.length);
1240
+ return ieee754.read(this, offset, false, 52, 8);
1241
+ };
1242
+ function checkInt(buf, value2, offset, ext, max, min) {
1243
+ if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1244
+ if (value2 > max || value2 < min) throw new RangeError('"value" argument is out of bounds');
1245
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1246
+ }
1247
+ Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value2, offset, byteLength2, noAssert) {
1248
+ value2 = +value2;
1249
+ offset = offset >>> 0;
1250
+ byteLength2 = byteLength2 >>> 0;
1251
+ if (!noAssert) {
1252
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1253
+ checkInt(this, value2, offset, byteLength2, maxBytes, 0);
1254
+ }
1255
+ let mul = 1;
1256
+ let i = 0;
1257
+ this[offset] = value2 & 255;
1258
+ while (++i < byteLength2 && (mul *= 256)) {
1259
+ this[offset + i] = value2 / mul & 255;
1260
+ }
1261
+ return offset + byteLength2;
1262
+ };
1263
+ Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value2, offset, byteLength2, noAssert) {
1264
+ value2 = +value2;
1265
+ offset = offset >>> 0;
1266
+ byteLength2 = byteLength2 >>> 0;
1267
+ if (!noAssert) {
1268
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1269
+ checkInt(this, value2, offset, byteLength2, maxBytes, 0);
1270
+ }
1271
+ let i = byteLength2 - 1;
1272
+ let mul = 1;
1273
+ this[offset + i] = value2 & 255;
1274
+ while (--i >= 0 && (mul *= 256)) {
1275
+ this[offset + i] = value2 / mul & 255;
1276
+ }
1277
+ return offset + byteLength2;
1278
+ };
1279
+ Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value2, offset, noAssert) {
1280
+ value2 = +value2;
1281
+ offset = offset >>> 0;
1282
+ if (!noAssert) checkInt(this, value2, offset, 1, 255, 0);
1283
+ this[offset] = value2 & 255;
1284
+ return offset + 1;
1285
+ };
1286
+ Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value2, offset, noAssert) {
1287
+ value2 = +value2;
1288
+ offset = offset >>> 0;
1289
+ if (!noAssert) checkInt(this, value2, offset, 2, 65535, 0);
1290
+ this[offset] = value2 & 255;
1291
+ this[offset + 1] = value2 >>> 8;
1292
+ return offset + 2;
1293
+ };
1294
+ Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value2, offset, noAssert) {
1295
+ value2 = +value2;
1296
+ offset = offset >>> 0;
1297
+ if (!noAssert) checkInt(this, value2, offset, 2, 65535, 0);
1298
+ this[offset] = value2 >>> 8;
1299
+ this[offset + 1] = value2 & 255;
1300
+ return offset + 2;
1301
+ };
1302
+ Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value2, offset, noAssert) {
1303
+ value2 = +value2;
1304
+ offset = offset >>> 0;
1305
+ if (!noAssert) checkInt(this, value2, offset, 4, 4294967295, 0);
1306
+ this[offset + 3] = value2 >>> 24;
1307
+ this[offset + 2] = value2 >>> 16;
1308
+ this[offset + 1] = value2 >>> 8;
1309
+ this[offset] = value2 & 255;
1310
+ return offset + 4;
1311
+ };
1312
+ Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value2, offset, noAssert) {
1313
+ value2 = +value2;
1314
+ offset = offset >>> 0;
1315
+ if (!noAssert) checkInt(this, value2, offset, 4, 4294967295, 0);
1316
+ this[offset] = value2 >>> 24;
1317
+ this[offset + 1] = value2 >>> 16;
1318
+ this[offset + 2] = value2 >>> 8;
1319
+ this[offset + 3] = value2 & 255;
1320
+ return offset + 4;
1321
+ };
1322
+ function wrtBigUInt64LE(buf, value2, offset, min, max) {
1323
+ checkIntBI(value2, min, max, buf, offset, 7);
1324
+ let lo = Number(value2 & BigInt(4294967295));
1325
+ buf[offset++] = lo;
1326
+ lo = lo >> 8;
1327
+ buf[offset++] = lo;
1328
+ lo = lo >> 8;
1329
+ buf[offset++] = lo;
1330
+ lo = lo >> 8;
1331
+ buf[offset++] = lo;
1332
+ let hi = Number(value2 >> BigInt(32) & BigInt(4294967295));
1333
+ buf[offset++] = hi;
1334
+ hi = hi >> 8;
1335
+ buf[offset++] = hi;
1336
+ hi = hi >> 8;
1337
+ buf[offset++] = hi;
1338
+ hi = hi >> 8;
1339
+ buf[offset++] = hi;
1340
+ return offset;
1341
+ }
1342
+ function wrtBigUInt64BE(buf, value2, offset, min, max) {
1343
+ checkIntBI(value2, min, max, buf, offset, 7);
1344
+ let lo = Number(value2 & BigInt(4294967295));
1345
+ buf[offset + 7] = lo;
1346
+ lo = lo >> 8;
1347
+ buf[offset + 6] = lo;
1348
+ lo = lo >> 8;
1349
+ buf[offset + 5] = lo;
1350
+ lo = lo >> 8;
1351
+ buf[offset + 4] = lo;
1352
+ let hi = Number(value2 >> BigInt(32) & BigInt(4294967295));
1353
+ buf[offset + 3] = hi;
1354
+ hi = hi >> 8;
1355
+ buf[offset + 2] = hi;
1356
+ hi = hi >> 8;
1357
+ buf[offset + 1] = hi;
1358
+ hi = hi >> 8;
1359
+ buf[offset] = hi;
1360
+ return offset + 8;
1361
+ }
1362
+ Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value2, offset = 0) {
1363
+ return wrtBigUInt64LE(this, value2, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1364
+ });
1365
+ Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value2, offset = 0) {
1366
+ return wrtBigUInt64BE(this, value2, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1367
+ });
1368
+ Buffer3.prototype.writeIntLE = function writeIntLE(value2, offset, byteLength2, noAssert) {
1369
+ value2 = +value2;
1370
+ offset = offset >>> 0;
1371
+ if (!noAssert) {
1372
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1373
+ checkInt(this, value2, offset, byteLength2, limit - 1, -limit);
1374
+ }
1375
+ let i = 0;
1376
+ let mul = 1;
1377
+ let sub = 0;
1378
+ this[offset] = value2 & 255;
1379
+ while (++i < byteLength2 && (mul *= 256)) {
1380
+ if (value2 < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1381
+ sub = 1;
1382
+ }
1383
+ this[offset + i] = (value2 / mul >> 0) - sub & 255;
1384
+ }
1385
+ return offset + byteLength2;
1386
+ };
1387
+ Buffer3.prototype.writeIntBE = function writeIntBE(value2, offset, byteLength2, noAssert) {
1388
+ value2 = +value2;
1389
+ offset = offset >>> 0;
1390
+ if (!noAssert) {
1391
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1392
+ checkInt(this, value2, offset, byteLength2, limit - 1, -limit);
1393
+ }
1394
+ let i = byteLength2 - 1;
1395
+ let mul = 1;
1396
+ let sub = 0;
1397
+ this[offset + i] = value2 & 255;
1398
+ while (--i >= 0 && (mul *= 256)) {
1399
+ if (value2 < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1400
+ sub = 1;
1401
+ }
1402
+ this[offset + i] = (value2 / mul >> 0) - sub & 255;
1403
+ }
1404
+ return offset + byteLength2;
1405
+ };
1406
+ Buffer3.prototype.writeInt8 = function writeInt8(value2, offset, noAssert) {
1407
+ value2 = +value2;
1408
+ offset = offset >>> 0;
1409
+ if (!noAssert) checkInt(this, value2, offset, 1, 127, -128);
1410
+ if (value2 < 0) value2 = 255 + value2 + 1;
1411
+ this[offset] = value2 & 255;
1412
+ return offset + 1;
1413
+ };
1414
+ Buffer3.prototype.writeInt16LE = function writeInt16LE(value2, offset, noAssert) {
1415
+ value2 = +value2;
1416
+ offset = offset >>> 0;
1417
+ if (!noAssert) checkInt(this, value2, offset, 2, 32767, -32768);
1418
+ this[offset] = value2 & 255;
1419
+ this[offset + 1] = value2 >>> 8;
1420
+ return offset + 2;
1421
+ };
1422
+ Buffer3.prototype.writeInt16BE = function writeInt16BE(value2, offset, noAssert) {
1423
+ value2 = +value2;
1424
+ offset = offset >>> 0;
1425
+ if (!noAssert) checkInt(this, value2, offset, 2, 32767, -32768);
1426
+ this[offset] = value2 >>> 8;
1427
+ this[offset + 1] = value2 & 255;
1428
+ return offset + 2;
1429
+ };
1430
+ Buffer3.prototype.writeInt32LE = function writeInt32LE(value2, offset, noAssert) {
1431
+ value2 = +value2;
1432
+ offset = offset >>> 0;
1433
+ if (!noAssert) checkInt(this, value2, offset, 4, 2147483647, -2147483648);
1434
+ this[offset] = value2 & 255;
1435
+ this[offset + 1] = value2 >>> 8;
1436
+ this[offset + 2] = value2 >>> 16;
1437
+ this[offset + 3] = value2 >>> 24;
1438
+ return offset + 4;
1439
+ };
1440
+ Buffer3.prototype.writeInt32BE = function writeInt32BE(value2, offset, noAssert) {
1441
+ value2 = +value2;
1442
+ offset = offset >>> 0;
1443
+ if (!noAssert) checkInt(this, value2, offset, 4, 2147483647, -2147483648);
1444
+ if (value2 < 0) value2 = 4294967295 + value2 + 1;
1445
+ this[offset] = value2 >>> 24;
1446
+ this[offset + 1] = value2 >>> 16;
1447
+ this[offset + 2] = value2 >>> 8;
1448
+ this[offset + 3] = value2 & 255;
1449
+ return offset + 4;
1450
+ };
1451
+ Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value2, offset = 0) {
1452
+ return wrtBigUInt64LE(this, value2, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1453
+ });
1454
+ Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value2, offset = 0) {
1455
+ return wrtBigUInt64BE(this, value2, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1456
+ });
1457
+ function checkIEEE754(buf, value2, offset, ext, max, min) {
1458
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1459
+ if (offset < 0) throw new RangeError("Index out of range");
1460
+ }
1461
+ function writeFloat(buf, value2, offset, littleEndian, noAssert) {
1462
+ value2 = +value2;
1463
+ offset = offset >>> 0;
1464
+ if (!noAssert) {
1465
+ checkIEEE754(buf, value2, offset, 4, 34028234663852886e22, -34028234663852886e22);
1466
+ }
1467
+ ieee754.write(buf, value2, offset, littleEndian, 23, 4);
1468
+ return offset + 4;
1469
+ }
1470
+ Buffer3.prototype.writeFloatLE = function writeFloatLE(value2, offset, noAssert) {
1471
+ return writeFloat(this, value2, offset, true, noAssert);
1472
+ };
1473
+ Buffer3.prototype.writeFloatBE = function writeFloatBE(value2, offset, noAssert) {
1474
+ return writeFloat(this, value2, offset, false, noAssert);
1475
+ };
1476
+ function writeDouble(buf, value2, offset, littleEndian, noAssert) {
1477
+ value2 = +value2;
1478
+ offset = offset >>> 0;
1479
+ if (!noAssert) {
1480
+ checkIEEE754(buf, value2, offset, 8, 17976931348623157e292, -17976931348623157e292);
1481
+ }
1482
+ ieee754.write(buf, value2, offset, littleEndian, 52, 8);
1483
+ return offset + 8;
1484
+ }
1485
+ Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value2, offset, noAssert) {
1486
+ return writeDouble(this, value2, offset, true, noAssert);
1487
+ };
1488
+ Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value2, offset, noAssert) {
1489
+ return writeDouble(this, value2, offset, false, noAssert);
1490
+ };
1491
+ Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
1492
+ if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
1493
+ if (!start) start = 0;
1494
+ if (!end && end !== 0) end = this.length;
1495
+ if (targetStart >= target.length) targetStart = target.length;
1496
+ if (!targetStart) targetStart = 0;
1497
+ if (end > 0 && end < start) end = start;
1498
+ if (end === start) return 0;
1499
+ if (target.length === 0 || this.length === 0) return 0;
1500
+ if (targetStart < 0) {
1501
+ throw new RangeError("targetStart out of bounds");
1502
+ }
1503
+ if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
1504
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
1505
+ if (end > this.length) end = this.length;
1506
+ if (target.length - targetStart < end - start) {
1507
+ end = target.length - targetStart + start;
1508
+ }
1509
+ const len = end - start;
1510
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1511
+ this.copyWithin(targetStart, start, end);
1512
+ } else {
1513
+ Uint8Array.prototype.set.call(
1514
+ target,
1515
+ this.subarray(start, end),
1516
+ targetStart
1517
+ );
1518
+ }
1519
+ return len;
1520
+ };
1521
+ Buffer3.prototype.fill = function fill(val, start, end, encoding) {
1522
+ if (typeof val === "string") {
1523
+ if (typeof start === "string") {
1524
+ encoding = start;
1525
+ start = 0;
1526
+ end = this.length;
1527
+ } else if (typeof end === "string") {
1528
+ encoding = end;
1529
+ end = this.length;
1530
+ }
1531
+ if (encoding !== void 0 && typeof encoding !== "string") {
1532
+ throw new TypeError("encoding must be a string");
1533
+ }
1534
+ if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
1535
+ throw new TypeError("Unknown encoding: " + encoding);
1536
+ }
1537
+ if (val.length === 1) {
1538
+ const code = val.charCodeAt(0);
1539
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1540
+ val = code;
1541
+ }
1542
+ }
1543
+ } else if (typeof val === "number") {
1544
+ val = val & 255;
1545
+ } else if (typeof val === "boolean") {
1546
+ val = Number(val);
1547
+ }
1548
+ if (start < 0 || this.length < start || this.length < end) {
1549
+ throw new RangeError("Out of range index");
1550
+ }
1551
+ if (end <= start) {
1552
+ return this;
1553
+ }
1554
+ start = start >>> 0;
1555
+ end = end === void 0 ? this.length : end >>> 0;
1556
+ if (!val) val = 0;
1557
+ let i;
1558
+ if (typeof val === "number") {
1559
+ for (i = start; i < end; ++i) {
1560
+ this[i] = val;
1561
+ }
1562
+ } else {
1563
+ const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
1564
+ const len = bytes.length;
1565
+ if (len === 0) {
1566
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1567
+ }
1568
+ for (i = 0; i < end - start; ++i) {
1569
+ this[i + start] = bytes[i % len];
1570
+ }
1571
+ }
1572
+ return this;
1573
+ };
1574
+ var errors = {};
1575
+ function E(sym, getMessage, Base) {
1576
+ errors[sym] = class NodeError extends Base {
1577
+ constructor() {
1578
+ super();
1579
+ Object.defineProperty(this, "message", {
1580
+ value: getMessage.apply(this, arguments),
1581
+ writable: true,
1582
+ configurable: true
1583
+ });
1584
+ this.name = `${this.name} [${sym}]`;
1585
+ this.stack;
1586
+ delete this.name;
1587
+ }
1588
+ get code() {
1589
+ return sym;
1590
+ }
1591
+ set code(value2) {
1592
+ Object.defineProperty(this, "code", {
1593
+ configurable: true,
1594
+ enumerable: true,
1595
+ value: value2,
1596
+ writable: true
1597
+ });
1598
+ }
1599
+ toString() {
1600
+ return `${this.name} [${sym}]: ${this.message}`;
1601
+ }
1602
+ };
1603
+ }
1604
+ E(
1605
+ "ERR_BUFFER_OUT_OF_BOUNDS",
1606
+ function(name) {
1607
+ if (name) {
1608
+ return `${name} is outside of buffer bounds`;
1609
+ }
1610
+ return "Attempt to access memory outside buffer bounds";
1611
+ },
1612
+ RangeError
1613
+ );
1614
+ E(
1615
+ "ERR_INVALID_ARG_TYPE",
1616
+ function(name, actual) {
1617
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1618
+ },
1619
+ TypeError
1620
+ );
1621
+ E(
1622
+ "ERR_OUT_OF_RANGE",
1623
+ function(str, range, input3) {
1624
+ let msg = `The value of "${str}" is out of range.`;
1625
+ let received = input3;
1626
+ if (Number.isInteger(input3) && Math.abs(input3) > 2 ** 32) {
1627
+ received = addNumericalSeparator(String(input3));
1628
+ } else if (typeof input3 === "bigint") {
1629
+ received = String(input3);
1630
+ if (input3 > BigInt(2) ** BigInt(32) || input3 < -(BigInt(2) ** BigInt(32))) {
1631
+ received = addNumericalSeparator(received);
1632
+ }
1633
+ received += "n";
1634
+ }
1635
+ msg += ` It must be ${range}. Received ${received}`;
1636
+ return msg;
1637
+ },
1638
+ RangeError
1639
+ );
1640
+ function addNumericalSeparator(val) {
1641
+ let res = "";
1642
+ let i = val.length;
1643
+ const start = val[0] === "-" ? 1 : 0;
1644
+ for (; i >= start + 4; i -= 3) {
1645
+ res = `_${val.slice(i - 3, i)}${res}`;
1646
+ }
1647
+ return `${val.slice(0, i)}${res}`;
1648
+ }
1649
+ function checkBounds(buf, offset, byteLength2) {
1650
+ validateNumber(offset, "offset");
1651
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1652
+ boundsError(offset, buf.length - (byteLength2 + 1));
1653
+ }
1654
+ }
1655
+ function checkIntBI(value2, min, max, buf, offset, byteLength2) {
1656
+ if (value2 > max || value2 < min) {
1657
+ const n = typeof min === "bigint" ? "n" : "";
1658
+ let range;
1659
+ if (byteLength2 > 3) {
1660
+ if (min === 0 || min === BigInt(0)) {
1661
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1662
+ } else {
1663
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1664
+ }
1665
+ } else {
1666
+ range = `>= ${min}${n} and <= ${max}${n}`;
1667
+ }
1668
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value2);
1669
+ }
1670
+ checkBounds(buf, offset, byteLength2);
1671
+ }
1672
+ function validateNumber(value2, name) {
1673
+ if (typeof value2 !== "number") {
1674
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value2);
1675
+ }
1676
+ }
1677
+ function boundsError(value2, length, type) {
1678
+ if (Math.floor(value2) !== value2) {
1679
+ validateNumber(value2, type);
1680
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value2);
1681
+ }
1682
+ if (length < 0) {
1683
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1684
+ }
1685
+ throw new errors.ERR_OUT_OF_RANGE(
1686
+ type || "offset",
1687
+ `>= ${type ? 1 : 0} and <= ${length}`,
1688
+ value2
1689
+ );
1690
+ }
1691
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1692
+ function base64clean(str) {
1693
+ str = str.split("=")[0];
1694
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1695
+ if (str.length < 2) return "";
1696
+ while (str.length % 4 !== 0) {
1697
+ str = str + "=";
1698
+ }
1699
+ return str;
1700
+ }
1701
+ function utf8ToBytes(string, units) {
1702
+ units = units || Infinity;
1703
+ let codePoint;
1704
+ const length = string.length;
1705
+ let leadSurrogate = null;
1706
+ const bytes = [];
1707
+ for (let i = 0; i < length; ++i) {
1708
+ codePoint = string.charCodeAt(i);
1709
+ if (codePoint > 55295 && codePoint < 57344) {
1710
+ if (!leadSurrogate) {
1711
+ if (codePoint > 56319) {
1712
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1713
+ continue;
1714
+ } else if (i + 1 === length) {
1715
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1716
+ continue;
1717
+ }
1718
+ leadSurrogate = codePoint;
1719
+ continue;
1720
+ }
1721
+ if (codePoint < 56320) {
1722
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1723
+ leadSurrogate = codePoint;
1724
+ continue;
1725
+ }
1726
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1727
+ } else if (leadSurrogate) {
1728
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1729
+ }
1730
+ leadSurrogate = null;
1731
+ if (codePoint < 128) {
1732
+ if ((units -= 1) < 0) break;
1733
+ bytes.push(codePoint);
1734
+ } else if (codePoint < 2048) {
1735
+ if ((units -= 2) < 0) break;
1736
+ bytes.push(
1737
+ codePoint >> 6 | 192,
1738
+ codePoint & 63 | 128
1739
+ );
1740
+ } else if (codePoint < 65536) {
1741
+ if ((units -= 3) < 0) break;
1742
+ bytes.push(
1743
+ codePoint >> 12 | 224,
1744
+ codePoint >> 6 & 63 | 128,
1745
+ codePoint & 63 | 128
1746
+ );
1747
+ } else if (codePoint < 1114112) {
1748
+ if ((units -= 4) < 0) break;
1749
+ bytes.push(
1750
+ codePoint >> 18 | 240,
1751
+ codePoint >> 12 & 63 | 128,
1752
+ codePoint >> 6 & 63 | 128,
1753
+ codePoint & 63 | 128
1754
+ );
1755
+ } else {
1756
+ throw new Error("Invalid code point");
1757
+ }
1758
+ }
1759
+ return bytes;
1760
+ }
1761
+ function asciiToBytes(str) {
1762
+ const byteArray = [];
1763
+ for (let i = 0; i < str.length; ++i) {
1764
+ byteArray.push(str.charCodeAt(i) & 255);
1765
+ }
1766
+ return byteArray;
1767
+ }
1768
+ function utf16leToBytes(str, units) {
1769
+ let c, hi, lo;
1770
+ const byteArray = [];
1771
+ for (let i = 0; i < str.length; ++i) {
1772
+ if ((units -= 2) < 0) break;
1773
+ c = str.charCodeAt(i);
1774
+ hi = c >> 8;
1775
+ lo = c % 256;
1776
+ byteArray.push(lo);
1777
+ byteArray.push(hi);
1778
+ }
1779
+ return byteArray;
1780
+ }
1781
+ function base64ToBytes(str) {
1782
+ return base64.toByteArray(base64clean(str));
1783
+ }
1784
+ function blitBuffer(src, dst, offset, length) {
1785
+ let i;
1786
+ for (i = 0; i < length; ++i) {
1787
+ if (i + offset >= dst.length || i >= src.length) break;
1788
+ dst[i + offset] = src[i];
1789
+ }
1790
+ return i;
1791
+ }
1792
+ function isInstance(obj, type) {
1793
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1794
+ }
1795
+ function numberIsNaN(obj) {
1796
+ return obj !== obj;
1797
+ }
1798
+ var hexSliceLookupTable = (function() {
1799
+ const alphabet = "0123456789abcdef";
1800
+ const table = new Array(256);
1801
+ for (let i = 0; i < 16; ++i) {
1802
+ const i16 = i * 16;
1803
+ for (let j = 0; j < 16; ++j) {
1804
+ table[i16 + j] = alphabet[i] + alphabet[j];
1805
+ }
1806
+ }
1807
+ return table;
1808
+ })();
1809
+ function defineBigIntMethod(fn) {
1810
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1811
+ }
1812
+ function BufferBigIntNotDefined() {
1813
+ throw new Error("BigInt not supported");
1814
+ }
1815
+ }
1816
+ });
1817
+
1818
+ // packages/safe-bash/browser/platform.mjs
1819
+ import { posixPath } from "@poe-platform/safe-fs/core";
1820
+ var import_buffer, TransformStream;
1821
+ var init_platform = __esm({
1822
+ "packages/safe-bash/browser/platform.mjs"() {
1823
+ "use strict";
1824
+ import_buffer = __toESM(require_buffer(), 1);
1825
+ TransformStream = globalThis.TransformStream;
1826
+ }
1827
+ });
1828
+
1829
+ // packages/safe-bash/src/commands/xml/index.ts
1830
+ init_platform();
1831
+ import { parseXmlSteps, XmlLimitError } from "@poe-platform/safe-fs/core";
1832
+
1833
+ // packages/safe-bash/src/contracts/command.ts
1834
+ init_platform();
1835
+
1836
+ // packages/safe-bash/src/contracts/value.ts
1837
+ init_platform();
1838
+ var byteValues = /* @__PURE__ */ new WeakMap();
1839
+ var encoder = new TextEncoder();
1840
+ var decoder = new TextDecoder("utf-8", { ignoreBOM: true });
1841
+ var typedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
1842
+ var viewBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
1843
+ var viewOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
1844
+ var viewLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
1845
+ function record(value2) {
1846
+ const result = byteValues.get(value2);
1847
+ if (!result) throw new TypeError("Expected an owned shell byte value");
1848
+ return result;
1849
+ }
1850
+ function allocationSize(length, multiplier) {
1851
+ const result = length * multiplier + 64;
1852
+ if (!Number.isSafeInteger(result)) throw new RangeError("Shell value allocation is too large");
1853
+ return result;
1854
+ }
1855
+ function allocate(bytes, allocation, create, slots = 1) {
1856
+ allocation?.assertOpen();
1857
+ const reservation = allocation?.reserve(bytes, slots);
1858
+ try {
1859
+ const result = create();
1860
+ reservation?.commit(result);
1861
+ return result;
1862
+ } catch (error) {
1863
+ try {
1864
+ reservation?.release();
1865
+ } catch (cleanup) {
1866
+ throw new AggregateError([error, cleanup], "Shell value allocation and release failed");
1867
+ }
1868
+ throw error;
1869
+ }
1870
+ }
1871
+ function ownedBytes(bytes) {
1872
+ const value2 = Object.freeze({});
1873
+ byteValues.set(value2, { bytes, text: decoder.decode(bytes) });
1874
+ return value2;
1875
+ }
1876
+ function shellValueFromBytes(bytes, allocation) {
1877
+ if (!(bytes instanceof Uint8Array)) throw new TypeError("Shell bytes must be Uint8Array");
1878
+ const buffer = viewBuffer.call(bytes);
1879
+ const offset = viewOffset.call(bytes);
1880
+ const length = viewLength.call(bytes);
1881
+ return allocate(allocationSize(length, 3), allocation, () => {
1882
+ if (viewOffset.call(bytes) !== offset || viewLength.call(bytes) < length) throw new TypeError("Shell byte input extent changed during admission");
1883
+ return ownedBytes(new Uint8Array(new Uint8Array(buffer, offset, length)));
1884
+ });
1885
+ }
1886
+ function shellValueText(value2) {
1887
+ return typeof value2 === "string" ? value2 : record(value2).text;
1888
+ }
1889
+ function shellValueByteLength(value2) {
1890
+ return typeof value2 === "string" ? import_buffer.Buffer.byteLength(value2) : record(value2).bytes.byteLength;
1891
+ }
1892
+ function shellValueRetainedBytes(value2) {
1893
+ const stored = record(value2);
1894
+ return stored.bytes.byteLength + stored.text.length * 2 + 64;
1895
+ }
1896
+ function shellValueBytes(value2, allocation) {
1897
+ const length = shellValueByteLength(value2);
1898
+ return allocate(allocationSize(length, 1), allocation, () => typeof value2 === "string" ? encoder.encode(value2) : new Uint8Array(record(value2).bytes));
1899
+ }
1900
+ function concatShellValues(values, allocation) {
1901
+ allocation?.assertOpen();
1902
+ if (!Array.isArray(values)) throw new TypeError("Shell value concatenation requires an array");
1903
+ const count = values.length;
1904
+ if (!Number.isSafeInteger(count) || count < 0 || count > 4294967295) throw new RangeError("Invalid shell value input extent");
1905
+ if (!count) return "";
1906
+ if (count === 1) {
1907
+ const value2 = values[0];
1908
+ if (typeof value2 !== "string") record(value2);
1909
+ if (values.length !== count) throw new TypeError("Shell value input extent changed");
1910
+ return value2;
1911
+ }
1912
+ let textOnly = true;
1913
+ for (let index = 0; index < count; index++) {
1914
+ if (typeof values[index] !== "string") {
1915
+ textOnly = false;
1916
+ break;
1917
+ }
1918
+ }
1919
+ if (textOnly) {
1920
+ let text = "";
1921
+ for (let index = 0; index < count; index++) {
1922
+ const value2 = values[index];
1923
+ if (typeof value2 !== "string") throw new TypeError("Shell value input type changed during text concatenation");
1924
+ text += value2;
1925
+ }
1926
+ if (values.length !== count) throw new TypeError("Shell value input extent changed");
1927
+ return text;
1928
+ }
1929
+ let reservation = allocation?.reserve(allocationSize(count, 16), count + 1);
1930
+ const release = () => {
1931
+ const pending = reservation;
1932
+ reservation = void 0;
1933
+ pending?.release();
1934
+ };
1935
+ try {
1936
+ if (values.length !== count) throw new TypeError("Shell value input extent changed during metadata admission");
1937
+ const snapshot = new Array(count);
1938
+ for (let index = 0; index < count; index++) {
1939
+ const value2 = values[index];
1940
+ if (typeof value2 !== "string") record(value2);
1941
+ snapshot[index] = value2;
1942
+ }
1943
+ if (values.length !== count) throw new TypeError("Shell value input extent changed during snapshot capture");
1944
+ Object.freeze(snapshot);
1945
+ reservation?.commit(snapshot);
1946
+ if (snapshot.every((value2) => typeof value2 === "string")) {
1947
+ const result = snapshot.join("");
1948
+ release();
1949
+ return result;
1950
+ }
1951
+ const length = encodeValues(snapshot);
1952
+ return allocate(allocationSize(length, 3), allocation, () => {
1953
+ const bytes = new Uint8Array(length);
1954
+ encodeValues(snapshot, bytes);
1955
+ const result = ownedBytes(bytes);
1956
+ release();
1957
+ return result;
1958
+ });
1959
+ } catch (error) {
1960
+ try {
1961
+ release();
1962
+ } catch (cleanup) {
1963
+ throw new AggregateError([error, cleanup], "Shell value snapshot and release failed");
1964
+ }
1965
+ throw error;
1966
+ }
1967
+ }
1968
+ function encodeValues(values, output2) {
1969
+ let offset = 0;
1970
+ let high = 0;
1971
+ const write = (byte) => {
1972
+ if (output2) output2[offset] = byte;
1973
+ offset++;
1974
+ };
1975
+ const point = (code) => {
1976
+ if (code < 128) write(code);
1977
+ else if (code < 2048) {
1978
+ write(192 | code >> 6);
1979
+ write(128 | code & 63);
1980
+ } else if (code < 65536) {
1981
+ write(224 | code >> 12);
1982
+ write(128 | code >> 6 & 63);
1983
+ write(128 | code & 63);
1984
+ } else {
1985
+ write(240 | code >> 18);
1986
+ write(128 | code >> 12 & 63);
1987
+ write(128 | code >> 6 & 63);
1988
+ write(128 | code & 63);
1989
+ }
1990
+ };
1991
+ for (const value2 of values) {
1992
+ if (typeof value2 !== "string") {
1993
+ if (high) {
1994
+ point(65533);
1995
+ high = 0;
1996
+ }
1997
+ const bytes = record(value2).bytes;
1998
+ output2?.set(bytes, offset);
1999
+ offset += bytes.byteLength;
2000
+ continue;
2001
+ }
2002
+ for (let index = 0; index < value2.length; index++) {
2003
+ const code = value2.charCodeAt(index);
2004
+ if (high) {
2005
+ const previous = high;
2006
+ high = 0;
2007
+ if (code >= 56320 && code <= 57343) {
2008
+ point(65536 + (previous - 55296 << 10) + code - 56320);
2009
+ continue;
2010
+ }
2011
+ point(65533);
2012
+ }
2013
+ if (code >= 55296 && code <= 56319) high = code;
2014
+ else point(code >= 56320 && code <= 57343 ? 65533 : code);
2015
+ }
2016
+ }
2017
+ if (high) point(65533);
2018
+ if (!Number.isSafeInteger(offset)) throw new RangeError("Shell value allocation is too large");
2019
+ return offset;
2020
+ }
2021
+
2022
+ // packages/safe-bash/src/contracts/command.ts
2023
+ var argumentCarriers = /* @__PURE__ */ new WeakSet();
2024
+ var CommandArgumentIdentityError = class extends TypeError {
2025
+ constructor() {
2026
+ super("Command argument identity does not match its carrier");
2027
+ }
2028
+ };
2029
+ function argumentAllocation(allocation) {
2030
+ const reservations = [];
2031
+ const tracked = allocation && {
2032
+ assertOpen() {
2033
+ allocation.assertOpen();
2034
+ },
2035
+ reserve(bytes, slots) {
2036
+ const reservation = allocation.reserve(bytes, slots);
2037
+ let released = false;
2038
+ const owned = {
2039
+ commit(value2) {
2040
+ reservation.commit(value2);
2041
+ },
2042
+ release() {
2043
+ if (released) return;
2044
+ released = true;
2045
+ reservation.release();
2046
+ }
2047
+ };
2048
+ reservations.push(owned);
2049
+ return owned;
2050
+ }
2051
+ };
2052
+ return {
2053
+ allocation: tracked,
2054
+ rollback(error) {
2055
+ const failures = [error];
2056
+ for (let index = reservations.length - 1; index >= 0; index--) {
2057
+ try {
2058
+ reservations[index].release();
2059
+ } catch (cleanup) {
2060
+ failures.push(cleanup);
2061
+ }
2062
+ }
2063
+ if (failures.length > 1) throw new AggregateError(failures, "Command argument allocation and release failed");
2064
+ throw error;
2065
+ }
2066
+ };
2067
+ }
2068
+ function ownedCommandArguments(size, valueAt, allocation, extent) {
2069
+ allocation?.assertOpen();
2070
+ const length = typeof size === "number" ? size : size();
2071
+ const bytes = 128 + length * 40;
2072
+ const slots = length * 4 + 1;
2073
+ if (!Number.isSafeInteger(length) || length < 0 || !Number.isSafeInteger(bytes) || !Number.isSafeInteger(slots)) {
2074
+ throw new RangeError("Command argument allocation is too large");
2075
+ }
2076
+ const transaction = argumentAllocation(allocation);
2077
+ const reservation = transaction.allocation?.reserve(bytes, slots);
2078
+ try {
2079
+ if (extent && extent() !== length) throw new TypeError("Command argument extent changed during admission");
2080
+ const snapshot = [];
2081
+ for (let index = 0; index < length; index++) snapshot.push(valueAt(index));
2082
+ if (extent && extent() !== length) throw new TypeError("Command argument extent changed during admission");
2083
+ const values = [];
2084
+ const args = [];
2085
+ for (const incoming of snapshot) {
2086
+ const value2 = incoming instanceof Uint8Array ? shellValueFromBytes(incoming, transaction.allocation) : incoming;
2087
+ args.push(shellValueText(value2));
2088
+ values.push(value2);
2089
+ }
2090
+ Object.freeze(values);
2091
+ Object.freeze(args);
2092
+ const carrier = Object.freeze({
2093
+ args,
2094
+ values,
2095
+ bytes(index) {
2096
+ return Number.isInteger(index) && index >= 0 && index < length ? shellValueBytes(values[index], allocation) : void 0;
2097
+ },
2098
+ slice(start = 0, end = length) {
2099
+ const offset = (index) => {
2100
+ const integral = Math.trunc(index) || 0;
2101
+ return integral < 0 ? Math.max(0, length + integral) : Math.min(length, integral);
2102
+ };
2103
+ const first = offset(start);
2104
+ return ownedCommandArguments(Math.max(0, offset(end) - first), (index) => values[first + index], allocation);
2105
+ },
2106
+ select(indices) {
2107
+ return ownedCommandArguments(() => {
2108
+ if (!Array.isArray(indices)) throw new TypeError("Command argument selection must be an array");
2109
+ return indices.length;
2110
+ }, (index) => {
2111
+ const selected = indices[index];
2112
+ if (!Number.isInteger(selected) || selected < 0 || selected >= length) throw new RangeError("Command argument index is out of range");
2113
+ return values[selected];
2114
+ }, allocation, () => indices.length);
2115
+ },
2116
+ concat(...others) {
2117
+ let total = length;
2118
+ for (const other of others) {
2119
+ if (!argumentCarriers.has(other)) throw new TypeError("Expected owned command arguments");
2120
+ total += other.values.length;
2121
+ }
2122
+ return ownedCommandArguments(total, (index) => {
2123
+ if (index < length) return values[index];
2124
+ let offset = index - length;
2125
+ for (const other of others) {
2126
+ if (offset < other.values.length) return other.values[offset];
2127
+ offset -= other.values.length;
2128
+ }
2129
+ throw new RangeError("Command argument index is out of range");
2130
+ }, allocation);
2131
+ },
2132
+ withValues(incoming) {
2133
+ return ownedCommandArguments(() => {
2134
+ if (!Array.isArray(incoming)) throw new TypeError("Command arguments must be an array");
2135
+ return incoming.length;
2136
+ }, (index) => incoming[index], allocation, () => incoming.length);
2137
+ },
2138
+ join(separator = "") {
2139
+ allocation?.assertOpen();
2140
+ const count = Math.max(0, length * 2 - 1);
2141
+ const bytes2 = 128 + count * 16;
2142
+ if (!Number.isSafeInteger(bytes2) || !Number.isSafeInteger(count + 1)) throw new RangeError("Command argument join allocation is too large");
2143
+ const transaction2 = argumentAllocation(allocation);
2144
+ const scratch = transaction2.allocation?.reserve(bytes2, count + 1);
2145
+ try {
2146
+ const parts2 = [];
2147
+ for (let index = 0; index < length; index++) {
2148
+ if (index) parts2.push(separator);
2149
+ parts2.push(values[index]);
2150
+ }
2151
+ Object.freeze(parts2);
2152
+ scratch?.commit(parts2);
2153
+ const result = concatShellValues(parts2, transaction2.allocation);
2154
+ scratch?.release();
2155
+ return result;
2156
+ } catch (error) {
2157
+ return transaction2.rollback(error);
2158
+ }
2159
+ }
2160
+ });
2161
+ reservation?.commit(carrier);
2162
+ argumentCarriers.add(carrier);
2163
+ return carrier;
2164
+ } catch (error) {
2165
+ return transaction.rollback(error);
2166
+ }
2167
+ }
2168
+ function createCommandArguments(values, allocation) {
2169
+ return ownedCommandArguments(() => {
2170
+ if (!Array.isArray(values)) throw new TypeError("Command arguments must be an array");
2171
+ return values.length;
2172
+ }, (index) => values[index], allocation, () => values.length);
2173
+ }
2174
+ function getCommandArguments(context) {
2175
+ const carrier = context.argumentValues;
2176
+ if (carrier === void 0) return createCommandArguments(context.args);
2177
+ if (!argumentCarriers.has(carrier)) throw new TypeError("Expected owned command arguments");
2178
+ if (carrier.args !== context.args) throw new CommandArgumentIdentityError();
2179
+ return carrier;
2180
+ }
2181
+ var CommandRegistry = class {
2182
+ #commands = /* @__PURE__ */ new Map();
2183
+ constructor(commands = []) {
2184
+ for (const command of commands) this.register(command);
2185
+ }
2186
+ register(command, options2 = {}) {
2187
+ const { name, execute: execute2 } = command;
2188
+ if (typeof name !== "string" || !name || /[\s/\0]/u.test(name)) {
2189
+ throw new TypeError("Command names must be nonempty and contain no whitespace, slash, or NUL");
2190
+ }
2191
+ if (typeof execute2 !== "function") {
2192
+ throw new TypeError("Command execute must be a function");
2193
+ }
2194
+ if (this.#commands.has(name) && !options2.replace) {
2195
+ throw new Error(`Command already registered: ${name}`);
2196
+ }
2197
+ this.#commands.set(name, Object.freeze({ ...command, name, execute: execute2 }));
2198
+ return this;
2199
+ }
2200
+ get(name) {
2201
+ return this.#commands.get(name);
2202
+ }
2203
+ has(name) {
2204
+ return this.#commands.has(name);
2205
+ }
2206
+ unregister(name) {
2207
+ return this.#commands.delete(name);
2208
+ }
2209
+ list() {
2210
+ return Array.from(this.#commands.values());
2211
+ }
2212
+ };
2213
+ function validateExitCode(exitCode) {
2214
+ if (!Number.isInteger(exitCode) || exitCode < 0 || exitCode > 255) {
2215
+ throw new RangeError("Exit status must be an integer between 0 and 255");
2216
+ }
2217
+ return exitCode;
2218
+ }
2219
+
2220
+ // packages/safe-bash/src/contracts/command-requirements.ts
2221
+ init_platform();
2222
+
2223
+ // packages/safe-bash/src/contracts/errors.ts
2224
+ init_platform();
2225
+ import { isErrnoCode, isFsError, toFsError, FsError } from "@poe-platform/safe-fs/core";
2226
+
2227
+ // packages/safe-bash/src/contracts/command-requirements.ts
2228
+ function evaluateMode(requirement, capabilities) {
2229
+ const missing = requirement.capabilities.filter((name) => capabilities[name] === false);
2230
+ const unknown = requirement.capabilities.filter((name) => capabilities[name] === void 0);
2231
+ if (requirement.mutates && capabilities.readOnly === true) missing.push("readOnly");
2232
+ const alternatives = requirement.anyOf;
2233
+ if (alternatives && !alternatives.some((group) => group.every((name) => capabilities[name] === true))) {
2234
+ if (alternatives.every((group) => group.some((name) => capabilities[name] === false))) {
2235
+ missing.push(...alternatives.flatMap((group) => group.filter((name) => capabilities[name] === false)));
2236
+ } else {
2237
+ unknown.push(...alternatives.filter((group) => !group.some((name) => capabilities[name] === false)).flatMap((group) => group.filter((name) => capabilities[name] === void 0)));
2238
+ }
2239
+ }
2240
+ return {
2241
+ ...requirement,
2242
+ status: missing.length ? "unsupported" : unknown.length ? "unknown" : "supported",
2243
+ missing: [...new Set(missing)],
2244
+ unknown: [...new Set(unknown)]
2245
+ };
2246
+ }
2247
+ function evaluateCommandSupport(command, capabilities) {
2248
+ const modes = (command.filesystemRequirements ?? []).map((requirement) => evaluateMode(requirement, capabilities));
2249
+ return {
2250
+ declared: command.filesystemRequirements !== void 0,
2251
+ status: command.filesystemRequirements !== void 0 && modes.every((mode) => mode.status === "supported") ? "supported" : modes.length && modes.every((mode) => mode.status === "unsupported") ? "unsupported" : "partial",
2252
+ modes
2253
+ };
2254
+ }
2255
+ function assertCommandRequirements(context, requirements, selected, capabilities = context.fs.capabilities) {
2256
+ context.signal.throwIfAborted();
2257
+ for (const id of new Set(selected)) {
2258
+ const requirement = requirements.find((mode) => mode.id === id);
2259
+ if (!requirement) throw new TypeError(`Unknown filesystem requirement mode: ${id}`);
2260
+ const support = evaluateMode(requirement, capabilities);
2261
+ if (support.status === "unsupported") {
2262
+ throw new FsError(support.missing.includes("readOnly") ? "EROFS" : "ENOTSUP", {
2263
+ syscall: context.command,
2264
+ message: `${requirement.description} requires unavailable filesystem capabilities: ${support.missing.join(", ")}`
2265
+ });
2266
+ }
2267
+ }
2268
+ }
2269
+
2270
+ // packages/safe-bash/src/contracts/io.ts
2271
+ init_platform();
2272
+ init_platform();
2273
+ import { collectBytes, readBytes } from "@poe-platform/safe-fs/core";
2274
+ import { collectBytes as collectBytes2, readBytes as readBytes2, toByteSource } from "@poe-platform/safe-fs/core";
2275
+ var outputFailure = /* @__PURE__ */ Symbol("output failure");
2276
+ function createBytePipe(options2 = {}) {
2277
+ const highWaterMark = options2.highWaterMark ?? 64 * 1024;
2278
+ const signal = options2.signal;
2279
+ if (!Number.isSafeInteger(highWaterMark) || highWaterMark < 1) {
2280
+ throw new RangeError("highWaterMark must be a positive safe integer");
2281
+ }
2282
+ const stream = new TransformStream(
2283
+ void 0,
2284
+ { highWaterMark: 1 },
2285
+ { highWaterMark, size: (chunk) => chunk.byteLength }
2286
+ );
2287
+ const reader = stream.readable.getReader();
2288
+ const writer = stream.writable.getWriter();
2289
+ let ended = false;
2290
+ let failed = false;
2291
+ let failure;
2292
+ let closePromise;
2293
+ let abortPromise;
2294
+ let finished = false;
2295
+ const consumer = new AbortController();
2296
+ const abort = (reason = new FsError("EPIPE", { syscall: "pipe" })) => {
2297
+ if (abortPromise) return abortPromise;
2298
+ if (finished) return Promise.resolve();
2299
+ failed = true;
2300
+ failure = reason;
2301
+ ended = true;
2302
+ consumer.abort(reason);
2303
+ abortPromise = Promise.allSettled([reader.cancel(reason), writer.abort(reason)]).then(() => {
2304
+ });
2305
+ return abortPromise;
2306
+ };
2307
+ const onAbort = () => {
2308
+ void abort(signal?.reason);
2309
+ };
2310
+ const cleanup = () => signal?.removeEventListener("abort", onAbort);
2311
+ void writer.closed.catch(() => {
2312
+ });
2313
+ void reader.closed.then(cleanup, cleanup);
2314
+ if (signal?.aborted) onAbort();
2315
+ else signal?.addEventListener("abort", onAbort, { once: true });
2316
+ const iterator = (async function* () {
2317
+ try {
2318
+ while (true) {
2319
+ if (failed) throw failure;
2320
+ const result = await reader.read();
2321
+ if (failed) throw failure;
2322
+ if (result.done) {
2323
+ finished = true;
2324
+ return;
2325
+ }
2326
+ yield result.value;
2327
+ }
2328
+ } finally {
2329
+ if (!finished) await abort();
2330
+ reader.releaseLock();
2331
+ }
2332
+ })();
2333
+ const readable = {
2334
+ [Symbol.asyncIterator]() {
2335
+ return this;
2336
+ },
2337
+ next() {
2338
+ return iterator.next();
2339
+ },
2340
+ async return() {
2341
+ if (!finished) await abort();
2342
+ try {
2343
+ return await iterator.return(void 0);
2344
+ } finally {
2345
+ reader.releaseLock();
2346
+ }
2347
+ },
2348
+ async throw(reason) {
2349
+ await abort(reason);
2350
+ try {
2351
+ return await iterator.throw(reason);
2352
+ } finally {
2353
+ reader.releaseLock();
2354
+ }
2355
+ }
2356
+ };
2357
+ const write = async (chunk) => {
2358
+ if (failed) throw failure;
2359
+ if (ended) throw new FsError("EPIPE", { syscall: "write" });
2360
+ if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sinks require Uint8Array chunks");
2361
+ if (chunk.byteLength > 0) await writer.write(new Uint8Array(chunk));
2362
+ };
2363
+ return {
2364
+ readable,
2365
+ writable: {
2366
+ write,
2367
+ [outputFailure]: abort,
2368
+ ownedOutput: { consumerClosed: consumer.signal, write }
2369
+ },
2370
+ close() {
2371
+ if (failed) return Promise.reject(failure);
2372
+ ended = true;
2373
+ closePromise ??= writer.close();
2374
+ return closePromise;
2375
+ },
2376
+ abort
2377
+ };
2378
+ }
2379
+ async function writeText(sink, text) {
2380
+ await sink.write(new TextEncoder().encode(text));
2381
+ }
2382
+ async function writeBytes(sink, chunk, signal) {
2383
+ if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sinks require Uint8Array chunks");
2384
+ await abortable(() => sink.write(chunk), signal);
2385
+ }
2386
+ async function pipeBytes(source, sink, signal) {
2387
+ signal?.throwIfAborted();
2388
+ for await (const chunk of readBytes(source, signal)) {
2389
+ await writeBytes(sink, chunk, signal);
2390
+ }
2391
+ signal?.throwIfAborted();
2392
+ }
2393
+ async function collectText(source, options2) {
2394
+ return new TextDecoder().decode(await collectBytes(source, options2));
2395
+ }
2396
+ async function abortable(operation, signal) {
2397
+ signal?.throwIfAborted();
2398
+ if (!signal) return operation();
2399
+ return new Promise((resolve, reject) => {
2400
+ const onAbort = () => {
2401
+ signal.removeEventListener("abort", onAbort);
2402
+ reject(signal.reason);
2403
+ };
2404
+ signal.addEventListener("abort", onAbort, { once: true });
2405
+ try {
2406
+ Promise.resolve(operation()).then(
2407
+ (result) => {
2408
+ signal.removeEventListener("abort", onAbort);
2409
+ resolve(result);
2410
+ },
2411
+ (error) => {
2412
+ signal.removeEventListener("abort", onAbort);
2413
+ reject(error);
2414
+ }
2415
+ );
2416
+ } catch (error) {
2417
+ signal.removeEventListener("abort", onAbort);
2418
+ reject(error);
2419
+ }
2420
+ });
2421
+ }
2422
+
2423
+ // packages/safe-bash/src/contracts/path.ts
2424
+ init_platform();
2425
+ import { validatePath, resolvePath, normalizePath, relativePath, isPathWithin, assertPathWithin, basename, dirname, extname, joinPath, isAbsolutePath, posixPath as posixPath2 } from "@poe-platform/safe-fs/core";
2426
+
2427
+ // packages/safe-bash/src/escaping.ts
2428
+ init_platform();
2429
+
2430
+ // packages/safe-bash/src/contracts/yield.ts
2431
+ init_platform();
2432
+ var checkpoints = /* @__PURE__ */ new WeakMap();
2433
+ function monotonicNow() {
2434
+ return globalThis.performance?.now() ?? Date.now();
2435
+ }
2436
+ function registerYieldCheckpoint(signal, checkpoint) {
2437
+ checkpoints.set(signal, checkpoint);
2438
+ }
2439
+ function scheduleTurn(callback) {
2440
+ const host = globalThis;
2441
+ return host.setImmediate ? { kind: "immediate", value: host.setImmediate(callback) } : { kind: "timeout", value: setTimeout(callback, 0) };
2442
+ }
2443
+ function cancelTurn(handle) {
2444
+ if (handle?.kind === "immediate") globalThis.clearImmediate?.(handle.value);
2445
+ else if (handle) clearTimeout(handle.value);
2446
+ }
2447
+ function yieldTurn(signal) {
2448
+ signal?.throwIfAborted();
2449
+ if (signal) checkpoints.get(signal)?.();
2450
+ return new Promise((resolve, reject) => {
2451
+ let handle;
2452
+ const finish = () => {
2453
+ signal?.removeEventListener("abort", abort);
2454
+ resolve();
2455
+ };
2456
+ const abort = () => {
2457
+ cancelTurn(handle);
2458
+ reject(signal.reason);
2459
+ };
2460
+ signal?.addEventListener("abort", abort, { once: true });
2461
+ if (signal?.aborted) abort();
2462
+ else handle = scheduleTurn(finish);
2463
+ });
2464
+ }
2465
+
2466
+ // packages/safe-bash/src/escaping.ts
2467
+ var controls = { 8: "\\b", 9: "\\t", 10: "\\n", 11: "\\v", 12: "\\f", 13: "\\r", 92: "\\\\" };
2468
+ var encoder2 = new TextEncoder();
2469
+ function* parts(value2, mode) {
2470
+ for (const character of value2) {
2471
+ const point = character.codePointAt(0);
2472
+ if (mode === "diagnostic" && (point === 9 || point === 10 || point >= 32 && (point < 127 || point > 159))) {
2473
+ yield character;
2474
+ } else {
2475
+ for (const byte of encoder2.encode(character)) {
2476
+ yield controls[byte] ?? (byte >= 32 && byte < 127 ? String.fromCharCode(byte) : `\\${byte.toString(8).padStart(3, "0")}`);
2477
+ }
2478
+ }
2479
+ }
2480
+ }
2481
+ function escapeText(value2, mode, checkOutput) {
2482
+ let result = "", bytes = 0;
2483
+ for (const part of parts(value2, mode)) {
2484
+ bytes += import_buffer.Buffer.byteLength(part);
2485
+ checkOutput?.(bytes);
2486
+ result += part;
2487
+ }
2488
+ return result;
2489
+ }
2490
+ async function writeDiagnostic(sink, value2, signal) {
2491
+ signal?.throwIfAborted();
2492
+ let chunk = "", bytes = 0, work = 0;
2493
+ for (const part of parts(value2, "diagnostic")) {
2494
+ signal?.throwIfAborted();
2495
+ const size = import_buffer.Buffer.byteLength(part);
2496
+ if (bytes + size > 16384) {
2497
+ await writeBytes(sink, encoder2.encode(chunk), signal);
2498
+ chunk = "";
2499
+ bytes = 0;
2500
+ }
2501
+ chunk += part;
2502
+ bytes += size;
2503
+ if (++work % 1024 === 0) await yieldTurn(signal);
2504
+ }
2505
+ if (bytes) await writeBytes(sink, encoder2.encode(chunk), signal);
2506
+ signal?.throwIfAborted();
2507
+ }
2508
+
2509
+ // packages/safe-bash/src/commands/internal.ts
2510
+ init_platform();
2511
+
2512
+ // packages/safe-bash/src/diagnostics.ts
2513
+ init_platform();
2514
+ var PublicDiagnostic = class extends Error {
2515
+ };
2516
+ function publicDiagnosticMessage(error, onInternalError) {
2517
+ if (error instanceof FsError || error instanceof CommandArgumentIdentityError) return error.message;
2518
+ if (error instanceof PublicDiagnostic && !Object.hasOwn(error, "cause")) return error.message;
2519
+ const original = error instanceof PublicDiagnostic ? error.cause : error;
2520
+ const detail = error instanceof PublicDiagnostic ? error.message : "internal error";
2521
+ try {
2522
+ const pending = onInternalError?.(original);
2523
+ if (pending !== void 0) void Promise.resolve(pending).catch(() => void 0);
2524
+ } catch {
2525
+ return detail;
2526
+ }
2527
+ return detail;
2528
+ }
2529
+
2530
+ // packages/safe-bash/src/commands/portable-requirements.ts
2531
+ init_platform();
2532
+ var inputRequirements = [
2533
+ { id: "stdin", description: "Read standard input", capabilities: [] },
2534
+ { id: "file", description: "Read file operands", capabilities: [], anyOf: [["streamingRead"], ["read"]] }
2535
+ ];
2536
+ var textOutputRequirements = [
2537
+ ...inputRequirements,
2538
+ { id: "output", description: "Write or truncate an output file", capabilities: [], anyOf: [["streamingWrite"], ["write"]], mutates: true }
2539
+ ];
2540
+ var pwdRequirements = [
2541
+ { id: "logical", description: "Print the logical working directory", capabilities: [] },
2542
+ { id: "physical", description: "Resolve the physical working directory (-P)", capabilities: ["realpath"] }
2543
+ ];
2544
+ var predicateRequirements = [
2545
+ { id: "expression", description: "Evaluate strings and integers", capabilities: [] },
2546
+ { id: "metadata", description: "Inspect file metadata", capabilities: ["stat"] },
2547
+ { id: "access", description: "Inspect path access permissions", capabilities: ["access"] }
2548
+ ];
2549
+
2550
+ // packages/safe-bash/src/commands/record-buffer.ts
2551
+ init_platform();
2552
+ var segmentSize = 4096;
2553
+ var RecordBuffer = class {
2554
+ constructor(capacity, finalizationCapacity = capacity * 2) {
2555
+ this.capacity = capacity;
2556
+ this.finalizationCapacity = finalizationCapacity;
2557
+ }
2558
+ capacity;
2559
+ finalizationCapacity;
2560
+ #segments = [];
2561
+ #size = 0;
2562
+ #allocated = 0;
2563
+ get size() {
2564
+ return this.#size;
2565
+ }
2566
+ #admit(length) {
2567
+ if (length > this.capacity - this.#size) {
2568
+ throw new FsError("EFBIG", { message: "line buffer limit exceeded" });
2569
+ }
2570
+ }
2571
+ append(bytes, start = 0, end = bytes.length) {
2572
+ this.#admit(end - start);
2573
+ let offset = start;
2574
+ while (offset < end) {
2575
+ let segment = this.#segments.at(-1);
2576
+ const used = this.#size % segmentSize;
2577
+ if (!segment || used === 0) {
2578
+ segment = new Uint8Array(Math.min(segmentSize, this.capacity - this.#allocated));
2579
+ this.#segments.push(segment);
2580
+ this.#allocated += segment.length;
2581
+ }
2582
+ const length = Math.min(end - offset, segment.length - used);
2583
+ segment.set(bytes.subarray(offset, offset + length), used);
2584
+ this.#size += length;
2585
+ offset += length;
2586
+ }
2587
+ }
2588
+ finish(admit, bytes, start = 0, end = bytes?.length ?? 0) {
2589
+ this.#admit(end - start);
2590
+ const size = this.#size + end - start;
2591
+ admit?.(size);
2592
+ if (size > this.finalizationCapacity - this.#allocated) {
2593
+ throw new FsError("EFBIG", { message: "line finalization buffer limit exceeded" });
2594
+ }
2595
+ const result = new Uint8Array(size);
2596
+ let offset = 0;
2597
+ for (const segment of this.#segments) {
2598
+ const length = Math.min(segment.length, this.#size - offset);
2599
+ result.set(segment.subarray(0, length), offset);
2600
+ offset += length;
2601
+ }
2602
+ if (bytes && end > start) result.set(bytes.subarray(start, end), offset);
2603
+ this.clear();
2604
+ return result;
2605
+ }
2606
+ clear() {
2607
+ this.#segments = [];
2608
+ this.#size = 0;
2609
+ this.#allocated = 0;
2610
+ }
2611
+ };
2612
+
2613
+ // packages/safe-bash/src/commands/internal.ts
2614
+ var encoder3 = new TextEncoder();
2615
+ var decoder2 = new TextDecoder();
2616
+ var bufferLimit = 32 * 1024 * 1024;
2617
+ var UsageError = class extends PublicDiagnostic {
2618
+ };
2619
+ function options(args, short, long = {}, stopAtOperand = false, onOperand) {
2620
+ const flags = /* @__PURE__ */ new Set();
2621
+ const values = /* @__PURE__ */ new Map();
2622
+ const operands = [];
2623
+ const specifications = /* @__PURE__ */ new Map();
2624
+ for (let index = 0; index < short.length; index++) {
2625
+ const key = short[index];
2626
+ specifications.set(key, short[index + 1] === ":");
2627
+ if (short[index + 1] === ":") index++;
2628
+ }
2629
+ let ended = false;
2630
+ for (let index = 0; index < args.length; index++) {
2631
+ const argument = args[index];
2632
+ if (ended || argument === "-" || !argument.startsWith("-")) {
2633
+ operands.push(argument);
2634
+ onOperand?.(index);
2635
+ if (stopAtOperand) ended = true;
2636
+ continue;
2637
+ }
2638
+ if (argument === "--") {
2639
+ ended = true;
2640
+ continue;
2641
+ }
2642
+ if (argument.startsWith("--")) {
2643
+ const equals = argument.indexOf("=");
2644
+ const name = argument.slice(2, equals < 0 ? void 0 : equals);
2645
+ const key = long[name];
2646
+ if (!key || !specifications.has(key)) throw new UsageError(`unrecognized option '${argument}'`);
2647
+ if (specifications.get(key)) {
2648
+ const value2 = equals >= 0 ? argument.slice(equals + 1) : args[++index];
2649
+ if (value2 === void 0) throw new UsageError(`option '--${name}' requires an argument`);
2650
+ values.set(key, [...values.get(key) ?? [], value2]);
2651
+ } else if (equals >= 0) throw new UsageError(`option '--${name}' does not take an argument`);
2652
+ flags.add(key);
2653
+ continue;
2654
+ }
2655
+ for (let offset = 1; offset < argument.length; offset++) {
2656
+ const key = argument[offset];
2657
+ if (!specifications.has(key)) throw new UsageError(`invalid option -- '${key}'`);
2658
+ if (specifications.get(key)) {
2659
+ const value2 = argument.slice(offset + 1) || args[++index];
2660
+ if (value2 === void 0) throw new UsageError(`option requires an argument -- '${key}'`);
2661
+ values.set(key, [...values.get(key) ?? [], value2]);
2662
+ offset = argument.length;
2663
+ }
2664
+ flags.add(key);
2665
+ }
2666
+ }
2667
+ return { flags, values, operands };
2668
+ }
2669
+ function value(parsed, key) {
2670
+ return parsed.values.get(key)?.at(-1);
2671
+ }
2672
+ function integer(text, minimum = 0) {
2673
+ if (!/^[+]?[0-9]+$/u.test(text)) throw new UsageError(`invalid number '${text}'`);
2674
+ const number = Number(text);
2675
+ if (!Number.isSafeInteger(number) || number < minimum) throw new UsageError(`invalid number '${text}'`);
2676
+ return number;
2677
+ }
2678
+ function requireOperands(operands, minimum = 1, maximum = Infinity) {
2679
+ if (operands.length < minimum) throw new UsageError("missing operand");
2680
+ if (operands.length > maximum) throw new UsageError(`extra operand '${operands[maximum]}'`);
2681
+ }
2682
+ function pathOf(context, path) {
2683
+ if (!path) throw new FsError("ENOENT", { path });
2684
+ validatePath(path);
2685
+ validatePath(context.cwd);
2686
+ if (!isAbsolutePath(context.cwd)) throw new FsError("EINVAL", { path: context.cwd, message: "cwd must be absolute" });
2687
+ return isAbsolutePath(path) ? path : `${context.cwd.replace(/\/$/u, "")}/${path}`;
2688
+ }
2689
+ function codeOf(error) {
2690
+ return error instanceof Error && "code" in error ? String(error.code) : void 0;
2691
+ }
2692
+ async function output(context, text) {
2693
+ context.signal.throwIfAborted();
2694
+ await writeBytes(context.stdout, typeof text === "string" ? encoder3.encode(text) : text, context.signal);
2695
+ }
2696
+ async function diagnostic(context, error) {
2697
+ context.signal.throwIfAborted();
2698
+ await writeDiagnostic(context.stderr, `${context.command}: ${publicDiagnosticMessage(error, context.onInternalError)}
2699
+ `, context.signal);
2700
+ }
2701
+ function define(name, handler, failureCode = 1) {
2702
+ return {
2703
+ name,
2704
+ async execute(context) {
2705
+ context.signal.throwIfAborted();
2706
+ try {
2707
+ return await handler(context);
2708
+ } catch (error) {
2709
+ context.signal.throwIfAborted();
2710
+ await diagnostic(context, error);
2711
+ return { exitCode: error instanceof UsageError ? 2 : failureCode };
2712
+ }
2713
+ }
2714
+ };
2715
+ }
2716
+ async function eachOperand(context, operands, operation) {
2717
+ let exitCode = 0;
2718
+ for (const operand of operands) {
2719
+ context.signal.throwIfAborted();
2720
+ try {
2721
+ await operation(operand);
2722
+ } catch (error) {
2723
+ await diagnostic(context, error);
2724
+ exitCode = 1;
2725
+ }
2726
+ }
2727
+ return { exitCode };
2728
+ }
2729
+ async function* input(context, name = "-") {
2730
+ context.signal.throwIfAborted();
2731
+ if (name === "-") {
2732
+ yield* readBytes2(context.stdin, context.signal);
2733
+ } else {
2734
+ await assertInputRequirements(context, [name]);
2735
+ const path = pathOf(context, name);
2736
+ const capabilities = await context.fs.capabilitiesFor?.(path, { signal: context.signal }) ?? context.fs.capabilities;
2737
+ if (context.fs.readStream && capabilities.streamingRead !== false) {
2738
+ let emitted = false;
2739
+ let reading = true;
2740
+ try {
2741
+ for await (const chunk of readBytes2(context.fs.readStream(path, { signal: context.signal }), context.signal)) {
2742
+ reading = false;
2743
+ if (chunk.byteLength) emitted = true;
2744
+ yield chunk;
2745
+ reading = true;
2746
+ }
2747
+ return;
2748
+ } catch (error) {
2749
+ context.signal.throwIfAborted();
2750
+ if (!reading || emitted || !(error instanceof FsError) || error.code !== "ENOTSUP") throw error;
2751
+ }
2752
+ }
2753
+ if (capabilities.read === false) throw new FsError("ENOTSUP", { syscall: "readFile", path });
2754
+ yield* readBytes2({
2755
+ async *[Symbol.asyncIterator]() {
2756
+ const bytes = await context.fs.readFile(path, { signal: context.signal, maxBytes: bufferLimit });
2757
+ context.signal.throwIfAborted();
2758
+ if (bytes.byteLength > bufferLimit) throw new FsError("EFBIG", { syscall: "readFile", path });
2759
+ yield bytes;
2760
+ }
2761
+ }, context.signal);
2762
+ }
2763
+ }
2764
+ async function assertInputRequirements(context, names) {
2765
+ const files = names.filter((name) => name !== "-");
2766
+ assertCommandRequirements(context, inputRequirements, [files.length ? "file" : "stdin"]);
2767
+ if (!context.fs.capabilitiesFor) return;
2768
+ for (const name of files) {
2769
+ try {
2770
+ const capabilities = await context.fs.capabilitiesFor(pathOf(context, name), { signal: context.signal });
2771
+ assertCommandRequirements(context, inputRequirements, ["file"], capabilities);
2772
+ } catch (error) {
2773
+ context.signal.throwIfAborted();
2774
+ if (codeOf(error) === "ENOTSUP" || codeOf(error) === "EROFS") throw error;
2775
+ }
2776
+ }
2777
+ }
2778
+ function concatenate(chunks, size = chunks.reduce((sum, chunk) => sum + chunk.length, 0)) {
2779
+ const result = new Uint8Array(size);
2780
+ let offset = 0;
2781
+ for (const chunk of chunks) {
2782
+ result.set(chunk, offset);
2783
+ offset += chunk.length;
2784
+ }
2785
+ return result;
2786
+ }
2787
+ async function* lines(source, separator = 10, admit) {
2788
+ const pending = new RecordBuffer(bufferLimit);
2789
+ try {
2790
+ for await (const chunk of source) {
2791
+ let start = 0;
2792
+ for (let offset = 0; offset < chunk.length; offset++) {
2793
+ if (chunk[offset] !== separator) continue;
2794
+ yield { bytes: pending.finish(admit, chunk, start, offset), terminated: true };
2795
+ start = offset + 1;
2796
+ }
2797
+ pending.append(chunk, start);
2798
+ }
2799
+ if (pending.size) yield { bytes: pending.finish(admit), terminated: false };
2800
+ } finally {
2801
+ pending.clear();
2802
+ }
2803
+ }
2804
+ function emptyInput() {
2805
+ return toByteSource("");
2806
+ }
2807
+ function replaceArgument(source, pattern, replacement) {
2808
+ if (typeof source === "string") return source.split(pattern).join(replacement);
2809
+ const needle = encoder3.encode(pattern);
2810
+ if (!needle.length) throw new UsageError("replacement string cannot be empty");
2811
+ const substituted = encoder3.encode(replacement);
2812
+ const chunks = [];
2813
+ let start = 0;
2814
+ for (let offset = 0; offset <= source.length - needle.length; ) {
2815
+ if (needle.every((byte, index) => source[offset + index] === byte)) {
2816
+ chunks.push(source.subarray(start, offset), substituted);
2817
+ offset += needle.length;
2818
+ start = offset;
2819
+ } else offset++;
2820
+ }
2821
+ chunks.push(source.subarray(start));
2822
+ return concatenate(chunks);
2823
+ }
2824
+ function escapeBytes(text, zeroOctal = false, bareOctal = false) {
2825
+ if (typeof text === "string") {
2826
+ const chunks = [];
2827
+ const control2 = { a: 7, b: 8, e: 27, E: 27, f: 12, n: 10, r: 13, t: 9, v: 11, "\\": 92 };
2828
+ for (let index = 0; index < text.length; ) {
2829
+ if (text[index] !== "\\" || index + 1 === text.length) {
2830
+ const character = String.fromCodePoint(text.codePointAt(index));
2831
+ chunks.push(encoder3.encode(character));
2832
+ index += character.length;
2833
+ continue;
2834
+ }
2835
+ const next = text[index + 1];
2836
+ if (next === "c") return { bytes: concatenate(chunks), stop: true };
2837
+ if (control2[next] !== void 0) {
2838
+ chunks.push(Uint8Array.of(control2[next]));
2839
+ index += 2;
2840
+ continue;
2841
+ }
2842
+ const rest = text.slice(index + 1);
2843
+ const octal = zeroOctal ? (bareOctal ? /^(?:0([0-7]{0,3})|([1-7][0-7]{0,2}))/u : /^0([0-7]{0,3})/u).exec(rest) : /^([0-7]{1,3})/u.exec(rest);
2844
+ if (octal) {
2845
+ chunks.push(Uint8Array.of(parseInt(octal[1] || octal[2] || "0", 8) & 255));
2846
+ index += 1 + octal[0].length;
2847
+ continue;
2848
+ }
2849
+ const hexadecimal = /^x([0-9a-fA-F]{1,2})/u.exec(rest);
2850
+ if (hexadecimal) {
2851
+ chunks.push(Uint8Array.of(parseInt(hexadecimal[1], 16)));
2852
+ index += 1 + hexadecimal[0].length;
2853
+ continue;
2854
+ }
2855
+ chunks.push(encoder3.encode(`\\${next}`));
2856
+ index += 2;
2857
+ }
2858
+ return { bytes: concatenate(chunks), stop: false };
2859
+ }
2860
+ const source = text;
2861
+ const bytes = new Uint8Array(source.length);
2862
+ const control = { 97: 7, 98: 8, 101: 27, 69: 27, 102: 12, 110: 10, 114: 13, 116: 9, 118: 11, 92: 92 };
2863
+ let size = 0;
2864
+ for (let index = 0; index < source.length; ) {
2865
+ if (source[index] !== 92 || index + 1 === source.length) {
2866
+ bytes[size++] = source[index++];
2867
+ continue;
2868
+ }
2869
+ const next = source[index + 1];
2870
+ if (next === 99) return { bytes: bytes.subarray(0, size), stop: true };
2871
+ if (control[next] !== void 0) {
2872
+ bytes[size++] = control[next];
2873
+ index += 2;
2874
+ continue;
2875
+ }
2876
+ if (zeroOctal ? next === 48 || bareOctal && next >= 49 && next <= 55 : next >= 48 && next <= 55) {
2877
+ let offset = index + (zeroOctal && next === 48 ? 2 : 1);
2878
+ const end = Math.min(source.length, offset + 3);
2879
+ let value2 = 0;
2880
+ while (offset < end && source[offset] >= 48 && source[offset] <= 55) value2 = value2 * 8 + source[offset++] - 48;
2881
+ bytes[size++] = value2 & 255;
2882
+ index = offset;
2883
+ continue;
2884
+ }
2885
+ if (next === 120) {
2886
+ let offset = index + 2;
2887
+ const end = Math.min(source.length, offset + 2);
2888
+ let value2 = 0;
2889
+ while (offset < end) {
2890
+ const digit = source[offset];
2891
+ const number = digit >= 48 && digit <= 57 ? digit - 48 : digit >= 65 && digit <= 70 ? digit - 55 : digit >= 97 && digit <= 102 ? digit - 87 : -1;
2892
+ if (number < 0) break;
2893
+ value2 = value2 * 16 + number;
2894
+ offset++;
2895
+ }
2896
+ if (offset > index + 2) {
2897
+ bytes[size++] = value2;
2898
+ index = offset;
2899
+ continue;
2900
+ }
2901
+ }
2902
+ bytes[size++] = 92;
2903
+ bytes[size++] = next;
2904
+ index += 2;
2905
+ }
2906
+ return { bytes: bytes.subarray(0, size), stop: false };
2907
+ }
2908
+
2909
+ // packages/safe-bash/src/commands/structured/limits.ts
2910
+ init_platform();
2911
+
2912
+ // packages/safe-bash/src/commands/structured/numbers.ts
2913
+ init_platform();
2914
+ var Decimal = class {
2915
+ constructor(digits, exponent, negative, text, double) {
2916
+ this.digits = digits;
2917
+ this.exponent = exponent;
2918
+ this.negative = negative;
2919
+ this.text = text;
2920
+ this.double = double;
2921
+ Object.freeze(this);
2922
+ }
2923
+ digits;
2924
+ exponent;
2925
+ negative;
2926
+ text;
2927
+ double;
2928
+ };
2929
+ function isNumber(value2) {
2930
+ return typeof value2 === "number" || value2 instanceof Decimal;
2931
+ }
2932
+ function numberValue(value2) {
2933
+ return typeof value2 === "number" ? value2 : value2.double;
2934
+ }
2935
+ function numericToken(token, budget) {
2936
+ budget.step(Math.ceil(token.length / 32));
2937
+ const end = token.indexOf("\0");
2938
+ const text = end < 0 ? token : token.slice(0, end);
2939
+ if (/^[+-]?s?nan[0-9]*$/iu.test(text)) return new Decimal("0", NaN, false, "null", NaN);
2940
+ if (/^[+-]?inf(?:inity)?$/iu.test(text)) {
2941
+ const negative = text[0] === "-";
2942
+ const value2 = negative ? -Infinity : Infinity;
2943
+ return new Decimal("1", Infinity, negative, numberText(value2), value2);
2944
+ }
2945
+ if (!/^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/u.test(text)) return void 0;
2946
+ return decimalNumber(text[0] === "+" ? text.slice(1) : text, budget);
2947
+ }
2948
+ function increment(digits) {
2949
+ let position = digits.length - 1;
2950
+ while (position >= 0 && digits[position] === "9") position--;
2951
+ return position < 0 ? `1${"0".repeat(digits.length)}` : `${digits.slice(0, position)}${Number(digits[position]) + 1}${"0".repeat(digits.length - position - 1)}`;
2952
+ }
2953
+ function decimalDouble(digits, exponent, negative) {
2954
+ let rounded = digits;
2955
+ if (digits.length > 17) {
2956
+ rounded = digits.slice(0, 17);
2957
+ const next = digits[17];
2958
+ if (next > "5" || next === "5" && (/[1-9]/u.test(digits.slice(18)) || Number(rounded[16]) % 2 !== 0)) rounded = increment(rounded);
2959
+ exponent += digits.length - 17;
2960
+ }
2961
+ return Number(`${negative ? "-" : ""}${rounded}e${exponent}`);
2962
+ }
2963
+ function decimalText(digits, exponent, negative) {
2964
+ const sign = negative ? "-" : "";
2965
+ const adjusted = exponent + digits.length - 1;
2966
+ if (exponent > 0 || adjusted < -6) return `${sign}${digits[0]}${digits.length > 1 ? `.${digits.slice(1)}` : ""}E${adjusted >= 0 ? "+" : ""}${adjusted}`;
2967
+ const point = digits.length + exponent;
2968
+ if (point <= 0) return `${sign}0.${"0".repeat(-point)}${digits}`;
2969
+ return `${sign}${digits.slice(0, point)}${point < digits.length ? `.${digits.slice(point)}` : ""}`;
2970
+ }
2971
+ function decimalNumber(token, budget) {
2972
+ budget.text(token);
2973
+ budget.step(Math.ceil(token.length / 32));
2974
+ const negative = token[0] === "-";
2975
+ const unsigned = negative ? token.slice(1) : token;
2976
+ const marker = unsigned.search(/[eE]/u);
2977
+ const coefficient = marker < 0 ? unsigned : unsigned.slice(0, marker);
2978
+ const point = coefficient.indexOf(".");
2979
+ let exponent = (marker < 0 ? 0 : Number(unsigned.slice(marker + 1))) - (point < 0 ? 0 : coefficient.length - point - 1);
2980
+ let digits = coefficient.replace(".", "").replace(/^0+/u, "") || "0";
2981
+ const minimumExponent = -1147483646;
2982
+ const maximumExponent = 999999999;
2983
+ if (digits === "0") exponent = Math.max(minimumExponent, Math.min(maximumExponent, exponent));
2984
+ else if (exponent + digits.length - 1 > maximumExponent) {
2985
+ const infinity = negative ? -Infinity : Infinity;
2986
+ return new Decimal("1", Infinity, negative, numberText(infinity), infinity);
2987
+ } else if (exponent < minimumExponent) {
2988
+ const retained = digits.length - (minimumExponent - exponent);
2989
+ const roundUp = retained >= 0 && digits[retained] >= "5";
2990
+ digits = retained > 0 ? digits.slice(0, retained) : "0";
2991
+ if (roundUp) digits = increment(digits);
2992
+ exponent = minimumExponent;
2993
+ }
2994
+ const text = decimalText(digits, exponent, negative);
2995
+ budget.text(text);
2996
+ return new Decimal(digits, exponent, negative, text, decimalDouble(digits, exponent, negative));
2997
+ }
2998
+ function compareNumbers(left, right, budget) {
2999
+ if (Number.isNaN(numberValue(left))) return -1;
3000
+ if (Number.isNaN(numberValue(right))) return 1;
3001
+ if (!(left instanceof Decimal) || !(right instanceof Decimal)) {
3002
+ const first = numberValue(left);
3003
+ const second = numberValue(right);
3004
+ return first < second ? -1 : first === second ? 0 : 1;
3005
+ }
3006
+ if (left.digits === "0" && right.digits === "0") return 0;
3007
+ const sign = left.negative ? -1 : 1;
3008
+ if (left.negative !== right.negative) return sign;
3009
+ if (left.digits === "0") return -sign;
3010
+ if (right.digits === "0") return sign;
3011
+ if (left.exponent === Infinity || right.exponent === Infinity) return left.exponent === right.exponent ? 0 : left.exponent === Infinity ? sign : -sign;
3012
+ const magnitude = left.exponent + left.digits.length - right.exponent - right.digits.length;
3013
+ if (magnitude) return Math.sign(magnitude) * sign;
3014
+ const length = Math.max(left.digits.length, right.digits.length);
3015
+ budget.step(Math.ceil(length / 32));
3016
+ for (let index = 0; index < length; index++) {
3017
+ if (index % 1024 === 0) budget.step();
3018
+ const first = left.digits[index] ?? "0";
3019
+ const second = right.digits[index] ?? "0";
3020
+ if (first !== second) return (first < second ? -1 : 1) * sign;
3021
+ }
3022
+ return 0;
3023
+ }
3024
+ function numberText(value2) {
3025
+ if (value2 instanceof Decimal) return value2.text;
3026
+ if (Number.isNaN(value2)) return "null";
3027
+ const bounded = Math.max(-Number.MAX_VALUE, Math.min(Number.MAX_VALUE, value2));
3028
+ const sign = bounded < 0 || Object.is(bounded, -0) ? "-" : "";
3029
+ const [mantissa, power] = Math.abs(bounded).toExponential().split("e");
3030
+ const digits = mantissa.replace(".", "");
3031
+ const exponent = Number(power);
3032
+ const point = exponent + 1;
3033
+ if (point <= -4 || point > digits.length + 15) return `${sign}${mantissa}e${exponent < 0 ? "-" : "+"}${String(Math.abs(exponent)).padStart(2, "0")}`;
3034
+ if (point <= 0) return `${sign}0.${"0".repeat(-point)}${digits}`;
3035
+ return `${sign}${point >= digits.length ? digits.padEnd(point, "0") : `${digits.slice(0, point)}.${digits.slice(point)}`}`;
3036
+ }
3037
+
3038
+ // packages/safe-bash/src/commands/structured/limits.ts
3039
+ var defaultJqLimits = Object.freeze({
3040
+ maxInputBytes: 64 * 1024 * 1024,
3041
+ maxValueBytes: 8 * 1024 * 1024,
3042
+ maxOutputBytes: 16 * 1024 * 1024,
3043
+ maxSourceBytes: 64 * 1024,
3044
+ maxDepth: 128,
3045
+ maxAstDepth: 64,
3046
+ maxSteps: 1e6,
3047
+ maxResults: 1e5,
3048
+ maxCollectionSize: 1e5
3049
+ });
3050
+ var JqError = class extends Error {
3051
+ constructor(message, exitCode = 5) {
3052
+ super(message);
3053
+ this.exitCode = exitCode;
3054
+ }
3055
+ exitCode;
3056
+ };
3057
+ var JqLimitError = class extends JqError {
3058
+ constructor(name) {
3059
+ super(`${name} limit exceeded`);
3060
+ }
3061
+ };
3062
+ function resolveJqLimits(options2 = {}) {
3063
+ const limits = { ...defaultJqLimits, ...options2 };
3064
+ for (const [name, value2] of Object.entries(limits)) {
3065
+ if (!Number.isSafeInteger(value2) || value2 < 1) throw new RangeError(`${name} must be a positive safe integer`);
3066
+ }
3067
+ if (limits.maxDepth > 256 || limits.maxAstDepth > 128) throw new RangeError("maxDepth must be <=256 and maxAstDepth <=128");
3068
+ return Object.freeze(limits);
3069
+ }
3070
+ var Budget = class {
3071
+ constructor(limits, signal) {
3072
+ this.limits = limits;
3073
+ this.signal = signal;
3074
+ }
3075
+ limits;
3076
+ signal;
3077
+ steps = 0;
3078
+ nextYield = 1024;
3079
+ lastYield = monotonicNow();
3080
+ inputBytes = 0;
3081
+ outputBytes = 0;
3082
+ results = 0;
3083
+ inputLocation = { name: "<unknown>", line: 0, complete: true };
3084
+ step(count = 1) {
3085
+ this.signal.throwIfAborted();
3086
+ this.steps += count;
3087
+ if (this.steps > this.limits.maxSteps) throw new JqLimitError("maxSteps");
3088
+ }
3089
+ async tick(count = 1) {
3090
+ this.step(count);
3091
+ if (this.steps >= this.nextYield || monotonicNow() - this.lastYield >= 25) {
3092
+ await yieldTurn(this.signal);
3093
+ this.signal.throwIfAborted();
3094
+ this.nextYield = this.steps + 1024;
3095
+ this.lastYield = monotonicNow();
3096
+ }
3097
+ }
3098
+ collection(size) {
3099
+ if (size > this.limits.maxCollectionSize) throw new JqLimitError("maxCollectionSize");
3100
+ }
3101
+ text(text) {
3102
+ if (text.length > this.limits.maxValueBytes || import_buffer.Buffer.byteLength(text) > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
3103
+ }
3104
+ value(value2) {
3105
+ let bytes = 0;
3106
+ const visit = (current, depth) => {
3107
+ this.step();
3108
+ if (depth > this.limits.maxDepth) throw new JqLimitError("maxDepth");
3109
+ if (current !== null && typeof current === "object" && !(current instanceof Decimal)) {
3110
+ if (depth + 1 > this.limits.maxDepth) throw new JqLimitError("maxDepth");
3111
+ const keys = Array.isArray(current) ? Object.keys(current) : objectKeys(current);
3112
+ this.collection(keys.length);
3113
+ bytes += 2 + Math.max(0, keys.length - 1);
3114
+ for (const key of keys) {
3115
+ if (!Array.isArray(current)) {
3116
+ this.text(key);
3117
+ bytes += import_buffer.Buffer.byteLength(JSON.stringify(key)) + 1;
3118
+ }
3119
+ if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
3120
+ visit(current[key], depth + 1);
3121
+ }
3122
+ } else {
3123
+ if (typeof current === "string") {
3124
+ this.step(current.length);
3125
+ this.text(current);
3126
+ }
3127
+ bytes += import_buffer.Buffer.byteLength(scalarJson(current, this));
3128
+ }
3129
+ if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
3130
+ };
3131
+ visit(value2, 0);
3132
+ return bytes;
3133
+ }
3134
+ };
3135
+ var keyOrders = /* @__PURE__ */ new WeakMap();
3136
+ function object() {
3137
+ const result = /* @__PURE__ */ Object.create(null);
3138
+ keyOrders.set(result, []);
3139
+ return result;
3140
+ }
3141
+ function objectKeys(value2) {
3142
+ return keyOrders.get(value2)?.slice() ?? Object.keys(value2);
3143
+ }
3144
+ function* objectKeyIterator(value2) {
3145
+ const keys = keyOrders.get(value2);
3146
+ if (keys) yield* keys;
3147
+ else for (const key in value2) if (Object.hasOwn(value2, key)) yield key;
3148
+ }
3149
+ function objectSize(value2) {
3150
+ return keyOrders.get(value2)?.length ?? Object.keys(value2).length;
3151
+ }
3152
+ function put(value2, key, item) {
3153
+ if (!Object.hasOwn(value2, key)) keyOrders.get(value2)?.push(key);
3154
+ value2[key] = item;
3155
+ }
3156
+ function remove(value2, key) {
3157
+ delete value2[key];
3158
+ const keys = keyOrders.get(value2);
3159
+ if (keys) {
3160
+ const index = keys.indexOf(key);
3161
+ if (index >= 0) keys.splice(index, 1);
3162
+ }
3163
+ }
3164
+ function copyObject(...sources) {
3165
+ const result = object();
3166
+ for (const source of sources) if (source) for (const key of objectKeys(source)) put(result, key, source[key]);
3167
+ return result;
3168
+ }
3169
+ function wellFormed(text) {
3170
+ for (let index = 0; index < text.length; index++) {
3171
+ const code = text.charCodeAt(index);
3172
+ if (code >= 55296 && code <= 56319) {
3173
+ const next = text.charCodeAt(++index);
3174
+ if (!(next >= 56320 && next <= 57343)) return false;
3175
+ } else if (code >= 56320 && code <= 57343) return false;
3176
+ }
3177
+ return true;
3178
+ }
3179
+ function isObject(value2) {
3180
+ return value2 !== null && typeof value2 === "object" && !Array.isArray(value2) && !(value2 instanceof Decimal);
3181
+ }
3182
+ function truth(value2) {
3183
+ return value2 !== null && value2 !== false;
3184
+ }
3185
+ function scalarJson(value2, budget) {
3186
+ if (value2 instanceof Decimal) budget.step(Math.ceil(value2.text.length / 32));
3187
+ return isNumber(value2) ? numberText(value2) : JSON.stringify(value2);
3188
+ }
3189
+ async function interruptible(operation, signal) {
3190
+ signal.throwIfAborted();
3191
+ return new Promise((resolve, reject) => {
3192
+ const aborted = () => {
3193
+ signal.removeEventListener("abort", aborted);
3194
+ reject(signal.reason);
3195
+ };
3196
+ signal.addEventListener("abort", aborted, { once: true });
3197
+ try {
3198
+ Promise.resolve(operation()).then(
3199
+ (result) => {
3200
+ signal.removeEventListener("abort", aborted);
3201
+ resolve(result);
3202
+ },
3203
+ (error) => {
3204
+ signal.removeEventListener("abort", aborted);
3205
+ reject(error);
3206
+ }
3207
+ );
3208
+ } catch (error) {
3209
+ signal.removeEventListener("abort", aborted);
3210
+ reject(error);
3211
+ }
3212
+ });
3213
+ }
3214
+
3215
+ // packages/safe-bash/src/commands/xml/limits.ts
3216
+ init_platform();
3217
+ var defaultXmlQueryLimits = Object.freeze({
3218
+ maxInputBytes: 8 * 1024 * 1024,
3219
+ maxOutputBytes: 8 * 1024 * 1024,
3220
+ maxSourceBytes: 64 * 1024,
3221
+ maxDepth: 64,
3222
+ maxNodes: 1e5,
3223
+ maxAttributes: 1e4,
3224
+ maxAttributesPerElement: 128,
3225
+ maxNamespaces: 256,
3226
+ maxSteps: 1e6,
3227
+ maxResults: 1e5
3228
+ });
3229
+ var XmlQueryError = class extends Error {
3230
+ constructor(message, status) {
3231
+ super(message);
3232
+ this.status = status;
3233
+ }
3234
+ status;
3235
+ };
3236
+ var XmlQueryLimitError = class extends XmlQueryError {
3237
+ constructor(name) {
3238
+ super(`${name} limit exceeded`, 5);
3239
+ }
3240
+ };
3241
+ function resolveXmlQueryLimits(options2 = {}) {
3242
+ const limits = { ...defaultXmlQueryLimits, ...options2 };
3243
+ for (const [name, value2] of Object.entries(limits)) {
3244
+ if (!Object.hasOwn(defaultXmlQueryLimits, name) || !Number.isSafeInteger(value2) || value2 < 1) {
3245
+ throw new RangeError(`${name} must be a positive safe integer XML limit`);
3246
+ }
3247
+ }
3248
+ if (limits.maxDepth > 256) throw new RangeError("maxDepth must be <=256");
3249
+ return Object.freeze(limits);
3250
+ }
3251
+ var XmlBudget = class {
3252
+ constructor(limits, signal) {
3253
+ this.limits = limits;
3254
+ this.signal = signal;
3255
+ }
3256
+ limits;
3257
+ signal;
3258
+ steps = 0;
3259
+ checkpoint = 0;
3260
+ outputBytes = 0;
3261
+ async tick(work = 1) {
3262
+ this.signal.throwIfAborted();
3263
+ this.steps += work;
3264
+ if (this.steps > this.limits.maxSteps) throw new XmlQueryLimitError("maxSteps");
3265
+ this.checkpoint += work;
3266
+ if (this.checkpoint >= 1024) {
3267
+ this.checkpoint = 0;
3268
+ await yieldTurn(this.signal);
3269
+ }
3270
+ }
3271
+ results(size) {
3272
+ if (size > this.limits.maxResults) throw new XmlQueryLimitError("maxResults");
3273
+ }
3274
+ };
3275
+
3276
+ // packages/safe-bash/src/commands/xml/query.ts
3277
+ init_platform();
3278
+ var nameStart = (character) => character >= "a" && character <= "z" || character >= "A" && character <= "Z" || character === "_";
3279
+ var namePart = (character) => nameStart(character) || character >= "0" && character <= "9" || character === "-" || character === ".";
3280
+ async function parseQuery(source, budget) {
3281
+ if (source.length > budget.limits.maxSourceBytes || import_buffer.Buffer.byteLength(source) > budget.limits.maxSourceBytes) throw new XmlQueryLimitError("maxSourceBytes");
3282
+ for (let offset = 0; offset < source.length; offset += 256) await budget.tick(Math.min(256, source.length - offset));
3283
+ let at = 0;
3284
+ const fail = () => {
3285
+ throw new XmlQueryError(`unsupported XPath syntax at offset ${at}`, 10);
3286
+ };
3287
+ const space = () => {
3288
+ while (source[at] === " " || source[at] === " " || source[at] === "\r" || source[at] === "\n") at++;
3289
+ };
3290
+ const expect = (value2) => {
3291
+ space();
3292
+ if (!source.startsWith(value2, at)) fail();
3293
+ at += value2.length;
3294
+ };
3295
+ const name = () => {
3296
+ space();
3297
+ const start = at;
3298
+ if (!nameStart(source[at] ?? "")) fail();
3299
+ while (namePart(source[at] ?? "")) at++;
3300
+ if (source[at] === ":") fail();
3301
+ return source.slice(start, at);
3302
+ };
3303
+ space();
3304
+ let scalar;
3305
+ if (source[at] !== "/") {
3306
+ const value2 = name();
3307
+ if (value2 !== "string" && value2 !== "count" && value2 !== "boolean") fail();
3308
+ scalar = value2;
3309
+ expect("(");
3310
+ }
3311
+ const steps = [];
3312
+ space();
3313
+ while (source[at] === "/") {
3314
+ at++;
3315
+ const descendant = source[at] === "/";
3316
+ if (descendant) at++;
3317
+ space();
3318
+ let kind = "element";
3319
+ if (source[at] === "@") {
3320
+ kind = "attribute";
3321
+ at++;
3322
+ }
3323
+ let selected;
3324
+ if (source[at] === "*") {
3325
+ selected = "*";
3326
+ at++;
3327
+ } else {
3328
+ selected = name();
3329
+ space();
3330
+ if (source[at] === "(") {
3331
+ if (selected !== "text" || kind !== "element") fail();
3332
+ expect("(");
3333
+ expect(")");
3334
+ kind = "text";
3335
+ }
3336
+ }
3337
+ const predicates = [];
3338
+ space();
3339
+ while (source[at] === "[") {
3340
+ at++;
3341
+ space();
3342
+ if (source[at] === "@") {
3343
+ at++;
3344
+ const attribute = name();
3345
+ expect("=");
3346
+ space();
3347
+ const quote = source[at++];
3348
+ if (quote !== "'" && quote !== '"') fail();
3349
+ const start = at;
3350
+ while (at < source.length && source[at] !== quote) at++;
3351
+ if (at === source.length) fail();
3352
+ predicates.push({ kind: "attribute", name: attribute, value: source.slice(start, at++) });
3353
+ } else {
3354
+ const start = at;
3355
+ while ((source[at] ?? "") >= "0" && (source[at] ?? "") <= "9") at++;
3356
+ const value2 = Number(source.slice(start, at));
3357
+ if (start === at || !Number.isSafeInteger(value2) || value2 < 1) fail();
3358
+ predicates.push({ kind: "position", value: value2 });
3359
+ }
3360
+ expect("]");
3361
+ space();
3362
+ }
3363
+ steps.push({ descendant, kind, name: selected, predicates });
3364
+ if (kind !== "element" && source[at] === "/") fail();
3365
+ await budget.tick();
3366
+ }
3367
+ if (!steps.length) fail();
3368
+ if (scalar !== void 0) expect(")");
3369
+ space();
3370
+ if (at !== source.length) fail();
3371
+ return { scalar, steps };
3372
+ }
3373
+
3374
+ // packages/safe-bash/src/commands/xml/evaluate.ts
3375
+ init_platform();
3376
+ var xmlns = "http://www.w3.org/2000/xmlns/";
3377
+ async function indexTree(root, budget) {
3378
+ const document = { kind: "document", children: [] };
3379
+ const order = [document];
3380
+ const pending = [{ parent: document, content: root }];
3381
+ while (pending.length) {
3382
+ await budget.tick();
3383
+ const { parent, content } = pending.pop();
3384
+ if (content.kind === "element") {
3385
+ const node = { kind: "element", value: content, children: [], attributes: [] };
3386
+ parent.children.push(node);
3387
+ order.push(node);
3388
+ for (const attribute of content.attributes) {
3389
+ await budget.tick();
3390
+ if (attribute.namespace === xmlns) continue;
3391
+ const selected = { kind: "attribute", value: attribute };
3392
+ node.attributes.push(selected);
3393
+ order.push(selected);
3394
+ }
3395
+ for (let index = content.content.length - 1; index >= 0; index--) {
3396
+ await budget.tick();
3397
+ pending.push({ parent: node, content: content.content[index] });
3398
+ }
3399
+ } else {
3400
+ const node = { kind: content.kind, value: content };
3401
+ parent.children.push(node);
3402
+ order.push(node);
3403
+ }
3404
+ }
3405
+ return { document, order };
3406
+ }
3407
+ function matches(node, step) {
3408
+ if (step.kind === "text") return node.kind === "text" || node.kind === "cdata";
3409
+ if (node.kind !== step.kind) return false;
3410
+ if (node.kind === "element" || node.kind === "attribute") {
3411
+ return step.name === "*" || node.value.namespace === "" && node.value.localName === step.name;
3412
+ }
3413
+ return false;
3414
+ }
3415
+ async function evaluate(query, root, budget) {
3416
+ const { document, order } = await indexTree(root, budget);
3417
+ let contexts = [document];
3418
+ for (const step of query.steps) {
3419
+ const parents = /* @__PURE__ */ new Set();
3420
+ const pending = [...contexts];
3421
+ while (pending.length) {
3422
+ await budget.tick();
3423
+ const node = pending.pop();
3424
+ if (parents.has(node)) continue;
3425
+ parents.add(node);
3426
+ if (step.descendant && (node.kind === "document" || node.kind === "element")) {
3427
+ for (const child of node.children) {
3428
+ await budget.tick();
3429
+ pending.push(child);
3430
+ }
3431
+ }
3432
+ }
3433
+ const selected = /* @__PURE__ */ new Set();
3434
+ for (const parent of parents) {
3435
+ await budget.tick();
3436
+ const candidates = step.kind === "attribute" ? parent.kind === "element" ? parent.attributes : [] : parent.kind === "element" || parent.kind === "document" ? parent.children : [];
3437
+ let matched = [];
3438
+ for (const candidate of candidates) {
3439
+ await budget.tick();
3440
+ if (matches(candidate, step)) matched.push(candidate);
3441
+ }
3442
+ for (const predicate of step.predicates) {
3443
+ await budget.tick();
3444
+ if (predicate.kind === "position") matched = matched[predicate.value - 1] ? [matched[predicate.value - 1]] : [];
3445
+ else {
3446
+ const filtered = [];
3447
+ for (const candidate of matched) {
3448
+ await budget.tick();
3449
+ if (candidate.kind !== "element") continue;
3450
+ for (const attribute of candidate.attributes) {
3451
+ await budget.tick(attribute.value.value.length + 1);
3452
+ if (attribute.value.namespace === "" && attribute.value.localName === predicate.name && attribute.value.value === predicate.value) {
3453
+ filtered.push(candidate);
3454
+ break;
3455
+ }
3456
+ }
3457
+ }
3458
+ matched = filtered;
3459
+ }
3460
+ }
3461
+ for (const node of matched) {
3462
+ await budget.tick();
3463
+ if (!selected.has(node)) {
3464
+ budget.results(selected.size + 1);
3465
+ selected.add(node);
3466
+ }
3467
+ }
3468
+ }
3469
+ contexts = [];
3470
+ for (const node of order) {
3471
+ await budget.tick();
3472
+ if (selected.has(node)) contexts.push(node);
3473
+ }
3474
+ }
3475
+ return contexts;
3476
+ }
3477
+ async function* stringValue(node, budget) {
3478
+ if (node === void 0) return;
3479
+ if (node.kind === "attribute") {
3480
+ yield node.value.value;
3481
+ return;
3482
+ }
3483
+ const pending = [node];
3484
+ while (pending.length) {
3485
+ await budget.tick();
3486
+ const current = pending.pop();
3487
+ if (current.kind === "element" || current.kind === "document") {
3488
+ for (let index = current.children.length - 1; index >= 0; index--) {
3489
+ await budget.tick();
3490
+ pending.push(current.children[index]);
3491
+ }
3492
+ } else if (current.kind === "text" || current.kind === "cdata") yield current.value.text;
3493
+ }
3494
+ }
3495
+ async function* serialize(node, budget) {
3496
+ if (node.kind === "attribute") {
3497
+ yield ` ${node.value.name}="`;
3498
+ yield* escape(node.value.value, true, budget);
3499
+ yield '"';
3500
+ return;
3501
+ }
3502
+ if (node.kind === "document") return;
3503
+ const pending = [node.value];
3504
+ while (pending.length) {
3505
+ await budget.tick();
3506
+ const current = pending.pop();
3507
+ if (typeof current === "string") {
3508
+ yield current;
3509
+ continue;
3510
+ }
3511
+ if (current.kind === "element") {
3512
+ yield `<${current.name}`;
3513
+ for (const attribute of current.attributes) {
3514
+ await budget.tick();
3515
+ yield ` ${attribute.name}="`;
3516
+ yield* escape(attribute.value, true, budget);
3517
+ yield '"';
3518
+ }
3519
+ if (!current.content.length) yield "/>";
3520
+ else {
3521
+ yield ">";
3522
+ pending.push(`</${current.name}>`);
3523
+ for (let index = current.content.length - 1; index >= 0; index--) {
3524
+ await budget.tick();
3525
+ pending.push(current.content[index]);
3526
+ }
3527
+ }
3528
+ } else if (current.kind === "text") yield* escape(current.text, false, budget);
3529
+ else if (current.kind === "cdata") {
3530
+ yield "<![CDATA[";
3531
+ yield current.text;
3532
+ yield "]]>";
3533
+ } else if (current.kind === "comment") {
3534
+ yield "<!--";
3535
+ yield current.text;
3536
+ yield "-->";
3537
+ } else if (current.kind === "processing-instruction") {
3538
+ yield `<?${current.target}`;
3539
+ if (current.text) {
3540
+ yield " ";
3541
+ yield current.text;
3542
+ }
3543
+ yield "?>";
3544
+ }
3545
+ }
3546
+ }
3547
+ async function* escape(value2, attribute, budget) {
3548
+ let part = "";
3549
+ for (const character of value2) {
3550
+ await budget.tick();
3551
+ part += character === "&" ? "&amp;" : character === "<" ? "&lt;" : character === ">" ? "&gt;" : attribute && character === '"' ? "&quot;" : attribute && character === "\n" ? "&#10;" : character === "\r" ? "&#13;" : attribute && character === " " ? "&#9;" : character;
3552
+ if (part.length >= 4096) {
3553
+ yield part;
3554
+ part = "";
3555
+ }
3556
+ }
3557
+ if (part) yield part;
3558
+ }
3559
+
3560
+ // packages/safe-bash/src/commands/xml/index.ts
3561
+ async function argumentsFor(context, budget) {
3562
+ if (context.args.length > 5) throw new XmlQueryError("expected one XML input FILE or -", 2);
3563
+ const carrier = getCommandArguments(context);
3564
+ const args = carrier.args;
3565
+ async function admitted(position, limit) {
3566
+ const text = args[position];
3567
+ if (text.length > budget.limits[limit]) throw new XmlQueryLimitError(limit);
3568
+ const size = shellValueByteLength(carrier.values[position]);
3569
+ if (size > budget.limits[limit]) throw new XmlQueryLimitError(limit);
3570
+ for (let offset = 0; offset < size; offset += 1024) await budget.tick(Math.min(1024, size - offset));
3571
+ let decoded;
3572
+ try {
3573
+ decoded = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(carrier.bytes(position));
3574
+ } catch {
3575
+ throw new XmlQueryError("XPath and filenames require valid UTF-8", 2);
3576
+ }
3577
+ if (decoded !== text) throw new XmlQueryError("XPath and filenames require lossless UTF-8", 2);
3578
+ return decoded;
3579
+ }
3580
+ let index = 0;
3581
+ if (context.command === "xmllint") {
3582
+ if (args[index++] !== "--xpath") throw new XmlQueryError("expected --xpath QUERY [FILE|-]", 2);
3583
+ }
3584
+ if (args[index] === "--") index++;
3585
+ const sourceIndex = index++;
3586
+ const source = args[sourceIndex];
3587
+ if (source === void 0 || source.startsWith("-")) throw new XmlQueryError("expected QUERY [FILE|-]", 2);
3588
+ if (args[index] === "--") index++;
3589
+ const fileIndex = index++;
3590
+ const file = args[fileIndex];
3591
+ if (index < args.length || file !== void 0 && file.startsWith("-") && file !== "-") throw new XmlQueryError("expected one XML input FILE or -", 2);
3592
+ const query = await parseQuery(await admitted(sourceIndex, "maxSourceBytes"), budget);
3593
+ return { query, file: file === void 0 ? void 0 : await admitted(fileIndex, "maxInputBytes") };
3594
+ }
3595
+ async function input2(context, file, budget) {
3596
+ let source = context.stdin;
3597
+ if (file !== void 0 && file !== "-") {
3598
+ const path = pathOf(context, file);
3599
+ const capabilities = context.fs.capabilitiesFor ? await interruptible(() => context.fs.capabilitiesFor(path, { signal: context.signal }), context.signal) : context.fs.capabilities;
3600
+ context.signal.throwIfAborted();
3601
+ if (context.fs.readStream && capabilities.streamingRead !== false) source = context.fs.readStream(path, { signal: context.signal });
3602
+ else {
3603
+ try {
3604
+ source = toByteSource(await interruptible(() => context.fs.readFile(path, { signal: context.signal, maxBytes: budget.limits.maxInputBytes }), context.signal));
3605
+ } catch (error) {
3606
+ context.signal.throwIfAborted();
3607
+ if (error instanceof FsError && error.code === "EFBIG") throw new XmlQueryLimitError("maxInputBytes");
3608
+ throw error;
3609
+ }
3610
+ }
3611
+ }
3612
+ const parts2 = [];
3613
+ let size = 0;
3614
+ const decoder3 = new TextDecoder("utf-8", { fatal: true });
3615
+ for await (const chunk of readBytes2(source, context.signal)) {
3616
+ await budget.tick();
3617
+ size += chunk.byteLength;
3618
+ if (size > budget.limits.maxInputBytes) throw new XmlQueryLimitError("maxInputBytes");
3619
+ for (let offset = 0; offset < chunk.length; offset += 4096) {
3620
+ await budget.tick(Math.min(4096, chunk.length - offset));
3621
+ try {
3622
+ parts2.push(decoder3.decode(chunk.subarray(offset, offset + 4096), { stream: true }));
3623
+ } catch {
3624
+ throw new XmlQueryError("XML input must be UTF-8", 1);
3625
+ }
3626
+ }
3627
+ }
3628
+ try {
3629
+ parts2.push(decoder3.decode());
3630
+ } catch {
3631
+ throw new XmlQueryError("XML input must be UTF-8", 1);
3632
+ }
3633
+ return parts2.join("");
3634
+ }
3635
+ async function execute(context, limits) {
3636
+ const budget = new XmlBudget(limits, context.signal);
3637
+ let outputFailed = false;
3638
+ try {
3639
+ const options2 = await argumentsFor(context, budget);
3640
+ const source = await input2(context, options2.file, budget);
3641
+ const parser = parseXmlSteps(source, { ...limits, maxContentNodes: limits.maxNodes, expectedEncoding: "UTF-8" });
3642
+ let parsed = parser.next();
3643
+ try {
3644
+ while (!parsed.done) {
3645
+ await budget.tick(parsed.value);
3646
+ parsed = parser.next();
3647
+ }
3648
+ } finally {
3649
+ if (!parsed.done) parser.return(void 0);
3650
+ }
3651
+ const nodes = await evaluate(options2.query, parsed.value, budget);
3652
+ async function write(part) {
3653
+ for (let offset = 0; offset < part.length; ) {
3654
+ let end = Math.min(offset + 4096, part.length);
3655
+ if (end < part.length && part.charCodeAt(end - 1) >= 55296 && part.charCodeAt(end - 1) <= 56319) end--;
3656
+ await budget.tick(end - offset);
3657
+ const slice = part.slice(offset, end);
3658
+ const size = import_buffer.Buffer.byteLength(slice);
3659
+ if (size > limits.maxOutputBytes - budget.outputBytes) throw new XmlQueryLimitError("maxOutputBytes");
3660
+ budget.outputBytes += size;
3661
+ try {
3662
+ await writeBytes(context.stdout, import_buffer.Buffer.from(slice), context.signal);
3663
+ } catch (error) {
3664
+ outputFailed = true;
3665
+ throw error;
3666
+ }
3667
+ offset = end;
3668
+ }
3669
+ }
3670
+ if (options2.query.scalar === "count") await write(String(nodes.length));
3671
+ else if (options2.query.scalar === "boolean") await write(nodes.length ? "true" : "false");
3672
+ else if (options2.query.scalar === "string") {
3673
+ for await (const part of stringValue(nodes[0], budget)) await write(part);
3674
+ } else {
3675
+ if (!nodes.length) throw new XmlQueryError("XPath set is empty", 11);
3676
+ for (const node of nodes) {
3677
+ for await (const part of serialize(node, budget)) await write(part);
3678
+ await write("\n");
3679
+ }
3680
+ return { exitCode: 0 };
3681
+ }
3682
+ await write("\n");
3683
+ return { exitCode: 0 };
3684
+ } catch (error) {
3685
+ context.signal.throwIfAborted();
3686
+ if (outputFailed || error instanceof FsError && error.code === "EPIPE") throw error;
3687
+ const status = error instanceof XmlQueryError ? error.status : error instanceof XmlLimitError ? 5 : error instanceof SyntaxError || error instanceof FsError ? 1 : void 0;
3688
+ if (status === void 0) throw error;
3689
+ const message = error instanceof Error ? error.message.slice(0, 1e3) : "XML query failed";
3690
+ await writeDiagnostic(context.stderr, `${context.command}: ${message}
3691
+ `, context.signal);
3692
+ return { exitCode: status };
3693
+ }
3694
+ }
3695
+ function createXmlCommands(options2 = {}) {
3696
+ const limits = resolveXmlQueryLimits(options2.limits);
3697
+ return ["xq", "xmllint"].map((name) => ({ name, execute: (context) => execute(context, limits) }));
3698
+ }
3699
+ function xmlCommands(options2 = {}) {
3700
+ const definitions = createXmlCommands(options2);
3701
+ const replace = options2.replace ?? false;
3702
+ return { name: "xml-commands", setup(host) {
3703
+ if (!replace) for (const definition of definitions) {
3704
+ if (host.commands.has(definition.name)) throw new Error(`Command already registered: ${definition.name}`);
3705
+ }
3706
+ for (const definition of definitions) host.commands.register(definition, { replace });
3707
+ } };
3708
+ }
3709
+
3710
+ export {
3711
+ import_buffer,
3712
+ init_platform,
3713
+ shellValueFromBytes,
3714
+ shellValueText,
3715
+ shellValueByteLength,
3716
+ shellValueRetainedBytes,
3717
+ shellValueBytes,
3718
+ concatShellValues,
3719
+ CommandArgumentIdentityError,
3720
+ createCommandArguments,
3721
+ getCommandArguments,
3722
+ CommandRegistry,
3723
+ validateExitCode,
3724
+ isErrnoCode,
3725
+ isFsError,
3726
+ toFsError,
3727
+ FsError,
3728
+ evaluateCommandSupport,
3729
+ assertCommandRequirements,
3730
+ outputFailure,
3731
+ createBytePipe,
3732
+ writeText,
3733
+ writeBytes,
3734
+ pipeBytes,
3735
+ collectText,
3736
+ collectBytes2 as collectBytes,
3737
+ readBytes2 as readBytes,
3738
+ toByteSource,
3739
+ PublicDiagnostic,
3740
+ publicDiagnosticMessage,
3741
+ monotonicNow,
3742
+ registerYieldCheckpoint,
3743
+ scheduleTurn,
3744
+ cancelTurn,
3745
+ yieldTurn,
3746
+ validatePath,
3747
+ resolvePath,
3748
+ relativePath,
3749
+ isPathWithin,
3750
+ basename,
3751
+ dirname,
3752
+ joinPath,
3753
+ isAbsolutePath,
3754
+ escapeText,
3755
+ writeDiagnostic,
3756
+ inputRequirements,
3757
+ textOutputRequirements,
3758
+ pwdRequirements,
3759
+ predicateRequirements,
3760
+ RecordBuffer,
3761
+ encoder3 as encoder,
3762
+ decoder2 as decoder,
3763
+ bufferLimit,
3764
+ UsageError,
3765
+ options,
3766
+ value,
3767
+ integer,
3768
+ requireOperands,
3769
+ pathOf,
3770
+ codeOf,
3771
+ output,
3772
+ diagnostic,
3773
+ define,
3774
+ eachOperand,
3775
+ input,
3776
+ assertInputRequirements,
3777
+ concatenate,
3778
+ lines,
3779
+ emptyInput,
3780
+ replaceArgument,
3781
+ escapeBytes,
3782
+ isNumber,
3783
+ numberValue,
3784
+ numericToken,
3785
+ decimalNumber,
3786
+ compareNumbers,
3787
+ defaultJqLimits,
3788
+ JqError,
3789
+ JqLimitError,
3790
+ resolveJqLimits,
3791
+ Budget,
3792
+ object,
3793
+ objectKeys,
3794
+ objectKeyIterator,
3795
+ objectSize,
3796
+ put,
3797
+ remove,
3798
+ copyObject,
3799
+ wellFormed,
3800
+ isObject,
3801
+ truth,
3802
+ scalarJson,
3803
+ interruptible,
3804
+ defaultXmlQueryLimits,
3805
+ createXmlCommands,
3806
+ xmlCommands
3807
+ };
3808
+ /*! Bundled license information:
3809
+
3810
+ ieee754/index.js:
3811
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
3812
+
3813
+ buffer/index.js:
3814
+ (*!
3815
+ * The buffer module from node.js, for the browser.
3816
+ *
3817
+ * @author Feross Aboukhadijeh <https://feross.org>
3818
+ * @license MIT
3819
+ *)
3820
+ */
3821
+ //# sourceMappingURL=chunk-3ISDVRIM.js.map