@cloudflare/deploy-helpers 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import { __commonJS, __name, __require, __toESM, fetchListResult, logger, fetchResult, confirm, fetchPagedListResult, prompt, isNonInteractiveOrCI } from './chunk-NAAB7FBS.mjs';
2
2
  export { initDeployHelpersContext } from './chunk-NAAB7FBS.mjs';
3
+ import * as path3 from 'node:path';
4
+ import path3__default, { resolve, isAbsolute, dirname, join, extname, sep } from 'node:path';
5
+ import fs2, { readFileSync, statSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
6
+ import { AsyncLocalStorage } from 'node:async_hooks';
3
7
  import * as z from 'zod';
4
8
  import { z as z$1 } from 'zod';
5
- import { AsyncLocalStorage } from 'node:async_hooks';
6
9
  import assert6 from 'node:assert';
7
- import { readFileSync, mkdirSync, writeFileSync } from 'node:fs';
8
- import * as path from 'node:path';
9
- import path__default, { resolve, extname, isAbsolute, sep } from 'node:path';
10
10
  import url, { URLSearchParams as URLSearchParams$1 } from 'node:url';
11
11
  import * as cli from '@cloudflare/cli-shared-helpers';
12
12
  import { cancel } from '@cloudflare/cli-shared-helpers';
13
- import { getEnvironmentVariableFactory, getHostFromRoute, retryOnAPIFailure, UserError, ParseError, getComplianceRegionSubdomain, configFileName, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, APIError, INHERIT_SYMBOL, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getWranglerTmpDir, getCIMatchTag, FatalError, formatConfigSnippet, readFileSync as readFileSync$1, parseJSON, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever as assertNever$1, experimental_patchConfig, getTodaysCompatDate, getDockerPath, parseNonHyphenedUuid, getWorkersCIBranchName } from '@cloudflare/workers-utils';
13
+ import { getEnvironmentVariableFactory, getHostFromRoute, retryOnAPIFailure, UserError as UserError$1, ParseError as ParseError$1, getComplianceRegionSubdomain, configFileName as configFileName$1, formatTime, getSubdomainMixedStateCheckDisabled, LOGGER_LEVELS, APIError, INHERIT_SYMBOL, COMPLIANCE_REGION_CONFIG_UNKNOWN, constructWranglerConfig, SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX, getWranglerTmpDir, getCIMatchTag, FatalError as FatalError$1, formatConfigSnippet as formatConfigSnippet$1, readFileSync as readFileSync$2, parseJSON as parseJSON$1, getBindingTypeFriendlyName, getBindingLocalSupport, assertNever as assertNever$1, experimental_patchConfig, getTodaysCompatDate, getDockerPath, parseNonHyphenedUuid as parseNonHyphenedUuid$1, getWorkersCIBranchName } from '@cloudflare/workers-utils';
14
14
  import { spawnSync, execSync, spawn } from 'node:child_process';
15
15
  import { FormData, Response } from 'undici';
16
16
  import chalk5 from 'chalk';
@@ -24,7 +24,7 @@ import { brandColor, white, gray, dim, blue } from '@cloudflare/cli-shared-helpe
24
24
  import { inputPrompt, leftT } from '@cloudflare/cli-shared-helpers/interactive';
25
25
  import { sync } from 'command-exists';
26
26
  import readline from 'node:readline';
27
- import { parse } from 'dotenv';
27
+ import { parse as parse$1 } from 'dotenv';
28
28
  import { stripVTControlCharacters } from 'node:util';
29
29
  import { getFreshSourceMapSupport, getNodeCompat } from 'miniflare';
30
30
  import { createHash } from 'node:crypto';
@@ -256,17 +256,17 @@ var require_ignore = __commonJS({
256
256
  var throwError = /* @__PURE__ */ __name((message, Ctor) => {
257
257
  throw new Ctor(message);
258
258
  }, "throwError");
259
- var checkPath = /* @__PURE__ */ __name((path8, originalPath, doThrow) => {
260
- if (!isString(path8)) {
259
+ var checkPath = /* @__PURE__ */ __name((path9, originalPath, doThrow) => {
260
+ if (!isString(path9)) {
261
261
  return doThrow(
262
262
  `path must be a string, but got \`${originalPath}\``,
263
263
  TypeError
264
264
  );
265
265
  }
266
- if (!path8) {
266
+ if (!path9) {
267
267
  return doThrow(`path must not be empty`, TypeError);
268
268
  }
269
- if (checkPath.isNotRelative(path8)) {
269
+ if (checkPath.isNotRelative(path9)) {
270
270
  const r = "`path.relative()`d";
271
271
  return doThrow(
272
272
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -275,7 +275,7 @@ var require_ignore = __commonJS({
275
275
  }
276
276
  return true;
277
277
  }, "checkPath");
278
- var isNotRelative = /* @__PURE__ */ __name((path8) => REGEX_TEST_INVALID_PATH.test(path8), "isNotRelative");
278
+ var isNotRelative = /* @__PURE__ */ __name((path9) => REGEX_TEST_INVALID_PATH.test(path9), "isNotRelative");
279
279
  checkPath.isNotRelative = isNotRelative;
280
280
  checkPath.convert = (p) => p;
281
281
  var Ignore = class {
@@ -337,7 +337,7 @@ var require_ignore = __commonJS({
337
337
  // setting `checkUnignored` to `false` could reduce additional
338
338
  // path matching.
339
339
  // @returns {TestResult} true if a file is ignored
340
- _testOne(path8, checkUnignored) {
340
+ _testOne(path9, checkUnignored) {
341
341
  let ignored = false;
342
342
  let unignored = false;
343
343
  this._rules.forEach((rule) => {
@@ -345,7 +345,7 @@ var require_ignore = __commonJS({
345
345
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
346
346
  return;
347
347
  }
348
- const matched = rule.regex.test(path8);
348
+ const matched = rule.regex.test(path9);
349
349
  if (matched) {
350
350
  ignored = !negative;
351
351
  unignored = negative;
@@ -358,24 +358,24 @@ var require_ignore = __commonJS({
358
358
  }
359
359
  // @returns {TestResult}
360
360
  _test(originalPath, cache, checkUnignored, slices) {
361
- const path8 = originalPath && checkPath.convert(originalPath);
361
+ const path9 = originalPath && checkPath.convert(originalPath);
362
362
  checkPath(
363
- path8,
363
+ path9,
364
364
  originalPath,
365
365
  this._allowRelativePaths ? RETURN_FALSE : throwError
366
366
  );
367
- return this._t(path8, cache, checkUnignored, slices);
367
+ return this._t(path9, cache, checkUnignored, slices);
368
368
  }
369
- _t(path8, cache, checkUnignored, slices) {
370
- if (path8 in cache) {
371
- return cache[path8];
369
+ _t(path9, cache, checkUnignored, slices) {
370
+ if (path9 in cache) {
371
+ return cache[path9];
372
372
  }
373
373
  if (!slices) {
374
- slices = path8.split(SLASH);
374
+ slices = path9.split(SLASH);
375
375
  }
376
376
  slices.pop();
377
377
  if (!slices.length) {
378
- return cache[path8] = this._testOne(path8, checkUnignored);
378
+ return cache[path9] = this._testOne(path9, checkUnignored);
379
379
  }
380
380
  const parent = this._t(
381
381
  slices.join(SLASH) + SLASH,
@@ -383,24 +383,24 @@ var require_ignore = __commonJS({
383
383
  checkUnignored,
384
384
  slices
385
385
  );
386
- return cache[path8] = parent.ignored ? parent : this._testOne(path8, checkUnignored);
386
+ return cache[path9] = parent.ignored ? parent : this._testOne(path9, checkUnignored);
387
387
  }
388
- ignores(path8) {
389
- return this._test(path8, this._ignoreCache, false).ignored;
388
+ ignores(path9) {
389
+ return this._test(path9, this._ignoreCache, false).ignored;
390
390
  }
391
391
  createFilter() {
392
- return (path8) => !this.ignores(path8);
392
+ return (path9) => !this.ignores(path9);
393
393
  }
394
394
  filter(paths) {
395
395
  return makeArray(paths).filter(this.createFilter());
396
396
  }
397
397
  // @returns {TestResult}
398
- test(path8) {
399
- return this._test(path8, this._testCache, true);
398
+ test(path9) {
399
+ return this._test(path9, this._testCache, true);
400
400
  }
401
401
  };
402
402
  var factory = /* @__PURE__ */ __name((options) => new Ignore(options), "factory");
403
- var isPathValid = /* @__PURE__ */ __name((path8) => checkPath(path8 && checkPath.convert(path8), path8, RETURN_FALSE), "isPathValid");
403
+ var isPathValid = /* @__PURE__ */ __name((path9) => checkPath(path9 && checkPath.convert(path9), path9, RETURN_FALSE), "isPathValid");
404
404
  factory.isPathValid = isPathValid;
405
405
  factory.default = factory;
406
406
  module.exports = factory;
@@ -411,7 +411,7 @@ var require_ignore = __commonJS({
411
411
  const makePosix = /* @__PURE__ */ __name((str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/"), "makePosix");
412
412
  checkPath.convert = makePosix;
413
413
  const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
414
- checkPath.isNotRelative = (path8) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path8) || isNotRelative(path8);
414
+ checkPath.isNotRelative = (path9) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path9) || isNotRelative(path9);
415
415
  }
416
416
  }
417
417
  });
@@ -1648,7 +1648,7 @@ var require_difflib2 = __commonJS({
1648
1648
  // ../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/util.js
1649
1649
  var require_util = __commonJS({
1650
1650
  "../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/util.js"(exports, module) {
1651
- var extendedTypeOf = /* @__PURE__ */ __name(function(obj) {
1651
+ var extendedTypeOf2 = /* @__PURE__ */ __name(function(obj) {
1652
1652
  const result = typeof obj;
1653
1653
  if (obj == null) {
1654
1654
  return "null";
@@ -1675,7 +1675,7 @@ var require_util = __commonJS({
1675
1675
  return data;
1676
1676
  }
1677
1677
  }, "roundObj");
1678
- module.exports = { extendedTypeOf, roundObj };
1678
+ module.exports = { extendedTypeOf: extendedTypeOf2, roundObj };
1679
1679
  }
1680
1680
  });
1681
1681
 
@@ -2351,7 +2351,7 @@ var require_safe = __commonJS({
2351
2351
  var require_colorize = __commonJS({
2352
2352
  "../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/colorize.js"(exports, module) {
2353
2353
  var color = require_safe();
2354
- var { extendedTypeOf } = require_util();
2354
+ var { extendedTypeOf: extendedTypeOf2 } = require_util();
2355
2355
  var Theme = {
2356
2356
  " "(s) {
2357
2357
  return s;
@@ -2373,7 +2373,7 @@ var require_colorize = __commonJS({
2373
2373
  output(" ", subindent + `... (${n} entries)`);
2374
2374
  }
2375
2375
  }, "outputElisions");
2376
- switch (extendedTypeOf(diff)) {
2376
+ switch (extendedTypeOf2(diff)) {
2377
2377
  case "object":
2378
2378
  if ("__old" in diff && "__new" in diff && Object.keys(diff).length === 2) {
2379
2379
  subcolorizeToCallback(options, key, diff.__old, output, "-", indent);
@@ -2397,7 +2397,7 @@ var require_colorize = __commonJS({
2397
2397
  output(color2, `${indent}${prefix}[`);
2398
2398
  let looksLikeDiff = true;
2399
2399
  for (const item of diff) {
2400
- if (extendedTypeOf(item) !== "array" || !(item.length === 2 || item.length === 1 && item[0] === " ") || !(typeof item[0] === "string") || item[0].length !== 1 || ![" ", "-", "+", "~"].includes(item[0])) {
2400
+ if (extendedTypeOf2(item) !== "array" || !(item.length === 2 || item.length === 1 && item[0] === " ") || !(typeof item[0] === "string") || item[0].length !== 1 || ![" ", "-", "+", "~"].includes(item[0])) {
2401
2401
  looksLikeDiff = false;
2402
2402
  }
2403
2403
  }
@@ -2463,7 +2463,7 @@ var require_colorize = __commonJS({
2463
2463
  var require_lib = __commonJS({
2464
2464
  "../../node_modules/.pnpm/json-diff@1.0.6/node_modules/json-diff/lib/index.js"(exports, module) {
2465
2465
  var { SequenceMatcher } = require_difflib2();
2466
- var { extendedTypeOf, roundObj } = require_util();
2466
+ var { extendedTypeOf: extendedTypeOf2, roundObj } = require_util();
2467
2467
  var { colorize, colorizeToCallback } = require_colorize();
2468
2468
  var JsonDiff = class {
2469
2469
  static {
@@ -2531,7 +2531,7 @@ var require_lib = __commonJS({
2531
2531
  for (const [key, { item: candidate, index: matchIndex }] of Object.entries(fuzzyOriginals)) {
2532
2532
  if (key !== "__next") {
2533
2533
  const indexDistance = Math.abs(matchIndex - index);
2534
- if (extendedTypeOf(item) === extendedTypeOf(candidate)) {
2534
+ if (extendedTypeOf2(item) === extendedTypeOf2(candidate)) {
2535
2535
  const { score } = this.diff(item, candidate);
2536
2536
  if (!bestMatch || score > bestMatch.score || score === bestMatch.score && indexDistance < bestMatch.indexDistance) {
2537
2537
  bestMatch = { score, key, indexDistance };
@@ -2693,8 +2693,8 @@ var require_lib = __commonJS({
2693
2693
  return { score, result, equal };
2694
2694
  }
2695
2695
  diff(obj1, obj2) {
2696
- const type1 = extendedTypeOf(obj1);
2697
- const type2 = extendedTypeOf(obj2);
2696
+ const type1 = extendedTypeOf2(obj1);
2697
+ const type2 = extendedTypeOf2(obj2);
2698
2698
  if (type1 === type2) {
2699
2699
  switch (type1) {
2700
2700
  case "object":
@@ -2748,6 +2748,2632 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
2748
2748
  var __commonJS2 = /* @__PURE__ */ __name((cb, mod) => function() {
2749
2749
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
2750
2750
  }, "__commonJS");
2751
+ var __defProp = Object.defineProperty;
2752
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", {
2753
+ value,
2754
+ configurable: true
2755
+ }), "__name");
2756
+ var UserError = class extends Error {
2757
+ static {
2758
+ __name(this, "UserError");
2759
+ }
2760
+ static {
2761
+ __name2(this, "UserError");
2762
+ }
2763
+ telemetryMessage;
2764
+ constructor(message, options) {
2765
+ super(message, options);
2766
+ Object.setPrototypeOf(this, new.target.prototype);
2767
+ this.telemetryMessage = typeof options?.telemetryMessage === "string" ? options.telemetryMessage : options?.telemetryMessage ? message : void 0;
2768
+ }
2769
+ };
2770
+ (class extends UserError {
2771
+ static {
2772
+ __name(this, "DeprecationError");
2773
+ }
2774
+ static {
2775
+ __name2(this, "DeprecationError");
2776
+ }
2777
+ constructor(message, options) {
2778
+ super(`Deprecation:
2779
+ ${message}`, options);
2780
+ }
2781
+ });
2782
+ var FatalError = class extends UserError {
2783
+ static {
2784
+ __name(this, "FatalError");
2785
+ }
2786
+ static {
2787
+ __name2(this, "FatalError");
2788
+ }
2789
+ code;
2790
+ constructor(message, options) {
2791
+ super(message, options);
2792
+ this.code = options.code;
2793
+ }
2794
+ };
2795
+ (class extends UserError {
2796
+ static {
2797
+ __name(this, "CommandLineArgsError");
2798
+ }
2799
+ static {
2800
+ __name2(this, "CommandLineArgsError");
2801
+ }
2802
+ });
2803
+ var JsonFriendlyFatalError = class extends FatalError {
2804
+ static {
2805
+ __name(this, "JsonFriendlyFatalError");
2806
+ }
2807
+ static {
2808
+ __name2(this, "JsonFriendlyFatalError");
2809
+ }
2810
+ };
2811
+ (class extends Error {
2812
+ static {
2813
+ __name(this, "MissingConfigError");
2814
+ }
2815
+ static {
2816
+ __name2(this, "MissingConfigError");
2817
+ }
2818
+ telemetryMessage;
2819
+ constructor(key) {
2820
+ super(`Missing config value for ${key}`);
2821
+ this.telemetryMessage = `Missing config value for ${key}`;
2822
+ }
2823
+ });
2824
+ function createFatalError(message, isJson, options) {
2825
+ if (isJson) return new JsonFriendlyFatalError(JSON.stringify(message), options);
2826
+ return new FatalError(`${message}`, options);
2827
+ }
2828
+ __name(createFatalError, "createFatalError");
2829
+ __name2(createFatalError, "createFatalError");
2830
+ function createScanner(text, ignoreTrivia = false) {
2831
+ const len = text.length;
2832
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
2833
+ function scanHexDigits(count, exact) {
2834
+ let digits = 0;
2835
+ let value2 = 0;
2836
+ while (digits < count || !exact) {
2837
+ let ch = text.charCodeAt(pos);
2838
+ if (ch >= 48 && ch <= 57) value2 = value2 * 16 + ch - 48;
2839
+ else if (ch >= 65 && ch <= 70) value2 = value2 * 16 + ch - 65 + 10;
2840
+ else if (ch >= 97 && ch <= 102) value2 = value2 * 16 + ch - 97 + 10;
2841
+ else break;
2842
+ pos++;
2843
+ digits++;
2844
+ }
2845
+ if (digits < count) value2 = -1;
2846
+ return value2;
2847
+ }
2848
+ __name(scanHexDigits, "scanHexDigits");
2849
+ __name2(scanHexDigits, "scanHexDigits");
2850
+ function setPosition(newPosition) {
2851
+ pos = newPosition;
2852
+ value = "";
2853
+ tokenOffset = 0;
2854
+ token = 16;
2855
+ scanError = 0;
2856
+ }
2857
+ __name(setPosition, "setPosition");
2858
+ __name2(setPosition, "setPosition");
2859
+ function scanNumber() {
2860
+ let start = pos;
2861
+ if (text.charCodeAt(pos) === 48) pos++;
2862
+ else {
2863
+ pos++;
2864
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
2865
+ }
2866
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
2867
+ pos++;
2868
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
2869
+ pos++;
2870
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
2871
+ } else {
2872
+ scanError = 3;
2873
+ return text.substring(start, pos);
2874
+ }
2875
+ }
2876
+ let end = pos;
2877
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
2878
+ pos++;
2879
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++;
2880
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
2881
+ pos++;
2882
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
2883
+ end = pos;
2884
+ } else scanError = 3;
2885
+ }
2886
+ return text.substring(start, end);
2887
+ }
2888
+ __name(scanNumber, "scanNumber");
2889
+ __name2(scanNumber, "scanNumber");
2890
+ function scanString() {
2891
+ let result = "", start = pos;
2892
+ while (true) {
2893
+ if (pos >= len) {
2894
+ result += text.substring(start, pos);
2895
+ scanError = 2;
2896
+ break;
2897
+ }
2898
+ const ch = text.charCodeAt(pos);
2899
+ if (ch === 34) {
2900
+ result += text.substring(start, pos);
2901
+ pos++;
2902
+ break;
2903
+ }
2904
+ if (ch === 92) {
2905
+ result += text.substring(start, pos);
2906
+ pos++;
2907
+ if (pos >= len) {
2908
+ scanError = 2;
2909
+ break;
2910
+ }
2911
+ switch (text.charCodeAt(pos++)) {
2912
+ case 34:
2913
+ result += '"';
2914
+ break;
2915
+ case 92:
2916
+ result += "\\";
2917
+ break;
2918
+ case 47:
2919
+ result += "/";
2920
+ break;
2921
+ case 98:
2922
+ result += "\b";
2923
+ break;
2924
+ case 102:
2925
+ result += "\f";
2926
+ break;
2927
+ case 110:
2928
+ result += "\n";
2929
+ break;
2930
+ case 114:
2931
+ result += "\r";
2932
+ break;
2933
+ case 116:
2934
+ result += " ";
2935
+ break;
2936
+ case 117:
2937
+ const ch3 = scanHexDigits(4, true);
2938
+ if (ch3 >= 0) result += String.fromCharCode(ch3);
2939
+ else scanError = 4;
2940
+ break;
2941
+ default:
2942
+ scanError = 5;
2943
+ }
2944
+ start = pos;
2945
+ continue;
2946
+ }
2947
+ if (ch >= 0 && ch <= 31) if (isLineBreak(ch)) {
2948
+ result += text.substring(start, pos);
2949
+ scanError = 2;
2950
+ break;
2951
+ } else scanError = 6;
2952
+ pos++;
2953
+ }
2954
+ return result;
2955
+ }
2956
+ __name(scanString, "scanString");
2957
+ __name2(scanString, "scanString");
2958
+ function scanNext() {
2959
+ value = "";
2960
+ scanError = 0;
2961
+ tokenOffset = pos;
2962
+ lineStartOffset = lineNumber;
2963
+ prevTokenLineStartOffset = tokenLineStartOffset;
2964
+ if (pos >= len) {
2965
+ tokenOffset = len;
2966
+ return token = 17;
2967
+ }
2968
+ let code = text.charCodeAt(pos);
2969
+ if (isWhiteSpace(code)) {
2970
+ do {
2971
+ pos++;
2972
+ value += String.fromCharCode(code);
2973
+ code = text.charCodeAt(pos);
2974
+ } while (isWhiteSpace(code));
2975
+ return token = 15;
2976
+ }
2977
+ if (isLineBreak(code)) {
2978
+ pos++;
2979
+ value += String.fromCharCode(code);
2980
+ if (code === 13 && text.charCodeAt(pos) === 10) {
2981
+ pos++;
2982
+ value += "\n";
2983
+ }
2984
+ lineNumber++;
2985
+ tokenLineStartOffset = pos;
2986
+ return token = 14;
2987
+ }
2988
+ switch (code) {
2989
+ case 123:
2990
+ pos++;
2991
+ return token = 1;
2992
+ case 125:
2993
+ pos++;
2994
+ return token = 2;
2995
+ case 91:
2996
+ pos++;
2997
+ return token = 3;
2998
+ case 93:
2999
+ pos++;
3000
+ return token = 4;
3001
+ case 58:
3002
+ pos++;
3003
+ return token = 6;
3004
+ case 44:
3005
+ pos++;
3006
+ return token = 5;
3007
+ case 34:
3008
+ pos++;
3009
+ value = scanString();
3010
+ return token = 10;
3011
+ case 47:
3012
+ const start = pos - 1;
3013
+ if (text.charCodeAt(pos + 1) === 47) {
3014
+ pos += 2;
3015
+ while (pos < len) {
3016
+ if (isLineBreak(text.charCodeAt(pos))) break;
3017
+ pos++;
3018
+ }
3019
+ value = text.substring(start, pos);
3020
+ return token = 12;
3021
+ }
3022
+ if (text.charCodeAt(pos + 1) === 42) {
3023
+ pos += 2;
3024
+ const safeLength = len - 1;
3025
+ let commentClosed = false;
3026
+ while (pos < safeLength) {
3027
+ const ch = text.charCodeAt(pos);
3028
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
3029
+ pos += 2;
3030
+ commentClosed = true;
3031
+ break;
3032
+ }
3033
+ pos++;
3034
+ if (isLineBreak(ch)) {
3035
+ if (ch === 13 && text.charCodeAt(pos) === 10) pos++;
3036
+ lineNumber++;
3037
+ tokenLineStartOffset = pos;
3038
+ }
3039
+ }
3040
+ if (!commentClosed) {
3041
+ pos++;
3042
+ scanError = 1;
3043
+ }
3044
+ value = text.substring(start, pos);
3045
+ return token = 13;
3046
+ }
3047
+ value += String.fromCharCode(code);
3048
+ pos++;
3049
+ return token = 16;
3050
+ case 45:
3051
+ value += String.fromCharCode(code);
3052
+ pos++;
3053
+ if (pos === len || !isDigit(text.charCodeAt(pos))) return token = 16;
3054
+ case 48:
3055
+ case 49:
3056
+ case 50:
3057
+ case 51:
3058
+ case 52:
3059
+ case 53:
3060
+ case 54:
3061
+ case 55:
3062
+ case 56:
3063
+ case 57:
3064
+ value += scanNumber();
3065
+ return token = 11;
3066
+ default:
3067
+ while (pos < len && isUnknownContentCharacter(code)) {
3068
+ pos++;
3069
+ code = text.charCodeAt(pos);
3070
+ }
3071
+ if (tokenOffset !== pos) {
3072
+ value = text.substring(tokenOffset, pos);
3073
+ switch (value) {
3074
+ case "true":
3075
+ return token = 8;
3076
+ case "false":
3077
+ return token = 9;
3078
+ case "null":
3079
+ return token = 7;
3080
+ }
3081
+ return token = 16;
3082
+ }
3083
+ value += String.fromCharCode(code);
3084
+ pos++;
3085
+ return token = 16;
3086
+ }
3087
+ }
3088
+ __name(scanNext, "scanNext");
3089
+ __name2(scanNext, "scanNext");
3090
+ function isUnknownContentCharacter(code) {
3091
+ if (isWhiteSpace(code) || isLineBreak(code)) return false;
3092
+ switch (code) {
3093
+ case 125:
3094
+ case 93:
3095
+ case 123:
3096
+ case 91:
3097
+ case 34:
3098
+ case 58:
3099
+ case 44:
3100
+ case 47:
3101
+ return false;
3102
+ }
3103
+ return true;
3104
+ }
3105
+ __name(isUnknownContentCharacter, "isUnknownContentCharacter");
3106
+ __name2(isUnknownContentCharacter, "isUnknownContentCharacter");
3107
+ function scanNextNonTrivia() {
3108
+ let result;
3109
+ do
3110
+ result = scanNext();
3111
+ while (result >= 12 && result <= 15);
3112
+ return result;
3113
+ }
3114
+ __name(scanNextNonTrivia, "scanNextNonTrivia");
3115
+ __name2(scanNextNonTrivia, "scanNextNonTrivia");
3116
+ return {
3117
+ setPosition,
3118
+ getPosition: /* @__PURE__ */ __name2(() => pos, "getPosition"),
3119
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
3120
+ getToken: /* @__PURE__ */ __name2(() => token, "getToken"),
3121
+ getTokenValue: /* @__PURE__ */ __name2(() => value, "getTokenValue"),
3122
+ getTokenOffset: /* @__PURE__ */ __name2(() => tokenOffset, "getTokenOffset"),
3123
+ getTokenLength: /* @__PURE__ */ __name2(() => pos - tokenOffset, "getTokenLength"),
3124
+ getTokenStartLine: /* @__PURE__ */ __name2(() => lineStartOffset, "getTokenStartLine"),
3125
+ getTokenStartCharacter: /* @__PURE__ */ __name2(() => tokenOffset - prevTokenLineStartOffset, "getTokenStartCharacter"),
3126
+ getTokenError: /* @__PURE__ */ __name2(() => scanError, "getTokenError")
3127
+ };
3128
+ }
3129
+ __name(createScanner, "createScanner");
3130
+ __name2(createScanner, "createScanner");
3131
+ function isWhiteSpace(ch) {
3132
+ return ch === 32 || ch === 9;
3133
+ }
3134
+ __name(isWhiteSpace, "isWhiteSpace");
3135
+ __name2(isWhiteSpace, "isWhiteSpace");
3136
+ function isLineBreak(ch) {
3137
+ return ch === 10 || ch === 13;
3138
+ }
3139
+ __name(isLineBreak, "isLineBreak");
3140
+ __name2(isLineBreak, "isLineBreak");
3141
+ function isDigit(ch) {
3142
+ return ch >= 48 && ch <= 57;
3143
+ }
3144
+ __name(isDigit, "isDigit");
3145
+ __name2(isDigit, "isDigit");
3146
+ var CharacterCodes;
3147
+ (function(CharacterCodes2) {
3148
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
3149
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
3150
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
3151
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
3152
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
3153
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
3154
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
3155
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
3156
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
3157
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
3158
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
3159
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
3160
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
3161
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
3162
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
3163
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
3164
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
3165
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
3166
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
3167
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
3168
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
3169
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
3170
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
3171
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
3172
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
3173
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
3174
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
3175
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
3176
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
3177
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
3178
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
3179
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
3180
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
3181
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
3182
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
3183
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
3184
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
3185
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
3186
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
3187
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
3188
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
3189
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
3190
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
3191
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
3192
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
3193
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
3194
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
3195
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
3196
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
3197
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
3198
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
3199
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
3200
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
3201
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
3202
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
3203
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
3204
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
3205
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
3206
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
3207
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
3208
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
3209
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
3210
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
3211
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
3212
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
3213
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
3214
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
3215
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
3216
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
3217
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
3218
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
3219
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
3220
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
3221
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
3222
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
3223
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
3224
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
3225
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
3226
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
3227
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
3228
+ })(CharacterCodes || (CharacterCodes = {}));
3229
+ function format(documentText, range, options) {
3230
+ let initialIndentLevel;
3231
+ let formatText;
3232
+ let formatTextStart;
3233
+ let rangeStart;
3234
+ let rangeEnd;
3235
+ if (range) {
3236
+ rangeStart = range.offset;
3237
+ rangeEnd = rangeStart + range.length;
3238
+ formatTextStart = rangeStart;
3239
+ while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) formatTextStart--;
3240
+ let endOffset = rangeEnd;
3241
+ while (endOffset < documentText.length && !isEOL(documentText, endOffset)) endOffset++;
3242
+ formatText = documentText.substring(formatTextStart, endOffset);
3243
+ initialIndentLevel = computeIndentLevel(formatText, options);
3244
+ } else {
3245
+ formatText = documentText;
3246
+ initialIndentLevel = 0;
3247
+ formatTextStart = 0;
3248
+ rangeStart = 0;
3249
+ rangeEnd = documentText.length;
3250
+ }
3251
+ const eol = getEOL(options, documentText);
3252
+ let numberLineBreaks = 0;
3253
+ let indentLevel = 0;
3254
+ let indentValue;
3255
+ if (options.insertSpaces) indentValue = repeat(" ", options.tabSize || 4);
3256
+ else indentValue = " ";
3257
+ let scanner = createScanner(formatText, false);
3258
+ let hasError = false;
3259
+ function newLinesAndIndent() {
3260
+ if (numberLineBreaks > 1) return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
3261
+ else return eol + repeat(indentValue, initialIndentLevel + indentLevel);
3262
+ }
3263
+ __name(newLinesAndIndent, "newLinesAndIndent");
3264
+ __name2(newLinesAndIndent, "newLinesAndIndent");
3265
+ function scanNext() {
3266
+ let token = scanner.scan();
3267
+ numberLineBreaks = 0;
3268
+ while (token === 15 || token === 14) {
3269
+ if (token === 14 && options.keepLines) numberLineBreaks += 1;
3270
+ else if (token === 14) numberLineBreaks = 1;
3271
+ token = scanner.scan();
3272
+ }
3273
+ hasError = token === 16 || scanner.getTokenError() !== 0;
3274
+ return token;
3275
+ }
3276
+ __name(scanNext, "scanNext");
3277
+ __name2(scanNext, "scanNext");
3278
+ const editOperations = [];
3279
+ function addEdit(text, startOffset, endOffset) {
3280
+ if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) editOperations.push({
3281
+ offset: startOffset,
3282
+ length: endOffset - startOffset,
3283
+ content: text
3284
+ });
3285
+ }
3286
+ __name(addEdit, "addEdit");
3287
+ __name2(addEdit, "addEdit");
3288
+ let firstToken = scanNext();
3289
+ if (options.keepLines && numberLineBreaks > 0) addEdit(repeat(eol, numberLineBreaks), 0, 0);
3290
+ if (firstToken !== 17) {
3291
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
3292
+ addEdit(repeat(indentValue, initialIndentLevel), formatTextStart, firstTokenStart);
3293
+ }
3294
+ while (firstToken !== 17) {
3295
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
3296
+ let secondToken = scanNext();
3297
+ let replaceContent = "";
3298
+ let needsLineBreak = false;
3299
+ while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
3300
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
3301
+ addEdit(" ", firstTokenEnd, commentTokenStart);
3302
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
3303
+ needsLineBreak = secondToken === 12;
3304
+ replaceContent = needsLineBreak ? newLinesAndIndent() : "";
3305
+ secondToken = scanNext();
3306
+ }
3307
+ if (secondToken === 2) {
3308
+ if (firstToken !== 1) indentLevel--;
3309
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) replaceContent = newLinesAndIndent();
3310
+ else if (options.keepLines) replaceContent = " ";
3311
+ } else if (secondToken === 4) {
3312
+ if (firstToken !== 3) indentLevel--;
3313
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) replaceContent = newLinesAndIndent();
3314
+ else if (options.keepLines) replaceContent = " ";
3315
+ } else {
3316
+ switch (firstToken) {
3317
+ case 3:
3318
+ case 1:
3319
+ indentLevel++;
3320
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) replaceContent = newLinesAndIndent();
3321
+ else replaceContent = " ";
3322
+ break;
3323
+ case 5:
3324
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) replaceContent = newLinesAndIndent();
3325
+ else replaceContent = " ";
3326
+ break;
3327
+ case 12:
3328
+ replaceContent = newLinesAndIndent();
3329
+ break;
3330
+ case 13:
3331
+ if (numberLineBreaks > 0) replaceContent = newLinesAndIndent();
3332
+ else if (!needsLineBreak) replaceContent = " ";
3333
+ break;
3334
+ case 6:
3335
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
3336
+ else if (!needsLineBreak) replaceContent = " ";
3337
+ break;
3338
+ case 10:
3339
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
3340
+ else if (secondToken === 6 && !needsLineBreak) replaceContent = "";
3341
+ break;
3342
+ case 7:
3343
+ case 8:
3344
+ case 9:
3345
+ case 11:
3346
+ case 2:
3347
+ case 4:
3348
+ if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
3349
+ else if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) replaceContent = " ";
3350
+ else if (secondToken !== 5 && secondToken !== 17) hasError = true;
3351
+ break;
3352
+ case 16:
3353
+ hasError = true;
3354
+ break;
3355
+ }
3356
+ if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) replaceContent = newLinesAndIndent();
3357
+ }
3358
+ if (secondToken === 17) if (options.keepLines && numberLineBreaks > 0) replaceContent = newLinesAndIndent();
3359
+ else replaceContent = options.insertFinalNewline ? eol : "";
3360
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
3361
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
3362
+ firstToken = secondToken;
3363
+ }
3364
+ return editOperations;
3365
+ }
3366
+ __name(format, "format");
3367
+ __name2(format, "format");
3368
+ function repeat(s, count) {
3369
+ let result = "";
3370
+ for (let i = 0; i < count; i++) result += s;
3371
+ return result;
3372
+ }
3373
+ __name(repeat, "repeat");
3374
+ __name2(repeat, "repeat");
3375
+ function computeIndentLevel(content, options) {
3376
+ let i = 0;
3377
+ let nChars = 0;
3378
+ const tabSize = options.tabSize || 4;
3379
+ while (i < content.length) {
3380
+ let ch = content.charAt(i);
3381
+ if (ch === " ") nChars++;
3382
+ else if (ch === " ") nChars += tabSize;
3383
+ else break;
3384
+ i++;
3385
+ }
3386
+ return Math.floor(nChars / tabSize);
3387
+ }
3388
+ __name(computeIndentLevel, "computeIndentLevel");
3389
+ __name2(computeIndentLevel, "computeIndentLevel");
3390
+ function getEOL(options, text) {
3391
+ for (let i = 0; i < text.length; i++) {
3392
+ const ch = text.charAt(i);
3393
+ if (ch === "\r") {
3394
+ if (i + 1 < text.length && text.charAt(i + 1) === "\n") return "\r\n";
3395
+ return "\r";
3396
+ } else if (ch === "\n") return "\n";
3397
+ }
3398
+ return options && options.eol || "\n";
3399
+ }
3400
+ __name(getEOL, "getEOL");
3401
+ __name2(getEOL, "getEOL");
3402
+ function isEOL(text, offset) {
3403
+ return "\r\n".indexOf(text.charAt(offset)) !== -1;
3404
+ }
3405
+ __name(isEOL, "isEOL");
3406
+ __name2(isEOL, "isEOL");
3407
+ var ParseOptions;
3408
+ (function(ParseOptions2) {
3409
+ ParseOptions2.DEFAULT = { allowTrailingComma: false };
3410
+ })(ParseOptions || (ParseOptions = {}));
3411
+ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
3412
+ let currentProperty = null;
3413
+ let currentParent = [];
3414
+ const previousParents = [];
3415
+ function onValue(value) {
3416
+ if (Array.isArray(currentParent)) currentParent.push(value);
3417
+ else if (currentProperty !== null) currentParent[currentProperty] = value;
3418
+ }
3419
+ __name(onValue, "onValue");
3420
+ __name2(onValue, "onValue");
3421
+ visit(text, {
3422
+ onObjectBegin: /* @__PURE__ */ __name2(() => {
3423
+ const object = {};
3424
+ onValue(object);
3425
+ previousParents.push(currentParent);
3426
+ currentParent = object;
3427
+ currentProperty = null;
3428
+ }, "onObjectBegin"),
3429
+ onObjectProperty: /* @__PURE__ */ __name2((name) => {
3430
+ currentProperty = name;
3431
+ }, "onObjectProperty"),
3432
+ onObjectEnd: /* @__PURE__ */ __name2(() => {
3433
+ currentParent = previousParents.pop();
3434
+ }, "onObjectEnd"),
3435
+ onArrayBegin: /* @__PURE__ */ __name2(() => {
3436
+ const array2 = [];
3437
+ onValue(array2);
3438
+ previousParents.push(currentParent);
3439
+ currentParent = array2;
3440
+ currentProperty = null;
3441
+ }, "onArrayBegin"),
3442
+ onArrayEnd: /* @__PURE__ */ __name2(() => {
3443
+ currentParent = previousParents.pop();
3444
+ }, "onArrayEnd"),
3445
+ onLiteralValue: onValue,
3446
+ onError: /* @__PURE__ */ __name2((error, offset, length) => {
3447
+ errors.push({
3448
+ error,
3449
+ offset,
3450
+ length
3451
+ });
3452
+ }, "onError")
3453
+ }, options);
3454
+ return currentParent[0];
3455
+ }
3456
+ __name(parse, "parse");
3457
+ __name2(parse, "parse");
3458
+ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
3459
+ let currentParent = {
3460
+ type: "array",
3461
+ offset: -1,
3462
+ length: -1,
3463
+ children: [],
3464
+ parent: void 0
3465
+ };
3466
+ function ensurePropertyComplete(endOffset) {
3467
+ if (currentParent.type === "property") {
3468
+ currentParent.length = endOffset - currentParent.offset;
3469
+ currentParent = currentParent.parent;
3470
+ }
3471
+ }
3472
+ __name(ensurePropertyComplete, "ensurePropertyComplete");
3473
+ __name2(ensurePropertyComplete, "ensurePropertyComplete");
3474
+ function onValue(valueNode) {
3475
+ currentParent.children.push(valueNode);
3476
+ return valueNode;
3477
+ }
3478
+ __name(onValue, "onValue");
3479
+ __name2(onValue, "onValue");
3480
+ visit(text, {
3481
+ onObjectBegin: /* @__PURE__ */ __name2((offset) => {
3482
+ currentParent = onValue({
3483
+ type: "object",
3484
+ offset,
3485
+ length: -1,
3486
+ parent: currentParent,
3487
+ children: []
3488
+ });
3489
+ }, "onObjectBegin"),
3490
+ onObjectProperty: /* @__PURE__ */ __name2((name, offset, length) => {
3491
+ currentParent = onValue({
3492
+ type: "property",
3493
+ offset,
3494
+ length: -1,
3495
+ parent: currentParent,
3496
+ children: []
3497
+ });
3498
+ currentParent.children.push({
3499
+ type: "string",
3500
+ value: name,
3501
+ offset,
3502
+ length,
3503
+ parent: currentParent
3504
+ });
3505
+ }, "onObjectProperty"),
3506
+ onObjectEnd: /* @__PURE__ */ __name2((offset, length) => {
3507
+ ensurePropertyComplete(offset + length);
3508
+ currentParent.length = offset + length - currentParent.offset;
3509
+ currentParent = currentParent.parent;
3510
+ ensurePropertyComplete(offset + length);
3511
+ }, "onObjectEnd"),
3512
+ onArrayBegin: /* @__PURE__ */ __name2((offset, length) => {
3513
+ currentParent = onValue({
3514
+ type: "array",
3515
+ offset,
3516
+ length: -1,
3517
+ parent: currentParent,
3518
+ children: []
3519
+ });
3520
+ }, "onArrayBegin"),
3521
+ onArrayEnd: /* @__PURE__ */ __name2((offset, length) => {
3522
+ currentParent.length = offset + length - currentParent.offset;
3523
+ currentParent = currentParent.parent;
3524
+ ensurePropertyComplete(offset + length);
3525
+ }, "onArrayEnd"),
3526
+ onLiteralValue: /* @__PURE__ */ __name2((value, offset, length) => {
3527
+ onValue({
3528
+ type: getNodeType(value),
3529
+ offset,
3530
+ length,
3531
+ parent: currentParent,
3532
+ value
3533
+ });
3534
+ ensurePropertyComplete(offset + length);
3535
+ }, "onLiteralValue"),
3536
+ onSeparator: /* @__PURE__ */ __name2((sep2, offset, length) => {
3537
+ if (currentParent.type === "property") {
3538
+ if (sep2 === ":") currentParent.colonOffset = offset;
3539
+ else if (sep2 === ",") ensurePropertyComplete(offset);
3540
+ }
3541
+ }, "onSeparator"),
3542
+ onError: /* @__PURE__ */ __name2((error, offset, length) => {
3543
+ errors.push({
3544
+ error,
3545
+ offset,
3546
+ length
3547
+ });
3548
+ }, "onError")
3549
+ }, options);
3550
+ const result = currentParent.children[0];
3551
+ if (result) delete result.parent;
3552
+ return result;
3553
+ }
3554
+ __name(parseTree, "parseTree");
3555
+ __name2(parseTree, "parseTree");
3556
+ function findNodeAtLocation(root, path22) {
3557
+ if (!root) return;
3558
+ let node = root;
3559
+ for (let segment of path22) if (typeof segment === "string") {
3560
+ if (node.type !== "object" || !Array.isArray(node.children)) return;
3561
+ let found = false;
3562
+ for (const propertyNode of node.children) if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
3563
+ node = propertyNode.children[1];
3564
+ found = true;
3565
+ break;
3566
+ }
3567
+ if (!found) return;
3568
+ } else {
3569
+ const index = segment;
3570
+ if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) return;
3571
+ node = node.children[index];
3572
+ }
3573
+ return node;
3574
+ }
3575
+ __name(findNodeAtLocation, "findNodeAtLocation");
3576
+ __name2(findNodeAtLocation, "findNodeAtLocation");
3577
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
3578
+ const _scanner = createScanner(text, false);
3579
+ const _jsonPath = [];
3580
+ function toNoArgVisit(visitFunction) {
3581
+ return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
3582
+ }
3583
+ __name(toNoArgVisit, "toNoArgVisit");
3584
+ __name2(toNoArgVisit, "toNoArgVisit");
3585
+ function toNoArgVisitWithPath(visitFunction) {
3586
+ return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
3587
+ }
3588
+ __name(toNoArgVisitWithPath, "toNoArgVisitWithPath");
3589
+ __name2(toNoArgVisitWithPath, "toNoArgVisitWithPath");
3590
+ function toOneArgVisit(visitFunction) {
3591
+ return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
3592
+ }
3593
+ __name(toOneArgVisit, "toOneArgVisit");
3594
+ __name2(toOneArgVisit, "toOneArgVisit");
3595
+ function toOneArgVisitWithPath(visitFunction) {
3596
+ return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
3597
+ }
3598
+ __name(toOneArgVisitWithPath, "toOneArgVisitWithPath");
3599
+ __name2(toOneArgVisitWithPath, "toOneArgVisitWithPath");
3600
+ const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
3601
+ const disallowComments = options && options.disallowComments;
3602
+ const allowTrailingComma = options && options.allowTrailingComma;
3603
+ function scanNext() {
3604
+ while (true) {
3605
+ const token = _scanner.scan();
3606
+ switch (_scanner.getTokenError()) {
3607
+ case 4:
3608
+ handleError(14);
3609
+ break;
3610
+ case 5:
3611
+ handleError(15);
3612
+ break;
3613
+ case 3:
3614
+ handleError(13);
3615
+ break;
3616
+ case 1:
3617
+ if (!disallowComments) handleError(11);
3618
+ break;
3619
+ case 2:
3620
+ handleError(12);
3621
+ break;
3622
+ case 6:
3623
+ handleError(16);
3624
+ break;
3625
+ }
3626
+ switch (token) {
3627
+ case 12:
3628
+ case 13:
3629
+ if (disallowComments) handleError(10);
3630
+ else onComment();
3631
+ break;
3632
+ case 16:
3633
+ handleError(1);
3634
+ break;
3635
+ case 15:
3636
+ case 14:
3637
+ break;
3638
+ default:
3639
+ return token;
3640
+ }
3641
+ }
3642
+ }
3643
+ __name(scanNext, "scanNext");
3644
+ __name2(scanNext, "scanNext");
3645
+ function handleError(error, skipUntilAfter = [], skipUntil2 = []) {
3646
+ onError(error);
3647
+ if (skipUntilAfter.length + skipUntil2.length > 0) {
3648
+ let token = _scanner.getToken();
3649
+ while (token !== 17) {
3650
+ if (skipUntilAfter.indexOf(token) !== -1) {
3651
+ scanNext();
3652
+ break;
3653
+ } else if (skipUntil2.indexOf(token) !== -1) break;
3654
+ token = scanNext();
3655
+ }
3656
+ }
3657
+ }
3658
+ __name(handleError, "handleError");
3659
+ __name2(handleError, "handleError");
3660
+ function parseString2(isValue) {
3661
+ const value = _scanner.getTokenValue();
3662
+ if (isValue) onLiteralValue(value);
3663
+ else {
3664
+ onObjectProperty(value);
3665
+ _jsonPath.push(value);
3666
+ }
3667
+ scanNext();
3668
+ return true;
3669
+ }
3670
+ __name(parseString2, "parseString2");
3671
+ __name2(parseString2, "parseString");
3672
+ function parseLiteral() {
3673
+ switch (_scanner.getToken()) {
3674
+ case 11:
3675
+ const tokenValue = _scanner.getTokenValue();
3676
+ let value = Number(tokenValue);
3677
+ if (isNaN(value)) {
3678
+ handleError(2);
3679
+ value = 0;
3680
+ }
3681
+ onLiteralValue(value);
3682
+ break;
3683
+ case 7:
3684
+ onLiteralValue(null);
3685
+ break;
3686
+ case 8:
3687
+ onLiteralValue(true);
3688
+ break;
3689
+ case 9:
3690
+ onLiteralValue(false);
3691
+ break;
3692
+ default:
3693
+ return false;
3694
+ }
3695
+ scanNext();
3696
+ return true;
3697
+ }
3698
+ __name(parseLiteral, "parseLiteral");
3699
+ __name2(parseLiteral, "parseLiteral");
3700
+ function parseProperty() {
3701
+ if (_scanner.getToken() !== 10) {
3702
+ handleError(3, [], [2, 5]);
3703
+ return false;
3704
+ }
3705
+ parseString2(false);
3706
+ if (_scanner.getToken() === 6) {
3707
+ onSeparator(":");
3708
+ scanNext();
3709
+ if (!parseValue2()) handleError(4, [], [2, 5]);
3710
+ } else handleError(5, [], [2, 5]);
3711
+ _jsonPath.pop();
3712
+ return true;
3713
+ }
3714
+ __name(parseProperty, "parseProperty");
3715
+ __name2(parseProperty, "parseProperty");
3716
+ function parseObject() {
3717
+ onObjectBegin();
3718
+ scanNext();
3719
+ let needsComma = false;
3720
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
3721
+ if (_scanner.getToken() === 5) {
3722
+ if (!needsComma) handleError(4, [], []);
3723
+ onSeparator(",");
3724
+ scanNext();
3725
+ if (_scanner.getToken() === 2 && allowTrailingComma) break;
3726
+ } else if (needsComma) handleError(6, [], []);
3727
+ if (!parseProperty()) handleError(4, [], [2, 5]);
3728
+ needsComma = true;
3729
+ }
3730
+ onObjectEnd();
3731
+ if (_scanner.getToken() !== 2) handleError(7, [2], []);
3732
+ else scanNext();
3733
+ return true;
3734
+ }
3735
+ __name(parseObject, "parseObject");
3736
+ __name2(parseObject, "parseObject");
3737
+ function parseArray2() {
3738
+ onArrayBegin();
3739
+ scanNext();
3740
+ let isFirstElement = true;
3741
+ let needsComma = false;
3742
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
3743
+ if (_scanner.getToken() === 5) {
3744
+ if (!needsComma) handleError(4, [], []);
3745
+ onSeparator(",");
3746
+ scanNext();
3747
+ if (_scanner.getToken() === 4 && allowTrailingComma) break;
3748
+ } else if (needsComma) handleError(6, [], []);
3749
+ if (isFirstElement) {
3750
+ _jsonPath.push(0);
3751
+ isFirstElement = false;
3752
+ } else _jsonPath[_jsonPath.length - 1]++;
3753
+ if (!parseValue2()) handleError(4, [], [4, 5]);
3754
+ needsComma = true;
3755
+ }
3756
+ onArrayEnd();
3757
+ if (!isFirstElement) _jsonPath.pop();
3758
+ if (_scanner.getToken() !== 4) handleError(8, [4], []);
3759
+ else scanNext();
3760
+ return true;
3761
+ }
3762
+ __name(parseArray2, "parseArray2");
3763
+ __name2(parseArray2, "parseArray");
3764
+ function parseValue2() {
3765
+ switch (_scanner.getToken()) {
3766
+ case 3:
3767
+ return parseArray2();
3768
+ case 1:
3769
+ return parseObject();
3770
+ case 10:
3771
+ return parseString2(true);
3772
+ default:
3773
+ return parseLiteral();
3774
+ }
3775
+ }
3776
+ __name(parseValue2, "parseValue2");
3777
+ __name2(parseValue2, "parseValue");
3778
+ scanNext();
3779
+ if (_scanner.getToken() === 17) {
3780
+ if (options.allowEmptyContent) return true;
3781
+ handleError(4, [], []);
3782
+ return false;
3783
+ }
3784
+ if (!parseValue2()) {
3785
+ handleError(4, [], []);
3786
+ return false;
3787
+ }
3788
+ if (_scanner.getToken() !== 17) handleError(9, [], []);
3789
+ return true;
3790
+ }
3791
+ __name(visit, "visit");
3792
+ __name2(visit, "visit");
3793
+ function getNodeType(value) {
3794
+ switch (typeof value) {
3795
+ case "boolean":
3796
+ return "boolean";
3797
+ case "number":
3798
+ return "number";
3799
+ case "string":
3800
+ return "string";
3801
+ case "object":
3802
+ if (!value) return "null";
3803
+ else if (Array.isArray(value)) return "array";
3804
+ return "object";
3805
+ default:
3806
+ return "null";
3807
+ }
3808
+ }
3809
+ __name(getNodeType, "getNodeType");
3810
+ __name2(getNodeType, "getNodeType");
3811
+ function setProperty(text, originalPath, value, options) {
3812
+ const path22 = originalPath.slice();
3813
+ const root = parseTree(text, []);
3814
+ let parent = void 0;
3815
+ let lastSegment = void 0;
3816
+ while (path22.length > 0) {
3817
+ lastSegment = path22.pop();
3818
+ parent = findNodeAtLocation(root, path22);
3819
+ if (parent === void 0 && value !== void 0) if (typeof lastSegment === "string") value = { [lastSegment]: value };
3820
+ else value = [value];
3821
+ else break;
3822
+ }
3823
+ if (!parent) {
3824
+ if (value === void 0) throw new Error("Can not delete in empty document");
3825
+ return withFormatting(text, {
3826
+ offset: root ? root.offset : 0,
3827
+ length: root ? root.length : 0,
3828
+ content: JSON.stringify(value)
3829
+ }, options);
3830
+ } else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
3831
+ const existing = findNodeAtLocation(parent, [lastSegment]);
3832
+ if (existing !== void 0) if (value === void 0) {
3833
+ if (!existing.parent) throw new Error("Malformed AST");
3834
+ const propertyIndex = parent.children.indexOf(existing.parent);
3835
+ let removeBegin;
3836
+ let removeEnd = existing.parent.offset + existing.parent.length;
3837
+ if (propertyIndex > 0) {
3838
+ let previous = parent.children[propertyIndex - 1];
3839
+ removeBegin = previous.offset + previous.length;
3840
+ } else {
3841
+ removeBegin = parent.offset + 1;
3842
+ if (parent.children.length > 1) removeEnd = parent.children[1].offset;
3843
+ }
3844
+ return withFormatting(text, {
3845
+ offset: removeBegin,
3846
+ length: removeEnd - removeBegin,
3847
+ content: ""
3848
+ }, options);
3849
+ } else return withFormatting(text, {
3850
+ offset: existing.offset,
3851
+ length: existing.length,
3852
+ content: JSON.stringify(value)
3853
+ }, options);
3854
+ else {
3855
+ if (value === void 0) return [];
3856
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
3857
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
3858
+ let edit;
3859
+ if (index > 0) {
3860
+ let previous = parent.children[index - 1];
3861
+ edit = {
3862
+ offset: previous.offset + previous.length,
3863
+ length: 0,
3864
+ content: "," + newProperty
3865
+ };
3866
+ } else if (parent.children.length === 0) edit = {
3867
+ offset: parent.offset + 1,
3868
+ length: 0,
3869
+ content: newProperty
3870
+ };
3871
+ else edit = {
3872
+ offset: parent.offset + 1,
3873
+ length: 0,
3874
+ content: newProperty + ","
3875
+ };
3876
+ return withFormatting(text, edit, options);
3877
+ }
3878
+ } else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
3879
+ const insertIndex = lastSegment;
3880
+ if (insertIndex === -1) {
3881
+ const newProperty = `${JSON.stringify(value)}`;
3882
+ let edit;
3883
+ if (parent.children.length === 0) edit = {
3884
+ offset: parent.offset + 1,
3885
+ length: 0,
3886
+ content: newProperty
3887
+ };
3888
+ else {
3889
+ const previous = parent.children[parent.children.length - 1];
3890
+ edit = {
3891
+ offset: previous.offset + previous.length,
3892
+ length: 0,
3893
+ content: "," + newProperty
3894
+ };
3895
+ }
3896
+ return withFormatting(text, edit, options);
3897
+ } else if (value === void 0 && parent.children.length >= 0) {
3898
+ const removalIndex = lastSegment;
3899
+ const toRemove = parent.children[removalIndex];
3900
+ let edit;
3901
+ if (parent.children.length === 1) edit = {
3902
+ offset: parent.offset + 1,
3903
+ length: parent.length - 2,
3904
+ content: ""
3905
+ };
3906
+ else if (parent.children.length - 1 === removalIndex) {
3907
+ let previous = parent.children[removalIndex - 1];
3908
+ let offset = previous.offset + previous.length;
3909
+ edit = {
3910
+ offset,
3911
+ length: parent.offset + parent.length - 2 - offset,
3912
+ content: ""
3913
+ };
3914
+ } else edit = {
3915
+ offset: toRemove.offset,
3916
+ length: parent.children[removalIndex + 1].offset - toRemove.offset,
3917
+ content: ""
3918
+ };
3919
+ return withFormatting(text, edit, options);
3920
+ } else if (value !== void 0) {
3921
+ let edit;
3922
+ const newProperty = `${JSON.stringify(value)}`;
3923
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
3924
+ const toModify = parent.children[lastSegment];
3925
+ edit = {
3926
+ offset: toModify.offset,
3927
+ length: toModify.length,
3928
+ content: newProperty
3929
+ };
3930
+ } else if (parent.children.length === 0 || lastSegment === 0) edit = {
3931
+ offset: parent.offset + 1,
3932
+ length: 0,
3933
+ content: parent.children.length === 0 ? newProperty : newProperty + ","
3934
+ };
3935
+ else {
3936
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
3937
+ const previous = parent.children[index - 1];
3938
+ edit = {
3939
+ offset: previous.offset + previous.length,
3940
+ length: 0,
3941
+ content: "," + newProperty
3942
+ };
3943
+ }
3944
+ return withFormatting(text, edit, options);
3945
+ } else throw new Error(`Can not ${value === void 0 ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
3946
+ } else throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
3947
+ }
3948
+ __name(setProperty, "setProperty");
3949
+ __name2(setProperty, "setProperty");
3950
+ function withFormatting(text, edit, options) {
3951
+ if (!options.formattingOptions) return [edit];
3952
+ let newText = applyEdit(text, edit);
3953
+ let begin = edit.offset;
3954
+ let end = edit.offset + edit.content.length;
3955
+ if (edit.length === 0 || edit.content.length === 0) {
3956
+ while (begin > 0 && !isEOL(newText, begin - 1)) begin--;
3957
+ while (end < newText.length && !isEOL(newText, end)) end++;
3958
+ }
3959
+ const edits = format(newText, {
3960
+ offset: begin,
3961
+ length: end - begin
3962
+ }, {
3963
+ ...options.formattingOptions,
3964
+ keepLines: false
3965
+ });
3966
+ for (let i = edits.length - 1; i >= 0; i--) {
3967
+ const edit2 = edits[i];
3968
+ newText = applyEdit(newText, edit2);
3969
+ begin = Math.min(begin, edit2.offset);
3970
+ end = Math.max(end, edit2.offset + edit2.length);
3971
+ end += edit2.content.length - edit2.length;
3972
+ }
3973
+ const editLength = text.length - (newText.length - end) - begin;
3974
+ return [{
3975
+ offset: begin,
3976
+ length: editLength,
3977
+ content: newText.substring(begin, end)
3978
+ }];
3979
+ }
3980
+ __name(withFormatting, "withFormatting");
3981
+ __name2(withFormatting, "withFormatting");
3982
+ function applyEdit(text, edit) {
3983
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
3984
+ }
3985
+ __name(applyEdit, "applyEdit");
3986
+ __name2(applyEdit, "applyEdit");
3987
+ var ScanError;
3988
+ (function(ScanError2) {
3989
+ ScanError2[ScanError2["None"] = 0] = "None";
3990
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
3991
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
3992
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
3993
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
3994
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
3995
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
3996
+ })(ScanError || (ScanError = {}));
3997
+ var SyntaxKind;
3998
+ (function(SyntaxKind2) {
3999
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
4000
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
4001
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
4002
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
4003
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
4004
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
4005
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
4006
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
4007
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
4008
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
4009
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
4010
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
4011
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
4012
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
4013
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
4014
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
4015
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
4016
+ })(SyntaxKind || (SyntaxKind = {}));
4017
+ var parse2 = parse;
4018
+ var ParseErrorCode;
4019
+ (function(ParseErrorCode2) {
4020
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
4021
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
4022
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
4023
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
4024
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
4025
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
4026
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
4027
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
4028
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
4029
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
4030
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
4031
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
4032
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
4033
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
4034
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
4035
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
4036
+ })(ParseErrorCode || (ParseErrorCode = {}));
4037
+ function printParseErrorCode(code) {
4038
+ switch (code) {
4039
+ case 1:
4040
+ return "InvalidSymbol";
4041
+ case 2:
4042
+ return "InvalidNumberFormat";
4043
+ case 3:
4044
+ return "PropertyNameExpected";
4045
+ case 4:
4046
+ return "ValueExpected";
4047
+ case 5:
4048
+ return "ColonExpected";
4049
+ case 6:
4050
+ return "CommaExpected";
4051
+ case 7:
4052
+ return "CloseBraceExpected";
4053
+ case 8:
4054
+ return "CloseBracketExpected";
4055
+ case 9:
4056
+ return "EndOfFileExpected";
4057
+ case 10:
4058
+ return "InvalidCommentToken";
4059
+ case 11:
4060
+ return "UnexpectedEndOfComment";
4061
+ case 12:
4062
+ return "UnexpectedEndOfString";
4063
+ case 13:
4064
+ return "UnexpectedEndOfNumber";
4065
+ case 14:
4066
+ return "InvalidUnicode";
4067
+ case 15:
4068
+ return "InvalidEscapeCharacter";
4069
+ case 16:
4070
+ return "InvalidCharacter";
4071
+ }
4072
+ return "<unknown ParseErrorCode>";
4073
+ }
4074
+ __name(printParseErrorCode, "printParseErrorCode");
4075
+ __name2(printParseErrorCode, "printParseErrorCode");
4076
+ function format2(documentText, range, options) {
4077
+ return format(documentText, range, options);
4078
+ }
4079
+ __name(format2, "format2");
4080
+ __name2(format2, "format");
4081
+ function modify(text, path22, value, options) {
4082
+ return setProperty(text, path22, value, options);
4083
+ }
4084
+ __name(modify, "modify");
4085
+ __name2(modify, "modify");
4086
+ function applyEdits(text, edits) {
4087
+ let sortedEdits = edits.slice(0).sort((a, b) => {
4088
+ const diff = a.offset - b.offset;
4089
+ if (diff === 0) return a.length - b.length;
4090
+ return diff;
4091
+ });
4092
+ let lastModifiedOffset = text.length;
4093
+ for (let i = sortedEdits.length - 1; i >= 0; i--) {
4094
+ let e = sortedEdits[i];
4095
+ if (e.offset + e.length <= lastModifiedOffset) text = applyEdit(text, e);
4096
+ else throw new Error("Overlapping edit");
4097
+ lastModifiedOffset = e.offset;
4098
+ }
4099
+ return text;
4100
+ }
4101
+ __name(applyEdits, "applyEdits");
4102
+ __name2(applyEdits, "applyEdits");
4103
+ function getLineColFromPtr(string2, ptr) {
4104
+ let lines = string2.slice(0, ptr).split(/\r\n|\n|\r/g);
4105
+ return [lines.length, lines.pop().length + 1];
4106
+ }
4107
+ __name(getLineColFromPtr, "getLineColFromPtr");
4108
+ __name2(getLineColFromPtr, "getLineColFromPtr");
4109
+ function makeCodeBlock(string2, line, column) {
4110
+ let lines = string2.split(/\r\n|\n|\r/g);
4111
+ let codeblock = "";
4112
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
4113
+ for (let i = line - 1; i <= line + 1; i++) {
4114
+ let l = lines[i - 1];
4115
+ if (!l) continue;
4116
+ codeblock += i.toString().padEnd(numberLen, " ");
4117
+ codeblock += ": ";
4118
+ codeblock += l;
4119
+ codeblock += "\n";
4120
+ if (i === line) {
4121
+ codeblock += " ".repeat(numberLen + column + 2);
4122
+ codeblock += "^\n";
4123
+ }
4124
+ }
4125
+ return codeblock;
4126
+ }
4127
+ __name(makeCodeBlock, "makeCodeBlock");
4128
+ __name2(makeCodeBlock, "makeCodeBlock");
4129
+ var TomlError = class extends Error {
4130
+ static {
4131
+ __name(this, "TomlError");
4132
+ }
4133
+ static {
4134
+ __name2(this, "TomlError");
4135
+ }
4136
+ line;
4137
+ column;
4138
+ codeblock;
4139
+ constructor(message, options) {
4140
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
4141
+ const codeblock = makeCodeBlock(options.toml, line, column);
4142
+ super(`Invalid TOML document: ${message}
4143
+
4144
+ ${codeblock}`, options);
4145
+ this.line = line;
4146
+ this.column = column;
4147
+ this.codeblock = codeblock;
4148
+ }
4149
+ };
4150
+ function isEscaped(str, ptr) {
4151
+ let i = 0;
4152
+ while (str[ptr - ++i] === "\\") ;
4153
+ return --i && i % 2;
4154
+ }
4155
+ __name(isEscaped, "isEscaped");
4156
+ __name2(isEscaped, "isEscaped");
4157
+ function indexOfNewline(str, start = 0, end = str.length) {
4158
+ let idx = str.indexOf("\n", start);
4159
+ if (str[idx - 1] === "\r") idx--;
4160
+ return idx <= end ? idx : -1;
4161
+ }
4162
+ __name(indexOfNewline, "indexOfNewline");
4163
+ __name2(indexOfNewline, "indexOfNewline");
4164
+ function skipComment(str, ptr) {
4165
+ for (let i = ptr; i < str.length; i++) {
4166
+ let c = str[i];
4167
+ if (c === "\n") return i;
4168
+ if (c === "\r" && str[i + 1] === "\n") return i + 1;
4169
+ if (c < " " && c !== " " || c === "\x7F") throw new TomlError("control characters are not allowed in comments", {
4170
+ toml: str,
4171
+ ptr
4172
+ });
4173
+ }
4174
+ return str.length;
4175
+ }
4176
+ __name(skipComment, "skipComment");
4177
+ __name2(skipComment, "skipComment");
4178
+ function skipVoid(str, ptr, banNewLines, banComments) {
4179
+ let c;
4180
+ while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n")) ptr++;
4181
+ return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
4182
+ }
4183
+ __name(skipVoid, "skipVoid");
4184
+ __name2(skipVoid, "skipVoid");
4185
+ function skipUntil(str, ptr, sep2, end, banNewLines = false) {
4186
+ if (!end) {
4187
+ ptr = indexOfNewline(str, ptr);
4188
+ return ptr < 0 ? str.length : ptr;
4189
+ }
4190
+ for (let i = ptr; i < str.length; i++) {
4191
+ let c = str[i];
4192
+ if (c === "#") i = indexOfNewline(str, i);
4193
+ else if (c === sep2) return i + 1;
4194
+ else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) return i;
4195
+ }
4196
+ throw new TomlError("cannot find end of structure", {
4197
+ toml: str,
4198
+ ptr
4199
+ });
4200
+ }
4201
+ __name(skipUntil, "skipUntil");
4202
+ __name2(skipUntil, "skipUntil");
4203
+ function getStringEnd(str, seek) {
4204
+ let first = str[seek];
4205
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
4206
+ seek += target.length - 1;
4207
+ do
4208
+ seek = str.indexOf(target, ++seek);
4209
+ while (seek > -1 && first !== "'" && isEscaped(str, seek));
4210
+ if (seek > -1) {
4211
+ seek += target.length;
4212
+ if (target.length > 1) {
4213
+ if (str[seek] === first) seek++;
4214
+ if (str[seek] === first) seek++;
4215
+ }
4216
+ }
4217
+ return seek;
4218
+ }
4219
+ __name(getStringEnd, "getStringEnd");
4220
+ __name2(getStringEnd, "getStringEnd");
4221
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
4222
+ var TomlDate = class _TomlDate extends Date {
4223
+ static {
4224
+ __name(this, "_TomlDate");
4225
+ }
4226
+ static {
4227
+ __name2(this, "TomlDate");
4228
+ }
4229
+ #hasDate = false;
4230
+ #hasTime = false;
4231
+ #offset = null;
4232
+ constructor(date) {
4233
+ let hasDate = true;
4234
+ let hasTime = true;
4235
+ let offset = "Z";
4236
+ if (typeof date === "string") {
4237
+ let match = date.match(DATE_TIME_RE);
4238
+ if (match) {
4239
+ if (!match[1]) {
4240
+ hasDate = false;
4241
+ date = `0000-01-01T${date}`;
4242
+ }
4243
+ hasTime = !!match[2];
4244
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
4245
+ if (match[2] && +match[2] > 23) date = "";
4246
+ else {
4247
+ offset = match[3] || null;
4248
+ date = date.toUpperCase();
4249
+ if (!offset && hasTime) date += "Z";
4250
+ }
4251
+ } else date = "";
4252
+ }
4253
+ super(date);
4254
+ if (!isNaN(this.getTime())) {
4255
+ this.#hasDate = hasDate;
4256
+ this.#hasTime = hasTime;
4257
+ this.#offset = offset;
4258
+ }
4259
+ }
4260
+ isDateTime() {
4261
+ return this.#hasDate && this.#hasTime;
4262
+ }
4263
+ isLocal() {
4264
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
4265
+ }
4266
+ isDate() {
4267
+ return this.#hasDate && !this.#hasTime;
4268
+ }
4269
+ isTime() {
4270
+ return this.#hasTime && !this.#hasDate;
4271
+ }
4272
+ isValid() {
4273
+ return this.#hasDate || this.#hasTime;
4274
+ }
4275
+ toISOString() {
4276
+ let iso = super.toISOString();
4277
+ if (this.isDate()) return iso.slice(0, 10);
4278
+ if (this.isTime()) return iso.slice(11, 23);
4279
+ if (this.#offset === null) return iso.slice(0, -1);
4280
+ if (this.#offset === "Z") return iso;
4281
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
4282
+ offset = this.#offset[0] === "-" ? offset : -offset;
4283
+ return (/* @__PURE__ */ new Date(this.getTime() - offset * 6e4)).toISOString().slice(0, -1) + this.#offset;
4284
+ }
4285
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
4286
+ let date = new _TomlDate(jsDate);
4287
+ date.#offset = offset;
4288
+ return date;
4289
+ }
4290
+ static wrapAsLocalDateTime(jsDate) {
4291
+ let date = new _TomlDate(jsDate);
4292
+ date.#offset = null;
4293
+ return date;
4294
+ }
4295
+ static wrapAsLocalDate(jsDate) {
4296
+ let date = new _TomlDate(jsDate);
4297
+ date.#hasTime = false;
4298
+ date.#offset = null;
4299
+ return date;
4300
+ }
4301
+ static wrapAsLocalTime(jsDate) {
4302
+ let date = new _TomlDate(jsDate);
4303
+ date.#hasDate = false;
4304
+ date.#offset = null;
4305
+ return date;
4306
+ }
4307
+ };
4308
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
4309
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
4310
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
4311
+ var ESCAPE_REGEX = /^[0-9a-f]{4,8}$/i;
4312
+ var ESC_MAP = {
4313
+ b: "\b",
4314
+ t: " ",
4315
+ n: "\n",
4316
+ f: "\f",
4317
+ r: "\r",
4318
+ '"': '"',
4319
+ "\\": "\\"
4320
+ };
4321
+ function parseString(str, ptr = 0, endPtr = str.length) {
4322
+ let isLiteral = str[ptr] === "'";
4323
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
4324
+ if (isMultiline) {
4325
+ endPtr -= 2;
4326
+ if (str[ptr += 2] === "\r") ptr++;
4327
+ if (str[ptr] === "\n") ptr++;
4328
+ }
4329
+ let tmp = 0;
4330
+ let isEscape;
4331
+ let parsed = "";
4332
+ let sliceStart = ptr;
4333
+ while (ptr < endPtr - 1) {
4334
+ let c = str[ptr++];
4335
+ if (c === "\n" || c === "\r" && str[ptr] === "\n") {
4336
+ if (!isMultiline) throw new TomlError("newlines are not allowed in strings", {
4337
+ toml: str,
4338
+ ptr: ptr - 1
4339
+ });
4340
+ } else if (c < " " && c !== " " || c === "\x7F") throw new TomlError("control characters are not allowed in strings", {
4341
+ toml: str,
4342
+ ptr: ptr - 1
4343
+ });
4344
+ if (isEscape) {
4345
+ isEscape = false;
4346
+ if (c === "u" || c === "U") {
4347
+ let code = str.slice(ptr, ptr += c === "u" ? 4 : 8);
4348
+ if (!ESCAPE_REGEX.test(code)) throw new TomlError("invalid unicode escape", {
4349
+ toml: str,
4350
+ ptr: tmp
4351
+ });
4352
+ try {
4353
+ parsed += String.fromCodePoint(parseInt(code, 16));
4354
+ } catch {
4355
+ throw new TomlError("invalid unicode escape", {
4356
+ toml: str,
4357
+ ptr: tmp
4358
+ });
4359
+ }
4360
+ } else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
4361
+ ptr = skipVoid(str, ptr - 1, true);
4362
+ if (str[ptr] !== "\n" && str[ptr] !== "\r") throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
4363
+ toml: str,
4364
+ ptr: tmp
4365
+ });
4366
+ ptr = skipVoid(str, ptr);
4367
+ } else if (c in ESC_MAP) parsed += ESC_MAP[c];
4368
+ else throw new TomlError("unrecognized escape sequence", {
4369
+ toml: str,
4370
+ ptr: tmp
4371
+ });
4372
+ sliceStart = ptr;
4373
+ } else if (!isLiteral && c === "\\") {
4374
+ tmp = ptr - 1;
4375
+ isEscape = true;
4376
+ parsed += str.slice(sliceStart, tmp);
4377
+ }
4378
+ }
4379
+ return parsed + str.slice(sliceStart, endPtr - 1);
4380
+ }
4381
+ __name(parseString, "parseString");
4382
+ __name2(parseString, "parseString");
4383
+ function parseValue(value, toml, ptr, integersAsBigInt) {
4384
+ if (value === "true") return true;
4385
+ if (value === "false") return false;
4386
+ if (value === "-inf") return -Infinity;
4387
+ if (value === "inf" || value === "+inf") return Infinity;
4388
+ if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
4389
+ if (value === "-0") return integersAsBigInt ? 0n : 0;
4390
+ let isInt = INT_REGEX.test(value);
4391
+ if (isInt || FLOAT_REGEX.test(value)) {
4392
+ if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", {
4393
+ toml,
4394
+ ptr
4395
+ });
4396
+ value = value.replace(/_/g, "");
4397
+ let numeric = +value;
4398
+ if (isNaN(numeric)) throw new TomlError("invalid number", {
4399
+ toml,
4400
+ ptr
4401
+ });
4402
+ if (isInt) {
4403
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", {
4404
+ toml,
4405
+ ptr
4406
+ });
4407
+ if (isInt || integersAsBigInt === true) numeric = BigInt(value);
4408
+ }
4409
+ return numeric;
4410
+ }
4411
+ const date = new TomlDate(value);
4412
+ if (!date.isValid()) throw new TomlError("invalid value", {
4413
+ toml,
4414
+ ptr
4415
+ });
4416
+ return date;
4417
+ }
4418
+ __name(parseValue, "parseValue");
4419
+ __name2(parseValue, "parseValue");
4420
+ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
4421
+ let value = str.slice(startPtr, endPtr);
4422
+ let commentIdx = value.indexOf("#");
4423
+ if (commentIdx > -1) {
4424
+ skipComment(str, commentIdx);
4425
+ value = value.slice(0, commentIdx);
4426
+ }
4427
+ let trimmed = value.trimEnd();
4428
+ if (!allowNewLines) {
4429
+ let newlineIdx = value.indexOf("\n", trimmed.length);
4430
+ if (newlineIdx > -1) throw new TomlError("newlines are not allowed in inline tables", {
4431
+ toml: str,
4432
+ ptr: startPtr + newlineIdx
4433
+ });
4434
+ }
4435
+ return [trimmed, commentIdx];
4436
+ }
4437
+ __name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
4438
+ __name2(sliceAndTrimEndOf, "sliceAndTrimEndOf");
4439
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
4440
+ if (depth === 0) throw new TomlError("document contains excessively nested structures. aborting.", {
4441
+ toml: str,
4442
+ ptr
4443
+ });
4444
+ let c = str[ptr];
4445
+ if (c === "[" || c === "{") {
4446
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
4447
+ let newPtr = end ? skipUntil(str, endPtr2, ",", end) : endPtr2;
4448
+ if (endPtr2 - newPtr && end === "}") {
4449
+ let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
4450
+ if (nextNewLine > -1) throw new TomlError("newlines are not allowed in inline tables", {
4451
+ toml: str,
4452
+ ptr: nextNewLine
4453
+ });
4454
+ }
4455
+ return [value, newPtr];
4456
+ }
4457
+ let endPtr;
4458
+ if (c === '"' || c === "'") {
4459
+ endPtr = getStringEnd(str, ptr);
4460
+ let parsed = parseString(str, ptr, endPtr);
4461
+ if (end) {
4462
+ endPtr = skipVoid(str, endPtr, end !== "]");
4463
+ if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") throw new TomlError("unexpected character encountered", {
4464
+ toml: str,
4465
+ ptr: endPtr
4466
+ });
4467
+ endPtr += +(str[endPtr] === ",");
4468
+ }
4469
+ return [parsed, endPtr];
4470
+ }
4471
+ endPtr = skipUntil(str, ptr, ",", end);
4472
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
4473
+ if (!slice[0]) throw new TomlError("incomplete key-value declaration: no value specified", {
4474
+ toml: str,
4475
+ ptr
4476
+ });
4477
+ if (end && slice[1] > -1) {
4478
+ endPtr = skipVoid(str, ptr + slice[1]);
4479
+ endPtr += +(str[endPtr] === ",");
4480
+ }
4481
+ return [parseValue(slice[0], str, ptr, integersAsBigInt), endPtr];
4482
+ }
4483
+ __name(extractValue, "extractValue");
4484
+ __name2(extractValue, "extractValue");
4485
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
4486
+ function parseKey(str, ptr, end = "=") {
4487
+ let dot = ptr - 1;
4488
+ let parsed = [];
4489
+ let endPtr = str.indexOf(end, ptr);
4490
+ if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
4491
+ toml: str,
4492
+ ptr
4493
+ });
4494
+ do {
4495
+ let c = str[ptr = ++dot];
4496
+ if (c !== " " && c !== " ") if (c === '"' || c === "'") {
4497
+ if (c === str[ptr + 1] && c === str[ptr + 2]) throw new TomlError("multiline strings are not allowed in keys", {
4498
+ toml: str,
4499
+ ptr
4500
+ });
4501
+ let eos = getStringEnd(str, ptr);
4502
+ if (eos < 0) throw new TomlError("unfinished string encountered", {
4503
+ toml: str,
4504
+ ptr
4505
+ });
4506
+ dot = str.indexOf(".", eos);
4507
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
4508
+ let newLine = indexOfNewline(strEnd);
4509
+ if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
4510
+ toml: str,
4511
+ ptr: ptr + dot + newLine
4512
+ });
4513
+ if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
4514
+ toml: str,
4515
+ ptr: eos
4516
+ });
4517
+ if (endPtr < eos) {
4518
+ endPtr = str.indexOf(end, eos);
4519
+ if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
4520
+ toml: str,
4521
+ ptr
4522
+ });
4523
+ }
4524
+ parsed.push(parseString(str, ptr, eos));
4525
+ } else {
4526
+ dot = str.indexOf(".", ptr);
4527
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
4528
+ if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
4529
+ toml: str,
4530
+ ptr
4531
+ });
4532
+ parsed.push(part.trimEnd());
4533
+ }
4534
+ } while (dot + 1 && dot < endPtr);
4535
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
4536
+ }
4537
+ __name(parseKey, "parseKey");
4538
+ __name2(parseKey, "parseKey");
4539
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
4540
+ let res = {};
4541
+ let seen = /* @__PURE__ */ new Set();
4542
+ let c;
4543
+ let comma = 0;
4544
+ ptr++;
4545
+ while ((c = str[ptr++]) !== "}" && c) {
4546
+ let err = {
4547
+ toml: str,
4548
+ ptr: ptr - 1
4549
+ };
4550
+ if (c === "\n") throw new TomlError("newlines are not allowed in inline tables", err);
4551
+ else if (c === "#") throw new TomlError("inline tables cannot contain comments", err);
4552
+ else if (c === ",") throw new TomlError("expected key-value, found comma", err);
4553
+ else if (c !== " " && c !== " ") {
4554
+ let k;
4555
+ let t = res;
4556
+ let hasOwn = false;
4557
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
4558
+ for (let i = 0; i < key.length; i++) {
4559
+ if (i) t = hasOwn ? t[k] : t[k] = {};
4560
+ k = key[i];
4561
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
4562
+ toml: str,
4563
+ ptr
4564
+ });
4565
+ if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
4566
+ enumerable: true,
4567
+ configurable: true,
4568
+ writable: true
4569
+ });
4570
+ }
4571
+ if (hasOwn) throw new TomlError("trying to redefine an already defined value", {
4572
+ toml: str,
4573
+ ptr
4574
+ });
4575
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
4576
+ seen.add(value);
4577
+ t[k] = value;
4578
+ ptr = valueEndPtr;
4579
+ comma = str[ptr - 1] === "," ? ptr - 1 : 0;
4580
+ }
4581
+ }
4582
+ if (comma) throw new TomlError("trailing commas are not allowed in inline tables", {
4583
+ toml: str,
4584
+ ptr: comma
4585
+ });
4586
+ if (!c) throw new TomlError("unfinished table encountered", {
4587
+ toml: str,
4588
+ ptr
4589
+ });
4590
+ return [res, ptr];
4591
+ }
4592
+ __name(parseInlineTable, "parseInlineTable");
4593
+ __name2(parseInlineTable, "parseInlineTable");
4594
+ function parseArray(str, ptr, depth, integersAsBigInt) {
4595
+ let res = [];
4596
+ let c;
4597
+ ptr++;
4598
+ while ((c = str[ptr++]) !== "]" && c) if (c === ",") throw new TomlError("expected value, found comma", {
4599
+ toml: str,
4600
+ ptr: ptr - 1
4601
+ });
4602
+ else if (c === "#") ptr = skipComment(str, ptr);
4603
+ else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
4604
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
4605
+ res.push(e[0]);
4606
+ ptr = e[1];
4607
+ }
4608
+ if (!c) throw new TomlError("unfinished array encountered", {
4609
+ toml: str,
4610
+ ptr
4611
+ });
4612
+ return [res, ptr];
4613
+ }
4614
+ __name(parseArray, "parseArray");
4615
+ __name2(parseArray, "parseArray");
4616
+ function peekTable(key, table, meta, type) {
4617
+ let t = table;
4618
+ let m = meta;
4619
+ let k;
4620
+ let hasOwn = false;
4621
+ let state;
4622
+ for (let i = 0; i < key.length; i++) {
4623
+ if (i) {
4624
+ t = hasOwn ? t[k] : t[k] = {};
4625
+ m = (state = m[k]).c;
4626
+ if (type === 0 && (state.t === 1 || state.t === 2)) return null;
4627
+ if (state.t === 2) {
4628
+ let l = t.length - 1;
4629
+ t = t[l];
4630
+ m = m[l].c;
4631
+ }
4632
+ }
4633
+ k = key[i];
4634
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
4635
+ if (!hasOwn) {
4636
+ if (k === "__proto__") {
4637
+ Object.defineProperty(t, k, {
4638
+ enumerable: true,
4639
+ configurable: true,
4640
+ writable: true
4641
+ });
4642
+ Object.defineProperty(m, k, {
4643
+ enumerable: true,
4644
+ configurable: true,
4645
+ writable: true
4646
+ });
4647
+ }
4648
+ m[k] = {
4649
+ t: i < key.length - 1 && type === 2 ? 3 : type,
4650
+ d: false,
4651
+ i: 0,
4652
+ c: {}
4653
+ };
4654
+ }
4655
+ }
4656
+ state = m[k];
4657
+ if (state.t !== type && !(type === 1 && state.t === 3)) return null;
4658
+ if (type === 2) {
4659
+ if (!state.d) {
4660
+ state.d = true;
4661
+ t[k] = [];
4662
+ }
4663
+ t[k].push(t = {});
4664
+ state.c[state.i++] = state = {
4665
+ t: 1,
4666
+ d: false,
4667
+ i: 0,
4668
+ c: {}
4669
+ };
4670
+ }
4671
+ if (state.d) return null;
4672
+ state.d = true;
4673
+ if (type === 1) t = hasOwn ? t[k] : t[k] = {};
4674
+ else if (type === 0 && hasOwn) return null;
4675
+ return [
4676
+ k,
4677
+ t,
4678
+ state.c
4679
+ ];
4680
+ }
4681
+ __name(peekTable, "peekTable");
4682
+ __name2(peekTable, "peekTable");
4683
+ function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
4684
+ let res = {};
4685
+ let meta = {};
4686
+ let tbl = res;
4687
+ let m = meta;
4688
+ for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
4689
+ if (toml[ptr] === "[") {
4690
+ let isTableArray = toml[++ptr] === "[";
4691
+ let k = parseKey(toml, ptr += +isTableArray, "]");
4692
+ if (isTableArray) {
4693
+ if (toml[k[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
4694
+ toml,
4695
+ ptr: k[1] - 1
4696
+ });
4697
+ k[1]++;
4698
+ }
4699
+ let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
4700
+ if (!p) throw new TomlError("trying to redefine an already defined table or value", {
4701
+ toml,
4702
+ ptr
4703
+ });
4704
+ m = p[2];
4705
+ tbl = p[1];
4706
+ ptr = k[1];
4707
+ } else {
4708
+ let k = parseKey(toml, ptr);
4709
+ let p = peekTable(k[0], tbl, m, 0);
4710
+ if (!p) throw new TomlError("trying to redefine an already defined table or value", {
4711
+ toml,
4712
+ ptr
4713
+ });
4714
+ let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
4715
+ p[1][p[0]] = v[0];
4716
+ ptr = v[1];
4717
+ }
4718
+ ptr = skipVoid(toml, ptr, true);
4719
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") throw new TomlError("each key-value declaration must be followed by an end-of-line", {
4720
+ toml,
4721
+ ptr
4722
+ });
4723
+ ptr = skipVoid(toml, ptr);
4724
+ }
4725
+ return res;
4726
+ }
4727
+ __name(parse3, "parse3");
4728
+ __name2(parse3, "parse");
4729
+ var BARE_KEY = /^[a-z0-9-_]+$/i;
4730
+ function extendedTypeOf(obj) {
4731
+ let type = typeof obj;
4732
+ if (type === "object") {
4733
+ if (Array.isArray(obj)) return "array";
4734
+ if (obj instanceof Date) return "date";
4735
+ }
4736
+ return type;
4737
+ }
4738
+ __name(extendedTypeOf, "extendedTypeOf");
4739
+ __name2(extendedTypeOf, "extendedTypeOf");
4740
+ function isArrayOfTables(obj) {
4741
+ for (let i = 0; i < obj.length; i++) if (extendedTypeOf(obj[i]) !== "object") return false;
4742
+ return obj.length != 0;
4743
+ }
4744
+ __name(isArrayOfTables, "isArrayOfTables");
4745
+ __name2(isArrayOfTables, "isArrayOfTables");
4746
+ function formatString(s) {
4747
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
4748
+ }
4749
+ __name(formatString, "formatString");
4750
+ __name2(formatString, "formatString");
4751
+ function stringifyValue(val, type, depth, numberAsFloat) {
4752
+ if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
4753
+ if (type === "number") {
4754
+ if (isNaN(val)) return "nan";
4755
+ if (val === Infinity) return "inf";
4756
+ if (val === -Infinity) return "-inf";
4757
+ if (numberAsFloat && Number.isInteger(val)) return val.toFixed(1);
4758
+ return val.toString();
4759
+ }
4760
+ if (type === "bigint" || type === "boolean") return val.toString();
4761
+ if (type === "string") return formatString(val);
4762
+ if (type === "date") {
4763
+ if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
4764
+ return val.toISOString();
4765
+ }
4766
+ if (type === "object") return stringifyInlineTable(val, depth, numberAsFloat);
4767
+ if (type === "array") return stringifyArray(val, depth, numberAsFloat);
4768
+ }
4769
+ __name(stringifyValue, "stringifyValue");
4770
+ __name2(stringifyValue, "stringifyValue");
4771
+ function stringifyInlineTable(obj, depth, numberAsFloat) {
4772
+ let keys = Object.keys(obj);
4773
+ if (keys.length === 0) return "{}";
4774
+ let res = "{ ";
4775
+ for (let i = 0; i < keys.length; i++) {
4776
+ let k = keys[i];
4777
+ if (i) res += ", ";
4778
+ res += BARE_KEY.test(k) ? k : formatString(k);
4779
+ res += " = ";
4780
+ res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
4781
+ }
4782
+ return res + " }";
4783
+ }
4784
+ __name(stringifyInlineTable, "stringifyInlineTable");
4785
+ __name2(stringifyInlineTable, "stringifyInlineTable");
4786
+ function stringifyArray(array2, depth, numberAsFloat) {
4787
+ if (array2.length === 0) return "[]";
4788
+ let res = "[ ";
4789
+ for (let i = 0; i < array2.length; i++) {
4790
+ if (i) res += ", ";
4791
+ if (array2[i] === null || array2[i] === void 0) throw new TypeError("arrays cannot contain null or undefined values");
4792
+ res += stringifyValue(array2[i], extendedTypeOf(array2[i]), depth - 1, numberAsFloat);
4793
+ }
4794
+ return res + " ]";
4795
+ }
4796
+ __name(stringifyArray, "stringifyArray");
4797
+ __name2(stringifyArray, "stringifyArray");
4798
+ function stringifyArrayTable(array2, key, depth, numberAsFloat) {
4799
+ if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
4800
+ let res = "";
4801
+ for (let i = 0; i < array2.length; i++) {
4802
+ res += `${res && "\n"}[[${key}]]
4803
+ `;
4804
+ res += stringifyTable(0, array2[i], key, depth, numberAsFloat);
4805
+ }
4806
+ return res;
4807
+ }
4808
+ __name(stringifyArrayTable, "stringifyArrayTable");
4809
+ __name2(stringifyArrayTable, "stringifyArrayTable");
4810
+ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
4811
+ if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
4812
+ let preamble = "";
4813
+ let tables = "";
4814
+ let keys = Object.keys(obj);
4815
+ for (let i = 0; i < keys.length; i++) {
4816
+ let k = keys[i];
4817
+ if (obj[k] !== null && obj[k] !== void 0) {
4818
+ let type = extendedTypeOf(obj[k]);
4819
+ if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
4820
+ let key = BARE_KEY.test(k) ? k : formatString(k);
4821
+ if (type === "array" && isArrayOfTables(obj[k])) tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
4822
+ else if (type === "object") {
4823
+ let tblKey = prefix ? `${prefix}.${key}` : key;
4824
+ tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
4825
+ } else {
4826
+ preamble += key;
4827
+ preamble += " = ";
4828
+ preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
4829
+ preamble += "\n";
4830
+ }
4831
+ }
4832
+ }
4833
+ if (tableKey && (preamble || !tables)) preamble = preamble ? `[${tableKey}]
4834
+ ${preamble}` : `[${tableKey}]`;
4835
+ return preamble && tables ? `${preamble}
4836
+ ${tables}` : preamble || tables;
4837
+ }
4838
+ __name(stringifyTable, "stringifyTable");
4839
+ __name2(stringifyTable, "stringifyTable");
4840
+ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
4841
+ if (extendedTypeOf(obj) !== "object") throw new TypeError("stringify can only be called with an object");
4842
+ let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
4843
+ if (str[str.length - 1] !== "\n") return str + "\n";
4844
+ return str;
4845
+ }
4846
+ __name(stringify, "stringify");
4847
+ __name2(stringify, "stringify");
4848
+ var dist_default = {
4849
+ parse: parse3,
4850
+ stringify,
4851
+ TomlDate,
4852
+ TomlError
4853
+ };
4854
+ var ParseError = class extends UserError {
4855
+ static {
4856
+ __name(this, "ParseError");
4857
+ }
4858
+ static {
4859
+ __name2(this, "ParseError");
4860
+ }
4861
+ text;
4862
+ notes;
4863
+ location;
4864
+ kind;
4865
+ constructor({ text, notes, location, kind, telemetryMessage }) {
4866
+ super(text, { telemetryMessage });
4867
+ this.name = this.constructor.name;
4868
+ this.text = text;
4869
+ this.notes = notes ?? [];
4870
+ this.location = location;
4871
+ this.kind = kind ?? "error";
4872
+ }
4873
+ };
4874
+ (class extends ParseError {
4875
+ static {
4876
+ __name(this, "APIError");
4877
+ }
4878
+ static {
4879
+ __name2(this, "APIError");
4880
+ }
4881
+ #status;
4882
+ code;
4883
+ accountTag;
4884
+ constructor({ status, ...rest }) {
4885
+ super(rest);
4886
+ this.name = this.constructor.name;
4887
+ this.#status = status;
4888
+ }
4889
+ get status() {
4890
+ return this.#status;
4891
+ }
4892
+ isGatewayError() {
4893
+ if (this.#status !== void 0) return [524].includes(this.#status);
4894
+ return false;
4895
+ }
4896
+ isRetryable() {
4897
+ return String(this.#status).startsWith("5");
4898
+ }
4899
+ #reportable = true;
4900
+ get reportable() {
4901
+ return this.#reportable;
4902
+ }
4903
+ preventReport() {
4904
+ this.#reportable = false;
4905
+ }
4906
+ });
4907
+ function parseTOML(tomlContent, filePath) {
4908
+ try {
4909
+ return dist_default.parse(tomlContent);
4910
+ } catch (err) {
4911
+ if (!(err instanceof TomlError)) throw err;
4912
+ const location = {
4913
+ lineText: tomlContent.split("\n")[err.line - 1],
4914
+ line: err.line,
4915
+ column: err.column - 1,
4916
+ file: filePath,
4917
+ fileText: tomlContent
4918
+ };
4919
+ throw new ParseError({
4920
+ text: err.message.substring(0, err.message.indexOf("\n")),
4921
+ location,
4922
+ telemetryMessage: "TOML parse error"
4923
+ });
4924
+ }
4925
+ }
4926
+ __name(parseTOML, "parseTOML");
4927
+ __name2(parseTOML, "parseTOML");
4928
+ function parsePackageJSON(input, file2) {
4929
+ return parseJSON(input, file2);
4930
+ }
4931
+ __name(parsePackageJSON, "parsePackageJSON");
4932
+ __name2(parsePackageJSON, "parsePackageJSON");
4933
+ function parseJSON(input, file2) {
4934
+ return parseJSONC(input, file2, {
4935
+ allowEmptyContent: false,
4936
+ allowTrailingComma: false,
4937
+ disallowComments: true
4938
+ });
4939
+ }
4940
+ __name(parseJSON, "parseJSON");
4941
+ __name2(parseJSON, "parseJSON");
4942
+ function parseJSONC(input, file2, options = { allowTrailingComma: true }) {
4943
+ const errors = [];
4944
+ const data = parse2(input, errors, options);
4945
+ if (errors.length) throw new ParseError({
4946
+ text: printParseErrorCode(errors[0].error),
4947
+ location: {
4948
+ ...indexLocation({
4949
+ file: file2,
4950
+ fileText: input
4951
+ }, errors[0].offset + 1),
4952
+ length: errors[0].length
4953
+ },
4954
+ telemetryMessage: "JSON(C) parse error"
4955
+ });
4956
+ return data;
4957
+ }
4958
+ __name(parseJSONC, "parseJSONC");
4959
+ __name2(parseJSONC, "parseJSONC");
4960
+ function readFileSyncToBuffer(file2) {
4961
+ try {
4962
+ return readFileSync(file2);
4963
+ } catch (err) {
4964
+ const { message } = err;
4965
+ throw new ParseError({
4966
+ text: `Could not read file: ${file2}`,
4967
+ notes: [{ text: message.replace(file2, resolve(file2)) }],
4968
+ telemetryMessage: false
4969
+ });
4970
+ }
4971
+ }
4972
+ __name(readFileSyncToBuffer, "readFileSyncToBuffer");
4973
+ __name2(readFileSyncToBuffer, "readFileSyncToBuffer");
4974
+ function readFileSync$1(file2) {
4975
+ try {
4976
+ return removeBOMAndValidate(readFileSync(file2), file2);
4977
+ } catch (err) {
4978
+ if (err instanceof ParseError) throw err;
4979
+ const { message } = err;
4980
+ throw new ParseError({
4981
+ text: `Could not read file: ${file2}`,
4982
+ notes: [{ text: message.replace(file2, resolve(file2)) }],
4983
+ telemetryMessage: "Could not read file"
4984
+ });
4985
+ }
4986
+ }
4987
+ __name(readFileSync$1, "readFileSync$1");
4988
+ __name2(readFileSync$1, "readFileSync");
4989
+ function indexLocation(file2, index) {
4990
+ let lineText, line = 0, column = 0, cursor = 0;
4991
+ const { fileText = "" } = file2;
4992
+ for (const row of fileText.split("\n")) {
4993
+ line++;
4994
+ cursor += row.length + 1;
4995
+ if (cursor >= index) {
4996
+ lineText = row;
4997
+ column = row.length - (cursor - index);
4998
+ break;
4999
+ }
5000
+ }
5001
+ return {
5002
+ lineText,
5003
+ line,
5004
+ column,
5005
+ ...file2
5006
+ };
5007
+ }
5008
+ __name(indexLocation, "indexLocation");
5009
+ __name2(indexLocation, "indexLocation");
5010
+ function searchLocation(file2, query) {
5011
+ let lineText, length, line = 0, column = 0;
5012
+ const queryText = String(query);
5013
+ const { fileText = "" } = file2;
5014
+ for (const content of fileText.split("\n")) {
5015
+ line++;
5016
+ const index = content.indexOf(queryText);
5017
+ if (index >= 0) {
5018
+ lineText = content;
5019
+ column = index;
5020
+ length = queryText.length;
5021
+ break;
5022
+ }
5023
+ }
5024
+ return {
5025
+ lineText,
5026
+ line,
5027
+ column,
5028
+ length,
5029
+ ...file2
5030
+ };
5031
+ }
5032
+ __name(searchLocation, "searchLocation");
5033
+ __name2(searchLocation, "searchLocation");
5034
+ var units = {
5035
+ nanoseconds: 1e-9,
5036
+ nanosecond: 1e-9,
5037
+ microseconds: 1e-6,
5038
+ microsecond: 1e-6,
5039
+ milliseconds: 1e-3,
5040
+ millisecond: 1e-3,
5041
+ seconds: 1,
5042
+ second: 1,
5043
+ minutes: 60,
5044
+ minute: 60,
5045
+ hours: 3600,
5046
+ hour: 3600,
5047
+ days: 86400,
5048
+ day: 86400,
5049
+ weeks: 604800,
5050
+ week: 604800,
5051
+ month: 18144e3,
5052
+ year: 220752e3,
5053
+ nsecs: 1e-9,
5054
+ nsec: 1e-9,
5055
+ usecs: 1e-6,
5056
+ usec: 1e-6,
5057
+ msecs: 1e-3,
5058
+ msec: 1e-3,
5059
+ secs: 1,
5060
+ sec: 1,
5061
+ mins: 60,
5062
+ min: 60,
5063
+ ns: 1e-9,
5064
+ us: 1e-6,
5065
+ ms: 1e-3,
5066
+ mo: 18144e3,
5067
+ yr: 220752e3,
5068
+ s: 1,
5069
+ m: 60,
5070
+ h: 3600,
5071
+ d: 86400,
5072
+ w: 604800,
5073
+ y: 220752e3
5074
+ };
5075
+ function parseHumanDuration(s) {
5076
+ const unitsMap = new Map(Object.entries(units));
5077
+ s = s.trim().toLowerCase();
5078
+ let base = 1;
5079
+ for (const [name, _] of unitsMap) if (s.endsWith(name)) {
5080
+ s = s.substring(0, s.length - name.length);
5081
+ base = unitsMap.get(name) || 1;
5082
+ break;
5083
+ }
5084
+ return Number(s) * base;
5085
+ }
5086
+ __name(parseHumanDuration, "parseHumanDuration");
5087
+ __name2(parseHumanDuration, "parseHumanDuration");
5088
+ function parseNonHyphenedUuid(uuid) {
5089
+ if (uuid == null || uuid.includes("-")) return uuid;
5090
+ if (uuid.length != 32) return null;
5091
+ const uuid_parts = [];
5092
+ uuid_parts.push(uuid.slice(0, 8));
5093
+ uuid_parts.push(uuid.slice(8, 12));
5094
+ uuid_parts.push(uuid.slice(12, 16));
5095
+ uuid_parts.push(uuid.slice(16, 20));
5096
+ uuid_parts.push(uuid.slice(20));
5097
+ let hyphenated = "";
5098
+ uuid_parts.forEach((part) => hyphenated += part + "-");
5099
+ return hyphenated.slice(0, 36);
5100
+ }
5101
+ __name(parseNonHyphenedUuid, "parseNonHyphenedUuid");
5102
+ __name2(parseNonHyphenedUuid, "parseNonHyphenedUuid");
5103
+ function parseByteSize(s, base = void 0) {
5104
+ const match = s.match(/^(\d*\.*\d*)\s*([kKmMgGtTpP]{0,1})([i]{0,1}[bB]{0,1})$/);
5105
+ if (!match) return NaN;
5106
+ const size = match[1];
5107
+ if (size.length === 0 || isNaN(Number(size))) return NaN;
5108
+ const unit = match[2].toLowerCase();
5109
+ const sizeUnits = {
5110
+ k: 1,
5111
+ m: 2,
5112
+ g: 3,
5113
+ t: 4,
5114
+ p: 5
5115
+ };
5116
+ if (unit.length !== 0 && !(unit in sizeUnits)) return NaN;
5117
+ const binary = match[3].toLowerCase() == "ib";
5118
+ if (binary && unit.length === 0) return NaN;
5119
+ const pow = sizeUnits[unit] || 0;
5120
+ return Math.floor(Number(size) * Math.pow(base ?? (binary ? 1024 : 1e3), pow));
5121
+ }
5122
+ __name(parseByteSize, "parseByteSize");
5123
+ __name2(parseByteSize, "parseByteSize");
5124
+ var UNSUPPORTED_BOMS = [
5125
+ {
5126
+ buffer: Buffer.from([
5127
+ 0,
5128
+ 0,
5129
+ 254,
5130
+ 255
5131
+ ]),
5132
+ encoding: "UTF-32 BE"
5133
+ },
5134
+ {
5135
+ buffer: Buffer.from([
5136
+ 255,
5137
+ 254,
5138
+ 0,
5139
+ 0
5140
+ ]),
5141
+ encoding: "UTF-32 LE"
5142
+ },
5143
+ {
5144
+ buffer: Buffer.from([254, 255]),
5145
+ encoding: "UTF-16 BE"
5146
+ },
5147
+ {
5148
+ buffer: Buffer.from([255, 254]),
5149
+ encoding: "UTF-16 LE"
5150
+ }
5151
+ ];
5152
+ function removeBOMAndValidate(buffer, file2) {
5153
+ for (const bom of UNSUPPORTED_BOMS) if (buffer.length >= bom.buffer.length && buffer.subarray(0, bom.buffer.length).equals(bom.buffer)) throw new ParseError({
5154
+ text: `Configuration file contains ${bom.encoding} byte order marker`,
5155
+ notes: [{ text: `The file "${file2}" appears to be encoded as ${bom.encoding}. Please save the file as UTF-8 without BOM.` }],
5156
+ location: {
5157
+ file: file2,
5158
+ line: 1,
5159
+ column: 0
5160
+ },
5161
+ telemetryMessage: `${bom.encoding} BOM detected`
5162
+ });
5163
+ const content = buffer.toString("utf-8");
5164
+ if (content.charCodeAt(0) === 65279) return content.slice(1);
5165
+ return content;
5166
+ }
5167
+ __name(removeBOMAndValidate, "removeBOMAndValidate");
5168
+ __name2(removeBOMAndValidate, "removeBOMAndValidate");
5169
+ var PATH_TO_DEPLOY_CONFIG = ".wrangler/deploy/config.json";
5170
+ function absolute(input, root) {
5171
+ return isAbsolute(input) ? input : resolve(root || ".", input);
5172
+ }
5173
+ __name(absolute, "absolute");
5174
+ __name2(absolute, "absolute");
5175
+ function up(base, options) {
5176
+ let { last, cwd } = options || {};
5177
+ let tmp = absolute(base, cwd);
5178
+ let root = absolute(last || "/", cwd);
5179
+ let prev, arr = [];
5180
+ while (prev !== root) {
5181
+ arr.push(tmp);
5182
+ tmp = dirname(prev = tmp);
5183
+ if (tmp === prev) break;
5184
+ }
5185
+ return arr;
5186
+ }
5187
+ __name(up, "up");
5188
+ __name2(up, "up");
5189
+ function file(name, options) {
5190
+ let dir, tmp;
5191
+ for (dir of up(options && options.cwd || "", options)) try {
5192
+ tmp = join(dir, name);
5193
+ if (statSync(tmp).isFile()) return tmp;
5194
+ } catch {
5195
+ }
5196
+ }
5197
+ __name(file, "file");
5198
+ __name2(file, "file");
5199
+ function dedent$2(templ) {
5200
+ var values = [];
5201
+ for (var _i = 1; _i < arguments.length; _i++) values[_i - 1] = arguments[_i];
5202
+ var strings = Array.from(typeof templ === "string" ? [templ] : templ);
5203
+ strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
5204
+ var indentLengths = strings.reduce(function(arr, str) {
5205
+ var matches = str.match(/\n([\t ]+|(?!\s).)/g);
5206
+ if (matches) return arr.concat(matches.map(function(match) {
5207
+ var _a, _b;
5208
+ return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
5209
+ }));
5210
+ return arr;
5211
+ }, []);
5212
+ if (indentLengths.length) {
5213
+ var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
5214
+ strings = strings.map(function(str) {
5215
+ return str.replace(pattern_1, "\n");
5216
+ });
5217
+ }
5218
+ strings[0] = strings[0].replace(/^\r?\n/, "");
5219
+ var string2 = strings[0];
5220
+ values.forEach(function(value, i) {
5221
+ var endentations = string2.match(/(?:^|\n)( *)$/);
5222
+ var endentation = endentations ? endentations[1] : "";
5223
+ var indentedValue = value;
5224
+ if (typeof value === "string" && value.includes("\n")) indentedValue = String(value).split("\n").map(function(str, i2) {
5225
+ return i2 === 0 ? str : "" + endentation + str;
5226
+ }).join("\n");
5227
+ string2 += indentedValue + strings[i + 1];
5228
+ });
5229
+ return string2;
5230
+ }
5231
+ __name(dedent$2, "dedent$2");
5232
+ __name2(dedent$2, "dedent");
5233
+ var esm_default = dedent$2;
5234
+ function resolveWranglerConfigPath({ config, script }, options) {
5235
+ if (config !== void 0) return {
5236
+ userConfigPath: config,
5237
+ configPath: config,
5238
+ deployConfigPath: void 0,
5239
+ redirected: false
5240
+ };
5241
+ return findWranglerConfig(script !== void 0 ? path3__default.dirname(script) : process.cwd(), options);
5242
+ }
5243
+ __name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
5244
+ __name2(resolveWranglerConfigPath, "resolveWranglerConfigPath");
5245
+ function findWranglerConfig(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
5246
+ const userConfigPath = file(`wrangler.json`, { cwd: referencePath }) ?? file(`wrangler.jsonc`, { cwd: referencePath }) ?? file(`wrangler.toml`, { cwd: referencePath });
5247
+ if (!useRedirectIfAvailable) return {
5248
+ userConfigPath,
5249
+ configPath: userConfigPath,
5250
+ deployConfigPath: void 0,
5251
+ redirected: false
5252
+ };
5253
+ const { configPath, deployConfigPath, redirected } = findRedirectedWranglerConfig(referencePath, userConfigPath);
5254
+ return {
5255
+ userConfigPath,
5256
+ configPath,
5257
+ deployConfigPath,
5258
+ redirected
5259
+ };
5260
+ }
5261
+ __name(findWranglerConfig, "findWranglerConfig");
5262
+ __name2(findWranglerConfig, "findWranglerConfig");
5263
+ function findRedirectedWranglerConfig(cwd, userConfigPath) {
5264
+ const deployConfigPath = file(PATH_TO_DEPLOY_CONFIG, { cwd });
5265
+ if (deployConfigPath === void 0) return {
5266
+ configPath: userConfigPath,
5267
+ deployConfigPath,
5268
+ redirected: false
5269
+ };
5270
+ let redirectedConfigPath;
5271
+ const deployConfigFile = readFileSync$1(deployConfigPath);
5272
+ try {
5273
+ const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
5274
+ redirectedConfigPath = deployConfig.configPath && path3__default.resolve(path3__default.dirname(deployConfigPath), deployConfig.configPath);
5275
+ } catch (e) {
5276
+ throw new UserError(`Failed to parse the deploy configuration file at ${path3__default.relative(".", deployConfigPath)}`, {
5277
+ cause: e,
5278
+ telemetryMessage: false
5279
+ });
5280
+ }
5281
+ if (!redirectedConfigPath) throw new UserError(esm_default`
5282
+ A deploy configuration file was found at "${path3__default.relative(".", deployConfigPath)}".
5283
+ But this is not valid - the required "configPath" property was not found.
5284
+ Instead this file contains:
5285
+ \`\`\`
5286
+ ${deployConfigFile}
5287
+ \`\`\`
5288
+ `, { telemetryMessage: false });
5289
+ if (!existsSync(redirectedConfigPath)) throw new UserError(esm_default`
5290
+ There is a deploy configuration at "${path3__default.relative(".", deployConfigPath)}".
5291
+ But the redirected configuration path it points to, "${path3__default.relative(".", redirectedConfigPath)}", does not exist.
5292
+ `, { telemetryMessage: false });
5293
+ if (userConfigPath) {
5294
+ if (path3__default.join(path3__default.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) throw new UserError(esm_default`
5295
+ Found both a user configuration file at "${path3__default.relative(".", userConfigPath)}"
5296
+ and a deploy configuration file at "${path3__default.relative(".", deployConfigPath)}".
5297
+ But these do not share the same base path so it is not clear which should be used.
5298
+ `, { telemetryMessage: false });
5299
+ }
5300
+ return {
5301
+ configPath: redirectedConfigPath,
5302
+ deployConfigPath,
5303
+ redirected: true
5304
+ };
5305
+ }
5306
+ __name(findRedirectedWranglerConfig, "findRedirectedWranglerConfig");
5307
+ __name2(findRedirectedWranglerConfig, "findRedirectedWranglerConfig");
5308
+ function isRedirectedConfig(config) {
5309
+ return config.configPath !== void 0 && config.configPath !== config.userConfigPath;
5310
+ }
5311
+ __name(isRedirectedConfig, "isRedirectedConfig");
5312
+ __name2(isRedirectedConfig, "isRedirectedConfig");
5313
+ function isRedirectedRawConfig(rawConfig, configPath, userConfigPath) {
5314
+ return isRedirectedConfig({
5315
+ configPath,
5316
+ userConfigPath
5317
+ });
5318
+ }
5319
+ __name(isRedirectedRawConfig, "isRedirectedRawConfig");
5320
+ __name2(isRedirectedRawConfig, "isRedirectedRawConfig");
5321
+ function configFormat(configPath) {
5322
+ if (configPath?.endsWith("toml")) return "toml";
5323
+ if (configPath?.endsWith("jsonc")) return "jsonc";
5324
+ if (configPath?.endsWith("json")) return "json";
5325
+ return "none";
5326
+ }
5327
+ __name(configFormat, "configFormat");
5328
+ __name2(configFormat, "configFormat");
5329
+ function configFileName(configPath) {
5330
+ switch (configFormat(configPath)) {
5331
+ case "toml":
5332
+ return "wrangler.toml";
5333
+ case "json":
5334
+ return "wrangler.json";
5335
+ case "jsonc":
5336
+ return "wrangler.jsonc";
5337
+ default:
5338
+ return "Wrangler configuration";
5339
+ }
5340
+ }
5341
+ __name(configFileName, "configFileName");
5342
+ __name2(configFileName, "configFileName");
5343
+ function formatConfigSnippet(snippet, configPath, formatted = true) {
5344
+ if (configFormat(configPath) === "toml") return dist_default.stringify(snippet);
5345
+ else return formatted ? JSON.stringify(snippet, null, 2) : JSON.stringify(snippet);
5346
+ }
5347
+ __name(formatConfigSnippet, "formatConfigSnippet");
5348
+ __name2(formatConfigSnippet, "formatConfigSnippet");
5349
+ function isDirectory(path22) {
5350
+ return fs2.statSync(path22, { throwIfNoEntry: false })?.isDirectory() ?? false;
5351
+ }
5352
+ __name(isDirectory, "isDirectory");
5353
+ __name2(isDirectory, "isDirectory");
5354
+ function removeDir(dirPath, { fireAndForget = false } = {}) {
5355
+ const result = fs2.promises.rm(dirPath, {
5356
+ recursive: true,
5357
+ force: true,
5358
+ maxRetries: 5,
5359
+ retryDelay: 100
5360
+ });
5361
+ if (fireAndForget) result.catch(() => {
5362
+ });
5363
+ else return result;
5364
+ }
5365
+ __name(removeDir, "removeDir");
5366
+ __name2(removeDir, "removeDir");
5367
+ function removeDirSync(dirPath) {
5368
+ fs2.rmSync(dirPath, {
5369
+ recursive: true,
5370
+ force: true,
5371
+ maxRetries: 5,
5372
+ retryDelay: 100
5373
+ });
5374
+ }
5375
+ __name(removeDirSync, "removeDirSync");
5376
+ __name2(removeDirSync, "removeDirSync");
2751
5377
  var AssetsSchema = z.strictObject({
2752
5378
  htmlHandling: z.enum([
2753
5379
  "auto-trailing-slash",
@@ -3091,7 +5717,7 @@ var ModuleTypeSchema = z.enum([
3091
5717
  "esm",
3092
5718
  "cjs",
3093
5719
  "python",
3094
- "pythonRequirement",
5720
+ "python-requirement",
3095
5721
  "wasm",
3096
5722
  "text",
3097
5723
  "data",
@@ -3780,10 +6406,10 @@ var UpdateApplicationRolloutRequest;
3780
6406
  // ../containers-shared/src/utils.ts
3781
6407
  var runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
3782
6408
  let aborted = false;
3783
- let resolve3;
6409
+ let resolve4;
3784
6410
  let reject;
3785
6411
  const ready = new Promise((res, rej) => {
3786
- resolve3 = res;
6412
+ resolve4 = res;
3787
6413
  reject = rej;
3788
6414
  });
3789
6415
  const child = spawn(dockerPath, args, {
@@ -3801,11 +6427,11 @@ var runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
3801
6427
  let errorHandled = false;
3802
6428
  child.on("close", (code) => {
3803
6429
  if (code === 0 || aborted) {
3804
- resolve3({ aborted });
6430
+ resolve4({ aborted });
3805
6431
  } else if (!errorHandled) {
3806
6432
  errorHandled = true;
3807
6433
  reject(
3808
- new UserError(`Docker command exited with code: ${code}`, {
6434
+ new UserError$1(`Docker command exited with code: ${code}`, {
3809
6435
  telemetryMessage: false
3810
6436
  })
3811
6437
  );
@@ -3815,7 +6441,7 @@ var runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
3815
6441
  if (!errorHandled) {
3816
6442
  errorHandled = true;
3817
6443
  reject(
3818
- new UserError(`Docker command failed: ${err.message}`, {
6444
+ new UserError$1(`Docker command failed: ${err.message}`, {
3819
6445
  telemetryMessage: false
3820
6446
  })
3821
6447
  );
@@ -3853,7 +6479,7 @@ var verifyDockerInstalled = /* @__PURE__ */ __name(async ({
3853
6479
  }) => {
3854
6480
  const dockerIsRunning = await isDockerRunning(dockerPath);
3855
6481
  if (!dockerIsRunning) {
3856
- throw new UserError(
6482
+ throw new UserError$1(
3857
6483
  getFailedToRunDockerErrorMessage({
3858
6484
  numberOfContainers,
3859
6485
  isDev,
@@ -3945,7 +6571,7 @@ async function getZoneIdFromHost(complianceConfig, from, zoneIdCache = /* @__PUR
3945
6571
  }
3946
6572
  hostPieces.shift();
3947
6573
  }
3948
- throw new UserError(
6574
+ throw new UserError$1(
3949
6575
  `Could not find zone for \`${from.host}\`. Make sure the domain is set up to be proxied by Cloudflare.
3950
6576
  For more details, refer to https://developers.cloudflare.com/workers/configuration/routing/routes/#set-up-a-route`,
3951
6577
  { telemetryMessage: "zones route zone not found" }
@@ -3993,7 +6619,7 @@ function renderRoute(route) {
3993
6619
  }
3994
6620
  __name(renderRoute, "renderRoute");
3995
6621
  function isAuthenticationError(e) {
3996
- return e instanceof ParseError && e.code === 1e4;
6622
+ return e instanceof ParseError$1 && e.code === 1e4;
3997
6623
  }
3998
6624
  __name(isAuthenticationError, "isAuthenticationError");
3999
6625
  async function publishRoutes(complianceConfig, routes, {
@@ -4034,7 +6660,7 @@ async function publishRoutesFallback(complianceConfig, routes, {
4034
6660
  accountId
4035
6661
  }) {
4036
6662
  if (useServiceEnvironments2) {
4037
- throw new UserError(
6663
+ throw new UserError$1(
4038
6664
  "Service environments combined with an API token that doesn't have 'All Zones' permissions is not supported.\nEither turn off service environments by setting `legacy_env = true`, creating an API token with 'All Zones' permissions, or logging in via OAuth",
4039
6665
  {
4040
6666
  telemetryMessage: "deploy service environments require all zones permission"
@@ -4100,7 +6726,7 @@ async function publishRoutesFallback(complianceConfig, routes, {
4100
6726
  alreadyDeployedRoutes.delete(routePattern);
4101
6727
  continue;
4102
6728
  } else {
4103
- throw new UserError(
6729
+ throw new UserError$1(
4104
6730
  `The route with pattern "${routePattern}" is already associated with another worker called "${knownScript}".`,
4105
6731
  { telemetryMessage: "route already associated with another worker" }
4106
6732
  );
@@ -4149,7 +6775,7 @@ async function publishCustomDomains(complianceConfig, workerUrl, accountId, doma
4149
6775
  const fail = /* @__PURE__ */ __name(() => {
4150
6776
  return {
4151
6777
  targets: [],
4152
- error: new UserError(
6778
+ error: new UserError$1(
4153
6779
  domains.length > 1 ? `Publishing to ${domains.length} Custom Domains was skipped, fix conflicts and try again` : `Publishing to Custom Domain "${domains[0].pattern}" was skipped, fix conflict and try again`,
4154
6780
  { telemetryMessage: "deploy custom domains skipped" }
4155
6781
  )
@@ -4231,7 +6857,7 @@ __name(listQueues, "listQueues");
4231
6857
  async function getQueue(complianceConfig, accountId, queueName) {
4232
6858
  const queues = await listQueues(complianceConfig, accountId, 1, queueName);
4233
6859
  if (queues.length === 0) {
4234
- throw new UserError(
6860
+ throw new UserError$1(
4235
6861
  `Queue "${queueName}" does not exist. To create it, run: wrangler queues create ${queueName}`,
4236
6862
  { telemetryMessage: "queues lookup missing queue" }
4237
6863
  );
@@ -4290,7 +6916,7 @@ async function resolveWorkerConsumerByName(complianceConfig, accountId, consumer
4290
6916
  (c) => c.type === "worker" && (c.script === consumerName || c.service === consumerName)
4291
6917
  );
4292
6918
  if (consumers.length === 0) {
4293
- throw new UserError(
6919
+ throw new UserError$1(
4294
6920
  `No worker consumer '${consumerName}' exists for queue ${queue.queue_name}`,
4295
6921
  { telemetryMessage: "queues worker consumer missing" }
4296
6922
  );
@@ -4301,7 +6927,7 @@ async function resolveWorkerConsumerByName(complianceConfig, accountId, consumer
4301
6927
  (c) => c.environment === targetEnv
4302
6928
  );
4303
6929
  if (targetConsumers.length === 0) {
4304
- throw new UserError(
6930
+ throw new UserError$1(
4305
6931
  `No worker consumer '${consumerName}' exists for queue ${queueName}`,
4306
6932
  { telemetryMessage: "queues worker consumer missing environment" }
4307
6933
  );
@@ -4311,7 +6937,7 @@ async function resolveWorkerConsumerByName(complianceConfig, accountId, consumer
4311
6937
  if (consumers[0].service) {
4312
6938
  const targetEnv = envName ?? await getDefaultService(complianceConfig, accountId, consumerName);
4313
6939
  if (targetEnv != consumers[0].environment) {
4314
- throw new UserError(
6940
+ throw new UserError$1(
4315
6941
  `No worker consumer '${consumerName}' exists for queue ${queueName}`,
4316
6942
  { telemetryMessage: "queues worker consumer environment mismatch" }
4317
6943
  );
@@ -4346,7 +6972,7 @@ async function deletePullConsumer(complianceConfig, accountId, queueName) {
4346
6972
  const queue = await getQueue(complianceConfig, accountId, queueName);
4347
6973
  const consumer = queue.consumers[0];
4348
6974
  if (consumer?.type !== "http_pull") {
4349
- throw new UserError(`No http_pull consumer exists for queue ${queueName}`, {
6975
+ throw new UserError$1(`No http_pull consumer exists for queue ${queueName}`, {
4350
6976
  telemetryMessage: "queues http pull consumer missing"
4351
6977
  });
4352
6978
  }
@@ -4459,7 +7085,7 @@ async function ensureQueuesExistByConfig(config, accountId) {
4459
7085
  const queueSet = new Set(existingQueues);
4460
7086
  for (const queue of queueNames) {
4461
7087
  if (!queueSet.has(queue)) {
4462
- throw new UserError(
7088
+ throw new UserError$1(
4463
7089
  `Queue "${queue}" does not exist. To create it, run: wrangler queues create ${queue}`,
4464
7090
  { telemetryMessage: "queues config missing queue" }
4465
7091
  );
@@ -4527,7 +7153,7 @@ function getRegistrationDeclinedError(registrationContext, accountId, configPath
4527
7153
  const onboardingLink = `https://dash.cloudflare.com/${accountId}/workers/onboarding`;
4528
7154
  switch (registrationContext) {
4529
7155
  case "workflows":
4530
- return new UserError(
7156
+ return new UserError$1(
4531
7157
  `Workflows require your account to have a workers.dev subdomain. Register a workers.dev subdomain here:
4532
7158
  ${onboardingLink}`,
4533
7159
  {
@@ -4535,8 +7161,8 @@ ${onboardingLink}`,
4535
7161
  }
4536
7162
  );
4537
7163
  case "workers_dev": {
4538
- const solutionMessage = `You can either deploy your worker to one or more routes by specifying them in your ${configFileName(configPath)} file, or register a workers.dev subdomain here:`;
4539
- return new UserError(`${solutionMessage}
7164
+ const solutionMessage = `You can either deploy your worker to one or more routes by specifying them in your ${configFileName$1(configPath)} file, or register a workers.dev subdomain here:`;
7165
+ return new UserError$1(`${solutionMessage}
4540
7166
  ${onboardingLink}`, {
4541
7167
  telemetryMessage: "routes workers dev registration declined"
4542
7168
  });
@@ -4714,7 +7340,7 @@ ${assignedRoutes.map(
4714
7340
  `https://dash.cloudflare.com/${accountId}/workers/overview`
4715
7341
  );
4716
7342
  const dashLink = `Visit ${dashHref} to unassign a worker from a route.`;
4717
- throw new UserError(`${errorMessage}
7343
+ throw new UserError$1(`${errorMessage}
4718
7344
  ${resolution}
4719
7345
  ${dashLink}`, {
4720
7346
  telemetryMessage: "triggers deploy routes assigned"
@@ -4794,7 +7420,7 @@ ${dashLink}`, {
4794
7420
  for (const workflow of config.workflows) {
4795
7421
  if (!isWorkflowDefinedInThisScript(workflow, scriptName)) {
4796
7422
  if (workflow.limits) {
4797
- throw new UserError(
7423
+ throw new UserError$1(
4798
7424
  `Workflow "${workflow.name}" has "limits" configured but references external script "${workflow.script_name}". Configure limits on the worker that defines the workflow.`,
4799
7425
  {
4800
7426
  telemetryMessage: "triggers deploy workflow limits external script"
@@ -4802,7 +7428,7 @@ ${dashLink}`, {
4802
7428
  );
4803
7429
  }
4804
7430
  if (workflow.schedules) {
4805
- throw new UserError(
7431
+ throw new UserError$1(
4806
7432
  `Workflow "${workflow.name}" has "schedules" configured but references external script "${workflow.script_name}". Configure schedules on the worker that defines the workflow.`,
4807
7433
  {
4808
7434
  telemetryMessage: "triggers deploy workflow schedules external script"
@@ -4853,7 +7479,7 @@ ${dashLink}`, {
4853
7479
  }
4854
7480
  const errors = completedDeployments.map((deployment) => deployment.error).filter((error) => error !== void 0);
4855
7481
  if (errors.length > 0) {
4856
- throw new UserError(
7482
+ throw new UserError$1(
4857
7483
  `Some triggers failed to deploy for ${workerName}:
4858
7484
  ` + errors.map((error) => ` - ${error.message}`).join("\n"),
4859
7485
  {
@@ -4872,7 +7498,7 @@ ${dashLink}`, {
4872
7498
  __name(triggersDeploy, "triggersDeploy");
4873
7499
  function aggregateTelemetryMessages(errors) {
4874
7500
  const labels = errors.map(
4875
- (error) => error instanceof UserError && error.telemetryMessage ? error.telemetryMessage : "non-user error"
7501
+ (error) => error instanceof UserError$1 && error.telemetryMessage ? error.telemetryMessage : "non-user error"
4876
7502
  );
4877
7503
  return Array.from(new Set(labels)).sort().join(", ");
4878
7504
  }
@@ -6247,12 +8873,12 @@ var Mime = class {
6247
8873
  }
6248
8874
  return this;
6249
8875
  }
6250
- getType(path8) {
6251
- if (typeof path8 !== "string")
8876
+ getType(path9) {
8877
+ if (typeof path9 !== "string")
6252
8878
  return null;
6253
- const last = path8.replace(/^.*[/\\]/s, "").toLowerCase();
8879
+ const last = path9.replace(/^.*[/\\]/s, "").toLowerCase();
6254
8880
  const ext = last.replace(/^.*\./s, "").toLowerCase();
6255
- const hasPath = last.length < path8.length;
8881
+ const hasPath = last.length < path9.length;
6256
8882
  const hasDot = ext.length < last.length - 1;
6257
8883
  if (!hasDot && hasPath)
6258
8884
  return null;
@@ -6392,14 +9018,14 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6392
9018
  body: JSON.stringify({ manifest })
6393
9019
  });
6394
9020
  if (!initializeAssetsResponse) {
6395
- throw new FatalError(
9021
+ throw new FatalError$1(
6396
9022
  "An unexpected response has been received from the Cloudflare API for assets upload. Please try again.",
6397
9023
  { code: 1, telemetryMessage: "assets upload unexpected api response" }
6398
9024
  );
6399
9025
  }
6400
9026
  if (initializeAssetsResponse.buckets.flat().length === 0) {
6401
9027
  if (!initializeAssetsResponse.jwt) {
6402
- throw new FatalError(
9028
+ throw new FatalError$1(
6403
9029
  "Could not find assets information to attach to deployment. Please try again.",
6404
9030
  { code: 1, telemetryMessage: "assets upload missing completion token" }
6405
9031
  );
@@ -6418,10 +9044,10 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6418
9044
  const assetBuckets = initializeAssetsResponse.buckets.map((bucket) => {
6419
9045
  return bucket.map((fileHash) => {
6420
9046
  const manifestEntry = manifestLookup.find(
6421
- (file) => file[1].hash === fileHash
9047
+ (file2) => file2[1].hash === fileHash
6422
9048
  );
6423
9049
  if (manifestEntry === void 0) {
6424
- throw new FatalError(
9050
+ throw new FatalError$1(
6425
9051
  `A file was requested that does not appear to exist.`,
6426
9052
  {
6427
9053
  code: 1,
@@ -6446,7 +9072,7 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6446
9072
  const payload = new FormData();
6447
9073
  const uploadedFiles = [];
6448
9074
  for (const manifestEntry of bucket) {
6449
- const absFilePath = path.join(assetDirectory, manifestEntry[0]);
9075
+ const absFilePath = path3.join(assetDirectory, manifestEntry[0]);
6450
9076
  uploadedFiles.push(manifestEntry[0]);
6451
9077
  payload.append(
6452
9078
  manifestEntry[1].hash,
@@ -6509,7 +9135,7 @@ var syncAssets = /* @__PURE__ */ __name(async (complianceConfig, accountId, asse
6509
9135
  }
6510
9136
  return doUpload();
6511
9137
  } else if (isJwtExpired(initializeAssetsResponse.jwt)) {
6512
- throw new FatalError(
9138
+ throw new FatalError$1(
6513
9139
  `Upload took too long.
6514
9140
  Asset upload took too long on bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}. Please try again.
6515
9141
  Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`,
@@ -6534,7 +9160,7 @@ Assets already uploaded have been saved, so the next attempt will automatically
6534
9160
  });
6535
9161
  await Promise.all(queuePromises);
6536
9162
  if (!completionJwt) {
6537
- throw new FatalError("Failed to complete asset upload. Please try again.", {
9163
+ throw new FatalError$1("Failed to complete asset upload. Please try again.", {
6538
9164
  code: 1,
6539
9165
  telemetryMessage: "assets upload completion failed"
6540
9166
  });
@@ -6559,7 +9185,7 @@ var buildAssetManifest = /* @__PURE__ */ __name(async (dir) => {
6559
9185
  logger.debug("Ignoring asset:", relativeFilepath);
6560
9186
  return;
6561
9187
  }
6562
- const filepath = path.join(dir, relativeFilepath);
9188
+ const filepath = path3.join(dir, relativeFilepath);
6563
9189
  const filestat = await stat(filepath);
6564
9190
  if (filestat.isSymbolicLink() || filestat.isDirectory()) {
6565
9191
  return;
@@ -6569,7 +9195,7 @@ var buildAssetManifest = /* @__PURE__ */ __name(async (dir) => {
6569
9195
  assetsIgnoreFilePresent
6570
9196
  );
6571
9197
  if (filestat.size > MAX_ASSET_SIZE) {
6572
- throw new UserError(
9198
+ throw new UserError$1(
6573
9199
  `Asset too large.
6574
9200
  Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
6575
9201
  MAX_ASSET_SIZE,
@@ -6612,22 +9238,22 @@ function logAssetsUploadStatus(numberFilesToUpload, uploadedAssetsCount, uploade
6612
9238
  logger.info(
6613
9239
  `Uploaded ${uploadedAssetsCount} of ${numberFilesToUpload} asset${numberFilesToUpload === 1 ? "" : "s"}`
6614
9240
  );
6615
- uploadedAssetFiles.forEach((file) => logger.debug(`\u2728 ${file}`));
9241
+ uploadedAssetFiles.forEach((file2) => logger.debug(`\u2728 ${file2}`));
6616
9242
  }
6617
9243
  __name(logAssetsUploadStatus, "logAssetsUploadStatus");
6618
9244
  function logReadFilesFromDirectory(directory, assetFiles) {
6619
9245
  logger.info(
6620
9246
  `\u2728 Read ${assetFiles.length} file${assetFiles.length === 1 ? "" : "s"} from the assets directory ${directory}`
6621
9247
  );
6622
- assetFiles.forEach((file) => logger.debug(`/${file}`));
9248
+ assetFiles.forEach((file2) => logger.debug(`/${file2}`));
6623
9249
  }
6624
9250
  __name(logReadFilesFromDirectory, "logReadFilesFromDirectory");
6625
9251
  var WORKER_JS_FILENAME = "_worker.js";
6626
- function errorOnLegacyPagesWorkerJSAsset(file, hasAssetsIgnoreFile) {
9252
+ function errorOnLegacyPagesWorkerJSAsset(file2, hasAssetsIgnoreFile) {
6627
9253
  if (!hasAssetsIgnoreFile) {
6628
- const workerJsType = file === WORKER_JS_FILENAME ? "file" : file.startsWith(WORKER_JS_FILENAME) ? "directory" : null;
9254
+ const workerJsType = file2 === WORKER_JS_FILENAME ? "file" : file2.startsWith(WORKER_JS_FILENAME) ? "directory" : null;
6629
9255
  if (workerJsType !== null) {
6630
- throw new UserError(
9256
+ throw new UserError$1(
6631
9257
  `
6632
9258
  Uploading a Pages ${WORKER_JS_FILENAME} ${workerJsType} as an asset.
6633
9259
  This could expose your private server-side code to the public Internet. Is this intended?
@@ -6661,13 +9287,13 @@ function resolveAssetOptions({ assetsDir, main }, config) {
6661
9287
  );
6662
9288
  }
6663
9289
  if (!routerConfig.has_user_worker && (routerConfig.invoke_user_worker_ahead_of_assets === true || routerConfig.static_routing)) {
6664
- throw new UserError(
9290
+ throw new UserError$1(
6665
9291
  "Cannot set run_worker_first without a Worker script.\nPlease remove run_worker_first from your configuration file, or provide a Worker script in your configuration file (`main`).",
6666
9292
  { telemetryMessage: "assets router missing worker script" }
6667
9293
  );
6668
9294
  }
6669
- const _redirects = directoryExists ? maybeGetFile(path.join(directory, REDIRECTS_FILENAME)) : void 0;
6670
- const _headers = directoryExists ? maybeGetFile(path.join(directory, HEADERS_FILENAME)) : void 0;
9295
+ const _redirects = directoryExists ? maybeGetFile(path3.join(directory, REDIRECTS_FILENAME)) : void 0;
9296
+ const _headers = directoryExists ? maybeGetFile(path3.join(directory, HEADERS_FILENAME)) : void 0;
6671
9297
  const assetConfig = {
6672
9298
  html_handling: config.assets?.html_handling,
6673
9299
  not_found_handling: config.assets?.not_found_handling,
@@ -7032,9 +9658,9 @@ var ONE_KIB_BYTES = 1024;
7032
9658
  var MAX_GZIP_SIZE_BYTES = 3 * ONE_KIB_BYTES * ONE_KIB_BYTES;
7033
9659
  async function getSize(modules) {
7034
9660
  const gzipSize = gzipSync(
7035
- await new Blob(modules.map((file) => file.content)).arrayBuffer()
9661
+ await new Blob(modules.map((file2) => file2.content)).arrayBuffer()
7036
9662
  ).byteLength;
7037
- const aggregateSize = new Blob(modules.map((file) => file.content)).size;
9663
+ const aggregateSize = new Blob(modules.map((file2) => file2.content)).size;
7038
9664
  return { size: aggregateSize, gzipSize };
7039
9665
  }
7040
9666
  __name(getSize, "getSize");
@@ -7917,7 +10543,7 @@ function handleUnsafeCapnp(capnp) {
7917
10543
  (x) => resolve(base_path, x)
7918
10544
  );
7919
10545
  if (!sync("capnp")) {
7920
- throw new UserError(
10546
+ throw new UserError$1(
7921
10547
  "The capnp compiler is required to upload capnp schemas, but is not present.",
7922
10548
  { telemetryMessage: "capnp compiler missing" }
7923
10549
  );
@@ -8094,7 +10720,7 @@ function createWorkerUploadForm(worker, bindings, options) {
8094
10720
  id ??= INHERIT_SYMBOL;
8095
10721
  }
8096
10722
  if (id === void 0) {
8097
- throw new UserError(`${binding} bindings must have an "id" field`, {
10723
+ throw new UserError$1(`${binding} bindings must have an "id" field`, {
8098
10724
  telemetryMessage: "kv namespace binding missing id"
8099
10725
  });
8100
10726
  }
@@ -8157,7 +10783,7 @@ function createWorkerUploadForm(worker, bindings, options) {
8157
10783
  bucket_name ??= INHERIT_SYMBOL;
8158
10784
  }
8159
10785
  if (bucket_name === void 0) {
8160
- throw new UserError(
10786
+ throw new UserError$1(
8161
10787
  `${binding} bindings must have a "bucket_name" field`,
8162
10788
  { telemetryMessage: "r2 bucket binding missing bucket_name" }
8163
10789
  );
@@ -8183,7 +10809,7 @@ function createWorkerUploadForm(worker, bindings, options) {
8183
10809
  database_id ??= INHERIT_SYMBOL;
8184
10810
  }
8185
10811
  if (database_id === void 0) {
8186
- throw new UserError(
10812
+ throw new UserError$1(
8187
10813
  `${binding} bindings must have a "database_id" field`,
8188
10814
  { telemetryMessage: "d1 database binding missing database_id" }
8189
10815
  );
@@ -8217,7 +10843,7 @@ function createWorkerUploadForm(worker, bindings, options) {
8217
10843
  namespace ??= INHERIT_SYMBOL;
8218
10844
  }
8219
10845
  if (namespace === void 0) {
8220
- throw new UserError(`${binding} bindings must have a "namespace" field`, {
10846
+ throw new UserError$1(`${binding} bindings must have a "namespace" field`, {
8221
10847
  telemetryMessage: "ai search namespace binding missing namespace"
8222
10848
  });
8223
10849
  }
@@ -8252,7 +10878,7 @@ function createWorkerUploadForm(worker, bindings, options) {
8252
10878
  namespace ??= INHERIT_SYMBOL;
8253
10879
  }
8254
10880
  if (namespace === void 0) {
8255
- throw new UserError(`${binding} bindings must have a "namespace" field`, {
10881
+ throw new UserError$1(`${binding} bindings must have a "namespace" field`, {
8256
10882
  telemetryMessage: false
8257
10883
  });
8258
10884
  }
@@ -8526,14 +11152,14 @@ function createWorkerUploadForm(worker, bindings, options) {
8526
11152
  if (hasManifest && main.type === "esm") {
8527
11153
  assert6(modules !== void 0);
8528
11154
  const subDirs = new Set(
8529
- modules.map((module) => path__default.posix.dirname(module.name))
11155
+ modules.map((module) => path3__default.posix.dirname(module.name))
8530
11156
  );
8531
11157
  for (const subDir of subDirs) {
8532
11158
  if (subDir === ".") {
8533
11159
  continue;
8534
11160
  }
8535
- const relativePath = path__default.posix.relative(subDir, manifestModuleName);
8536
- const filePath = path__default.posix.join(subDir, manifestModuleName);
11161
+ const relativePath = path3__default.posix.relative(subDir, manifestModuleName);
11162
+ const filePath = path3__default.posix.join(subDir, manifestModuleName);
8537
11163
  modules.push({
8538
11164
  name: filePath,
8539
11165
  filePath,
@@ -8803,7 +11429,7 @@ async function getMigrationsToUpload(scriptName, props) {
8803
11429
  );
8804
11430
  if (foundIndex === -1) {
8805
11431
  logger.warn(
8806
- `The published script ${scriptName} has a migration tag "${script.migration_tag}, which was not found in your ${configFileName(config.configPath)} file. You may have already deleted it. Applying all available migrations to the script...`
11432
+ `The published script ${scriptName} has a migration tag "${script.migration_tag}, which was not found in your ${configFileName$1(config.configPath)} file. You may have already deleted it. Applying all available migrations to the script...`
8807
11433
  );
8808
11434
  migrations = {
8809
11435
  old_tag: script.migration_tag,
@@ -8912,7 +11538,7 @@ function dedent(templ) {
8912
11538
  return string2;
8913
11539
  }
8914
11540
  __name(dedent, "dedent");
8915
- var esm_default = dedent;
11541
+ var esm_default2 = dedent;
8916
11542
 
8917
11543
  // src/deploy/helpers/friendly-validator-errors.ts
8918
11544
  async function helpIfErrorIsSizeOrScriptStartup(err, dependencies, workerBundle, projectRoot, analyseBundle) {
@@ -8931,7 +11557,7 @@ async function helpIfErrorIsSizeOrScriptStartup(err, dependencies, workerBundle,
8931
11557
  }
8932
11558
  __name(helpIfErrorIsSizeOrScriptStartup, "helpIfErrorIsSizeOrScriptStartup");
8933
11559
  function diagnoseScriptSizeError(err, dependencies) {
8934
- let message = esm_default`
11560
+ let message = esm_default2`
8935
11561
  Your Worker failed validation because it exceeded size limits.
8936
11562
 
8937
11563
  ${err.text}
@@ -8945,7 +11571,7 @@ function diagnoseScriptSizeError(err, dependencies) {
8945
11571
  }
8946
11572
  __name(diagnoseScriptSizeError, "diagnoseScriptSizeError");
8947
11573
  async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundle) {
8948
- let errorMessage = esm_default`
11574
+ let errorMessage = esm_default2`
8949
11575
  Your Worker failed validation because it exceeded startup limits.
8950
11576
 
8951
11577
  ${err.text}
@@ -8964,12 +11590,12 @@ async function diagnoseStartupError(err, workerBundle, projectRoot, analyseBundl
8964
11590
  "startup-profile",
8965
11591
  false
8966
11592
  );
8967
- const profile = path__default.relative(
11593
+ const profile = path3__default.relative(
8968
11594
  projectRoot ?? process.cwd(),
8969
- path__default.join(tmpDir.path, `worker.cpuprofile`)
11595
+ path3__default.join(tmpDir.path, `worker.cpuprofile`)
8970
11596
  );
8971
11597
  await writeFile(profile, JSON.stringify(cpuProfile));
8972
- errorMessage += esm_default`
11598
+ errorMessage += esm_default2`
8973
11599
 
8974
11600
  A CPU Profile of your Worker's startup phase has been written to ${profile} - load it into the Chrome DevTools profiler (or directly in VSCode) to view a flamegraph.`;
8975
11601
  } catch (profilingError) {
@@ -9004,7 +11630,7 @@ function getOffendingDependenciesMessage(dependencies) {
9004
11630
  }
9005
11631
  __name(getOffendingDependenciesMessage, "getOffendingDependenciesMessage");
9006
11632
  function errIsScriptSize(err) {
9007
- if (!(err instanceof ParseError)) {
11633
+ if (!(err instanceof ParseError$1)) {
9008
11634
  return false;
9009
11635
  }
9010
11636
  if ("code" in err && err.code === 10027) {
@@ -9014,7 +11640,7 @@ function errIsScriptSize(err) {
9014
11640
  }
9015
11641
  __name(errIsScriptSize, "errIsScriptSize");
9016
11642
  function errIsStartupErr(err) {
9017
- if (!(err instanceof ParseError)) {
11643
+ if (!(err instanceof ParseError$1)) {
9018
11644
  return false;
9019
11645
  }
9020
11646
  if ("code" in err && err.code === 10021 && /startup/i.test(err.notes[0]?.text)) {
@@ -9040,8 +11666,8 @@ async function verifyWorkerMatchesCITag(complianceConfig, accountId, workerName,
9040
11666
  }
9041
11667
  const envAccountID = getCloudflareAccountIdFromEnv();
9042
11668
  if (accountId !== envAccountID) {
9043
- throw new FatalError(
9044
- `The \`account_id\` in your ${configFileName(configPath)} file must match the \`account_id\` for this account. Please update your ${configFileName(configPath)} file with \`${formatConfigSnippet({ account_id: envAccountID }, configPath, false)}\``,
11669
+ throw new FatalError$1(
11670
+ `The \`account_id\` in your ${configFileName$1(configPath)} file must match the \`account_id\` for this account. Please update your ${configFileName$1(configPath)} file with \`${formatConfigSnippet$1({ account_id: envAccountID }, configPath, false)}\``,
9045
11671
  { telemetryMessage: "ci match tag account mismatch" }
9046
11672
  );
9047
11673
  }
@@ -9056,17 +11682,17 @@ async function verifyWorkerMatchesCITag(complianceConfig, accountId, workerName,
9056
11682
  } catch (e) {
9057
11683
  logger.debug(e);
9058
11684
  if (isWorkerNotFoundError(e)) {
9059
- throw new FatalError(
9060
- `The name in your ${configFileName(configPath)} file (${workerName}) must match the name of your Worker. Please update the name field in your ${configFileName(configPath)} file.`,
11685
+ throw new FatalError$1(
11686
+ `The name in your ${configFileName$1(configPath)} file (${workerName}) must match the name of your Worker. Please update the name field in your ${configFileName$1(configPath)} file.`,
9061
11687
  { telemetryMessage: "ci match tag worker not found" }
9062
11688
  );
9063
11689
  } else if (e instanceof APIError) {
9064
- throw new FatalError(
11690
+ throw new FatalError$1(
9065
11691
  "An error occurred while trying to validate that the Worker name matches what is expected by the build system.\n" + e.message + "\n" + e.notes.map((note) => note.text).join("\n"),
9066
11692
  { telemetryMessage: "ci match tag validation api error" }
9067
11693
  );
9068
11694
  } else {
9069
- throw new FatalError(
11695
+ throw new FatalError$1(
9070
11696
  "Wrangler cannot validate that your Worker name matches what is expected by the build system. Please retry the build. If the problem persists, please contact support.",
9071
11697
  { telemetryMessage: "ci match tag validation failed" }
9072
11698
  );
@@ -9076,8 +11702,8 @@ async function verifyWorkerMatchesCITag(complianceConfig, accountId, workerName,
9076
11702
  logger.debug(
9077
11703
  `Failed to match Worker tag. The API returned "${tag}", but the CI system expected "${matchTag}"`
9078
11704
  );
9079
- throw new FatalError(
9080
- `The name in your ${configFileName(configPath)} file (${workerName}) must match the name of your Worker. Please update the name field in your ${configFileName(configPath)} file.`,
11705
+ throw new FatalError$1(
11706
+ `The name in your ${configFileName$1(configPath)} file (${workerName}) must match the name of your Worker. Please update the name field in your ${configFileName$1(configPath)} file.`,
9081
11707
  { telemetryMessage: "ci match tag tag mismatch" }
9082
11708
  );
9083
11709
  }
@@ -9085,7 +11711,7 @@ async function verifyWorkerMatchesCITag(complianceConfig, accountId, workerName,
9085
11711
  __name(verifyWorkerMatchesCITag, "verifyWorkerMatchesCITag");
9086
11712
  function validateFileSecrets(content, jsonFilePath) {
9087
11713
  if (content === null || typeof content !== "object") {
9088
- throw new FatalError(
11714
+ throw new FatalError$1(
9089
11715
  `The contents of "${jsonFilePath}" is not valid. It should be a JSON object of string values.`,
9090
11716
  { telemetryMessage: "secret bulk file invalid contents" }
9091
11717
  );
@@ -9093,7 +11719,7 @@ function validateFileSecrets(content, jsonFilePath) {
9093
11719
  const entries = Object.entries(content);
9094
11720
  for (const [key, value] of entries) {
9095
11721
  if (value != null && typeof value !== "string") {
9096
- throw new FatalError(
11722
+ throw new FatalError$1(
9097
11723
  `The value for "${key}" in "${jsonFilePath}" is not null or a "string" instead it is of type "${typeof value}"`,
9098
11724
  { telemetryMessage: "secret bulk file invalid value type" }
9099
11725
  );
@@ -9117,16 +11743,16 @@ async function parseBulkInputToObject(input, includeNull = false) {
9117
11743
  let secretFormat;
9118
11744
  if (input) {
9119
11745
  secretSource = "file";
9120
- const jsonFilePath = path__default.resolve(input);
9121
- const fileContent = readFileSync$1(jsonFilePath);
11746
+ const jsonFilePath = path3__default.resolve(input);
11747
+ const fileContent = readFileSync$2(jsonFilePath);
9122
11748
  try {
9123
- content = parseJSON(fileContent);
11749
+ content = parseJSON$1(fileContent);
9124
11750
  secretFormat = "json";
9125
11751
  } catch {
9126
- content = parse(fileContent);
11752
+ content = parse$1(fileContent);
9127
11753
  secretFormat = "dotenv";
9128
11754
  if (Object.keys(content).length === 0) {
9129
- throw new UserError(`The contents of "${input}" is not valid.`, {
11755
+ throw new UserError$1(`The contents of "${input}" is not valid.`, {
9130
11756
  telemetryMessage: "secret bulk invalid input"
9131
11757
  });
9132
11758
  }
@@ -9141,10 +11767,10 @@ async function parseBulkInputToObject(input, includeNull = false) {
9141
11767
  }
9142
11768
  const pipedInput = pipedInputLines.join("\n");
9143
11769
  try {
9144
- content = parseJSON(pipedInput);
11770
+ content = parseJSON$1(pipedInput);
9145
11771
  secretFormat = "json";
9146
11772
  } catch (e) {
9147
- content = parse(pipedInput);
11773
+ content = parse$1(pipedInput);
9148
11774
  secretFormat = "dotenv";
9149
11775
  if (Object.keys(content).length === 0) {
9150
11776
  throw e;
@@ -9581,13 +12207,15 @@ function printBindings(bindings, tailConsumers = [], streamingTailConsumers = []
9581
12207
  }
9582
12208
  if (services.length > 0) {
9583
12209
  output.push(
9584
- ...services.map(({ binding, service, entrypoint, remote }) => {
12210
+ ...services.map(({ binding, service, entrypoint, remote, dev }) => {
9585
12211
  let value = service;
9586
12212
  let mode = void 0;
9587
12213
  if (entrypoint) {
9588
12214
  value += `#${entrypoint}`;
9589
12215
  }
9590
- if (remote) {
12216
+ if (dev !== void 0 && context.local) {
12217
+ mode = getMode({ isSimulatedLocally: true });
12218
+ } else if (remote) {
9591
12219
  mode = getMode({ isSimulatedLocally: false });
9592
12220
  } else if (context.local && context.registry !== null) {
9593
12221
  const isSelfBinding = service === context.name;
@@ -9979,7 +12607,7 @@ function warnOrError(type, remote) {
9979
12607
  return;
9980
12608
  case "local-only":
9981
12609
  if (remote === true) {
9982
- throw new UserError(
12610
+ throw new UserError$1(
9983
12611
  `${getBindingTypeFriendlyName(type)} bindings do not support accessing remote resources.`,
9984
12612
  {
9985
12613
  telemetryMessage: "utils bindings unsupported remote resources"
@@ -9989,7 +12617,7 @@ function warnOrError(type, remote) {
9989
12617
  return;
9990
12618
  case "remote":
9991
12619
  if (remote === false) {
9992
- throw new UserError(
12620
+ throw new UserError$1(
9993
12621
  `${getBindingTypeFriendlyName(type)} bindings do not support local development. You can set \`remote: true\` for the binding definition in your configuration file to access a remote version of the resource.`,
9994
12622
  {
9995
12623
  telemetryMessage: "utils bindings unsupported local development"
@@ -10004,7 +12632,7 @@ function warnOrError(type, remote) {
10004
12632
  return;
10005
12633
  case "DO-NOT-USE-this-resource-will-never-have-a-local-simulator":
10006
12634
  if (remote === false) {
10007
- throw new UserError(
12635
+ throw new UserError$1(
10008
12636
  `${getBindingTypeFriendlyName(type)} bindings do not support local development. You can set \`remote: true\` for the binding definition in your configuration file to access a remote version of the resource.`,
10009
12637
  {
10010
12638
  telemetryMessage: "utils bindings unsupported local development always remote"
@@ -10038,7 +12666,7 @@ function addRequiredSecretsInheritBindings(config, bindings, options) {
10038
12666
  return;
10039
12667
  }
10040
12668
  if (options.type === "deploy" && !options.workerExists) {
10041
- throw new UserError(
12669
+ throw new UserError$1(
10042
12670
  `The following required secrets have not been set: ${inheritedSecrets.join(", ")}
10043
12671
  Use \`wrangler secret put <NAME>\` to set secrets before deploying.
10044
12672
  See https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-deployed-workers for more information.`,
@@ -10057,7 +12685,7 @@ function handleMissingSecretsError(err, config, options) {
10057
12685
  const missingSecretNames = err.notes.map((note) => note.text.match(/^inherit binding '(.+?)' is invalid/)).filter((match) => match !== null).map((match) => match[1]).filter((secretName) => config.secrets?.required?.includes(secretName));
10058
12686
  if (missingSecretNames.length > 0) {
10059
12687
  err.preventReport();
10060
- throw new UserError(
12688
+ throw new UserError$1(
10061
12689
  `The following required secrets have not been set: ${missingSecretNames.join(", ")}
10062
12690
  Use \`wrangler ${options.type === "deploy" ? "secret put" : "versions secret put"} <NAME>\` to set secrets before ${options.type === "deploy" ? "deploying" : "uploading"}.
10063
12691
  See https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-deployed-workers for more information.`,
@@ -10175,8 +12803,8 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
10175
12803
  // Make sure we're using fresh copies of files each time we source map
10176
12804
  emptyCacheBetweenOperations: true,
10177
12805
  // Allow retriever to be overridden at prepare stack trace time
10178
- retrieveSourceMap(path8) {
10179
- return retrieveSourceMapOverride?.(path8) ?? null;
12806
+ retrieveSourceMap(path9) {
12807
+ return retrieveSourceMapOverride?.(path9) ?? null;
10180
12808
  }
10181
12809
  });
10182
12810
  sourceMappingPrepareStackTrace = Error.prepareStackTrace;
@@ -10389,7 +13017,7 @@ var validateRoutes = /* @__PURE__ */ __name((routes, assets) => {
10389
13017
  }
10390
13018
  }
10391
13019
  if (Object.keys(invalidRoutes).length > 0) {
10392
- throw new UserError(
13020
+ throw new UserError$1(
10393
13021
  `Invalid Routes:
10394
13022
  ` + Object.entries(invalidRoutes).map(([route, errors]) => `${route}:
10395
13023
  ` + errors.join("\n")).join(`
@@ -10399,13 +13027,13 @@ var validateRoutes = /* @__PURE__ */ __name((routes, assets) => {
10399
13027
  );
10400
13028
  }
10401
13029
  if (mountedAssetRoutes.length > 0 && assets?.directory !== void 0) {
10402
- const relativeAssetsDir = path__default.relative(process.cwd(), assets.directory);
13030
+ const relativeAssetsDir = path3__default.relative(process.cwd(), assets.directory);
10403
13031
  const warnFn = logger.once?.warn ?? logger.warn;
10404
13032
  warnFn(
10405
13033
  `Warning: The following routes will attempt to serve Assets on a configured path:
10406
13034
  ${mountedAssetRoutes.map((route) => {
10407
13035
  const routeNoScheme = route.replace(/https?:\/\//g, "");
10408
- const assetPath = path__default.join(
13036
+ const assetPath = path3__default.join(
10409
13037
  relativeAssetsDir,
10410
13038
  routeNoScheme.substring(routeNoScheme.indexOf("/"))
10411
13039
  );
@@ -10416,7 +13044,7 @@ ${mountedAssetRoutes.map((route) => {
10416
13044
  }, "validateRoutes");
10417
13045
 
10418
13046
  // src/deploy/helpers/workers-sites-bindings.ts
10419
- function addWorkersSitesBindings(bindings, namespace, manifest, format) {
13047
+ function addWorkersSitesBindings(bindings, namespace, manifest, format3) {
10420
13048
  const withSites = { ...bindings };
10421
13049
  if (namespace) {
10422
13050
  withSites["__STATIC_CONTENT"] = {
@@ -10424,7 +13052,7 @@ function addWorkersSitesBindings(bindings, namespace, manifest, format) {
10424
13052
  id: namespace
10425
13053
  };
10426
13054
  }
10427
- if (manifest && format === "service-worker") {
13055
+ if (manifest && format3 === "service-worker") {
10428
13056
  withSites["__STATIC_CONTENT_MANIFEST"] = {
10429
13057
  type: "text_blob",
10430
13058
  source: { contents: "__STATIC_CONTENT_MANIFEST" }
@@ -10437,7 +13065,7 @@ __name(addWorkersSitesBindings, "addWorkersSitesBindings");
10437
13065
  // src/deploy/deploy.ts
10438
13066
  async function deploy(props, config, buildResult, callbacks) {
10439
13067
  if (!props.name) {
10440
- throw new UserError(
13068
+ throw new UserError$1(
10441
13069
  'You need to provide a name when publishing a worker. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`',
10442
13070
  { telemetryMessage: "deploy command missing worker name" }
10443
13071
  );
@@ -10513,7 +13141,7 @@ Deploying the Worker will override the remote configuration with your local one.
10513
13141
  return { versionId, workerTag };
10514
13142
  }
10515
13143
  }
10516
- } else if (script.last_deployed_from === "api") {
13144
+ } else if (script.last_deployed_from === "api" && !props.skipLastDeployedFromApiCheck) {
10517
13145
  logger.warn(
10518
13146
  `You are about to publish a Workers Service that was last updated via the script API.
10519
13147
  Edits that have been made via the script API will be overridden by your local code and config.`
@@ -10554,10 +13182,10 @@ Edits that have been made via the script API will be overridden by your local co
10554
13182
  }
10555
13183
  if (!compatibilityDate) {
10556
13184
  const compatibilityDateStr = getTodaysCompatDate();
10557
- throw new UserError(
10558
- `A compatibility_date is required when publishing. Add the following to your ${configFileName(config.configPath)} file:
13185
+ throw new UserError$1(
13186
+ `A compatibility_date is required when publishing. Add the following to your ${configFileName$1(config.configPath)} file:
10559
13187
  \`\`\`
10560
- ${formatConfigSnippet({ compatibility_date: compatibilityDateStr }, config.configPath, false)}
13188
+ ${formatConfigSnippet$1({ compatibility_date: compatibilityDateStr }, config.configPath, false)}
10561
13189
  \`\`\`
10562
13190
  Or you could pass it in your terminal as \`--compatibility-date ${compatibilityDateStr}\`
10563
13191
  See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.`,
@@ -10575,7 +13203,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10575
13203
  const useServiceEnvironments2 = props.useServiceEnvApiPath;
10576
13204
  const workerName = useServiceEnvironments2 ? `${scriptName} (${envName})` : scriptName;
10577
13205
  const workerUrl = props.dispatchNamespace ? `/accounts/${accountId}/workers/dispatch/namespaces/${props.dispatchNamespace}/scripts/${scriptName}` : useServiceEnvironments2 ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${envName}` : `/accounts/${accountId}/workers/scripts/${scriptName}`;
10578
- const { format } = entry;
13206
+ const { format: format3 } = entry;
10579
13207
  const { projectRoot } = entry;
10580
13208
  if (!props.dispatchNamespace && !useServiceEnvironments2 && accountId && scriptName) {
10581
13209
  const yes = await confirmLatestDeploymentOverwrite(
@@ -10588,27 +13216,27 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10588
13216
  return { versionId, workerTag };
10589
13217
  }
10590
13218
  }
10591
- if (!props.isWorkersSite && Boolean(props.legacyAssetPaths) && format === "service-worker") {
10592
- throw new UserError(
13219
+ if (!props.isWorkersSite && Boolean(props.legacyAssetPaths) && format3 === "service-worker") {
13220
+ throw new UserError$1(
10593
13221
  "You cannot use the service-worker format with an `assets` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/",
10594
13222
  { telemetryMessage: "deploy service worker assets unsupported" }
10595
13223
  );
10596
13224
  }
10597
- if (config.wasm_modules && format === "modules") {
10598
- throw new UserError(
13225
+ if (config.wasm_modules && format3 === "modules") {
13226
+ throw new UserError$1(
10599
13227
  "You cannot configure [wasm_modules] with an ES module worker. Instead, import the .wasm module directly in your code",
10600
13228
  { telemetryMessage: "deploy wasm modules with es module worker" }
10601
13229
  );
10602
13230
  }
10603
- if (config.text_blobs && format === "modules") {
10604
- throw new UserError(
10605
- `You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName(config.configPath)} file`,
13231
+ if (config.text_blobs && format3 === "modules") {
13232
+ throw new UserError$1(
13233
+ `You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName$1(config.configPath)} file`,
10606
13234
  { telemetryMessage: "[text_blobs] with an ES module worker" }
10607
13235
  );
10608
13236
  }
10609
- if (config.data_blobs && format === "modules") {
10610
- throw new UserError(
10611
- `You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName(config.configPath)} file`,
13237
+ if (config.data_blobs && format3 === "modules") {
13238
+ throw new UserError$1(
13239
+ `You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName$1(config.configPath)} file`,
10612
13240
  { telemetryMessage: "[data_blobs] with an ES module worker" }
10613
13241
  );
10614
13242
  }
@@ -10686,7 +13314,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10686
13314
  });
10687
13315
  }
10688
13316
  const placement = parseConfigPlacement(config);
10689
- const entryPointName = path__default.basename(resolvedEntryPointPath);
13317
+ const entryPointName = path3__default.basename(resolvedEntryPointPath);
10690
13318
  const main = {
10691
13319
  name: entryPointName,
10692
13320
  filePath: resolvedEntryPointPath,
@@ -10729,10 +13357,10 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10729
13357
  0
10730
13358
  );
10731
13359
  await printBundleSize(
10732
- { name: path__default.basename(resolvedEntryPointPath), content },
13360
+ { name: path3__default.basename(resolvedEntryPointPath), content },
10733
13361
  modules
10734
13362
  );
10735
- const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && !useServiceEnvironments2 && format === "modules" && migrations === void 0 && !config.first_party_worker && config.containers === void 0;
13363
+ const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && !useServiceEnvironments2 && format3 === "modules" && migrations === void 0 && !config.first_party_worker && config.containers === void 0;
10736
13364
  let workerBundle;
10737
13365
  const dockerPath = getDockerPath();
10738
13366
  if (normalisedContainerConfig.length && props.containersRollout !== "none") {
@@ -10767,7 +13395,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10767
13395
  bindings ?? {},
10768
13396
  workersSitesAssets.namespace,
10769
13397
  workersSitesAssets.manifest,
10770
- format
13398
+ format3
10771
13399
  ),
10772
13400
  {
10773
13401
  dryRun: true,
@@ -10800,7 +13428,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10800
13428
  bindings ?? {},
10801
13429
  workersSitesAssets.namespace,
10802
13430
  workersSitesAssets.manifest,
10803
- format
13431
+ format3
10804
13432
  ),
10805
13433
  {
10806
13434
  unsafe: config.unsafe
@@ -10906,7 +13534,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10906
13534
  config.containers,
10907
13535
  { unsafeMetadata: config.unsafe?.metadata }
10908
13536
  );
10909
- versionId = parseNonHyphenedUuid(result.deployment_id);
13537
+ versionId = parseNonHyphenedUuid$1(result.deployment_id);
10910
13538
  if (config.first_party_worker) {
10911
13539
  if (result.id) {
10912
13540
  logger.log("Worker ID: ", result.id);
@@ -10949,7 +13577,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10949
13577
  if (err instanceof APIError && "code" in err && err.code === 10021 && err.notes.length > 0) {
10950
13578
  err.preventReport();
10951
13579
  if (err.notes[0].text === "binding DB of type d1 must have a valid `id` specified [code: 10021]") {
10952
- throw new UserError(
13580
+ throw new UserError$1(
10953
13581
  "You must use a real database in the database_id configuration. You can find your databases using 'wrangler d1 list', or read how to develop locally with D1 here: https://developers.cloudflare.com/d1/configuration/local-development",
10954
13582
  { telemetryMessage: "deploy d1 database binding invalid id" }
10955
13583
  );
@@ -10977,7 +13605,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
10977
13605
  }
10978
13606
  }
10979
13607
  if (props.outfile) {
10980
- mkdirSync(path__default.dirname(props.outfile), { recursive: true });
13608
+ mkdirSync(path3__default.dirname(props.outfile), { recursive: true });
10981
13609
  const serializedFormData = await new Response(workerBundle).arrayBuffer();
10982
13610
  writeFileSync(props.outfile, Buffer.from(serializedFormData));
10983
13611
  }
@@ -11021,7 +13649,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11021
13649
  __name(deploy, "deploy");
11022
13650
  async function versionsUpload(props, config, buildResult, callbacks) {
11023
13651
  if (!props.name) {
11024
- throw new UserError(
13652
+ throw new UserError$1(
11025
13653
  'You need to provide a name of your worker. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`',
11026
13654
  { telemetryMessage: "versions upload missing worker name" }
11027
13655
  );
@@ -11064,7 +13692,7 @@ Edits that have been made via the dashboard will be overridden by your local cod
11064
13692
  workerTag
11065
13693
  };
11066
13694
  }
11067
- } else if (script.last_deployed_from === "api") {
13695
+ } else if (script.last_deployed_from === "api" && !props.skipLastDeployedFromApiCheck) {
11068
13696
  logger.warn(
11069
13697
  `You are about to upload a Workers Version that was last updated via the API.
11070
13698
  Edits that have been made via the API will be overridden by your local code and config.`
@@ -11084,10 +13712,10 @@ Edits that have been made via the API will be overridden by your local code and
11084
13712
  }
11085
13713
  if (!compatibilityDate) {
11086
13714
  const compatibilityDateStr = getTodaysCompatDate();
11087
- throw new UserError(
11088
- `A compatibility_date is required when uploading a Worker Version. Add the following to your ${configFileName(config.configPath)} file:
13715
+ throw new UserError$1(
13716
+ `A compatibility_date is required when uploading a Worker Version. Add the following to your ${configFileName$1(config.configPath)} file:
11089
13717
  \`\`\`
11090
- ${formatConfigSnippet({ compatibility_date: compatibilityDateStr }, config.configPath, false)}
13718
+ ${formatConfigSnippet$1({ compatibility_date: compatibilityDateStr }, config.configPath, false)}
11091
13719
  \`\`\`
11092
13720
  Or you could pass it in your terminal as \`--compatibility-date ${compatibilityDateStr}\`
11093
13721
  See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.`,
@@ -11098,7 +13726,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11098
13726
  }
11099
13727
  const scriptName = name;
11100
13728
  if (config.site && !config.site.bucket) {
11101
- throw new UserError(
13729
+ throw new UserError$1(
11102
13730
  "A [site] definition requires a `bucket` field with a path to the site's assets directory.",
11103
13731
  { telemetryMessage: "versions upload sites missing bucket" }
11104
13732
  );
@@ -11106,27 +13734,27 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11106
13734
  const start = Date.now();
11107
13735
  const workerName = scriptName;
11108
13736
  const workerUrl = `/accounts/${accountId}/workers/scripts/${scriptName}`;
11109
- const { format } = entry;
13737
+ const { format: format3 } = entry;
11110
13738
  const projectRoot = entry.projectRoot;
11111
- if (config.wasm_modules && format === "modules") {
11112
- throw new UserError(
13739
+ if (config.wasm_modules && format3 === "modules") {
13740
+ throw new UserError$1(
11113
13741
  "You cannot configure [wasm_modules] with an ES module worker. Instead, import the .wasm module directly in your code",
11114
13742
  {
11115
13743
  telemetryMessage: "versions upload wasm modules unsupported module worker"
11116
13744
  }
11117
13745
  );
11118
13746
  }
11119
- if (config.text_blobs && format === "modules") {
11120
- throw new UserError(
11121
- `You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName(config.configPath)} file`,
13747
+ if (config.text_blobs && format3 === "modules") {
13748
+ throw new UserError$1(
13749
+ `You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName$1(config.configPath)} file`,
11122
13750
  {
11123
13751
  telemetryMessage: "versions upload text blobs unsupported module worker"
11124
13752
  }
11125
13753
  );
11126
13754
  }
11127
- if (config.data_blobs && format === "modules") {
11128
- throw new UserError(
11129
- `You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName(config.configPath)} file`,
13755
+ if (config.data_blobs && format3 === "modules") {
13756
+ throw new UserError$1(
13757
+ `You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure \`[rules]\` in your ${configFileName$1(config.configPath)} file`,
11130
13758
  {
11131
13759
  telemetryMessage: "versions upload data blobs unsupported module worker"
11132
13760
  }
@@ -11172,7 +13800,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11172
13800
  }
11173
13801
  addRequiredSecretsInheritBindings(config, bindings, { type: "upload" });
11174
13802
  const placement = parseConfigPlacement(config);
11175
- const entryPointName = path__default.basename(resolvedEntryPointPath);
13803
+ const entryPointName = path3__default.basename(resolvedEntryPointPath);
11176
13804
  const main = {
11177
13805
  name: entryPointName,
11178
13806
  filePath: resolvedEntryPointPath,
@@ -11219,7 +13847,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11219
13847
  );
11220
13848
  }
11221
13849
  await printBundleSize(
11222
- { name: path__default.basename(resolvedEntryPointPath), content },
13850
+ { name: path3__default.basename(resolvedEntryPointPath), content },
11223
13851
  modules
11224
13852
  );
11225
13853
  let workerBundle;
@@ -11299,7 +13927,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11299
13927
  logger.error(message);
11300
13928
  }
11301
13929
  handleMissingSecretsError(err, config, { type: "upload" });
11302
- if (err instanceof ParseError && "code" in err && err.code === 10021 && err.notes.length > 0) {
13930
+ if (err instanceof ParseError$1 && "code" in err && err.code === 10021 && err.notes.length > 0) {
11303
13931
  const maybeNameToFilePath = /* @__PURE__ */ __name((moduleName) => {
11304
13932
  if (bundleType === "commonjs") {
11305
13933
  return resolvedEntryPointPath;
@@ -11333,7 +13961,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11333
13961
  }
11334
13962
  }
11335
13963
  if (props.outfile) {
11336
- mkdirSync(path__default.dirname(props.outfile), { recursive: true });
13964
+ mkdirSync(path3__default.dirname(props.outfile), { recursive: true });
11337
13965
  const serializedFormData = await new Response(workerBundle).arrayBuffer();
11338
13966
  writeFileSync(props.outfile, Buffer.from(serializedFormData));
11339
13967
  }
@@ -11342,7 +13970,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
11342
13970
  return { versionId, workerTag };
11343
13971
  }
11344
13972
  if (!accountId) {
11345
- throw new UserError("Missing accountId", {
13973
+ throw new UserError$1("Missing accountId", {
11346
13974
  telemetryMessage: "versions upload missing account id"
11347
13975
  });
11348
13976
  }
@@ -11448,13 +14076,13 @@ function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibili
11448
14076
  hasExperimentalNodejsCompatV2Flag
11449
14077
  } = getNodeCompat(compatibilityDateStr, compatibilityFlags);
11450
14078
  if (hasExperimentalNodejsCompatV2Flag) {
11451
- throw new UserError(
14079
+ throw new UserError$1(
11452
14080
  "The `experimental:` prefix on `nodejs_compat_v2` is no longer valid. Please remove it and try again.",
11453
14081
  { telemetryMessage: "experimental nodejs compat v2 prefix unsupported" }
11454
14082
  );
11455
14083
  }
11456
14084
  if (hasNodejsCompatFlag && hasNodejsCompatV2Flag) {
11457
- throw new UserError(
14085
+ throw new UserError$1(
11458
14086
  "The `nodejs_compat` and `nodejs_compat_v2` compatibility flags cannot be used in together. Please select just one.",
11459
14087
  { telemetryMessage: "conflicting nodejs compat flags" }
11460
14088
  );