@hawkeyexl/manni 2.11.0 → 2.12.0

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.
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@hawkeyexl/manni",
11
- version: "2.11.0",
11
+ version: "2.12.0",
12
12
  description: "One command line for documentation that is meant to be checked. `manni meta` validates the presence and format of document metadata (Markdown frontmatter and more) against JSON Schema, built for CI. Formerly docmeta.",
13
13
  type: "module",
14
14
  bin: {
@@ -901,7 +901,12 @@ var DocmetaError = class extends ToolError {
901
901
  };
902
902
 
903
903
  // src/meta/extractors/frontmatter-write.ts
904
- import { parseDocument as parseDocument3, isMap as isMap3, isCollection } from "yaml";
904
+ import {
905
+ parseDocument as parseDocument3,
906
+ isMap as isMap4,
907
+ isCollection,
908
+ isScalar as isScalar4
909
+ } from "yaml";
905
910
  import { parse as parseToml2, stringify as stringifyToml } from "smol-toml";
906
911
 
907
912
  // src/meta/extractors/patch-util.ts
@@ -947,6 +952,174 @@ function toJsonText(value) {
947
952
  return JSON.stringify(value);
948
953
  }
949
954
 
955
+ // src/meta/core/yaml-splice.ts
956
+ import {
957
+ isMap as isMap3,
958
+ isNode as isNode2,
959
+ isPair,
960
+ isScalar as isScalar3,
961
+ isSeq as isSeq2,
962
+ stringify
963
+ } from "yaml";
964
+ function insertKey(text2, entryMap, key, value, style) {
965
+ const firstKey = rangeOf(entryMap.items[0]?.key);
966
+ const end = contentEnd(text2, entryMap);
967
+ if (!firstKey || end === void 0) return void 0;
968
+ const pos = lineEnd(text2, end);
969
+ return {
970
+ start: pos,
971
+ end: pos,
972
+ insert: style.eol + blockLines({ [key]: value }, colOf(text2, firstKey[0]), style)
973
+ };
974
+ }
975
+ function replaceBlockValue(text2, pair, value, style) {
976
+ const colon = colonEnd(text2, pair);
977
+ const keyRange = rangeOf(pair.key);
978
+ if (colon === void 0 || !keyRange) return void 0;
979
+ const keyCol = colOf(text2, keyRange[0]);
980
+ let start = colon;
981
+ let ownLine = false;
982
+ let i = colon;
983
+ while (text2.charAt(i) === " " || text2.charAt(i) === " ") i++;
984
+ if (text2.charAt(i) === "#") {
985
+ start = lineEnd(text2, i);
986
+ ownLine = true;
987
+ }
988
+ const old = pair.value;
989
+ const oldEnd = isScalar3(old) && old.value === null && emptySource(text2, old) ? start : contentEnd(text2, old) ?? start;
990
+ const end = Math.max(start, oldEnd);
991
+ let insert = afterColon(value, keyCol, style);
992
+ if (ownLine && !insert.startsWith(style.eol)) {
993
+ insert = style.eol + " ".repeat(keyCol + style.step) + insert.trimStart();
994
+ }
995
+ return { start, end, insert };
996
+ }
997
+ function replaceFlowValue(text2, pair, value, padded) {
998
+ const r = rangeOf(pair.value);
999
+ if (!r || emptySource(text2, pair.value)) return void 0;
1000
+ const end = contentEnd(text2, pair.value) ?? r[1];
1001
+ return { start: r[0], end, insert: flowText(value, padded) };
1002
+ }
1003
+ function keyLines(text2, from, to, eol) {
1004
+ let start = text2.lastIndexOf("\n", from - 1) + 1;
1005
+ let end = lineEnd(text2, to);
1006
+ if (text2.startsWith(eol, end)) end += eol.length;
1007
+ else if (start >= eol.length) start -= eol.length;
1008
+ return { start, end };
1009
+ }
1010
+ function removeKey(text2, pair, eol) {
1011
+ const from = rangeOf(pair.key);
1012
+ const to = contentEnd(text2, pair.value) ?? contentEnd(text2, pair.key);
1013
+ if (!from || to === void 0) return void 0;
1014
+ const { start, end } = keyLines(text2, from[0], to, eol);
1015
+ return { start, end, insert: "" };
1016
+ }
1017
+ function blockLines(pair, col, style) {
1018
+ const s = stringify(pair, { lineWidth: 0, indent: style.step, indentSeq: style.indentSeq });
1019
+ return indentLines(s.replace(/\n$/, "").split("\n"), col, 0).join(style.eol);
1020
+ }
1021
+ function afterColon(value, col, style) {
1022
+ const s = stringify({ k: value }, { lineWidth: 0, indent: style.step, indentSeq: style.indentSeq });
1023
+ const lines = s.replace(/\n$/, "").slice("k:".length).split("\n");
1024
+ return indentLines(lines, col, 1).join(style.eol);
1025
+ }
1026
+ function indentLines(lines, col, from) {
1027
+ const pad2 = " ".repeat(col);
1028
+ return lines.map((l, i) => i < from || l === "" ? l : pad2 + l);
1029
+ }
1030
+ function flowText(value, padded) {
1031
+ const s = stringify(value, {
1032
+ lineWidth: 0,
1033
+ collectionStyle: "flow",
1034
+ ...padded === void 0 ? {} : { flowCollectionPadding: padded }
1035
+ }).replace(/\n$/, "");
1036
+ return s.includes("\n") ? JSON.stringify(value) : s;
1037
+ }
1038
+ function detectEol(text2) {
1039
+ const i = text2.indexOf("\n");
1040
+ return i > 0 && text2.charAt(i - 1) === "\r" ? "\r\n" : "\n";
1041
+ }
1042
+ function detectStyle(text2, root, eol) {
1043
+ let step = 2;
1044
+ for (const pair of root.items) {
1045
+ const v = pair.value;
1046
+ const entryKey = rangeOf(pair.key);
1047
+ const ownedKey = isMap3(v) && v.flow !== true ? rangeOf(v.items[0]?.key) : void 0;
1048
+ if (entryKey && ownedKey) {
1049
+ const d = colOf(text2, ownedKey[0]) - colOf(text2, entryKey[0]);
1050
+ if (d > 0) {
1051
+ step = d;
1052
+ break;
1053
+ }
1054
+ }
1055
+ }
1056
+ return { step, indentSeq: seqIndented(text2, root) ?? true, eol };
1057
+ }
1058
+ function seqIndented(text2, node) {
1059
+ if (isMap3(node)) {
1060
+ for (const pair of node.items) {
1061
+ const v = pair.value;
1062
+ if (isSeq2(v) && v.flow !== true && v.items.length > 0) {
1063
+ const k = rangeOf(pair.key);
1064
+ const s = rangeOf(v);
1065
+ if (k && s) return colOf(text2, s[0]) > colOf(text2, k[0]);
1066
+ }
1067
+ const inner = seqIndented(text2, v);
1068
+ if (inner !== void 0) return inner;
1069
+ }
1070
+ } else if (isSeq2(node)) {
1071
+ for (const item of node.items) {
1072
+ const inner = seqIndented(text2, item);
1073
+ if (inner !== void 0) return inner;
1074
+ }
1075
+ }
1076
+ return void 0;
1077
+ }
1078
+ function contentEnd(text2, node) {
1079
+ if (isMap3(node) && node.flow !== true) {
1080
+ const last = node.items.at(-1);
1081
+ if (last) return contentEnd(text2, last.value) ?? contentEnd(text2, last.key);
1082
+ } else if (isSeq2(node) && node.flow !== true) {
1083
+ const last = node.items.at(-1);
1084
+ if (last !== void 0) {
1085
+ return isPair(last) ? contentEnd(text2, last.value) ?? contentEnd(text2, last.key) : contentEnd(text2, last);
1086
+ }
1087
+ }
1088
+ const r = rangeOf(node);
1089
+ if (!r) return void 0;
1090
+ let end = r[1];
1091
+ while (end > r[0] && /\s/.test(text2.charAt(end - 1))) end--;
1092
+ return end;
1093
+ }
1094
+ function colonEnd(text2, pair) {
1095
+ const r = rangeOf(pair.key);
1096
+ if (!r) return void 0;
1097
+ let i = r[1];
1098
+ while (text2.charAt(i) === " " || text2.charAt(i) === " ") i++;
1099
+ return text2.charAt(i) === ":" ? i + 1 : void 0;
1100
+ }
1101
+ function lineEnd(text2, i) {
1102
+ const j = text2.indexOf("\n", i);
1103
+ if (j < 0) return text2.length;
1104
+ return j > 0 && text2.charAt(j - 1) === "\r" ? j - 1 : j;
1105
+ }
1106
+ function colOf(text2, offset) {
1107
+ if (offset === 0) return 0;
1108
+ let start = text2.lastIndexOf("\n", offset - 1) + 1;
1109
+ if (start === 0 && text2.startsWith("\uFEFF")) start = 1;
1110
+ return offset - start;
1111
+ }
1112
+ function rangeOf(node) {
1113
+ return isNode2(node) ? node.range ?? void 0 : void 0;
1114
+ }
1115
+ function emptySource(text2, node) {
1116
+ const r = rangeOf(node);
1117
+ return !r || text2.slice(r[0], r[1]).trim() === "";
1118
+ }
1119
+ function keyString(key) {
1120
+ return isScalar3(key) ? String(key.value) : String(key);
1121
+ }
1122
+
950
1123
  // src/meta/extractors/frontmatter-write.ts
951
1124
  var FENCE = {
952
1125
  yaml: "---",
@@ -1024,17 +1197,91 @@ function mergeBlock(flavor, inner, patch, deletions = []) {
1024
1197
  }
1025
1198
  }
1026
1199
  function mergeYaml(inner, patch, deletions = []) {
1027
- const doc = parseDocument3(inner);
1028
- if (doc.errors.length > 0) {
1200
+ const parsed2 = parseYamlBlock2(inner);
1201
+ const root = parsed2.contents;
1202
+ if (root != null && !isMap4(root)) {
1029
1203
  throw new DocmetaError(
1030
- `Cannot rewrite invalid YAML front matter: ${doc.errors[0]?.message ?? "parse error"}`
1204
+ "Cannot rewrite front matter: the root must be a mapping."
1031
1205
  );
1032
1206
  }
1033
- if (doc.contents != null && !isMap3(doc.contents)) {
1207
+ if (isMap4(root) && root.flow === true) {
1208
+ return reemitYaml(inner, patch, deletions);
1209
+ }
1210
+ let text2 = inner;
1211
+ let first = parsed2;
1212
+ for (const [key, value] of Object.entries(patch)) {
1213
+ const next = spliceYamlKey(text2, key, value, first);
1214
+ first = void 0;
1215
+ if (next === void 0) return reemitYaml(inner, patch, deletions);
1216
+ text2 = next;
1217
+ }
1218
+ for (const key of deletions) {
1219
+ const next = removeYamlKey(text2, key);
1220
+ if (next === void 0) return reemitYaml(inner, patch, deletions);
1221
+ text2 = next;
1222
+ }
1223
+ return text2;
1224
+ }
1225
+ function parseYamlBlock2(text2) {
1226
+ const doc = parseDocument3(text2);
1227
+ if (doc.errors.length > 0) {
1034
1228
  throw new DocmetaError(
1035
- "Cannot rewrite front matter: the root must be a mapping."
1229
+ `Cannot rewrite invalid YAML front matter: ${doc.errors[0]?.message ?? "parse error"}`
1036
1230
  );
1037
1231
  }
1232
+ return doc;
1233
+ }
1234
+ function rootPair(root, key) {
1235
+ return root.items.find((p) => keyString(p.key) === key);
1236
+ }
1237
+ function spliceYamlKey(text2, key, value, parsed2 = parseYamlBlock2(text2)) {
1238
+ const root = parsed2.contents;
1239
+ const eol = detectEol(text2);
1240
+ if (root == null) {
1241
+ const lines = blockLines({ [key]: value }, 0, { step: 2, indentSeq: true, eol });
1242
+ if (text2 === "") return lines;
1243
+ return text2.endsWith("\n") ? text2 + lines : text2 + eol + lines;
1244
+ }
1245
+ if (!isMap4(root) || root.flow === true) return void 0;
1246
+ const style = detectStyle(text2, root, eol);
1247
+ const pair = rootPair(root, key);
1248
+ let edit;
1249
+ if (pair === void 0) {
1250
+ edit = insertKey(text2, root, key, value, style);
1251
+ } else {
1252
+ const old = pair.value;
1253
+ const isCollectionValue = value !== null && typeof value === "object";
1254
+ if (isCollectionValue && isCollection(old) && old.flow === true) {
1255
+ const r = rangeOf(old);
1256
+ const padded = r !== void 0 && /^[[{][ \t]/.test(text2.slice(r[0], r[0] + 2));
1257
+ edit = replaceFlowValue(text2, pair, value, padded);
1258
+ } else if (!isCollectionValue && isScalar4(old)) {
1259
+ const node = old.clone();
1260
+ if (!isScalar4(node)) return void 0;
1261
+ node.value = value;
1262
+ node.comment = void 0;
1263
+ node.commentBefore = void 0;
1264
+ node.spaceBefore = void 0;
1265
+ edit = replaceBlockValue(text2, pair, node, style);
1266
+ } else {
1267
+ edit = replaceBlockValue(text2, pair, value, style);
1268
+ }
1269
+ }
1270
+ if (edit === void 0) return void 0;
1271
+ return text2.slice(0, edit.start) + edit.insert + text2.slice(edit.end);
1272
+ }
1273
+ function removeYamlKey(text2, key) {
1274
+ const root = parseYamlBlock2(text2).contents;
1275
+ if (!isMap4(root)) return text2;
1276
+ if (root.flow === true) return void 0;
1277
+ const pair = rootPair(root, key);
1278
+ if (pair === void 0) return text2;
1279
+ const edit = removeKey(text2, pair, detectEol(text2));
1280
+ if (edit === void 0) return void 0;
1281
+ return text2.slice(0, edit.start) + text2.slice(edit.end);
1282
+ }
1283
+ function reemitYaml(inner, patch, deletions) {
1284
+ const doc = parseYamlBlock2(inner);
1038
1285
  for (const [key, value] of Object.entries(patch)) {
1039
1286
  if (value !== null && typeof value === "object") {
1040
1287
  const prev = doc.get(key, true);
@@ -1458,8 +1705,8 @@ function ditaShape(content, root, filePath) {
1458
1705
  const lower = filePath?.toLowerCase() ?? "";
1459
1706
  const byExtension2 = (lower.endsWith(".dita") || lower.endsWith(".ditamap")) && DITA_ROOTS.has(name2);
1460
1707
  if (!byDoctype && !byClass && !byArch && !byExtension2) return void 0;
1461
- const isMap10 = /^\s*[-+]\s+map\//.test(cls) || MAP_ROOTS.has(name2) || lower.endsWith(".ditamap");
1462
- return isMap10 ? { kind: "map", container: "topicmeta", preamble: /* @__PURE__ */ new Set(["title"]) } : {
1708
+ const isMap11 = /^\s*[-+]\s+map\//.test(cls) || MAP_ROOTS.has(name2) || lower.endsWith(".ditamap");
1709
+ return isMap11 ? { kind: "map", container: "topicmeta", preamble: /* @__PURE__ */ new Set(["title"]) } : {
1463
1710
  kind: "topic",
1464
1711
  container: "metadata",
1465
1712
  preamble: /* @__PURE__ */ new Set([
@@ -8064,10 +8311,10 @@ import { readFile as readFile6 } from "node:fs/promises";
8064
8311
  import { isAbsolute as isAbsolute5, relative as relative8, resolve as resolve12, sep as sep3 } from "node:path";
8065
8312
  import {
8066
8313
  LineCounter as LineCounter3,
8067
- isMap as isMap5,
8068
- isNode as isNode2,
8069
- isScalar as isScalar3,
8070
- isSeq as isSeq2,
8314
+ isMap as isMap6,
8315
+ isNode as isNode3,
8316
+ isScalar as isScalar5,
8317
+ isSeq as isSeq3,
8071
8318
  parseDocument as parseDocument5
8072
8319
  } from "yaml";
8073
8320
 
@@ -8146,7 +8393,7 @@ import { spawnSync } from "node:child_process";
8146
8393
  import { readFile as readFile5 } from "node:fs/promises";
8147
8394
  import { basename as basename4, dirname as dirname6, join as join6, relative as relative7, resolve as resolve11 } from "node:path";
8148
8395
  import { isDeepStrictEqual } from "node:util";
8149
- import { isMap as isMap4, parseDocument as parseDocument4, parse as parseYaml3, stringify } from "yaml";
8396
+ import { isMap as isMap5, parseDocument as parseDocument4, parse as parseYaml3, stringify as stringify2 } from "yaml";
8150
8397
 
8151
8398
  // src/shared/write-file.ts
8152
8399
  import { chmod as chmod2, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
@@ -8244,7 +8491,7 @@ function withKey(text2, key, previous, source, toError) {
8244
8491
  if (first !== void 0) {
8245
8492
  throw toError(`${source}: invalid YAML: ${first.message}`);
8246
8493
  }
8247
- if (doc.contents !== null && !isMap4(doc.contents)) {
8494
+ if (doc.contents !== null && !isMap5(doc.contents)) {
8248
8495
  throw toError(`${source}: top level must be a mapping.`);
8249
8496
  }
8250
8497
  doc.set(ENCRYPTION_KEY_FIELD, key);
@@ -8284,7 +8531,7 @@ async function writeEncryptionKey(opts) {
8284
8531
  );
8285
8532
  }
8286
8533
  const target = file === null ? await defaultTarget(opts.cwd) : await fileTarget(file, toError);
8287
- const text2 = target.text === null ? stringify({
8534
+ const text2 = target.text === null ? stringify2({
8288
8535
  [ENCRYPTION_KEY_FIELD]: key,
8289
8536
  ...typeof previous === "string" ? { [ENCRYPTION_KEY_PREVIOUS_FIELD]: previous } : {}
8290
8537
  }) : withKey(target.text, key, previous, target.source, toError);
@@ -8730,21 +8977,21 @@ function parseManifest(manifest, collection, text2, file, configDir, join11) {
8730
8977
  );
8731
8978
  }
8732
8979
  const root = doc.contents;
8733
- if (root === null || isScalar3(root) && root.value === null)
8980
+ if (root === null || isScalar5(root) && root.value === null)
8734
8981
  return { values: target, entries };
8735
- if (!isMap5(root)) {
8982
+ if (!isMap6(root)) {
8736
8983
  throw new DocmetaError(
8737
8984
  `Manifest ${file}: the manifest must be a mapping from document ${join11 === PATH_JOIN2 ? "path" : `"${join11}"`} to owned keys.`
8738
8985
  );
8739
8986
  }
8740
8987
  const owned = new Set(manifest.keys);
8741
8988
  const lineAt = (node) => {
8742
- const range = isNode2(node) ? node.range : void 0;
8989
+ const range = isNode3(node) ? node.range : void 0;
8743
8990
  return range ? lc.linePos(range[0]).line : void 0;
8744
8991
  };
8745
8992
  const seen = /* @__PURE__ */ new Map();
8746
8993
  for (const pair of root.items) {
8747
- const spelled = isScalar3(pair.key) ? String(pair.key.value) : String(pair.key);
8994
+ const spelled = isScalar5(pair.key) ? String(pair.key.value) : String(pair.key);
8748
8995
  const entryLine = lineAt(pair.key);
8749
8996
  const where = entryLine === void 0 ? file : `${file}:${entryLine}`;
8750
8997
  if (seen.has(spelled)) {
@@ -8754,7 +9001,7 @@ function parseManifest(manifest, collection, text2, file, configDir, join11) {
8754
9001
  );
8755
9002
  }
8756
9003
  seen.set(spelled, entryLine);
8757
- if (!isMap5(pair.value)) {
9004
+ if (!isMap6(pair.value)) {
8758
9005
  throw new DocmetaError(
8759
9006
  `Manifest ${where}: "${spelled}" must be a mapping of owned keys to values.`
8760
9007
  );
@@ -8762,7 +9009,7 @@ function parseManifest(manifest, collection, text2, file, configDir, join11) {
8762
9009
  const indexKey = join11 === PATH_JOIN2 ? resolve12(configDir, spelled) : spelled;
8763
9010
  const values = target.get(indexKey) ?? /* @__PURE__ */ new Map();
8764
9011
  for (const kv of pair.value.items) {
8765
- const key = isScalar3(kv.key) ? String(kv.key.value) : String(kv.key);
9012
+ const key = isScalar5(kv.key) ? String(kv.key.value) : String(kv.key);
8766
9013
  if (key === FILE_SCHEMA_KEY) {
8767
9014
  throw new DocmetaError(
8768
9015
  `Manifest ${where}: "${spelled}" sets "${FILE_SCHEMA_KEY}" \u2014 a manifest never chooses the schema a document is judged by; use "overrides" in the config.`
@@ -8797,15 +9044,15 @@ function parseManifest(manifest, collection, text2, file, configDir, join11) {
8797
9044
  return { values: target, entries };
8798
9045
  }
8799
9046
  function nodeLines(node, lineAt, prefix = "", out = /* @__PURE__ */ new Map()) {
8800
- if (isMap5(node)) {
9047
+ if (isMap6(node)) {
8801
9048
  for (const kv of node.items) {
8802
- const seg = isScalar3(kv.key) ? String(kv.key.value) : String(kv.key);
9049
+ const seg = isScalar5(kv.key) ? String(kv.key.value) : String(kv.key);
8803
9050
  const pointer = `${prefix}/${escapePointerSegment(seg)}`;
8804
9051
  const line = lineAt(kv.key) ?? lineAt(kv.value);
8805
9052
  if (line !== void 0) out.set(pointer, line);
8806
9053
  nodeLines(kv.value, lineAt, pointer, out);
8807
9054
  }
8808
- } else if (isSeq2(node)) {
9055
+ } else if (isSeq3(node)) {
8809
9056
  node.items.forEach((item, i) => {
8810
9057
  const pointer = `${prefix}/${String(i)}`;
8811
9058
  const line = lineAt(item);
@@ -12094,9 +12341,9 @@ import { basename as basename5, extname as extname3, isAbsolute as isAbsolute8,
12094
12341
  import picomatch6 from "picomatch";
12095
12342
  import {
12096
12343
  LineCounter as LineCounter5,
12097
- isMap as isMap7,
12098
- isNode as isNode4,
12099
- isScalar as isScalar5,
12344
+ isMap as isMap8,
12345
+ isNode as isNode5,
12346
+ isScalar as isScalar7,
12100
12347
  isSeq as isSeq4,
12101
12348
  parse as parseYaml5,
12102
12349
  parseDocument as parseDocument7
@@ -12106,13 +12353,11 @@ import {
12106
12353
  import { posix as posix6 } from "node:path";
12107
12354
  import {
12108
12355
  LineCounter as LineCounter4,
12109
- isMap as isMap6,
12110
- isNode as isNode3,
12111
- isPair,
12112
- isScalar as isScalar4,
12113
- isSeq as isSeq3,
12356
+ isMap as isMap7,
12357
+ isNode as isNode4,
12358
+ isScalar as isScalar6,
12114
12359
  parseDocument as parseDocument6,
12115
- stringify as stringify2
12360
+ stringify as stringify3
12116
12361
  } from "yaml";
12117
12362
  function spliceManifestValue(text2, options) {
12118
12363
  const { entry, key, value, file } = options;
@@ -12145,9 +12390,9 @@ function spliceManifestValue(text2, options) {
12145
12390
  const root = doc.contents;
12146
12391
  let spelled = entry;
12147
12392
  let edit;
12148
- if (root === null || isScalar4(root) && root.value === null && emptySource(text2, root)) {
12393
+ if (root === null || isScalar6(root) && root.value === null && emptySource(text2, root)) {
12149
12394
  edit = startManifest(text2, entry, key, value, eol);
12150
- } else if (!isMap6(root)) {
12395
+ } else if (!isMap7(root)) {
12151
12396
  throw new DocmetaError(
12152
12397
  `${at2()}: the manifest must be a mapping from document ${join11 === PATH_JOIN2 ? "path" : `"${join11}"`} to owned keys.`
12153
12398
  );
@@ -12171,7 +12416,7 @@ function spliceManifestValue(text2, options) {
12171
12416
  spelled = keyString(first.key);
12172
12417
  const where = at2(keyLine(first.key));
12173
12418
  const v = first.value;
12174
- if (!isMap6(v)) {
12419
+ if (!isMap7(v)) {
12175
12420
  throw new DocmetaError(`${where}: "${spelled}" must be a mapping of owned keys to values.`);
12176
12421
  }
12177
12422
  const hits = v.items.filter((kv) => keyString(kv.key) === key);
@@ -12218,14 +12463,14 @@ function readManifestValue(text2, options) {
12218
12463
  const doc = parseDocument6(text2, { uniqueKeys: false });
12219
12464
  if (doc.errors.length > 0) return void 0;
12220
12465
  const root = doc.contents;
12221
- if (!isMap6(root)) return void 0;
12466
+ if (!isMap7(root)) return void 0;
12222
12467
  const same2 = join11 === PATH_JOIN2 ? (a, b) => posix6.normalize(a) === posix6.normalize(b) : (a, b) => a === b;
12223
12468
  const pair = root.items.find((p) => same2(keyString(p.key), options.entry));
12224
12469
  const held = pair?.value;
12225
- if (!isMap6(held)) return void 0;
12470
+ if (!isMap7(held)) return void 0;
12226
12471
  const kv = held.items.find((p) => keyString(p.key) === options.key);
12227
12472
  const node = kv?.value;
12228
- return isNode3(node) ? node.toJSON() : void 0;
12473
+ return isNode4(node) ? node.toJSON() : void 0;
12229
12474
  }
12230
12475
  function removeManifestKey(text2, options) {
12231
12476
  const { entry, key, file } = options;
@@ -12247,8 +12492,8 @@ function removeManifestKey(text2, options) {
12247
12492
  return r ? lc.linePos(r[0]).line : void 0;
12248
12493
  };
12249
12494
  const root = doc.contents;
12250
- if (root === null || isScalar4(root) && root.value === null) return { text: text2 };
12251
- if (!isMap6(root)) {
12495
+ if (root === null || isScalar6(root) && root.value === null) return { text: text2 };
12496
+ if (!isMap7(root)) {
12252
12497
  throw new DocmetaError(
12253
12498
  `${at2()}: the manifest must be a mapping from document ${join11 === PATH_JOIN2 ? "path" : `"${join11}"`} to owned keys.`
12254
12499
  );
@@ -12265,7 +12510,7 @@ function removeManifestKey(text2, options) {
12265
12510
  const spelled = keyString(first.key);
12266
12511
  const where = at2(keyLine(first.key));
12267
12512
  const v = first.value;
12268
- if (!isMap6(v)) {
12513
+ if (!isMap7(v)) {
12269
12514
  throw new DocmetaError(`${where}: "${spelled}" must be a mapping of owned keys to values.`);
12270
12515
  }
12271
12516
  const hits = v.items.filter((kv) => keyString(kv.key) === key);
@@ -12289,10 +12534,7 @@ function removeManifestKey(text2, options) {
12289
12534
  `${where}: "${spelled}" writes a key in a form this writer does not edit. Write it as "${key}: \u2026".`
12290
12535
  );
12291
12536
  }
12292
- let start = text2.lastIndexOf("\n", from[0] - 1) + 1;
12293
- let end = lineEnd(text2, to);
12294
- if (text2.startsWith(eol, end)) end += eol.length;
12295
- else if (start >= eol.length) start -= eol.length;
12537
+ let { start, end } = keyLines(text2, from[0], to, eol);
12296
12538
  if (whole) {
12297
12539
  if (text2.slice(start - 2 * eol.length, start) === eol + eol) start -= eol.length;
12298
12540
  else if (start === 0 && text2.startsWith(eol, end)) end += eol.length;
@@ -12335,8 +12577,8 @@ function renameManifestEntry(text2, options) {
12335
12577
  return r2 ? lc.linePos(r2[0]).line : void 0;
12336
12578
  };
12337
12579
  const root = doc.contents;
12338
- if (root === null || isScalar4(root) && root.value === null) return { text: text2 };
12339
- if (!isMap6(root)) {
12580
+ if (root === null || isScalar6(root) && root.value === null) return { text: text2 };
12581
+ if (!isMap7(root)) {
12340
12582
  throw new DocmetaError(
12341
12583
  `${at2()}: the manifest must be a mapping from document ${join11 === PATH_JOIN2 ? "path" : `"${join11}"`} to owned keys.`
12342
12584
  );
@@ -12363,8 +12605,8 @@ function renameManifestEntry(text2, options) {
12363
12605
  `${at2(keyLine(first.key))}: "${spelled}" is written in a form this writer does not edit. Write it as "${spelled}: \u2026".`
12364
12606
  );
12365
12607
  }
12366
- const quoted = isScalar4(first.key) && (first.key.type === "QUOTE_DOUBLE" || first.key.type === "QUOTE_SINGLE");
12367
- const plain = stringify2(to, { lineWidth: 0 }).replace(/\n$/, "");
12608
+ const quoted = isScalar6(first.key) && (first.key.type === "QUOTE_DOUBLE" || first.key.type === "QUOTE_SINGLE");
12609
+ const plain = stringify3(to, { lineWidth: 0 }).replace(/\n$/, "");
12368
12610
  const insert = quoted || plain.includes("\n") ? JSON.stringify(to) : plain;
12369
12611
  const out = text2.slice(0, r[0]) + insert + text2.slice(end);
12370
12612
  const after = parseDocument6(out, { uniqueKeys: false });
@@ -12401,24 +12643,13 @@ function appendEntry(text2, root, entry, key, value, style) {
12401
12643
  const col = firstKey ? colOf(text2, firstKey[0]) : 0;
12402
12644
  const pos = lineEnd(text2, contentEnd(text2, root) ?? text2.length);
12403
12645
  const last = root.items.at(-1);
12404
- const spaced = root.items.length > 1 && isNode3(last?.key) && last.key.spaceBefore === true;
12646
+ const spaced = root.items.length > 1 && isNode4(last?.key) && last.key.spaceBefore === true;
12405
12647
  return {
12406
12648
  start: pos,
12407
12649
  end: pos,
12408
12650
  insert: style.eol + (spaced ? style.eol : "") + blockLines(body, col, style)
12409
12651
  };
12410
12652
  }
12411
- function insertKey(text2, entryMap, key, value, style) {
12412
- const firstKey = rangeOf(entryMap.items[0]?.key);
12413
- const end = contentEnd(text2, entryMap);
12414
- if (!firstKey || end === void 0) return void 0;
12415
- const pos = lineEnd(text2, end);
12416
- return {
12417
- start: pos,
12418
- end: pos,
12419
- insert: style.eol + blockLines({ [key]: value }, colOf(text2, firstKey[0]), style)
12420
- };
12421
- }
12422
12653
  function fillEmptyEntry(text2, entryPair, key, value, style) {
12423
12654
  const start = colonEnd(text2, entryPair);
12424
12655
  const keyRange = rangeOf(entryPair.key);
@@ -12427,34 +12658,6 @@ function fillEmptyEntry(text2, entryPair, key, value, style) {
12427
12658
  const col = colOf(text2, keyRange[0]) + style.step;
12428
12659
  return { start, end, insert: style.eol + blockLines({ [key]: value }, col, style) };
12429
12660
  }
12430
- function replaceBlockValue(text2, pair, value, style) {
12431
- const colon = colonEnd(text2, pair);
12432
- const keyRange = rangeOf(pair.key);
12433
- if (colon === void 0 || !keyRange) return void 0;
12434
- const keyCol = colOf(text2, keyRange[0]);
12435
- let start = colon;
12436
- let ownLine = false;
12437
- let i = colon;
12438
- while (text2.charAt(i) === " " || text2.charAt(i) === " ") i++;
12439
- if (text2.charAt(i) === "#") {
12440
- start = lineEnd(text2, i);
12441
- ownLine = true;
12442
- }
12443
- const old = pair.value;
12444
- const oldEnd = isScalar4(old) && old.value === null && emptySource(text2, old) ? start : contentEnd(text2, old) ?? start;
12445
- const end = Math.max(start, oldEnd);
12446
- let insert = afterColon(value, keyCol, style);
12447
- if (ownLine && !insert.startsWith(style.eol)) {
12448
- insert = style.eol + " ".repeat(keyCol + style.step) + insert.trimStart();
12449
- }
12450
- return { start, end, insert };
12451
- }
12452
- function replaceFlowValue(text2, pair, value) {
12453
- const r = rangeOf(pair.value);
12454
- if (!r || emptySource(text2, pair.value)) return void 0;
12455
- const end = contentEnd(text2, pair.value) ?? r[1];
12456
- return { start: r[0], end, insert: flowText(value) };
12457
- }
12458
12661
  function readBack(before, out, spelled, key, value, fail2) {
12459
12662
  const lc = new LineCounter4();
12460
12663
  const after = parseDocument6(out, { lineCounter: lc, uniqueKeys: false });
@@ -12478,114 +12681,13 @@ function readBack(before, out, spelled, key, value, fail2) {
12478
12681
  throw fail2("Another value in the manifest would have changed.");
12479
12682
  }
12480
12683
  const root = after.contents;
12481
- const pair = isMap6(root) ? root.items.find((p) => keyString(p.key) === spelled) : void 0;
12684
+ const pair = isMap7(root) ? root.items.find((p) => keyString(p.key) === spelled) : void 0;
12482
12685
  const entryMap = pair?.value;
12483
- const kv = isMap6(entryMap) ? entryMap.items.find((p) => keyString(p.key) === key) : void 0;
12686
+ const kv = isMap7(entryMap) ? entryMap.items.find((p) => keyString(p.key) === key) : void 0;
12484
12687
  const r = rangeOf(kv?.value) ?? rangeOf(kv?.key);
12485
12688
  if (!r) throw fail2("The written value could not be found again.");
12486
12689
  return lc.linePos(r[0]).line;
12487
12690
  }
12488
- function blockLines(pair, col, style) {
12489
- const s = stringify2(pair, { lineWidth: 0, indent: style.step, indentSeq: style.indentSeq });
12490
- return indentLines(s.replace(/\n$/, "").split("\n"), col, 0).join(style.eol);
12491
- }
12492
- function afterColon(value, col, style) {
12493
- const s = stringify2({ k: value }, { lineWidth: 0, indent: style.step, indentSeq: style.indentSeq });
12494
- const lines = s.replace(/\n$/, "").slice("k:".length).split("\n");
12495
- return indentLines(lines, col, 1).join(style.eol);
12496
- }
12497
- function indentLines(lines, col, from) {
12498
- const pad2 = " ".repeat(col);
12499
- return lines.map((l, i) => i < from || l === "" ? l : pad2 + l);
12500
- }
12501
- function flowText(value) {
12502
- const s = stringify2(value, { lineWidth: 0, collectionStyle: "flow" }).replace(/\n$/, "");
12503
- return s.includes("\n") ? JSON.stringify(value) : s;
12504
- }
12505
- function detectEol(text2) {
12506
- const i = text2.indexOf("\n");
12507
- return i > 0 && text2.charAt(i - 1) === "\r" ? "\r\n" : "\n";
12508
- }
12509
- function detectStyle(text2, root, eol) {
12510
- let step = 2;
12511
- for (const pair of root.items) {
12512
- const v = pair.value;
12513
- const entryKey = rangeOf(pair.key);
12514
- const ownedKey = isMap6(v) && v.flow !== true ? rangeOf(v.items[0]?.key) : void 0;
12515
- if (entryKey && ownedKey) {
12516
- const d = colOf(text2, ownedKey[0]) - colOf(text2, entryKey[0]);
12517
- if (d > 0) {
12518
- step = d;
12519
- break;
12520
- }
12521
- }
12522
- }
12523
- return { step, indentSeq: seqIndented(text2, root) ?? true, eol };
12524
- }
12525
- function seqIndented(text2, node) {
12526
- if (isMap6(node)) {
12527
- for (const pair of node.items) {
12528
- const v = pair.value;
12529
- if (isSeq3(v) && v.flow !== true && v.items.length > 0) {
12530
- const k = rangeOf(pair.key);
12531
- const s = rangeOf(v);
12532
- if (k && s) return colOf(text2, s[0]) > colOf(text2, k[0]);
12533
- }
12534
- const inner = seqIndented(text2, v);
12535
- if (inner !== void 0) return inner;
12536
- }
12537
- } else if (isSeq3(node)) {
12538
- for (const item of node.items) {
12539
- const inner = seqIndented(text2, item);
12540
- if (inner !== void 0) return inner;
12541
- }
12542
- }
12543
- return void 0;
12544
- }
12545
- function contentEnd(text2, node) {
12546
- if (isMap6(node) && node.flow !== true) {
12547
- const last = node.items.at(-1);
12548
- if (last) return contentEnd(text2, last.value) ?? contentEnd(text2, last.key);
12549
- } else if (isSeq3(node) && node.flow !== true) {
12550
- const last = node.items.at(-1);
12551
- if (last !== void 0) {
12552
- return isPair(last) ? contentEnd(text2, last.value) ?? contentEnd(text2, last.key) : contentEnd(text2, last);
12553
- }
12554
- }
12555
- const r = rangeOf(node);
12556
- if (!r) return void 0;
12557
- let end = r[1];
12558
- while (end > r[0] && /\s/.test(text2.charAt(end - 1))) end--;
12559
- return end;
12560
- }
12561
- function colonEnd(text2, pair) {
12562
- const r = rangeOf(pair.key);
12563
- if (!r) return void 0;
12564
- let i = r[1];
12565
- while (text2.charAt(i) === " " || text2.charAt(i) === " ") i++;
12566
- return text2.charAt(i) === ":" ? i + 1 : void 0;
12567
- }
12568
- function lineEnd(text2, i) {
12569
- const j = text2.indexOf("\n", i);
12570
- if (j < 0) return text2.length;
12571
- return j > 0 && text2.charAt(j - 1) === "\r" ? j - 1 : j;
12572
- }
12573
- function colOf(text2, offset) {
12574
- if (offset === 0) return 0;
12575
- let start = text2.lastIndexOf("\n", offset - 1) + 1;
12576
- if (start === 0 && text2.startsWith("\uFEFF")) start = 1;
12577
- return offset - start;
12578
- }
12579
- function rangeOf(node) {
12580
- return isNode3(node) ? node.range ?? void 0 : void 0;
12581
- }
12582
- function emptySource(text2, node) {
12583
- const r = rangeOf(node);
12584
- return !r || text2.slice(r[0], r[1]).trim() === "";
12585
- }
12586
- function keyString(key) {
12587
- return isScalar4(key) ? String(key.value) : String(key);
12588
- }
12589
12691
  function isRecord6(x) {
12590
12692
  return typeof x === "object" && x !== null && !Array.isArray(x);
12591
12693
  }
@@ -13260,7 +13362,7 @@ async function planRelocation(ctx, request) {
13260
13362
  if (!o.drop) text2 = spliceManifestValue(text2, { ...where, entry: o.entry, key: o.key, value: o.value }).text;
13261
13363
  }
13262
13364
  for (const i of ins) text2 = removeManifestKey(text2, { ...where, entry: i.entry, key: i.key }).text;
13263
- const found = keyLines(text2, m.join);
13365
+ const found = keyLines2(text2, m.join);
13264
13366
  for (const o of outs) {
13265
13367
  const line = found.get(entryId(o.entry, m.join))?.get(o.key);
13266
13368
  if (line !== void 0) lines.set(lineId(o.page, file, o.key), line);
@@ -13399,19 +13501,19 @@ async function readManifestText(path, file, perPage) {
13399
13501
  }
13400
13502
  var entryId = (entry, join11) => join11 === PATH_JOIN2 ? toPosix3(entry).replace(/^\.\//, "").replace(/\/+/g, "/") : entry;
13401
13503
  var lineId = (page, manifest, key) => `${page}\0${manifest}\0${key}`;
13402
- function keyLines(text2, join11) {
13504
+ function keyLines2(text2, join11) {
13403
13505
  const out = /* @__PURE__ */ new Map();
13404
13506
  const lc = new LineCounter5();
13405
13507
  const doc = parseDocument7(text2, { lineCounter: lc, uniqueKeys: false });
13406
13508
  const root = doc.contents;
13407
- if (!isMap7(root)) return out;
13509
+ if (!isMap8(root)) return out;
13408
13510
  for (const pair of root.items) {
13409
- const spelled = isScalar5(pair.key) ? String(pair.key.value) : String(pair.key);
13410
- if (!isMap7(pair.value)) continue;
13511
+ const spelled = isScalar7(pair.key) ? String(pair.key.value) : String(pair.key);
13512
+ if (!isMap8(pair.value)) continue;
13411
13513
  const keys = /* @__PURE__ */ new Map();
13412
13514
  for (const kv of pair.value.items) {
13413
- const name2 = isScalar5(kv.key) ? String(kv.key.value) : String(kv.key);
13414
- const range = isNode4(kv.key) ? kv.key.range : void 0;
13515
+ const name2 = isScalar7(kv.key) ? String(kv.key.value) : String(kv.key);
13516
+ const range = isNode5(kv.key) ? kv.key.range : void 0;
13415
13517
  if (range) keys.set(name2, lc.linePos(range[0]).line);
13416
13518
  }
13417
13519
  out.set(entryId(spelled, join11), keys);
@@ -13446,7 +13548,7 @@ function editConfig(text2, model, source) {
13446
13548
  const doc = parseDocument7(text2 ?? "");
13447
13549
  const [problem] = doc.errors;
13448
13550
  if (problem !== void 0) throw new DocmetaError(`${source}: invalid YAML: ${problem.message}`);
13449
- if (doc.contents !== null && !isMap7(doc.contents)) {
13551
+ if (doc.contents !== null && !isMap8(doc.contents)) {
13450
13552
  throw new DocmetaError(`${source}: top level must be a mapping.`);
13451
13553
  }
13452
13554
  const fail2 = () => {
@@ -13456,7 +13558,7 @@ function editConfig(text2, model, source) {
13456
13558
  if (!isSeq4(node)) return;
13457
13559
  node.flow = true;
13458
13560
  if (quoted) {
13459
- for (const item of node.items) if (isScalar5(item)) item.type = "QUOTE_DOUBLE";
13561
+ for (const item of node.items) if (isScalar7(item)) item.type = "QUOTE_DOUBLE";
13460
13562
  }
13461
13563
  };
13462
13564
  const manifestNode = (d, file, keys) => {
@@ -13470,13 +13572,13 @@ function editConfig(text2, model, source) {
13470
13572
  for (let i = 0; i < declared; i++) {
13471
13573
  const c = model.collections[i];
13472
13574
  const node = isSeq4(existing) ? existing.items[i] : void 0;
13473
- if (c === void 0 || !isMap7(node)) return fail2();
13575
+ if (c === void 0 || !isMap8(node)) return fail2();
13474
13576
  for (const added of model.pathsAdded.filter((p) => p.collection === c.name)) {
13475
13577
  const paths = node.get("paths", true);
13476
13578
  if (!isSeq4(paths)) return fail2();
13477
13579
  const scalar = doc.createNode(added.path);
13478
13580
  const first = paths.items[0];
13479
- if (isScalar5(first) && first.type !== void 0) scalar.type = first.type;
13581
+ if (isScalar7(first) && first.type !== void 0) scalar.type = first.type;
13480
13582
  paths.add(scalar);
13481
13583
  }
13482
13584
  const refs = model.manifestsOf(c.name);
@@ -13493,7 +13595,7 @@ function editConfig(text2, model, source) {
13493
13595
  }
13494
13596
  if (m.keysAdded.length === 0) continue;
13495
13597
  const entry = node.getIn(["externalMetadata", m.index], true);
13496
- const keys = isMap7(entry) ? entry.get("keys", true) : void 0;
13598
+ const keys = isMap8(entry) ? entry.get("keys", true) : void 0;
13497
13599
  if (!isSeq4(keys)) return fail2();
13498
13600
  for (const key of m.keysAdded) keys.add(doc.createNode(key));
13499
13601
  }
@@ -13502,10 +13604,10 @@ function editConfig(text2, model, source) {
13502
13604
  if (m.keysRemoved.length === 0) continue;
13503
13605
  if (!isSeq4(list2)) return fail2();
13504
13606
  const entry = list2.items[m.index];
13505
- const keys = isMap7(entry) ? entry.get("keys", true) : void 0;
13607
+ const keys = isMap8(entry) ? entry.get("keys", true) : void 0;
13506
13608
  if (!isSeq4(keys)) return fail2();
13507
13609
  for (const key of m.keysRemoved) {
13508
- const at2 = keys.items.findIndex((item) => (isScalar5(item) ? String(item.value) : String(item)) === key);
13610
+ const at2 = keys.items.findIndex((item) => (isScalar7(item) ? String(item.value) : String(item)) === key);
13509
13611
  if (at2 >= 0) keys.delete(at2);
13510
13612
  }
13511
13613
  if (keys.items.length === 0) list2.delete(m.index);
@@ -13524,7 +13626,7 @@ function editConfig(text2, model, source) {
13524
13626
  flowSeq(node.get("paths", true), true);
13525
13627
  const made = node.get("externalMetadata", true);
13526
13628
  if (isSeq4(made)) {
13527
- for (const item of made.items) if (isMap7(item)) flowSeq(item.get("keys", true), false);
13629
+ for (const item of made.items) if (isMap8(item)) flowSeq(item.get("keys", true), false);
13528
13630
  }
13529
13631
  const seq = doc.get("collections", true);
13530
13632
  if (isSeq4(seq)) seq.add(node);
@@ -14776,7 +14878,7 @@ function parseJsonPointer(pointer) {
14776
14878
  import { existsSync as existsSync4 } from "node:fs";
14777
14879
  import { mkdir as mkdir3, readFile as readFile11 } from "node:fs/promises";
14778
14880
  import { dirname as dirname10, extname as extname6, isAbsolute as isAbsolute10, join as join9, relative as relative14, resolve as resolve19, sep as sep9 } from "node:path";
14779
- import { parseDocument as parseDocument8, parse as parseYaml6, stringify as stringify3 } from "yaml";
14881
+ import { parseDocument as parseDocument8, parse as parseYaml6, stringify as stringify4 } from "yaml";
14780
14882
  function getSchemasInfo() {
14781
14883
  return { builtins: listBuiltins(), formats: listFormats() };
14782
14884
  }
@@ -14846,7 +14948,7 @@ function foldEntry(entries, next) {
14846
14948
  }
14847
14949
  function renderConfig(existing, entries, section) {
14848
14950
  if (existing === null) {
14849
- return stringify3({ [META_SECTION]: { schemas: entries } });
14951
+ return stringify4({ [META_SECTION]: { schemas: entries } });
14850
14952
  }
14851
14953
  const doc = parseDocument8(existing);
14852
14954
  doc.setIn(section === void 0 ? ["schemas"] : [section, "schemas"], entries);
@@ -15261,10 +15363,10 @@ async function ensureEncryptionKey(opts) {
15261
15363
  }
15262
15364
 
15263
15365
  // src/meta/commands/query.ts
15264
- import { parseDocument as parseDocument10, isMap as isMap9, isSeq as isSeq5, isScalar as isScalar7 } from "yaml";
15366
+ import { parseDocument as parseDocument10, isMap as isMap10, isSeq as isSeq5, isScalar as isScalar9 } from "yaml";
15265
15367
 
15266
15368
  // src/meta/core/location-writes.ts
15267
- import { LineCounter as LineCounter6, isMap as isMap8, isNode as isNode5, isScalar as isScalar6, parseDocument as parseDocument9 } from "yaml";
15369
+ import { LineCounter as LineCounter6, isMap as isMap9, isNode as isNode6, isScalar as isScalar8, parseDocument as parseDocument9 } from "yaml";
15268
15370
  var dedupe3 = (xs) => [...new Set(xs)];
15269
15371
  var pages = (n) => `${String(n)} page${n === 1 ? "" : "s"}`;
15270
15372
  async function offerExternalHomes(ctx, writes, hooks) {
@@ -15351,13 +15453,13 @@ function manifestKeyLine(text2, entry, key, join11) {
15351
15453
  const lc = new LineCounter6();
15352
15454
  const doc = parseDocument9(text2, { lineCounter: lc, uniqueKeys: false });
15353
15455
  const root = doc.contents;
15354
- if (!isMap8(root)) return void 0;
15456
+ if (!isMap9(root)) return void 0;
15355
15457
  for (const pair of root.items) {
15356
- const spelled = isScalar6(pair.key) ? String(pair.key.value) : String(pair.key);
15357
- if (norm(spelled) !== norm(entry) || !isMap8(pair.value)) continue;
15458
+ const spelled = isScalar8(pair.key) ? String(pair.key.value) : String(pair.key);
15459
+ if (norm(spelled) !== norm(entry) || !isMap9(pair.value)) continue;
15358
15460
  for (const kv of pair.value.items) {
15359
- const name2 = isScalar6(kv.key) ? String(kv.key.value) : String(kv.key);
15360
- const range = isNode5(kv.key) ? kv.key.range : void 0;
15461
+ const name2 = isScalar8(kv.key) ? String(kv.key.value) : String(kv.key);
15462
+ const range = isNode6(kv.key) ? kv.key.range : void 0;
15361
15463
  if (name2 === key && range) return lc.linePos(range[0]).line;
15362
15464
  }
15363
15465
  }
@@ -16559,8 +16661,8 @@ async function planConfigEdit(ctx, edit, runRefs) {
16559
16661
  const doc = parseDocument10(stripBom2(text2));
16560
16662
  const display = displayPath(ctx, configPath);
16561
16663
  const rawRefOf = (item) => {
16562
- if (isScalar7(item) && typeof item.value === "string") return item.value;
16563
- if (isMap9(item)) {
16664
+ if (isScalar9(item) && typeof item.value === "string") return item.value;
16665
+ if (isMap10(item)) {
16564
16666
  const ref = item.get("ref");
16565
16667
  if (typeof ref === "string") return ref;
16566
16668
  }
@@ -16582,10 +16684,10 @@ async function planConfigEdit(ctx, edit, runRefs) {
16582
16684
  for (const item of node.items) {
16583
16685
  const raw = rawRefOf(item);
16584
16686
  if (raw === void 0 || !wants(raw)) continue;
16585
- if (isScalar7(item)) {
16687
+ if (isScalar9(item)) {
16586
16688
  item.value = spec.newRef;
16587
16689
  n += 1;
16588
- } else if (isMap9(item)) {
16690
+ } else if (isMap10(item)) {
16589
16691
  item.set("ref", spec.newRef);
16590
16692
  n += 1;
16591
16693
  }
@@ -16593,13 +16695,13 @@ async function planConfigEdit(ctx, edit, runRefs) {
16593
16695
  return n;
16594
16696
  };
16595
16697
  const root = ctx.configSection === void 0 ? doc : doc.get(ctx.configSection, true);
16596
- const keyOf2 = (key) => root === doc ? doc.get(key, true) : isMap9(root) ? root.get(key, true) : void 0;
16698
+ const keyOf2 = (key) => root === doc ? doc.get(key, true) : isMap10(root) ? root.get(key, true) : void 0;
16597
16699
  const topSeq = keyOf2("schemas");
16598
16700
  let repointCount = repoint(topSeq);
16599
16701
  const overrides = keyOf2("overrides");
16600
16702
  if (isSeq5(overrides)) {
16601
16703
  for (const entry of overrides.items) {
16602
- if (isMap9(entry)) repointCount += repoint(entry.get("schemas", true));
16704
+ if (isMap10(entry)) repointCount += repoint(entry.get("schemas", true));
16603
16705
  }
16604
16706
  }
16605
16707
  const repointed = repointCount > 0;
@@ -16608,7 +16710,7 @@ async function planConfigEdit(ctx, edit, runRefs) {
16608
16710
  if (edit.integrity && isSeq5(topSeq)) {
16609
16711
  const wantPath = foldPath(edit.integrity.path);
16610
16712
  for (const item of topSeq.items) {
16611
- if (!isMap9(item)) continue;
16713
+ if (!isMap10(item)) continue;
16612
16714
  const raw = rawRefOf(item);
16613
16715
  if (raw === void 0 || classifyRef(raw).kind !== "file") continue;
16614
16716
  const abs = isAbsolute11(raw) ? raw : resolve20(configDir, raw);
@@ -20559,4 +20661,4 @@ export {
20559
20661
  renderQuery,
20560
20662
  renderQueryCsv
20561
20663
  };
20562
- //# sourceMappingURL=chunk-BUXVMARH.js.map
20664
+ //# sourceMappingURL=chunk-P4V5IMHM.js.map