@decimalturn/toml-patch 3.3.3-dev → 3.3.3-lite
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/patch.js +20 -0
- package/package.json +6 -11
- package/dist/dev/comment-alignment.js +0 -371
- package/dist/dev/comment-alignment.js.map +0 -1
- package/dist/dev/comment-ownership.js +0 -672
- package/dist/dev/comment-ownership.js.map +0 -1
- package/dist/dev/cst-source.js +0 -117
- package/dist/dev/cst-source.js.map +0 -1
- package/dist/dev/cst.js +0 -67
- package/dist/dev/cst.js.map +0 -1
- package/dist/dev/cursor.js +0 -65
- package/dist/dev/cursor.js.map +0 -1
- package/dist/dev/date-format.js +0 -286
- package/dist/dev/date-format.js.map +0 -1
- package/dist/dev/decode-utf8.js +0 -26
- package/dist/dev/decode-utf8.js.map +0 -1
- package/dist/dev/diff-lite.js +0 -107
- package/dist/dev/diff-lite.js.map +0 -1
- package/dist/dev/diff.js +0 -264
- package/dist/dev/diff.js.map +0 -1
- package/dist/dev/encode-lite.js +0 -209
- package/dist/dev/encode-lite.js.map +0 -1
- package/dist/dev/escape-preference.js +0 -165
- package/dist/dev/escape-preference.js.map +0 -1
- package/dist/dev/find-by-path.js +0 -114
- package/dist/dev/find-by-path.js.map +0 -1
- package/dist/dev/formatter.js +0 -297
- package/dist/dev/formatter.js.map +0 -1
- package/dist/dev/generate.js +0 -479
- package/dist/dev/generate.js.map +0 -1
- package/dist/dev/inline-comma-space.js +0 -12
- package/dist/dev/inline-comma-space.js.map +0 -1
- package/dist/dev/inline-format.js +0 -105
- package/dist/dev/inline-format.js.map +0 -1
- package/dist/dev/inline-layout.js +0 -106
- package/dist/dev/inline-layout.js.map +0 -1
- package/dist/dev/line-ending-backslash.js +0 -319
- package/dist/dev/line-ending-backslash.js.map +0 -1
- package/dist/dev/literal-string.js +0 -45
- package/dist/dev/literal-string.js.map +0 -1
- package/dist/dev/location.js +0 -103
- package/dist/dev/location.js.map +0 -1
- package/dist/dev/parse-error.js +0 -26
- package/dist/dev/parse-error.js.map +0 -1
- package/dist/dev/parse-js.js +0 -149
- package/dist/dev/parse-js.js.map +0 -1
- package/dist/dev/parse-string.js +0 -119
- package/dist/dev/parse-string.js.map +0 -1
- package/dist/dev/parse-toml.js +0 -713
- package/dist/dev/parse-toml.js.map +0 -1
- package/dist/dev/patch-lite.js +0 -4
- package/dist/dev/patch-lite2.js +0 -96
- package/dist/dev/patch-lite2.js.map +0 -1
- package/dist/dev/patch.js +0 -3143
- package/dist/dev/patch.js.map +0 -1
- package/dist/dev/smol-toml-date.js +0 -60
- package/dist/dev/smol-toml-date.js.map +0 -1
- package/dist/dev/to-js.js +0 -307
- package/dist/dev/to-js.js.map +0 -1
- package/dist/dev/to-toml.js +0 -873
- package/dist/dev/to-toml.js.map +0 -1
- package/dist/dev/tokenizer.js +0 -224
- package/dist/dev/tokenizer.js.map +0 -1
- package/dist/dev/toml-document.js +0 -220
- package/dist/dev/toml-document.js.map +0 -1
- package/dist/dev/toml-format.js +0 -548
- package/dist/dev/toml-format.js.map +0 -1
- package/dist/dev/toml-patch.js +0 -93
- package/dist/dev/toml-patch.js.map +0 -1
- package/dist/dev/traverse.js +0 -60
- package/dist/dev/traverse.js.map +0 -1
- package/dist/dev/truncate.js +0 -63
- package/dist/dev/truncate.js.map +0 -1
- package/dist/dev/update-order.js +0 -234
- package/dist/dev/update-order.js.map +0 -1
- package/dist/dev/utils.js +0 -295
- package/dist/dev/utils.js.map +0 -1
- package/dist/dev/writer.js +0 -757
- package/dist/dev/writer.js.map +0 -1
- package/dist/toml-patch.d.ts +0 -548
- /package/dist/{patch-lite.d.ts → patch.d.ts} +0 -0
package/dist/dev/patch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","names":["isIntegerNode","isInteger","updated_js","parentSection"],"sources":["../../src/patch.ts"],"sourcesContent":["import parseTOML from './parse-toml';\nimport parseJS from './parse-js';\nimport toJS from './to-js';\nimport toTOML, { toTOMLCursor } from './to-toml';\nimport { TomlFormat } from './toml-format';\nimport {\n isKeyValue,\n WithItems,\n KeyValue,\n Comment,\n isTable,\n TreeNode,\n Key,\n Document,\n isDocument,\n Block,\n NodeType,\n isTableArray,\n isInlineArray,\n isInlineTable,\n isInlineItem,\n isString,\n isComment,\n isInteger as isIntegerNode,\n Integer as IntegerNode,\n isFloat,\n Float as FloatNode,\n hasItem,\n hasItems,\n InlineItem,\n InlineTable,\n InlineArray,\n CST,\n Table,\n TableArray,\n Value,\n isDateTime\n} from './cst';\nimport diff, { Change, ChangeType, Move, isAdd, isEdit, isRemove, isMove, isRename } from './diff';\nimport findByPath, { tryFindByPath, findParent, Path } from './find-by-path';\nimport { last, isInteger, arraysEqual, isTemporal, temporalToTomlString, hasTemporal, isObject, stableStringify, isDate, datesEqual } from './utils';\nimport { insert, replace, remove, applyWrites, applyBracketSpacing, hasInlineContainerNeedingTighten, deleteInlineContainerNeedingTighten, shiftNode, recalcContainerEnd, addExitOffset, markDirty, getPendingEnterOffsets, getExitOffsets, setRootIndentWidth, setInlineIndentColumn, perLine } from './writer';\nimport { removeMember, moveInlineElement, findHostContainer, resolveGroups } from './comment-ownership';\nimport { applyKeyOrderMoves } from './update-order';\nimport { generateInlineItem, generateTable, generateTableArray, generateString, generateKey, generateKeyValue, generateComment } from './generate';\nimport { IS_BARE_KEY, createNewlineScanState } from './tokenizer';\nimport { escapeStringContent } from './escape-preference';\nimport { resolveTomlFormat } from './toml-format';\nimport { arrayHadTrailingCommas, tableHadTrailingCommas, postInlineItemRemovalAdjustment, calculateTableDepth, normalizeGeneratedInlineContainerRows, normalizeInlineContainerRows } from './formatter';\nimport { DateFormatHelper, padFractionalSeconds } from './date-format';\nimport {\n getInlineInsertColumnDelta,\n normalizeInlineCommentAlignmentInString,\n preserveAlignedInlineCommentColumn,\n preserveAlignedInlineCommentForDelta,\n recordInlineTableCommentDelta\n} from './comment-alignment';\nimport { getSpan } from './location';\nimport { attachSources } from './cst-source';\nimport { stripLeadingBom, UTF8_BOM } from './decode-utf8';\nimport traverse from './traverse';\nimport { prepareInsertedNestedInlineContainer, positionGeneratedNestedInlineTables } from './inline-layout';\nimport {\n findInlineContainerDepth,\n findInlineContainerParent,\n hasStructuralMultilineRows,\n resolveInlineContainerLayout\n} from './inline-format';\n\n/**\n * Applies modifications to a TOML document by comparing an existing TOML string with updated JavaScript data.\n * \n * This function preserves formatting and comments from the existing TOML document while\n * applying changes from the updated data structure. It performs a diff between the existing\n * and updated data, then strategically applies only the necessary changes to maintain the\n * original document structure as much as possible.\n * \n * @param existing - The original TOML document as a string\n * @param updated - The updated JavaScript object with desired changes\n * @param format - Optional formatting options to apply to new or modified sections\n * @returns A new TOML string with the changes applied\n */\nexport default function patch(existing: string, updated: any, format?: Partial<TomlFormat> | TomlFormat): string {\n // The tokenizer flags mixed line endings as it scans, so this requires no\n // separate pass over the input.\n const newlineState = createNewlineScanState();\n const existingToml = stripLeadingBom(existing);\n const existing_cst = Array.from(parseTOML(existingToml, newlineState));\n attachSources(existing_cst, existingToml);\n\n // Auto-detect formatting preferences from the existing TOML string for fallback\n const autoDetectedFormat = TomlFormat.autoDetectFormatWithCst(existing, existing_cst);\n const fmt = resolveTomlFormat(format, autoDetectedFormat);\n\n if (newlineState.mixed) {\n const normalized = fmt.newLine === '\\r\\n' ? 'CRLF' : 'LF';\n console.warn(\n `toml-patch: Mixed line endings detected. ` +\n `Line endings in the output will be normalized to ${normalized}`\n );\n }\n\n const indentWidthExplicit = format instanceof TomlFormat ||\n (format != null && Object.prototype.hasOwnProperty.call(format, 'indentWidth'));\n const trailingCommaExplicit = format instanceof TomlFormat ||\n (format != null && Object.prototype.hasOwnProperty.call(format, 'trailingComma'));\n const inlineTableStartExplicit = format instanceof TomlFormat ||\n (format != null && Object.prototype.hasOwnProperty.call(format, 'inlineTableStart'));\n const patchedToml = patchCst(\n existing_cst, updated, fmt, indentWidthExplicit, trailingCommaExplicit, inlineTableStartExplicit\n ).tomlString;\n const withBom = (toml: string) => (fmt.leadingBom ? `${UTF8_BOM}${toml}` : toml);\n return withBom(patchedToml);\n}\n\n/**\n * Length of the existing dotted key's prefix that the edit path matches.\n * Only the path's RELATIVE tail (past the key's container) is eligible:\n * the absolute path carries the container's own key segments (e.g. the\n * [mbe.\"\"] header consumes ['mbe',''] before the row key), and matching\n * against those keeps extra key segments when the container's key echoes\n * the row's — editing `mbe[\"\"][\"\"]` once truncated the row\n * `\"\".\"\".\"mfn31vru\"` to `\"\".\"\"` instead of `\"\"` (fuzz seed 13057).\n */\nfunction truncationMatchLen(changePath: Path, existingKey: string[], containerAbsLen: number): number {\n const relPath = changePath.slice(containerAbsLen);\n let matchLen = 0;\n const max = Math.min(relPath.length, existingKey.length);\n for (let i = 1; i <= max; i++) {\n if (arraysEqual(relPath.slice(relPath.length - i), existingKey.slice(0, i))) {\n matchLen = i;\n }\n }\n return matchLen;\n}\n\nfunction inlineTableAddIndex(parent: InlineTable, child: KeyValue, beforeKey?: string): number | undefined {\n if (beforeKey === undefined) return undefined;\n\n const childKey = child.key.value;\n if (childKey.length < 2) return undefined;\n\n const prefix = childKey.slice(0, -1);\n for (let index = 0; index < parent.items.length; index++) {\n const item = parent.items[index];\n if (!isInlineItem(item) || !isKeyValue(item.item)) continue;\n const existingKey = item.item.key.value;\n if (existingKey.length === childKey.length &&\n arraysEqual(existingKey.slice(0, -1), prefix) &&\n existingKey[existingKey.length - 1] === beforeKey) {\n return index;\n }\n }\n\n return undefined;\n}\n\n/** Every node currently in `document`, seeding updateOrder's isEligibleForLeading guard. */\nfunction collectPrePatchNodes(document: Document): WeakSet<TreeNode> {\n const nodes = new WeakSet<TreeNode>();\n const visit = (node: TreeNode) => { nodes.add(node); };\n traverse(document, {\n Document: visit,\n Table: visit,\n TableKey: visit,\n TableArray: visit,\n TableArrayKey: visit,\n KeyValue: visit,\n Key: visit,\n String: visit,\n Integer: visit,\n Float: visit,\n Boolean: visit,\n DateTime: visit,\n InlineArray: visit,\n InlineItem: visit,\n InlineTable: visit,\n Comment: visit\n });\n return nodes;\n}\n\n/**\n * updateOrder needs `updated_js`'s TOP-level key order to reflect exactly what the caller\n * requested — but parseJS -> formatTopLevel unconditionally hoists any inline-table/AOT-shaped\n * root key into its own [section]/[[array]] block via remove-then-APPEND (src/formatter.ts).\n * That's a genuine TOML requirement (root scalars must precede section headers) when the\n * value becomes an actual section, but formatTopLevel applies it to ANY nested object at the\n * default inlineTableStart, even when the existing document represents it as a plain inline\n * value with no such constraint — silently reordering it after every scalar key, regardless\n * of the caller's request or updateOrder.\n *\n * Fixes this by re-deriving the root key order from a throwaway, un-hoisted parse\n * (inlineTableStart: 0 disables the section conversion entirely) and re-keying `updated_js`'s\n * top level to match. Only the top-level key ORDER is affected — values, nested levels, and\n * the actual output format of newly-added content (still driven by `format`/`diffing_fmt`,\n * unrelated to this) are untouched. Only called when `format.updateOrder` is set, so it costs\n * nothing when the option is off.\n */\nfunction applyRequestedRootKeyOrder(updated: any, updated_js: any, diffing_fmt: TomlFormat, useTemporal: boolean): any {\n if (!isObject(updated_js)) return updated_js;\n\n const unhoisted_fmt = resolveTomlFormat({ ...diffing_fmt, inlineTableStart: 0 }, diffing_fmt);\n const unhoisted_document = parseJS(updated, unhoisted_fmt);\n const unhoisted_js = toJS(unhoisted_document.items, '', { temporal: useTemporal });\n if (!isObject(unhoisted_js)) return updated_js;\n\n const reordered: any = {};\n for (const key of Object.keys(unhoisted_js)) {\n if (Object.prototype.hasOwnProperty.call(updated_js, key)) reordered[key] = updated_js[key];\n }\n // Defensive: any key present in updated_js but not in the un-hoisted probe (shouldn't\n // happen — both come from the same `updated`) is appended rather than silently dropped.\n for (const key of Object.keys(updated_js)) {\n if (!Object.prototype.hasOwnProperty.call(reordered, key)) reordered[key] = updated_js[key];\n }\n return reordered;\n}\n\n/**\n * The parser's table-body loop consumes comments between consecutive [[x]] entries\n * as trailing children of the first entry (it sees `# comment` before the next\n * `[[x]]` header). This function promotes those trailing comments to Document-level\n * siblings so that resolveGroups can assign them to the correct entry.\n */\nfunction normalizeAotEntryComments(doc: Document, ancestorBoundariesOnly = false): void {\n const items = doc.items as TreeNode[];\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n // Handle both Table and TableArray: comments between a section header\n // and its next sibling AOT entry, or between consecutive AOT entries,\n // are parsed as trailing children of the first section. Promote them.\n if (!((isTable(item) || isTableArray(item)) && hasItems(item))) continue;\n\n const containerItems = item.items as TreeNode[];\n // Find trailing comments at the end of this entry\n let commentStart = containerItems.length;\n while (commentStart > 0 && isComment(containerItems[commentStart - 1])) {\n commentStart--;\n }\n\n if (commentStart < containerItems.length) {\n // Check if the next Document item is another TableArray with a\n // matching key prefix (for Tables: child AOT; for TableArrays: sibling AOT)\n const nextItem = items[i + 1];\n if (nextItem && isTableArray(nextItem)) {\n const thisKey = (item as Table | TableArray).key.item.value;\n const nextKey = (nextItem as TableArray).key.item.value;\n const isDescendantBoundary = arraysEqual(thisKey, nextKey.slice(0, thisKey.length));\n const isAncestorBoundary = arraysEqual(nextKey, thisKey.slice(0, nextKey.length));\n if (ancestorBoundariesOnly ? isAncestorBoundary : isDescendantBoundary) {\n // Promote trailing comments to Document level\n const comments = containerItems.splice(commentStart);\n const nextIdx = items.indexOf(nextItem);\n for (const comment of [...comments].reverse()) {\n items.splice(nextIdx, 0, comment);\n }\n // Fix up loc.end\n recalcContainerEnd(item);\n }\n }\n }\n }\n}\n\nexport function patchCst(\n existing_cst: CST,\n updated: any,\n format: TomlFormat,\n indentWidthExplicit = false,\n trailingCommaExplicit = true,\n inlineTableStartExplicit = false\n): { tomlString: string; document: Document } {\n const items = [...existing_cst];\n updated = compactSparseArrays(updated);\n\n // Auto-detect Temporal in the updated JS object so that the internal\n // toJS() diff uses Temporal objects when the user provides them.\n const useTemporal = hasTemporal(updated);\n\n // Compute the Document's end position from its children so that\n // offset-based position updates in applyWrites start from the correct\n // baseline (instead of 0,0 which under-counts after expansion).\n let endLine = 1;\n let endColumn = 0;\n for (const item of items) {\n const e = item.loc.end;\n if (e.line > endLine || (e.line === endLine && e.column > endColumn)) {\n endLine = e.line;\n endColumn = e.column;\n }\n }\n\n const existing_js = toJS(items, '', { temporal: useTemporal });\n const existing_document: Document = {\n type: NodeType.Document,\n loc: { start: { line: 1, column: 0 }, end: { line: endLine, column: endColumn } },\n items\n };\n setRootIndentWidth(existing_document, format.indentWidth);\n\n // Certain formatting options should not be applied to the updated document during patching, because it would\n // override the existing formatting too aggressively. For example, preferNestedTablesMultiline would\n // convert all nested tables to multiline, which would not be desired during patching.\n // Therefore, we create a modified format for generating the updated document used for diffing.\n // When inlineTableStart > 1, formatNestedTablesMultiline would split nested inline tables in the\n // updated document into separate sections, causing the diff to see only the empty parent. Clamp to\n // 1 (the default) so only top-level tables are converted to sections — the same as when unset.\n // inlineTableStart of 0 or 1 (or undefined) already produce the correct AST shape for diffing.\n const diffing_inlineTableStart = (format.inlineTableStart != null && format.inlineTableStart > 1)\n ? 1\n : format.inlineTableStart;\n const diffing_fmt = resolveTomlFormat({...format, inlineTableStart: diffing_inlineTableStart}, format);\n const updated_document = parseJS(updated, diffing_fmt);\n\n // Diff against the JS representation rather than\n // the raw `updated` value, so that any undefined keys (which parseJS already\n // stripped) are consistently absent from both sides of the diff.\n const updated_js_raw = toJS(updated_document.items, '', { temporal: useTemporal });\n const updated_js = format.updateOrder\n ? applyRequestedRootKeyOrder(updated, updated_js_raw, diffing_fmt, useTemporal)\n : updated_js_raw;\n if (!format.updateOrder && valuesEqualIterative(existing_js, updated_js)) {\n return {\n tomlString: toTOML(items, format),\n document: existing_document\n };\n }\n const changes = reorder(coalesceStructuralReplacements(\n existing_document,\n updated_js,\n diff(existing_js, updated_js, [], { updateOrder: format.updateOrder, orderSource: updated })\n ));\n\n if (changes.length === 0) {\n return {\n tomlString: toTOML(items, format),\n document: existing_document\n };\n }\n\n // Snapshot every node that exists BEFORE any change is applied. Passed through to\n // applyKeyOrderMoves, which feeds it to resolveGroups' isEligibleForLeading predicate so a\n // key that was just Added by this same patch can't adopt a preceding comment block via R2 —\n // node identity is stable across remove()/insert() (they splice the same objects), so this\n // has to be captured now, before applyChanges runs. applyChanges also adds to this set as it\n // runs: a structural edit (e.g. table→scalar) regenerates a fresh node in place of an existing\n // one, and that replacement is conceptually the same entry, not a new one — so it needs to\n // stay eligible for R2 too, even though its object identity postdates the snapshot.\n const commentEligibleNodes = format.updateOrder\n ? collectPrePatchNodes(existing_document)\n : new WeakSet<TreeNode>();\n\n const patched_document = applyChanges(\n existing_document,\n updated_document,\n changes,\n format,\n useTemporal,\n commentEligibleNodes,\n updated,\n indentWidthExplicit,\n trailingCommaExplicit,\n inlineTableStartExplicit,\n updated_js_raw\n );\n const tomlString = normalizeInlineCommentAlignmentInString(\n patched_document,\n toTOMLCursor(patched_document.items, format),\n format\n );\n\n return {\n tomlString,\n document: patched_document\n };\n}\n\nfunction valuesEqualIterative(left: any, right: any): boolean {\n const pending: Array<[any, any]> = [[left, right]];\n while (pending.length > 0) {\n const [a, b] = pending.pop()!;\n if (typeof a === 'number' && typeof b === 'number' &&\n (!Number.isFinite(a) || !Number.isFinite(b))) {\n return false;\n }\n if (typeof a === 'number' && typeof b === 'number' &&\n Number.isNaN(a) && Number.isNaN(b)) {\n return false;\n }\n if (Object.is(a, b)) continue;\n if (isDate(a) && isDate(b)) {\n // Not a plain `getTime()` comparison: two sub-millisecond spellings of\n // the same millisecond are different instants, and skipping them here\n // would drop the edit before the diff ever sees it.\n if (!datesEqual(a, b)) return false;\n continue;\n }\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n if (!Array.isArray(a)) {\n const aPrototype = Object.getPrototypeOf(a);\n const bPrototype = Object.getPrototypeOf(b);\n if ((aPrototype !== Object.prototype && aPrototype !== null) ||\n (bPrototype !== Object.prototype && bPrototype !== null)) {\n return false;\n }\n }\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) return false;\n for (const key of aKeys) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n pending.push([a[key], b[key]]);\n }\n }\n return true;\n}\n\nfunction compactSparseArrays(value: any): any {\n if (Array.isArray(value)) {\n let changed = false;\n const compacted: any[] = [];\n for (let index = 0; index < value.length; index++) {\n if (!Object.prototype.hasOwnProperty.call(value, index)) {\n changed = true;\n continue;\n }\n const child = compactSparseArrays(value[index]);\n changed ||= child !== value[index];\n compacted.push(child);\n }\n return changed ? compacted : value;\n }\n if (!isObject(value)) return value;\n\n let normalized = value;\n for (const key of Object.keys(value)) {\n const child = compactSparseArrays(value[key]);\n if (child !== value[key]) {\n if (normalized === value) normalized = { ...value };\n normalized[key] = child;\n }\n }\n return normalized;\n}\n\nfunction reorder(changes: Change[]): Change[] {\n //Reorder deletions among themselves to avoid index issues when removing\n // multiple array elements. Remove higher indices first so earlier indices\n // remain valid after each removal. Compare the last path element (the index)\n // and the prefix (everything before it) to group related removes.\n\n for (let i = 0; i < changes.length; i++) {\n const change = changes[i];\n if (isRemove(change)) {\n // The array this Remove targets, and the Remove's own index within it.\n const aIdx = last(change.path);\n const aPrefix = change.path.slice(0, -1);\n let j = i + 1;\n while (j < changes.length) {\n const next_change = changes[j];\n\n // A Remove emitted AFTER a same-array Add or Move is in post-shift\n // (sequential) coordinates: the Add changed the array's length and the\n // Move changed the element order, so hoisting the Remove back across\n // that barrier would apply its index to the wrong element (fuzz seed\n // 1137525: `Remove[1], Add[2], Add[3], Remove[6]` must keep Remove[6]\n // after the Adds, where index 6 is the surplus duplicate, not the\n // source index 6). Same-array Edits are length-preserving, so they are\n // safe to cross (fuzz seed 50448), and Adds/Moves in a DIFFERENT array\n // context do not shift this one (fuzz seeds 84522/473477) — so only a\n // same-array Add or Move forms a barrier.\n if (isAdd(next_change)) {\n const bIdx = last(next_change.path);\n if (typeof bIdx === 'number' && arraysEqual(aPrefix, next_change.path.slice(0, -1))) {\n // A source-coordinate remove remains valid against the original array and\n // therefore has to run before a same-array Add, even when the diff emitted the\n // remove after that Add (seed 2591153). Post-shift removes deliberately stay on\n // the far side of the Add (seed 1137525).\n if (change.coordinate === 'source') {\n let sourceRemove = -1;\n for (let k = j + 1; k < changes.length; k++) {\n const candidate = changes[k];\n if (isRemove(candidate)\n && candidate.coordinate === 'source'\n && arraysEqual(aPrefix, candidate.path.slice(0, -1))) {\n sourceRemove = k;\n break;\n }\n }\n if (sourceRemove !== -1) {\n const sourceChange = changes.splice(sourceRemove, 1)[0];\n changes.splice(i, 0, sourceChange);\n i = -1;\n break;\n }\n }\n break;\n }\n j++;\n continue;\n }\n // Object-key Moves (`updateOrder`, key set) reorder object members, not\n // array elements, so they never shift this array's indices.\n if (isMove(next_change) && next_change.key === undefined) {\n if (arraysEqual(aPrefix, next_change.path)) {\n break;\n }\n j++;\n continue;\n }\n if (!isRemove(next_change)) { j++; continue; }\n\n const bIdx = last(next_change.path);\n const bPrefix = next_change.path.slice(0, -1);\n\n // Same array context AND higher index should come first.\n // Only reorder numeric array indices (skip string keys).\n if (typeof aIdx === 'number' && typeof bIdx === 'number' && arraysEqual(aPrefix, bPrefix) && bIdx > aIdx) {\n changes.splice(j, 1);\n changes.splice(i, 0, next_change);\n // We reset i to -1 so that after the for-loop's i++ the next iteration\n // starts at 0 and re-checks the newly promoted element.\n i = -1;\n break;\n }\n j++;\n }\n }\n }\n \n return changes;\n\n}\n\n/**\n * Merges sibling `Remove(prefix.oldKey)` + `Add(prefix.newKey)` changes that\n * share a common parent path into a single `Edit(prefix)` change.\n *\n * When a table/AOT is replaced by an incompatible type at a shallower path\n * (e.g. `[a.b]` → `a = { x = 1 }`), the object-diff sees the whole `a`\n * subtree disappear and a differently-shaped `a` appear, and reports it as\n * a `Remove` of the old child (`a.b`) plus one `Add` per key of the new\n * value (`a.x`) — never a single `Edit` on `a` itself, since `a` never\n * existed as its own JS-diff node (it was only implicit via the dotted\n * table key). Left alone, the generic Add handling resolves the missing\n * `a` container by walking up to the document root (`findParent`), silently\n * dropping the `a` nesting. Coalescing back into one `Edit(prefix)` routes\n * it through `handleStructuralEdit`, which already rebuilds the correct\n * nested structure from the full updated value at that path.\n *\n * Only applies when `prefix` has no literal node of its own in `original`\n * (it was purely implicit) — if `prefix` is an actual existing table, the\n * normal per-key Add/Remove handling already does the right thing.\n *\n * Also merges per-index Edit/Add/Remove changes under an existing\n * array-of-tables (AOT) whose updated value is still a JS array but no\n * longer made up entirely of plain objects (e.g. `[[i]]` → `i = [1, 2, 3]`\n * or `i = [9]`). An AOT entry is a Table living at the document level, not\n * an item inside an array node, so it can't be edited/appended/removed in\n * place the way the diff assumes — the whole array needs to be rebuilt via\n * `handleStructuralEdit`. When every element of the updated array is still\n * a plain object, the AOT stays an AOT and the normal per-entry handling is\n * left untouched.\n */\nfunction coalesceStructuralReplacements(original: Document, updated_js: any, changes: Change[]): Change[] {\n const consumed = new Set<Change>();\n const coalescedEdits: Change[] = [];\n\n // Strategy 1: Remove(prefix.oldKey) + Add(prefix.newKey) sharing an\n // implicit parent with no literal node of its own.\n const groups = new Map<string, { path: Change['path']; removes: Change[]; adds: Change[] }>();\n for (const change of changes) {\n if (!isRemove(change) && !isAdd(change)) continue;\n\n const parentPath = change.path.slice(0, -1);\n if (parentPath.length === 0) continue; // never coalesce at the document root itself\n\n const key = JSON.stringify(parentPath);\n let group = groups.get(key);\n if (!group) {\n group = { path: parentPath, removes: [], adds: [] };\n groups.set(key, group);\n }\n (isRemove(change) ? group.removes : group.adds).push(change);\n }\n for (const group of groups.values()) {\n if (group.removes.length === 0 || group.adds.length === 0) continue;\n if (tryFindByPath(original, group.path)) continue; // parent still exists literally\n\n group.removes.forEach(change => consumed.add(change));\n group.adds.forEach(change => consumed.add(change));\n coalescedEdits.push({ type: ChangeType.Edit, path: group.path });\n }\n\n // Replacing every member of an inline-table object inside an inline array is safer as one\n // element replacement. Applying the individual Remove/Add changes can leave the emptied\n // multiline inline table's offsets attached to its new rows and corrupt the enclosing array.\n for (const change of changes) {\n if (consumed.has(change) || (!isRemove(change) && !isAdd(change))) continue;\n\n const elementPath = change.path.slice(0, -1);\n if (elementPath.length === 0 || typeof last(elementPath) !== 'number') continue;\n const element = tryFindByPath(original, elementPath);\n if (!element || !isInlineItem(element) || !isInlineTable(element.item)) continue;\n\n const siblings = changes.filter(candidate =>\n !consumed.has(candidate) &&\n (isRemove(candidate) || isAdd(candidate)) &&\n arraysEqual(candidate.path.slice(0, -1), elementPath)\n );\n if (siblings.length === 0 || siblings.some(candidate => candidate.path.length !== elementPath.length + 1)) continue;\n\n const existingKeys = new Set(\n (element.item.items as TreeNode[])\n .filter(isInlineItem)\n .map(item => {\n const keyValue = isKeyValue(item.item) ? item.item : undefined;\n return keyValue?.key.value.length === 1 ? keyValue.key.value[0] : undefined;\n })\n .filter((key): key is string => key !== undefined)\n );\n const removedKeys = new Set(\n siblings.filter(isRemove).map(candidate => last(candidate.path))\n );\n if (!siblings.some(isRemove) || !siblings.some(isAdd) ||\n existingKeys.size !== removedKeys.size ||\n [...existingKeys].some(key => !removedKeys.has(key))) continue;\n\n for (const sibling of siblings) consumed.add(sibling);\n coalescedEdits.push({ type: ChangeType.Edit, path: elementPath });\n }\n\n // Strategy 2: AOT being replaced by an array that no longer holds only\n // plain objects.\n const arrayPrefixes = new Map<string, Change['path']>();\n for (const change of changes) {\n if (consumed.has(change)) continue;\n if (!isEdit(change) && !isAdd(change) && !isRemove(change)) continue;\n\n const index = last(change.path);\n if (typeof index !== 'number') continue;\n\n const prefix = change.path.slice(0, -1);\n if (prefix.length === 0) continue;\n\n const firstEntry = tryFindByPath(original, prefix.concat(0));\n if (!firstEntry || !isTableArray(firstEntry)) continue;\n\n arrayPrefixes.set(JSON.stringify(prefix), prefix);\n }\n for (const prefix of arrayPrefixes.values()) {\n let value: any = updated_js;\n for (const key of prefix) value = value?.[key];\n if (!Array.isArray(value)) continue;\n\n // The array no longer holds only AOT-shaped entries once ANY element is a\n // scalar / array / date / Temporal — `isObject` already excludes those.\n // (A bare `typeof el === 'object'` check wrongly kept Dates as \"objects\",\n // so `[[x]]` → `[date1, date2]` was missed and the redundant per-element\n // Add double-added the tail — fuzz seed 86724.)\n const staysAllObjects = value.every(el => isObject(el));\n if (staysAllObjects) continue;\n\n // Only coalesce when the diff actually split the replacement across\n // multiple element-level changes (e.g. Edit[0] + Add[1]). A single Edit\n // (e.g. `[[a.b.c]]` → `[date]`) is handled correctly by the\n // isTableArray(existing) branch, which re-renders the parent as a proper\n // `[section]` header — collapsing it here would instead route through\n // handleStructuralEdit and flatten it to an inline table (fuzz seed 3333).\n // Element-level changes include both entry adds/edits (path `prefix+[i]`)\n // and edits nested INSIDE an entry (path `prefix+[i, key]`): a mixed array\n // like `[{…}, -4619]` diffs as `Add[1]` plus per-key edits under entry 0,\n // and counting only the direct children (prefix.length + 1) missed the\n // nested edits, leaving the scalar entry to be re-materialised as an empty\n // AOT row (fuzz seed 136865).\n const elementChanges = changes.filter(c =>\n !consumed.has(c)\n && (isEdit(c) || isAdd(c) || isRemove(c))\n && c.path.length > prefix.length\n && arraysEqual(c.path.slice(0, prefix.length), prefix)\n );\n if (elementChanges.length < 2) continue;\n\n for (const change of elementChanges) {\n consumed.add(change);\n }\n coalescedEdits.push({ type: ChangeType.Edit, path: prefix });\n }\n\n if (consumed.size === 0) return changes;\n\n const result = changes.filter(change => !consumed.has(change));\n result.push(...coalescedEdits);\n return result;\n}\n\nfunction preserveEscapedKeyRaw(existingRaw: string, keyParts: string[], escapeSequenceUpperCase = true): string {\n return keyParts\n .map(part => (IS_BARE_KEY.test(part) ? part : `\"${escapeStringContent(part, existingRaw, 'singleline-basic', escapeSequenceUpperCase)}\"`))\n .join('.');\n}\n\nfunction dottedKeySeparators(raw: string): string[] {\n const separators: string[] = [];\n let quote: '\"' | \"'\" | undefined;\n let escaped = false;\n\n for (let index = 0; index < raw.length; index++) {\n const character = raw[index];\n if (quote) {\n if (quote === '\"' && escaped) {\n escaped = false;\n } else if (quote === '\"' && character === '\\\\') {\n escaped = true;\n } else if (character === quote) {\n quote = undefined;\n }\n continue;\n }\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n if (character !== '.') continue;\n\n let start = index;\n while (start > 0 && (raw[start - 1] === ' ' || raw[start - 1] === '\\t')) start--;\n let end = index + 1;\n while (end < raw.length && (raw[end] === ' ' || raw[end] === '\\t')) end++;\n separators.push(raw.slice(start, end));\n }\n\n return separators;\n}\n\nfunction dottedKeyParts(raw: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quote: '\"' | \"'\" | undefined;\n let escaped = false;\n\n for (let index = 0; index < raw.length; index++) {\n const character = raw[index];\n if (quote) {\n if (quote === '\"' && escaped) {\n escaped = false;\n } else if (quote === '\"' && character === '\\\\') {\n escaped = true;\n } else if (character === quote) {\n quote = undefined;\n }\n continue;\n }\n if (character === '\"' || character === \"'\") {\n quote = character;\n } else if (character === '.') {\n parts.push(raw.slice(start, index));\n start = index + 1;\n }\n }\n parts.push(raw.slice(start));\n return parts;\n}\n\nfunction preserveDottedKeySpacing(key: Key, styleRaw: string): void {\n const separators = dottedKeySeparators(styleRaw);\n if (separators.length === 0) return;\n\n const parts = dottedKeyParts(key.raw);\n key.raw = parts.reduce((raw, part, index) => {\n if (index === 0) return part;\n const separator = separators[Math.min(index - 1, separators.length - 1)];\n return `${raw}${separator}${part}`;\n }, '');\n key.loc.end.column = key.loc.start.column + key.raw.length;\n}\n\nfunction findDottedKeyStyle(root: Document, prefix: string[]): KeyValue | undefined {\n let style: KeyValue | undefined;\n traverse(root, {\n KeyValue: (node) => {\n if (!style && node.key.value.length > prefix.length\n && arraysEqual(node.key.value.slice(0, prefix.length), prefix)\n && dottedKeySeparators(node.key.raw).length > 0) {\n style = node;\n }\n }\n });\n return style;\n}\n\n/**\n * Analyzes an existing float's raw text: whether it uses exponent notation and\n * whether its fractional part is all zeros (a \"round\" float such as `1.0`).\n */\nfunction analyzeFloatStyle(raw: string): { hasExponent: boolean; fractionLength: number; isRound: boolean } {\n const expIndex = raw.search(/[eE]/);\n const mantissa = expIndex === -1 ? raw : raw.slice(0, expIndex);\n const dotIndex = mantissa.indexOf('.');\n const fraction = dotIndex === -1 ? '' : mantissa.slice(dotIndex + 1);\n return {\n hasExponent: expIndex !== -1,\n fractionLength: fraction.length,\n isRound: !/[1-9]/.test(fraction),\n };\n}\n\n/** Counts the decimal places written in a float's raw text (before any exponent). */\nfunction decimalPlacesOfRaw(raw: string): number {\n const expIndex = raw.search(/[eE]/);\n const mantissa = expIndex === -1 ? raw : raw.slice(0, expIndex);\n const dotIndex = mantissa.indexOf('.');\n return dotIndex === -1 ? 0 : mantissa.length - dotIndex - 1;\n}\n\n/** Renders a value in TOML exponent notation (e.g. `1.0e11`) with at least `minimumDecimals` decimals. */\nfunction renderExponentNotation(value: number, minimumDecimals: number, uppercaseExponent = false): string {\n const [mantissa, exponent] = value.toExponential().split(/[eE]/);\n const decimals = Math.max(minimumDecimals, decimalPlacesOfRaw(mantissa));\n const renderedMantissa = decimals > 0\n ? Number(mantissa).toFixed(decimals)\n : String(Number(mantissa));\n return `${renderedMantissa}${uppercaseExponent ? 'E' : 'e'}${exponent.replace(/^\\+/, '')}`;\n}\n\n/** Detects the radix and prefix of a prefixed integer literal (`0x`/`0o`/`0b`). */\nfunction integerRadixOf(raw: string): { radix: number; prefix: string } | undefined {\n if (raw.startsWith('0x')) return { radix: 16, prefix: '0x' };\n if (raw.startsWith('0o')) return { radix: 8, prefix: '0o' };\n if (raw.startsWith('0b')) return { radix: 2, prefix: '0b' };\n return undefined;\n}\n\n/** Extracts the underscore grouping period: the digit count of the rightmost group. */\nfunction underscorePeriodOf(raw: string): number | undefined {\n let body = raw;\n if (body.startsWith('+') || body.startsWith('-')) body = body.slice(1);\n if (body.startsWith('0x') || body.startsWith('0o') || body.startsWith('0b')) body = body.slice(2);\n const lastUnderscore = body.lastIndexOf('_');\n return lastUnderscore === -1 ? undefined : body.length - lastUnderscore - 1;\n}\n\n/** Inserts an underscore every `period` digits, counted from the right. */\nfunction groupDigits(digits: string, period: number): string {\n if (digits.length <= period) return digits;\n let result = '';\n let count = 0;\n for (let i = digits.length - 1; i >= 0; i--) {\n result = digits[i] + result;\n count++;\n if (count === period && i > 0) {\n result = '_' + result;\n count = 0;\n }\n }\n return result;\n}\n\n/** Renders an integer in the style of an existing integer literal (radix, digit case, grouping). */\nfunction renderIntegerLike(value: number | bigint, existingRaw: string): string | undefined {\n const radixInfo = integerRadixOf(existingRaw);\n const period = underscorePeriodOf(existingRaw);\n\n if (radixInfo) {\n // TOML prefixed integers (hex/octal/binary) cannot carry a sign, so a\n // negative value cannot keep the original radix. Fall back to the default\n // decimal rendering by returning undefined.\n const negative = typeof value === 'bigint' ? value < 0n : value < 0;\n if (negative) return undefined;\n\n const uppercaseHex = radixInfo.radix === 16 && /[A-F]/.test(existingRaw);\n let digits = value.toString(radixInfo.radix);\n if (uppercaseHex) digits = digits.toUpperCase();\n return radixInfo.prefix + (period ? groupDigits(digits, period) : digits);\n }\n\n if (period) {\n const negative = typeof value === 'bigint' ? value < 0n : value < 0;\n const abs = negative ? value.toString().slice(1) : value.toString();\n return (negative ? '-' : '') + groupDigits(abs, period);\n }\n\n return undefined;\n}\n\n/**\n * Preserves formatting from the existing node when applying it to the replacement node.\n * This includes multiline string formats, trailing commas, DateTime formats, etc.\n * \n * @param existing - The existing node with formatting to preserve\n * @param replacement - The replacement node to apply formatting to\n */\nfunction preserveFormatting(\n existing: Value,\n replacement: Value,\n escapeSequenceUpperCase = true,\n minimumTimeDecimals = 0\n): void {\n \n // Preserve string format (handles basic, literal, multiline in all variants)\n if (isString(existing) && isString(replacement)) {\n const newString = generateString(replacement.value, existing.raw, escapeSequenceUpperCase);\n replacement.raw = newString.raw;\n replacement.loc = newString.loc;\n }\n \n // Preserve DateTime format\n if (isDateTime(existing) && isDateTime(replacement)) {\n // Analyze the original raw format and create a properly formatted replacement\n const originalRaw = existing.raw;\n const newValue = replacement.value;\n\n if (isTemporal(newValue)) {\n // Temporal objects preserve their own type — no format conversion needed.\n let raw = temporalToTomlString(newValue);\n // Preserve the original separator style (T vs space) from the existing TOML.\n if (originalRaw.includes(' ') && raw.includes('T')) {\n raw = raw.replace('T', ' ');\n }\n // Preserve +00:00 / -00:00 vs Z offset format\n if (/(?:\\+00:00|-00:00)/.test(originalRaw) && raw.endsWith('Z')) {\n const offset = originalRaw.match(/([+-]00:00)/)![1];\n raw = raw.replace(/Z$/, offset);\n }\n // minimumTimeDecimals is a floor on the written digits, and a Temporal\n // value carries its own precision, so this only ever pads.\n raw = padFractionalSeconds(raw, minimumTimeDecimals);\n replacement.raw = raw;\n replacement.loc.end.column = replacement.loc.start.column + replacement.raw.length;\n // Keep the Temporal object as the value — it will serialize correctly.\n } else if (DateFormatHelper.IS_TIME_ONLY.test(originalRaw)\n && newValue instanceof Date && newValue.getUTCFullYear() > 1) {\n // The existing value is a bare local time, but the replacement carries\n // a real date component that a time-only format cannot represent.\n // Converting would silently drop the date (fuzz seed 2583: an implicit\n // table `dp6t.uhds = 18:06:01` truncated to `dp6t = 2036-10-16` came\n // back as `00:00:00`). Keep the replacement's own formatting instead.\n // Time-only values are represented internally as Date objects with\n // year 0000, so year > 1 reliably separates real dates from bare times.\n } else {\n // Create a new date with the original format preserved\n const formattedDate = DateFormatHelper.createDateWithOriginalFormat(newValue, originalRaw);\n\n // Update the replacement with the properly formatted date. The\n // minimumTimeDecimals floor pads the fraction, never removes source digits.\n replacement.value = formattedDate;\n replacement.raw = padFractionalSeconds(formattedDate.toISOString(), minimumTimeDecimals);\n replacement.loc.end.column = replacement.loc.start.column + replacement.raw.length;\n }\n }\n \n // Preserve float NaN sign format\n if (isFloat(existing) && isFloat(replacement)\n && Number.isNaN(existing.value) && Number.isNaN(replacement.value)) {\n const existingFloat = existing as FloatNode;\n const replacementFloat = replacement as FloatNode;\n if (existingFloat.nanSign) {\n // Existing had a sign (+ or -), replacement has none (canonical NaN).\n // Preserve the signed style: always use '+' for positive/unsigned.\n replacementFloat.nanSign = '+';\n replacementFloat.raw = '+nan';\n }\n // If existing had no sign and replacement has no sign, leave as-is (nan)\n }\n\n // Preserve integer literal formatting (underscore grouping and radix prefix)\n // when an integer is replaced by another integer. `1_000_000 -> 10000` keeps\n // the grouping and becomes `10_000`; `0xFF -> 256` stays hexadecimal `0x100`.\n if (isIntegerNode(existing) && replacement.type === NodeType.Integer) {\n const existingInt = existing as IntegerNode;\n const newRaw = renderIntegerLike(replacement.value, existingInt.raw);\n if (newRaw !== undefined) {\n const replacementInt = replacement as IntegerNode;\n replacementInt.raw = newRaw;\n replacementInt.loc.end.column = replacementInt.loc.start.column + newRaw.length;\n }\n }\n\n // Preserve number formatting when replacing an existing float:\n // - a \"round\" float (zero fraction, e.g. `1.0`, `1.00`, `1.0e10`) keeps its\n // decimal-place count when the new value is a whole number;\n // - exponent notation is kept when the source used it, dropping a non-zero\n // fraction once the new value becomes a whole number (e.g. `1.25e10 -> 1e11`);\n // - a fractional float without an exponent still collapses to an integer.\n if (isFloat(existing) && (replacement.type === NodeType.Integer || replacement.type === NodeType.Float)) {\n const existingFloat = existing as FloatNode;\n const value = replacement.value;\n\n if (typeof value === 'number') {\n const { hasExponent, fractionLength, isRound } = analyzeFloatStyle(existingFloat.raw);\n const valueIsIntegral = Number.isInteger(value) && !Object.is(value, -0);\n const replacementDecimals = decimalPlacesOfRaw(replacement.raw);\n\n let newRaw: string | undefined;\n // `inf`, `nan` and `-0` carry no exponent component: their generated raw\n // form already expresses the value, and rendering them as mantissa and\n // exponent either throws (there is no exponent part to read) or drops the\n // sign of the zero.\n if (hasExponent && Number.isFinite(value) && !Object.is(value, -0)) {\n const uppercaseExponent = existingFloat.raw.includes('E');\n const minDecimals = valueIsIntegral\n ? Math.max(isRound ? fractionLength : 0, replacementDecimals)\n : replacementDecimals;\n newRaw = renderExponentNotation(value, minDecimals, uppercaseExponent);\n } else if (valueIsIntegral && isRound) {\n newRaw = value.toFixed(Math.max(fractionLength, replacementDecimals));\n }\n\n if (newRaw !== undefined) {\n const replacementFloat = replacement as unknown as FloatNode;\n replacementFloat.type = NodeType.Float;\n replacementFloat.raw = newRaw;\n replacementFloat.loc.end.column = replacementFloat.loc.start.column + newRaw.length;\n }\n }\n }\n\n // Preserve array trailing comma format\n if (isInlineArray(existing) && isInlineArray(replacement)) {\n const originalHadTrailingCommas = arrayHadTrailingCommas(existing);\n if (replacement.items.length > 0) {\n const lastItem = replacement.items[replacement.items.length - 1];\n if (lastItem.comma !== originalHadTrailingCommas) {\n lastItem.comma = originalHadTrailingCommas;\n // Adding a trailing comma widens the array by one column, but the\n // regenerated/replacement value's `loc.end` was laid out for the\n // comma-less form. Without extending it, the closing `]` (written at\n // `end.column - 1`) lands on the same column as the comma, colliding\n // into `...,,` (fuzz seed 30330).\n if (originalHadTrailingCommas) {\n replacement.loc.end.column += 1;\n }\n }\n }\n }\n \n // Preserve inline table trailing comma format\n if (isInlineTable(existing) && isInlineTable(replacement)) {\n const originalHadTrailingCommas = tableHadTrailingCommas(existing);\n if (replacement.items.length > 0) {\n const lastItem = replacement.items[replacement.items.length - 1];\n if (lastItem.comma !== originalHadTrailingCommas) {\n lastItem.comma = originalHadTrailingCommas;\n // Same as the array case above: make room for the added comma before\n // the closing `}`.\n if (originalHadTrailingCommas) {\n replacement.loc.end.column += 1;\n }\n }\n }\n }\n}\n\n/**\n * Applies a list of changes to the original TOML document CST while preserving formatting and structure.\n * \n * This function processes different types of changes (Add, Edit, Remove, Move, Rename) and applies them\n * to the original document in a way that maintains the existing formatting preferences, comments, and\n * structural elements as much as possible. Special handling is provided for different node types like\n * inline tables, arrays, and table arrays to ensure proper formatting consistency.\n * \n * @param original - The original TOML document CST to be modified\n * @param updated - The updated document CST containing new values for changes\n * @param changes - Array of change objects describing what modifications to apply\n * @param format - Formatting preferences to use for newly added elements\n * @returns The modified original document with all changes applied\n * \n * @example\n * ```typescript\n * const changes = [\n * { type: 'add', path: ['newKey'], value: 'newValue' },\n * { type: 'edit', path: ['existingKey'], value: 'updatedValue' }\n * ];\n * const result = applyChanges(originalDoc, updatedDoc, changes, format);\n * ```\n */\nfunction applyChanges(\n original: Document,\n updated: Document,\n changes: Change[],\n format: TomlFormat,\n temporal: boolean = false,\n commentEligibleNodes: WeakSet<TreeNode> = new WeakSet(),\n rawUpdated: any = undefined,\n indentWidthExplicit = false,\n trailingCommaExplicit = true,\n inlineTableStartExplicit = false,\n updatedJs: any = undefined\n): Document {\n const convertedUpdated = updatedJs ?? toJS(updated.items, '', { temporal });\n // Track AOT paths whose entries were all removed so we can insert empty arrays. The full\n // path keeps separate parent AOT entries distinct, while a nested key like [[a.b]] still\n // carries enough information to be re-materialised as `a.b = []`.\n const emptiedAotKeys = new Map<string, Path>();\n\n // Tables materialised in-place during this patch (R2 extension). After\n // applyWrites, fix up their line position to remove spurious blank lines\n // between preceding comments and the materialised header. Only tracked\n // when the preceding item in Document.items is an R2-adjacent Comment\n // (R3 gaps are intentional and left alone).\n const materialisedTables = new Set<Table>();\n\n function trackAdjacentComment(table: Table) {\n const items = original.items as TreeNode[];\n const idx = items.indexOf(table as TreeNode);\n if (idx > 0) {\n const prev = items[idx - 1];\n if (isComment(prev) && prev.loc.end.line + 1 === table.loc.start.line) {\n materialisedTables.add(table);\n }\n }\n }\n\n // Compute the absolute lookup path of a node by walking the document tree.\n // Used to tell whether findByPath matched a dotted KeyValue exactly or by\n // key-prefix (the key is longer than the consumed path segments).\n const absolutePathCache = new WeakMap<TreeNode, Path>();\n function absolutePathOf(target: TreeNode): Path | undefined {\n const cached = absolutePathCache.get(target);\n if (cached !== undefined) return cached;\n const indexes: Record<string, number> = {};\n function walk(node: TreeNode, path: Path): Path | undefined {\n if (node === target) return path;\n if (isKeyValue(node)) return walk(node.value, path);\n if (isInlineItem(node)) return walk(node.item, path);\n if (!hasItems(node)) return undefined;\n for (let i = 0; i < node.items.length; i++) {\n const item = node.items[i];\n let key: Path = [];\n if (isKeyValue(item)) {\n key = item.key.value;\n } else if (isTable(item) || isTableArray(item)) {\n key = item.key.item.value;\n if (isTableArray(item)) {\n const ks = stableStringify(key);\n indexes[ks] = (indexes[ks] ?? -1) + 1;\n key = key.concat(indexes[ks]);\n }\n } else if (isInlineItem(item)) {\n if (isKeyValue(item.item)) {\n key = item.item.key.value;\n } else {\n key = [i];\n }\n }\n const full = key.length ? path.concat(key) : path;\n const found = walk(item, full);\n if (found) return found;\n }\n return undefined;\n }\n const result = walk(original, []);\n if (result !== undefined) absolutePathCache.set(target, result);\n return result;\n }\n\n // findByPath returns a dotted KeyValue (or its InlineItem wrapper) when the\n // probe path is a PREFIX of the key (the key is longer than the path). Such\n // a match is not a real location: the node's value belongs to a different\n // subtree, so Adds must resolve past it to the shared ancestor container.\n function isPrefixMatchedNode(candidate: TreeNode, probe: Path): boolean {\n const kv = isKeyValue(candidate)\n ? candidate\n : isInlineItem(candidate) && isKeyValue(candidate.item)\n ? candidate.item\n : undefined;\n if (!kv) return false;\n const keyLen = kv.key.value.length;\n // The probe fully consumed the key's prefix and the key continues past\n // it (e.g. ['ak'] matching key ['ak','k99']).\n if (keyLen > probe.length) return true;\n // An exact match consumes the key's own segments as the probe's tail —\n // for nodes under an array-of-tables the absolute path carries the\n // entry's numeric index, which the probe doesn't, so comparing absolute\n // lengths misflags exact matches as prefix matches (fuzz seed 3632:\n // adding under `js-uda0fp0` skipped the KV and inserted at the entry\n // level, right after the closing `}` of the multiline inline table).\n return !arraysEqual(kv.key.value, probe.slice(probe.length - keyLen));\n }\n\n function aotEntryUsesDottedKey(styleEntry: TableArray, relativeKey: string[]): boolean {\n const entryKey = styleEntry.key.item.value;\n const fullKey = entryKey.concat(relativeKey);\n\n if ((styleEntry.items as TreeNode[]).some(item =>\n isKeyValue(item)\n && item.key.value.length > relativeKey.length\n && arraysEqual(item.key.value.slice(0, relativeKey.length), relativeKey)\n )) {\n return true;\n }\n\n return (original.items as TreeNode[]).some(item => {\n if (!isTable(item) && !isTableArray(item)) return false;\n const key = item.key.item.value;\n return key.length > fullKey.length\n && arraysEqual(key.slice(0, fullKey.length), fullKey);\n });\n }\n\n function preserveAotEntryDottedKeys(entry: TableArray, styleEntry: TableArray): TableArray {\n const rows: TreeNode[] = [];\n let changed = false;\n\n for (const item of entry.items as TreeNode[]) {\n if (!isKeyValue(item) || !isInlineTable(item.value)\n || !aotEntryUsesDottedKey(styleEntry, item.key.value)) {\n rows.push(item);\n continue;\n }\n\n const replacementRows: KeyValue[] = [];\n for (const nestedItem of item.value.items as TreeNode[]) {\n if (!isInlineItem(nestedItem) || !isKeyValue(nestedItem.item)) continue;\n const nestedObject = toJS([nestedItem.item], '', { temporal });\n let nestedValue: any = nestedObject;\n for (const key of nestedItem.item.key.value) nestedValue = nestedValue?.[key];\n const freshValue = regenerateValue(nestedValue, format);\n if (freshValue !== undefined) {\n replacementRows.push(generateKeyValue(\n item.key.value.concat(nestedItem.item.key.value),\n freshValue\n ));\n }\n }\n\n if (replacementRows.length > 0) {\n rows.push(...replacementRows);\n changed = true;\n } else {\n rows.push(item);\n }\n }\n\n if (!changed) return entry;\n\n const rebuilt = generateTableArray(entry.key.item.value, format.escapeSequenceUpperCase);\n for (const row of rows) insert(rebuilt, rebuilt, row);\n applyWrites(rebuilt);\n return rebuilt;\n }\n\n // The immediate structural container holding `target` in its `.items`\n // array — any container type (Document/Table/TableArray/InlineTable/\n // InlineArray), descending through KeyValue values and InlineItem\n // wrappers. Used when path-based parent resolution lands on a container\n // that doesn't physically contain the node (fuzz seed 50: a dotted KV\n // inside an inline table that is itself an inline-array element).\n function findStructuralParent(root: TreeNode, target: TreeNode): TreeNode | undefined {\n function walk(node: TreeNode): TreeNode | undefined {\n if (isKeyValue(node)) return walk(node.value);\n if (isInlineItem(node)) return walk(node.item);\n if (!hasItems(node)) return undefined;\n const items = node.items as TreeNode[];\n for (const item of items) {\n if (item === target) return node;\n if (isInlineItem(item) && item.item === target) return node;\n }\n for (const item of items) {\n const found = walk(isInlineItem(item) ? item.item : item);\n if (found) return found;\n }\n return undefined;\n }\n return walk(root);\n }\n\n // A table/AOT replaced by a scalar whose PARENT key is expressed implicitly\n // through dotted key-values (`\"\".nfh = …` defines the \"\" table without a\n // header). Re-emitting a `[\"\"]` header would conflict with the implicit\n // definition and fail the re-parse with \"Implicit table already defined\"\n // (fuzz seed 6803). Extend the fresh KV's key with the parent prefix and\n // swap it in for the old section directly.\n function extendKeyWithParentAndReplace(\n freshKV: KeyValue,\n parentKey: string[],\n existing: TreeNode,\n tableParent: TreeNode\n ): void {\n const dottedKey = parentKey.concat(freshKV.key.value);\n const oldRaw = freshKV.key.raw;\n freshKV.key.value = dottedKey;\n freshKV.key.raw = dottedKey\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const delta = freshKV.key.raw.length - oldRaw.length;\n freshKV.key.loc.end.column = freshKV.key.loc.start.column + freshKV.key.raw.length;\n freshKV.equals += delta;\n shiftNode(freshKV.value, { lines: 0, columns: delta }, { first_line_only: true });\n if (freshKV.loc.end.line === freshKV.loc.start.line) {\n freshKV.loc.end.column += delta;\n }\n replace(original, tableParent, existing, freshKV);\n // The extended dotted KV belongs to the root table — once the old\n // section header is gone, leaving it in place would bind it to the\n // nearest surviving section above (fuzz seed 6803: it landed inside\n // `[l6n1z.f]`). Hoist it above the first section header.\n hoistRootKeyValueAboveTables(original, freshKV);\n }\n\n // Extend a regenerated Table/TableArray section's key with a parent prefix\n // IN PLACE: a `[[c]]` whose key carries only the last segment becomes\n // `[[a.b.c]]` when `parentKey` is `['a','b']`. A `[[c]]` child of a\n // generated `[a.b]` header would otherwise fragment into a stray top-level\n // section. The section's items live on their own lines, so only the header\n // key (not the item columns) needs shifting.\n function extendSectionKeyInPlace(section: Table | TableArray, parentKey: string[]): void {\n const keyNode = section.key.item;\n const oldRaw = keyNode.raw;\n const dottedKey = parentKey.concat(keyNode.value);\n const newRaw = dottedKey\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const delta = newRaw.length - oldRaw.length;\n keyNode.value = dottedKey;\n keyNode.raw = newRaw;\n keyNode.loc.end.column = keyNode.loc.start.column + newRaw.length;\n if (section.key.loc.end.line === section.key.loc.start.line) {\n section.key.loc.end.column += delta;\n }\n }\n\n // Same as extendKeyWithParentAndReplace, but for a regenerated Table/TableArray\n // section: when a `[a.b.c]` section (or `[[a.b.c]]`) is replaced by a fresh\n // section whose key carries only the last segment (`[[c]]`), extend its key\n // with the parent prefix IN PLACE so it re-renders as `[[a.b.c]]` (fuzz seed\n // 41613).\n function extendSectionKeyWithParentAndReplace(\n section: Table | TableArray,\n parentKey: string[],\n existing: TreeNode,\n tableParent: TreeNode\n ): void {\n extendSectionKeyInPlace(section, parentKey);\n replace(original, tableParent, existing, section);\n }\n\n // When an Add's path traverses intermediate key segments that do not exist in the\n // original document (their KV was removed by an earlier change in this same patch),\n // findParent resolves to the nearest existing ancestor and the inserted child would\n // keep only its own key — silently dropping the missing prefix. Replacing\n // `ak.b.c = 1` with `ak = { k99 = 1 }` would emit `k99 = 1` at the parent level\n // (fuzz seed 4). Extend the child's key with the missing segments instead.\n // Returns a fresh KV to insert, or null when no extension is needed.\n function restoreMissingKeySegments(parent_path: Path, child: KeyValue, change_path: Path): KeyValue | null {\n const direct = tryFindByPath(original, parent_path);\n if (direct && !isPrefixMatchedNode(direct, parent_path)) return null;\n\n // Longest prefix of parent_path that resolves to a real location in the\n // original document. Prefix-matched dotted KVs don't count — they are the\n // very situation we are restoring around.\n let prefixLen = parent_path.length;\n while (prefixLen > 0) {\n const node = tryFindByPath(original, parent_path.slice(0, prefixLen));\n if (node && !isPrefixMatchedNode(node, parent_path.slice(0, prefixLen))) break;\n prefixLen--;\n }\n const missing = parent_path.slice(prefixLen) as string[];\n if (missing.length === 0 || !missing.every(seg => typeof seg === 'string')) return null;\n\n // The child's value comes from the updated document, whose coordinates are\n // unrelated to the insertion target. Regenerate it from the JS value with\n // clean locs first (same discipline as the key-truncation branch in the Edit\n // handler), then build a fresh KV with the extended dotted key.\n if (rawUpdated !== undefined) {\n let jsValue: any = rawUpdated;\n for (const k of change_path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const freshValue = regenerateValue(jsValue, format);\n if (freshValue !== undefined) {\n return generateKeyValue([...missing, ...child.key.value], freshValue, false, format.escapeSequenceUpperCase);\n }\n }\n }\n\n // Fallback: extend the key in place and shift the value's first line right by\n // the added width. Later lines of a multiline value keep their absolute\n // columns — insert() translates the whole subtree rigidly afterwards.\n const oldKey = child.key;\n const newRaw = [...missing, ...oldKey.value]\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const colDelta = newRaw.length - oldKey.raw.length;\n oldKey.raw = newRaw;\n oldKey.value = [...missing, ...oldKey.value];\n oldKey.loc.end.column = oldKey.loc.start.column + newRaw.length;\n child.equals += colDelta;\n shiftNode(child.value, { lines: 0, columns: colDelta }, { first_line_only: true });\n if (child.loc.end.line === child.loc.start.line) {\n child.loc.end.column += colDelta;\n }\n return child;\n }\n\n // Containers that already received a KV whose key was extended by\n // restoreMissingKeySegments. A second such insert into the same container\n // must resolve the first insert's pending offsets before measuring its target\n // position, or the two rows overlap (fuzz seed 4).\n const restoredInsertContainers = new Set<TreeNode>();\n\n // Multi-line inline containers already inserted into during this patch. The stale-position\n // problem only arises on the SECOND insertion into the same container, so this lets the\n // flush be paid just-in-time there rather than after every insertion — a patch touching\n // many containers once each (the common shape) then pays nothing.\n const insertedInlineContainers = new Set<TreeNode>();\n const removedInlineTrailingCommas = new WeakMap<InlineArray | InlineTable, boolean>();\n\n function trailingCommaForAddedItem(\n container: InlineArray | InlineTable,\n detected: boolean\n ): boolean {\n const carried = removedInlineTrailingCommas.get(container);\n return carried ?? detected;\n }\n\n // Object-key Moves (updateOrder) are only collected here, not applied — they're relayed\n // out in one batch at the very end, after every other structural change in this patch has\n // already been applied (see docs/PLAN-Update-Order.md §3.1 on why: the reorder phase must\n // never call insert()/remove(), which would re-dirty offsets nothing downstream flushes).\n const objectMoves: Move[] = [];\n const replacedInlineArrays = new Set<InlineArray>();\n // Inline containers spliced in as a replacement, together with the node that\n // owns them (the key-value or inline item whose row they sit on). Their\n // nested multiline rows are realigned in final coordinates once every other\n // pass has moved them (fuzz3 seed 18515).\n const replacedInlineContainers: { owner: TreeNode; container: InlineArray | InlineTable }[] = [];\n\n function regenerateInlineChildForParent(parent: TreeNode, changePath: Path, child: TreeNode): TreeNode {\n if ((!isInlineArray(parent) && !isInlineTable(parent)) || !isInlineItem(child)) return child;\n if (isInlineTable(parent) && !isKeyValue(child.item)) return child;\n\n let jsValue: any = rawUpdated;\n for (const key of changePath) jsValue = jsValue?.[key];\n if (!Array.isArray(jsValue) && !isObject(jsValue)) return child;\n\n const parentDepth = findInlineContainerDepth(original, parent) ?? 0;\n const parentIsMultiline = perLine(parent) ||\n (parent.items.length === 0 && parent.loc.end.line > parent.loc.start.line);\n const generatedIndentWidth = indentWidthExplicit\n ? format.indentWidth\n : isInlineArray(parent) && parent.items.length === 0\n ? Math.max(format.indentWidth, 4)\n : format.indentWidth;\n if (isInlineArray(parent) && parent.items.length === 0 && !format.useTabsForIndentation) {\n setInlineIndentColumn(parent, Math.max(generatedIndentWidth, 4));\n }\n const kind = Array.isArray(jsValue) ? 'array' : 'table';\n const sibling = (parent.items as InlineItem[])\n .map(item => isInlineTable(parent) && isKeyValue(item.item) ? item.item.value : item.item)\n .find(item => kind === 'array' ? isInlineArray(item) : isInlineTable(item));\n const siblingTrailingComma = sibling && kind === 'array'\n ? arrayHadTrailingCommas(sibling)\n : sibling && kind === 'table'\n ? tableHadTrailingCommas(sibling)\n : false;\n const siblingContainer = sibling as InlineArray | InlineTable | undefined;\n const siblingBracketSpacing = siblingContainer && (siblingContainer.items.length > 0)\n ? siblingContainer.items[0].loc.start.column - siblingContainer.loc.start.column > 1\n : undefined;\n const multiline = resolveInlineContainerLayout(\n kind,\n parentDepth + 1,\n parentIsMultiline,\n format\n );\n const modeProperty = kind === 'array' ? 'multilineArray' : 'multilineTable';\n const contextualFormat = resolveTomlFormat({\n ...format,\n inlineTableStart: 0,\n [modeProperty]: multiline,\n trailingComma: trailingCommaExplicit ? format.trailingComma : siblingTrailingComma,\n bracketSpacing: siblingBracketSpacing ?? format.bracketSpacing,\n indentWidth: generatedIndentWidth\n }, format);\n const valueDocument = parseJS(\n { tmp: jsValue },\n contextualFormat,\n parentDepth + 1,\n parentIsMultiline\n );\n const wrapper = valueDocument.items[0];\n if (!wrapper || !isKeyValue(wrapper)) return child;\n\n const value = wrapper.value;\n if (multiline && (isInlineArray(value) || isInlineTable(value))) {\n const startColumn = value.loc.start.column;\n value.loc.start.column = 0;\n if (value.loc.end.line === value.loc.start.line) {\n value.loc.end.column -= startColumn;\n } else if (resolveInlineContainerLayout(\n isInlineArray(value) ? 'array' : 'table',\n parentDepth + 1,\n parentIsMultiline,\n contextualFormat\n )) {\n value.loc.end.column = 1;\n }\n }\n if (isInlineTable(parent)) {\n const keyValue = generateKeyValue((child.item as KeyValue).key.value, value, false, format.escapeSequenceUpperCase);\n const regenerated = generateInlineItem(keyValue);\n regenerated.comma = child.comma;\n return regenerated;\n }\n\n const regenerated = generateInlineItem(value);\n if (parent.items.length === 0 && isInlineArray(parent) && isInlineTable(value)) {\n regenerated.comma = true;\n }\n return regenerated;\n }\n\n function regenerateInlineReplacement(existing: TreeNode, replacement: TreeNode, changePath: Path): TreeNode {\n const replacementValue = isInlineItem(replacement) ? replacement.item : replacement;\n if (!isInlineArray(replacementValue) && !isInlineTable(replacementValue)) return replacement;\n\n let jsValue: any = rawUpdated;\n for (const key of changePath) jsValue = jsValue?.[key];\n if (!Array.isArray(jsValue) && !isObject(jsValue)) return replacement;\n\n const parent = findInlineContainerParent(original, existing);\n const parentDepth = parent ? findInlineContainerDepth(original, parent) ?? 0 : -1;\n const parentIsMultiline = parent\n ? perLine(parent) || (parent.items.length === 0 && parent.loc.end.line > parent.loc.start.line)\n : false;\n const kind = Array.isArray(jsValue) ? 'array' : 'table';\n const mode = kind === 'array' ? format.multilineArray : format.multilineTable;\n const selected = resolveInlineContainerLayout(\n kind,\n parentDepth + 1,\n parentIsMultiline,\n format\n );\n const existingValue = isInlineItem(existing) ? existing.item : existing;\n const existingInlineValue = isInlineArray(existingValue) || isInlineTable(existingValue)\n ? existingValue\n : undefined;\n const existingKind = isInlineArray(existingValue)\n ? 'array'\n : isInlineTable(existingValue)\n ? 'table'\n : undefined;\n const preserveSourceLayout =\n existingInlineValue !== undefined &&\n existingKind !== kind &&\n hasStructuralMultilineRows(existingInlineValue) &&\n mode === 'auto';\n const multiline = selected || preserveSourceLayout;\n if (!multiline) return replacement;\n\n const modeProperty = kind === 'array' ? 'multilineArray' : 'multilineTable';\n const contextualFormat = resolveTomlFormat({\n ...format,\n inlineTableStart: 0,\n [modeProperty]: true,\n trailingComma: trailingCommaExplicit ? format.trailingComma : false\n }, format);\n const valueDocument = parseJS(\n { tmp: jsValue },\n contextualFormat,\n parentDepth + 1,\n parentIsMultiline\n );\n const wrapper = valueDocument.items[0];\n if (!wrapper || !isKeyValue(wrapper)) return replacement;\n\n const value = wrapper.value;\n if (isInlineArray(value) || isInlineTable(value)) {\n const targetColumn = isInlineItem(existing)\n ? existing.item.loc.start.column\n : existing.loc.start.column;\n if (value.loc.end.line === value.loc.start.line) {\n value.loc.end.column += targetColumn - value.loc.start.column;\n } else {\n value.loc.end.column = 1;\n }\n value.loc.start.column = targetColumn;\n }\n\n if (isInlineItem(replacement)) {\n const regenerated = generateInlineItem(value);\n regenerated.comma = replacement.comma;\n return regenerated;\n }\n return value;\n }\n\n // Potential Changes:\n //\n // Add: Add key-value to object, add item to array\n // Edit: Change in value\n // Remove: Remove key-value from object, remove item from array\n // Move: Move item in array\n // Rename: Rename key in key-value\n //\n // Special consideration, inline comments need to move as-needed\n\n const mayAddTableArray = changes.some(change => {\n if (!isAdd(change)) return false;\n const child = findByPath(updated, change.path);\n if (child && isTableArray(child)) return true;\n\n const parentPath = change.path.slice(0, -1);\n const index = last(change.path);\n const sibling = tryFindByPath(original, parentPath.concat(0));\n return isInteger(index) && !isInteger(last(parentPath)) &&\n !!sibling && isTableArray(sibling);\n });\n const originalAotItems = mayAddTableArray ? [...original.items] as Block[] : undefined;\n const aotStylePathsByKey = new Map<\n TableArray | undefined,\n Map<string, { tablePaths: Set<string>; tableArrayPaths: Set<string>; inlineTablePaths: Set<string> } | undefined>\n >();\n const getAotStylePaths = (entryKey: string[], owner?: TableArray) => {\n let stylePathsByKey = aotStylePathsByKey.get(owner);\n if (!stylePathsByKey) {\n stylePathsByKey = new Map();\n aotStylePathsByKey.set(owner, stylePathsByKey);\n }\n const cacheKey = JSON.stringify(entryKey);\n if (stylePathsByKey.has(cacheKey)) return stylePathsByKey.get(cacheKey);\n\n const paths = {\n tablePaths: new Set<string>(),\n tableArrayPaths: new Set<string>(),\n inlineTablePaths: new Set<string>()\n };\n const items = originalAotItems ?? original.items as Block[];\n const ownerScope = owner\n ? new Set(findAotEntryScopeItems(original, owner, items.indexOf(owner), items))\n : undefined;\n const collectNestedInlineTableStyles = (table: InlineTable, basePath: string[]) => {\n for (const item of table.items as InlineItem[]) {\n if (!isInlineItem(item) || !isKeyValue(item.item) || !isInlineTable(item.item.value)) continue;\n const path = basePath.concat(item.item.key.value);\n paths.inlineTablePaths.add(JSON.stringify(path));\n collectNestedInlineTableStyles(item.item.value, path);\n }\n };\n const collectInlineTableStyles = (container: Table | TableArray, basePath: string[]) => {\n for (const item of container.items as TreeNode[]) {\n if (!isKeyValue(item) || !isInlineTable(item.value)) continue;\n const path = basePath.concat(item.key.value);\n paths.inlineTablePaths.add(JSON.stringify(path));\n collectNestedInlineTableStyles(item.value, path);\n }\n };\n for (let index = 0; index < items.length; index++) {\n const entry = items[index];\n if (!isTableArray(entry) || !arraysEqual(entry.key.item.value, entryKey) ||\n (ownerScope && !ownerScope.has(entry))) continue;\n\n collectInlineTableStyles(entry, entryKey);\n const sections = findAotEntryScopeItems(original, entry, index, items);\n for (const section of sections) {\n if (!isTable(section) && !isTableArray(section)) continue;\n const sectionKey = itemKey(section);\n if (!sectionKey || sectionKey.length <= entryKey.length || !keyStartsWith(sectionKey, entryKey)) {\n continue;\n }\n collectInlineTableStyles(section, sectionKey);\n if (isTable(section)) paths.tablePaths.add(JSON.stringify(sectionKey));\n else paths.tableArrayPaths.add(JSON.stringify(sectionKey));\n }\n }\n\n const result = paths.tablePaths.size > 0 || paths.tableArrayPaths.size > 0 || paths.inlineTablePaths.size > 0\n ? paths\n : undefined;\n stylePathsByKey.set(cacheKey, result);\n return result;\n };\n\n changes.forEach(change => {\n if (isAdd(change)) {\n\n let child = findByPath(updated, change.path);\n const parent_path = change.path.slice(0, -1);\n let index = last(change.path)! as number;\n\n let is_table_array = isTableArray(child);\n // Detect AOT append: the new entry is an integer index and the immediate\n // parent key is a string (covers both top-level and nested AOTs such as\n // [[fruit]] or [[fruit.variety]]).\n if (isInteger(index) && !is_table_array && !isInteger(last(parent_path))) {\n const sibling = tryFindByPath(original, parent_path.concat(0));\n if (sibling && isTableArray(sibling)) {\n is_table_array = true;\n }\n }\n const owner = findAotEntryForPath(original, parent_path);\n if (is_table_array && isInteger(index) && !isInteger(last(parent_path))) {\n const updated_js = convertedUpdated;\n let updatedArray: any = updated_js;\n for (const segment of parent_path) updatedArray = updatedArray?.[segment];\n\n if (Array.isArray(updatedArray) && !updatedArray.every(isObject)) {\n const arrayKey = parent_path.filter((segment): segment is string => typeof segment === 'string');\n const explicitParent = findDeepestExplicitTable(\n original,\n arrayKey,\n owner?.key.item.value.length ?? 0,\n owner\n );\n const parentKey = explicitParent?.key.item.value ?? owner?.key.item.value ?? [];\n const relativeKey = arrayKey.slice(parentKey.length);\n const replacementRow = generateExplicitParentRow(relativeKey, updatedArray, format);\n if (replacementRow) {\n const oldSections = findAotScopedDocumentItems(original, arrayKey, owner)\n .filter(item => (isTable(item) || isTableArray(item)) && keyStartsWith(itemKey(item), arrayKey));\n const oldSectionSet = new Set(oldSections);\n const commentsToRelocate = new Set<Comment>();\n for (const section of oldSections) {\n traverse(section, { Comment: comment => commentsToRelocate.add(comment) });\n }\n for (const group of resolveGroups(original)) {\n if (!group.member || !oldSectionSet.has(group.member as Block)) continue;\n for (const item of group.items) {\n if (isComment(item)) commentsToRelocate.add(item);\n }\n }\n const comments = [...commentsToRelocate]\n .sort((a, b) => a.loc.start.line - b.loc.start.line || a.loc.start.column - b.loc.start.column)\n .map(comment => comment.raw);\n for (const section of oldSections.reverse()) {\n removeMember(original, original, section);\n }\n const destination = explicitParent ?? owner ?? original;\n let insertionIndex = isDocument(destination) ? rootKeyValueInsertIndex(original) : undefined;\n for (const comment of comments) {\n insert(original, destination, generateComment(comment), insertionIndex);\n if (insertionIndex !== undefined) insertionIndex++;\n }\n insert(original, destination, replacementRow, insertionIndex);\n commentEligibleNodes.add(replacementRow);\n return;\n }\n }\n }\n // The converse of the guard below: parseJS renders an array of objects as [[key]]\n // sections at the default inlineTableStart, but the document may hold that array\n // inline (`key = [{ ... }]`). The document's shape has to win, or the new element\n // arrives as a section while `key = [...]` stays put — defining the key twice, and\n // re-parsing as the original array nested inside the new element.\n if (is_table_array && isInteger(index) && !isInteger(last(parent_path))) {\n const existingParent = tryFindByPath(original, parent_path);\n const existingArray = existingParent && isKeyValue(existingParent)\n ? existingParent.value\n : existingParent;\n\n if (existingArray && isInlineArray(existingArray)) {\n const updated_js = convertedUpdated;\n let jsValue: any = updated_js;\n for (const k of change.path) jsValue = jsValue?.[k];\n\n // Wrap in a throwaway key so parseJS yields a value node, then take that value.\n // inlineTableStart: 0 keeps it inline — the element belongs inside an inline array,\n // so it must be an inline table whatever the configured depth would have chosen for\n // a top-level key (at the default it would come back as a `[tmp]` section).\n const inlineFmt = resolveTomlFormat({ ...format, inlineTableStart: 0 }, format);\n const valueDoc = jsValue === undefined ? undefined : parseJS({ tmp: jsValue }, inlineFmt);\n const wrapper = valueDoc?.items[0];\n if (wrapper && isKeyValue(wrapper)) {\n child = generateInlineItem(wrapper.value);\n is_table_array = false;\n\n // Match sibling bracket spacing. parseJS may or may not have applied it\n // depending on the format path; fill in the gap when siblings have it.\n if (isInlineItem(child) && isInlineTable(child.item) && child.item.items.length > 0) {\n const table = child.item;\n const alreadySpaced = table.items[0].loc.start.column - table.loc.start.column > 1;\n if (!alreadySpaced) {\n const sibling = (existingArray.items as InlineItem[])\n .map(item => item.item)\n .find(item => isInlineTable(item) && item.items.length > 0) as InlineTable | undefined;\n const siblingSpaced = sibling\n && sibling.items[0].loc.start.column - sibling.loc.start.column > 1;\n if (siblingSpaced) {\n applyBracketSpacing(original, table, true);\n }\n }\n }\n }\n }\n }\n\n const tableArrayKey = parent_path.filter((part): part is string => typeof part === 'string');\n const aotStyle = is_table_array && !inlineTableStartExplicit\n ? getAotStylePaths(tableArrayKey, owner)\n : undefined;\n const preserveScopedSections = is_table_array && !inlineTableStartExplicit && !!aotStyle;\n const updated_js = convertedUpdated;\n let jsValue: any = updated_js;\n for (const k of change.path) jsValue = jsValue?.[k];\n const hasMatchingInlineStyle = (value: any, relativePath: string[] = []): boolean => {\n if (!value || typeof value !== 'object') return false;\n if (Array.isArray(value)) return value.some(item => hasMatchingInlineStyle(item, relativePath));\n return Object.entries(value).some(([key, nestedValue]) => {\n const fullPath = JSON.stringify(tableArrayKey.concat(relativePath, key));\n if (aotStyle?.inlineTablePaths.has(fullPath) && isObject(nestedValue)) return true;\n return hasMatchingInlineStyle(nestedValue, relativePath.concat(key));\n });\n };\n const hasMatchingSectionStyle = (value: any, relativePath: string[] = []): boolean => {\n if (!value || typeof value !== 'object') return false;\n if (Array.isArray(value)) return value.some(item => hasMatchingSectionStyle(item, relativePath));\n return Object.entries(value).some(([key, nestedValue]) => {\n const fullPath = JSON.stringify(tableArrayKey.concat(relativePath, key));\n if ((aotStyle?.tablePaths.has(fullPath) && !Array.isArray(nestedValue)) ||\n (aotStyle?.tableArrayPaths.has(fullPath) && Array.isArray(nestedValue))) return true;\n return hasMatchingSectionStyle(nestedValue, relativePath.concat(key));\n });\n };\n const hasMatchingInlineStyleForEntry = preserveScopedSections && hasMatchingInlineStyle(jsValue);\n const hasMatchingStyle = preserveScopedSections &&\n (hasMatchingInlineStyleForEntry || hasMatchingSectionStyle(jsValue));\n\n // Rebuild a new AOT entry when its nested values have a section-style\n // precedent in another entry of the same array.\n if (is_table_array && (!isTableArray(child) || hasMatchingStyle)) {\n if (jsValue !== undefined) {\n const freshTableArray = generateTableArray(tableArrayKey, format.escapeSequenceUpperCase);\n const entryFormat = hasMatchingInlineStyleForEntry\n ? resolveTomlFormat({ ...format, inlineTableStart: 0 }, format)\n : format;\n const entryDoc = parseJS(jsValue, entryFormat);\n for (const item of entryDoc.items) {\n insert(freshTableArray, freshTableArray, item, undefined);\n }\n if (preserveScopedSections && aotStyle) {\n const preserveNestedAotArrays = (container: Table | TableArray, relativePath: string[]) => {\n for (const item of [...container.items] as TreeNode[]) {\n if (isKeyValue(item) && isInlineTable(item.value)) {\n const fullPath = tableArrayKey.concat(relativePath, item.key.value);\n if (aotStyle.tablePaths.has(JSON.stringify(fullPath))) {\n remove(freshTableArray, container, item);\n const table = generateTable(relativePath.concat(item.key.value), format.escapeSequenceUpperCase);\n for (const row of item.value.items as InlineItem[]) {\n insert(freshTableArray, table, row.item, undefined, undefined, undefined, undefined, true);\n }\n insert(freshTableArray, container, table);\n preserveNestedAotArrays(table, relativePath.concat(item.key.value));\n continue;\n }\n }\n if (isKeyValue(item) && isInlineArray(item.value)) {\n const fullPath = tableArrayKey.concat(relativePath, item.key.value);\n if (aotStyle.tableArrayPaths.has(JSON.stringify(fullPath)) && item.value.items.length > 0 &&\n item.value.items.every(value => isInlineItem(value) && isInlineTable(value.item))) {\n remove(freshTableArray, container, item);\n for (const value of item.value.items as InlineItem[]) {\n const tableArray = generateTableArray(relativePath.concat(item.key.value), format.escapeSequenceUpperCase);\n for (const row of (value.item as InlineTable).items as InlineItem[]) {\n insert(freshTableArray, tableArray, row.item, undefined, undefined, undefined, undefined, true);\n }\n insert(freshTableArray, container, tableArray);\n preserveNestedAotArrays(tableArray, relativePath.concat(item.key.value));\n }\n continue;\n }\n }\n if (isTable(item) || isTableArray(item)) {\n preserveNestedAotArrays(item, relativePath.concat(item.key.item.value));\n }\n }\n };\n preserveNestedAotArrays(freshTableArray, []);\n }\n // The entry value was parsed standalone, so any [table]/[[array]]\n // sections inside it carry their LOCAL keys (e.g. `[k79]` for\n // `{ k79: { … } }`). Inside the parent array-of-tables those\n // headers must carry the full key (`[d6r6.p.k79]`), or they\n // re-parse as root-level sections detached from the entry\n // (fuzz seed 6746).\n const prefixNestedSectionKeys = (node: TreeNode) => {\n if (!hasItems(node)) return;\n for (const item of node.items as TreeNode[]) {\n if (!isTable(item) && !isTableArray(item)) continue;\n const holder = item.key;\n const keyNode = holder.item;\n const fullKey = tableArrayKey.concat(keyNode.value);\n keyNode.value = fullKey;\n keyNode.raw = generateKey(fullKey, format.escapeSequenceUpperCase).raw;\n keyNode.loc.start.column = holder.loc.start.column + 1;\n keyNode.loc.end.column = keyNode.loc.start.column + keyNode.raw.length;\n holder.loc.end.column = keyNode.loc.start.column + keyNode.raw.length + 1;\n prefixNestedSectionKeys(item);\n }\n };\n prefixNestedSectionKeys(freshTableArray);\n applyWrites(freshTableArray);\n child = freshTableArray;\n }\n }\n\n // Determine the parent node where the new child will be inserted\n let parent: TreeNode;\n if (isTable(child)) {\n parent = original;\n } else if (is_table_array) {\n parent = original;\n\n // The index needs to be updated to top-level items\n // to properly account for other items, comments, and nesting\n const document = original as Document;\n const before = tryFindByPath(document, parent_path.concat(index - 1)) as Block | undefined;\n const after = tryFindByPath(document, parent_path.concat(index)) as Block | undefined;\n if (after) {\n index = document.items.indexOf(after);\n } else if (before) {\n index = document.items.indexOf(before) + 1;\n // Appending a new entry must land after the PREVIOUS entry's full\n // scope. Sub-tables of an AOT entry live as document-level items\n // after the entry header (both pre-existing `[a.b.sub]` sections\n // and sub-tables materialised in-place by an earlier Remove in the\n // same batch, e.g. a dotted key emptied to `{}`). Skipping them\n // here keeps those sections in the previous entry — otherwise the\n // new [[entry]] header lands before them and the re-parse swallows\n // them into the new entry (fuzz seed 21525).\n if (isTableArray(before)) {\n const aotKey = (before as TableArray).key.item.value;\n // Sub-tables of an AOT entry are NOT necessarily contiguous:\n // an unrelated section (e.g. `[[c]]`) may sit between the entry\n // header and one of its sub-tables (`[y.\"!\"..]`), and that\n // sub-table still belongs to the previous entry because it comes\n // before the next `[[y]]` header. Find the LAST such sub-table\n // anywhere later in the document and place the new entry after\n // it — otherwise the new [[entry]] header splits the sub-table\n // off and the re-parse re-associates it with the new entry\n // (fuzz seed 742554, a non-contiguous variant of seed 21525).\n let lastSubTable = index - 1;\n for (let i = index; i < document.items.length; i++) {\n const item = document.items[i];\n if (isTableArray(item)) {\n const itemKey = (item as TableArray).key.item.value;\n if (itemKey.length < aotKey.length\n && arraysEqual(aotKey.slice(0, itemKey.length), itemKey)) {\n break;\n }\n }\n const key = isTable(item) || isTableArray(item)\n ? (item as Table | TableArray).key.item.value\n : undefined;\n if (key && key.length > aotKey.length\n && arraysEqual(key.slice(0, aotKey.length), aotKey)) {\n lastSubTable = i;\n }\n }\n index = lastSubTable + 1;\n if (isTableArray(child)) {\n child = preserveAotEntryDottedKeys(child, before as TableArray);\n }\n }\n } else {\n index = document.items.length;\n }\n } else {\n // Walk change.path prefixes from longest to shortest to find the\n // insertion container. A dotted KeyValue matched by prefix (its key\n // is longer than the consumed path, e.g. `ak` matching `ak.k99`) is\n // NOT the parent: its value belongs to a different subtree, and\n // consecutive adds under the same dotted prefix must land in the\n // shared ancestor (fuzz seed 4). restoreMissingKeySegments then\n // re-attaches the missing prefix to the child's key.\n parent = original;\n for (let pLen = change.path.length - 1; pLen >= 0; pLen--) {\n const candidate = tryFindByPath(original, change.path.slice(0, pLen));\n if (!candidate) continue;\n if (isPrefixMatchedNode(candidate, change.path.slice(0, pLen))) continue;\n parent = candidate;\n break;\n }\n if (isKeyValue(parent)) {\n parent = parent.value;\n } else if (isInlineItem(parent) && isKeyValue(parent.item)) {\n parent = parent.item.value;\n } else if (isInlineItem(parent) && isInlineTable(parent.item)) {\n parent = parent.item;\n } else if (isInlineItem(parent) && isInlineArray(parent.item)) {\n // Unwrap InlineArrayItem to the inner InlineArray so insert()\n // sees a container with items, e.g. adding to [\"a\",\"b\"] inside\n // [18:45:20, false, [\"a\",\"b\"]]\n parent = parent.item;\n }\n }\n\n if (isInlineArray(parent) || isInlineTable(parent)) {\n child = regenerateInlineChildForParent(parent, change.path, child);\n prepareInsertedNestedInlineContainer(parent, child, format.indentWidth);\n }\n\n if (isInlineArray(parent)) {\n const rowNode = tryFindByPath(original, parent_path);\n const rowContainer = tryFindByPath(original, parent_path.slice(0, -1));\n if (rowNode && isKeyValue(rowNode) && rowContainer) {\n const deltaColumns = getInlineInsertColumnDelta(parent, child, index);\n if (deltaColumns !== 0) {\n preserveAlignedInlineCommentForDelta(rowContainer, rowNode, deltaColumns);\n }\n }\n }\n\n // insert() positions a new element against its previous sibling's `.loc`, but that\n // position stays pre-offset until applyWrites resolves it. A second insertion into the\n // same multi-line container would therefore measure against a stale line and land on\n // top of the row before it (`2, 99,` on one line instead of two rows). Resolve the\n // earlier insertion first — but only on the second one, since applyWrites walks the\n // whole tree and a patch inserting into many containers once each needs none of this.\n const multilineInlineParent =\n (isInlineArray(parent) || isInlineTable(parent)) && parent.loc.end.line > parent.loc.start.line;\n if (multilineInlineParent && insertedInlineContainers.has(parent)) {\n applyWrites(original);\n }\n\n // The comments hoisted out of a multiline InlineArray/InlineTable live in the\n // nearest enclosing Document/Table/TableArray's own items, not necessarily\n // `original.items` — resolve it once so insert() can compensate the array the\n // hoisted comments actually live in, matching removeMember/moveInlineElement.\n const inlineHostItems = (isInlineArray(parent) || isInlineTable(parent))\n ? (findHostContainer(original, parent)?.items as TreeNode[] | undefined)\n : undefined;\n\n if (isTableArray(parent) || isInlineArray(parent) || isDocument(parent)) {\n if (is_table_array && !isInteger(last(parent_path))) {\n normalizeAotEntryComments(original, true);\n }\n\n // Special handling for InlineArray: preserve original trailing comma format\n if (isInlineArray(parent)) {\n const originalHadTrailingCommas = trailingCommaForAddedItem(\n parent,\n arrayHadTrailingCommas(parent)\n );\n // If this is an InlineItem being added to an array, check its comma setting\n if (isInlineItem(child)) {\n // The child comes from the updated document with global format applied\n // Override with the original array's format\n const generatedMultilineTable = parent.items.length === 0 &&\n isInlineTable(child.item) &&\n perLine(child.item);\n child.comma = generatedMultilineTable || originalHadTrailingCommas;\n\n // `format.trailingComma` is a single flag, but it is read off whichever\n // separator the detector happened to see. An array written `[ { a = 1 }, ]`\n // sets it from the comma after the inline table, then that same flag decides\n // the comma *inside* the new table — emitting `{ z = 0, }` next to `{ a = 1 }`.\n // The two are independent, so take the inner one from a sibling table.\n //\n // Regenerated rather than patched in place: clearing the flag on a node already\n // laid out with a comma leaves the slot behind as `{ z = 0 }`.\n const addedItem = child;\n const addedTable = isInlineTable(addedItem.item) ? addedItem.item : undefined;\n const siblingTable = addedTable && addedTable.items.length > 0\n ? (parent.items as InlineItem[])\n .map(item => item.item)\n .find(item => item !== addedItem.item && isInlineTable(item))\n : undefined;\n\n if (addedTable && siblingTable) {\n const wanted = tableHadTrailingCommas(siblingTable);\n if (wanted !== tableHadTrailingCommas(addedTable)) {\n const updated_js = convertedUpdated;\n let jsValue: any = updated_js;\n for (const k of change.path) jsValue = jsValue?.[k];\n\n const matchedFmt = resolveTomlFormat(\n { ...format, inlineTableStart: 0, trailingComma: wanted },\n format\n );\n const rebuilt = jsValue === undefined\n ? undefined\n : parseJS({ tmp: jsValue }, matchedFmt).items[0];\n\n if (rebuilt && isKeyValue(rebuilt)) {\n const replacementItem = generateInlineItem(rebuilt.value);\n replacementItem.comma = addedItem.comma;\n child = replacementItem;\n }\n }\n }\n }\n }\n \n // Check if we should convert nested inline tables to multiline tables\n if (format.inlineTableStart !== undefined && format.inlineTableStart > 0 && isDocument(parent) && isTable(child)) {\n const additionalTables = convertNestedInlineTablesToMultiline(child, original, format);\n \n // Insert the main table first\n insert(original, parent, child, index);\n \n // Then insert all the additional tables\n for (const table of additionalTables) {\n insert(original, original, table, undefined);\n }\n } else {\n // Root-level key-values belong to TOML's implicit root table, which\n // spans from the start of the document up to (but not including) the\n // first explicit section header ([table] or [[array]]). When the index\n // is a string key, insert() falls back to parent.items.length —\n // appending after all sections and silently nesting the new key under\n // the last one. Clamp to the end of the root table scope instead.\n // For non-KV children (e.g. table-array entries) the index was already\n // resolved to a correct integer above, so leave it as-is.\n //\n // Unwrap InlineItem first: a KV added under the document root arrives\n // wrapped in an InlineItem (it was resolved inside an inline table in\n // the updated CST), and the clamp below must see the inner KV to\n // recognise a root-level key-value (fuzz seed 297).\n let childToInsert = child;\n if (isInlineItem(child) && (isTableArray(parent) || isDocument(parent))) {\n childToInsert = child.item;\n }\n let resolvedIndex = index;\n if (isDocument(parent) && isKeyValue(childToInsert)) {\n const rootTableEnd = rootKeyValueInsertIndex(parent as Document);\n if (rootTableEnd !== undefined) {\n resolvedIndex = rootTableEnd;\n }\n }\n // Restore intermediate key segments the path traverses that no longer\n // exist in the original document (fuzz seed 4).\n let restoredKeySegments = false;\n if ((isTableArray(parent) || isDocument(parent)) && isKeyValue(childToInsert)) {\n const restored = restoreMissingKeySegments(parent_path, childToInsert, change.path);\n if (restored) {\n if (restoredInsertContainers.has(parent)) {\n applyWrites(original);\n }\n childToInsert = restored;\n restoredKeySegments = true;\n }\n }\n // Adding the first item back into an inline array emptied by\n // earlier removals in this same patch has the same pending-offset\n // hazard as the inline-table case below (fuzz seed 92).\n if (isInlineArray(parent) && parent.items.length === 0) {\n applyWrites(original);\n }\n // Inserting at the FRONT of a non-empty single-line inline array\n // after leading elements were removed in this same patch: removing a\n // leading element with no previous sibling registers a pending ENTER\n // offset on the array itself (writer.remove() targets `parent`), and\n // insert() positions an index-0 child against parent.loc.start — a\n // stale, pre-offset column. The re-inserted elements then land on\n // top of the enclosing dotted key's text and applyWrites clobbers it\n // (fuzz seed 86547). Flush first, same discipline as the guards\n // above and below.\n if (resolvedIndex === 0 && isInlineArray(parent) &&\n getPendingEnterOffsets(original).has(parent)) {\n applyWrites(original);\n }\n // Inserting at index 0 of a Document/Table/TableArray that still\n // carries a pending ENTER offset from an earlier removal: the\n // offset would drag the new row above line 1 (fuzz seed 11557 —\n // deleting the first dotted KV then re-adding its key emitted the\n // new row at line -1). Flush first, like every other insert that\n // follows removals in the same patch.\n if (resolvedIndex === 0 && (isDocument(parent) || isTable(parent) || isTableArray(parent)) &&\n getPendingEnterOffsets(original).has(parent)) {\n applyWrites(original);\n }\n if (isKeyValue(childToInsert) && childToInsert.key.value.length > 1) {\n const style = findDottedKeyStyle(original, childToInsert.key.value.slice(0, -1));\n if (style) {\n const oldEquals = childToInsert.equals;\n preserveDottedKeySpacing(childToInsert.key, style.key.raw);\n childToInsert.equals = childToInsert.key.loc.end.column\n + style.equals - style.key.loc.end.column;\n const columnDelta = childToInsert.equals - oldEquals;\n shiftNode(childToInsert.value, { lines: 0, columns: columnDelta }, { first_line_only: true });\n if (childToInsert.loc.end.line === childToInsert.loc.start.line) {\n childToInsert.loc.end.column += columnDelta;\n }\n }\n }\n insert(original, parent, childToInsert, resolvedIndex, undefined, inlineHostItems);\n if (restoredKeySegments) restoredInsertContainers.add(parent);\n }\n } else if (isInlineTable(parent)) {\n // Adding the first item back into an inline table emptied by\n // earlier removals in this same patch: the removal registered an\n // enter offset on the table itself, which applyWrites would also\n // apply to the new items — dragging them into the preceding key\n // area (fuzz seed 92). Resolve it first so insert() positions\n // against final coordinates.\n if (parent.items.length === 0) {\n applyWrites(original);\n // This multiline inline table was emptied from its own bracket line\n // (the removal zeroed its offset, leaving a stale multiline end line).\n // Collapse it to a single line NOW so the insert below places the new\n // item on the bracket row instead of a phantom second line — the\n // latter leaves the stale lines dangling and pulls a trailing\n // sibling of an enclosing inline table inside this one (fuzz seed\n // 272851).\n if (hasInlineContainerNeedingTighten(parent) &&\n parent.loc.end.line > parent.loc.start.line) {\n parent.loc.end.line = parent.loc.start.line;\n }\n }\n // Special handling for adding KeyValue to InlineTable\n // Preserve original trailing comma format\n const originalHadTrailingCommas = trailingCommaForAddedItem(\n parent,\n tableHadTrailingCommas(parent)\n );\n // InlineTable items must be wrapped in InlineItem\n if (isKeyValue(child)) {\n const inlineItem = generateInlineItem(child);\n // Override with the original table's format\n inlineItem.comma = originalHadTrailingCommas;\n const insertIndex = inlineTableAddIndex(parent, child, change.before);\n insert(original, parent, inlineItem, insertIndex, undefined, inlineHostItems);\n } else if (isInlineItem(child) && isKeyValue(child.item)) {\n // The child was resolved through an inline table in the updated\n // CST, so it arrives as an InlineItem-wrapped KV. When the\n // insertion parent is a shallower ancestor than the change path\n // (the dotted KV holding the missing intermediate segments was\n // removed earlier in this same patch — fuzz seed 305: removing\n // `o247.bjbdmm11-.y773gunzy` then adding `o247.k2`), restore the\n // missing key segments on the inner KV so the new key lands under\n // the right dotted prefix instead of at the container's top level.\n let kv = child.item as KeyValue;\n const restored = restoreMissingKeySegments(parent_path, kv, change.path);\n if (restored) {\n if (restoredInsertContainers.has(parent)) {\n applyWrites(original);\n }\n kv = restored;\n }\n const inlineItem = generateInlineItem(kv);\n inlineItem.comma = originalHadTrailingCommas;\n const insertIndex = inlineTableAddIndex(parent, kv, change.before);\n insert(original, parent, inlineItem, insertIndex, undefined, inlineHostItems);\n if (restored) restoredInsertContainers.add(parent);\n } else {\n insert(original, parent, child, undefined, undefined, inlineHostItems);\n }\n } else {\n // Check if we should convert inline tables to multiline tables when adding to existing tables\n if (format.inlineTableStart !== undefined && format.inlineTableStart > 0 && isKeyValue(child) && isInlineTable(child.value) && isTable(parent)) {\n // Calculate the depth of the inline table that would be created\n const baseTableKey = parent.key.item.value;\n const nestedTableKey = [...baseTableKey, ...child.key.value];\n const depth = calculateTableDepth(nestedTableKey);\n \n // Convert to separate section only if depth is less than inlineTableStart\n if (depth < format.inlineTableStart) {\n convertInlineTableToSeparateSection(child, parent, original, format);\n } else {\n insert(original, parent, child);\n }\n } else if (format.inlineTableStart === 0 && isKeyValue(child) && isInlineTable(child.value) && isDocument(parent)) {\n insert(original, parent, child, undefined, true);\n } else {\n // Unwrap InlineItem if we're adding to a Table, TableArray, or\n // Document. InlineItems should only exist within InlineTables or\n // InlineArrays — block containers expect raw KV/Table nodes.\n let childToInsert = child;\n if (isInlineItem(child) && (isTable(parent) || isTableArray(parent) || isDocument(parent))) {\n childToInsert = child.item;\n }\n // Restore intermediate key segments the path traverses that no longer\n // exist in the original document (fuzz seed 4).\n let restoredKeySegments = false;\n if (isTable(parent) && isKeyValue(childToInsert)) {\n const restored = restoreMissingKeySegments(parent_path, childToInsert, change.path);\n if (restored) {\n if (restoredInsertContainers.has(parent)) {\n applyWrites(original);\n }\n childToInsert = restored;\n restoredKeySegments = true;\n }\n }\n const leadingLines = (isTable(parent) || isTableArray(parent))\n && parent.items.length > 0\n && parent.items.every(isComment)\n ? 2\n : undefined;\n insert(original, parent, childToInsert, undefined, undefined, undefined, leadingLines);\n if (restoredKeySegments) restoredInsertContainers.add(parent);\n }\n }\n\n if (multilineInlineParent) insertedInlineContainers.add(parent);\n\n } else if (isEdit(change)) {\n let existing = tryFindByPath(original, change.path);\n let replacement: TreeNode | undefined;\n try {\n replacement = findByPath(updated, change.path);\n } catch {\n replacement = undefined;\n }\n\n // When the existing node can't be found — or the replacement can't be\n // resolved in the updated CST (e.g. `one = { … }` became an array of\n // tables, whose entries live at path [one, 0] so the bare path [one]\n // resolves nowhere — fuzz seed 477) — this is a structural type change\n // (table→scalar, implicit-table→AOT, array→empty, …).\n // Handle by removing old nodes and inserting fresh KV.\n if (!existing || !replacement) {\n handleStructuralEdit(original, updated, change, format, temporal, commentEligibleNodes, materialisedTables);\n return; // skip generic edit handling\n }\n\n // A KV replaced by a Table section whose key already owns sibling\n // document nodes (e.g. `\"\" = {…}` becoming `[\"\".y4ywkew]` while the\n // document also holds `\"\".9UI = …`) — the generic replace would leave\n // those siblings behind, and the section would collide with the\n // implicit table they define on re-parse (\"Value already defined\",\n // fuzz seed 3607). Let the structural-edit path clear the prefix\n // and rebuild the key instead.\n if (isKeyValue(existing) && isTable(replacement)) {\n const tableKey = (replacement as Table).key.item.value;\n const prefixNodes = findDocumentItemsByKeyPrefix(original, tableKey);\n if (prefixNodes.some(n => n !== existing)) {\n handleStructuralEdit(original, updated, change, format, temporal, commentEligibleNodes, materialisedTables);\n return; // handled; skip generic edit handling\n }\n }\n\n // An inline-array element replaced by an object that parseJS rendered as\n // a Table/TableArray: an array-of-objects at the default inlineTableStart\n // becomes `[[key]]` sections, so findByPath resolves the replacement to an\n // AOT entry — but the document holds the array INLINE (`key = [...]`).\n // Splicing that section in place of the InlineItem emits `[[key]]` inside\n // the array (fuzz seed 121096). Regenerate the element as an inline\n // table, exactly like the converse guard in the Add handler.\n if (isInlineItem(existing) && (isTable(replacement) || isTableArray(replacement))) {\n const parentArr = tryFindByPath(original, change.path.slice(0, -1));\n const parentArray = parentArr && isKeyValue(parentArr) ? parentArr.value : parentArr;\n if (parentArray && isInlineArray(parentArray)) {\n let jsValue: any = rawUpdated;\n for (const k of change.path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const inlineFmt = resolveTomlFormat({ ...format, inlineTableStart: 0 }, format);\n const valueDoc = parseJS({ tmp: jsValue }, inlineFmt);\n const wrapper = valueDoc?.items[0];\n if (wrapper && isKeyValue(wrapper)) {\n replacement = generateInlineItem(wrapper.value);\n }\n }\n }\n }\n\n let parent;\n let containerParent = tryFindByPath(original, change.path.slice(0, -1));\n // The parent path can resolve to a dotted KV by PREFIX when the edited\n // key sits under an implicit table (e.g. editing `[\"\", 0, \"\", \"\"]` while\n // the CST holds `\"\".\"\".lh8butjh6i`): the probe is shorter than the key,\n // so tryFindByPath returns the KV, not its container. The sibling\n // sweeps below must look in the REAL container (the AOT entry) or stale\n // children survive the collapse and re-parse fails with \"Value already\n // defined\" (fuzz seed 1674968). Resolve it structurally.\n if (containerParent &&\n (isKeyValue(containerParent) || isInlineItem(containerParent)) &&\n isPrefixMatchedNode(containerParent, change.path.slice(0, -1))) {\n containerParent = findStructuralParent(original, containerParent);\n }\n const inlineTableRowContext = findEnclosingInlineTableRowContext(original, change.path);\n\n if (isKeyValue(existing) && isKeyValue(replacement)) {\n // Edit for key-value means value changes\n // Preserve formatting from existing value in replacement value\n \n // If findByPath matched via prefix (the path is shorter than the\n // existing dotted key), truncate the key. We detect this by finding\n // the longest suffix of change.path that matches a prefix of the\n // existing key — this handles cases where parseJS restructured keys\n // (e.g. it splits { '': { swr: x } } into Table [\\\"\\\"] + KV swr).\n let keyTruncated = false;\n if (existing.key.value.length > 1) {\n const absPath = absolutePathOf(existing);\n const matchLen = truncationMatchLen(\n change.path,\n existing.key.value,\n absPath ? absPath.length - existing.key.value.length : 0\n );\n if (matchLen > 0 && matchLen < existing.key.value.length) {\n existing.key.value = existing.key.value.slice(0, matchLen);\n existing.key.raw = generateKey(existing.key.value).raw;\n // The key is now shorter — shift key loc, equals, and the\n // existing value's loc so the writer moves the replacement\n // to the correct position.\n const oldEndCol = existing.key.loc.end.column;\n const newEndCol = existing.key.loc.start.column + existing.key.raw.length;\n const delta = newEndCol - oldEndCol;\n existing.key.loc.end.column = newEndCol;\n existing.equals += delta;\n existing.value.loc.start.column += delta;\n if (existing.value.loc.end.line === existing.value.loc.start.line) existing.value.loc.end.column += delta;\n if (existing.loc.end.line === existing.loc.start.line) existing.loc.end.column += delta;\n keyTruncated = true;\n\n // When a dotted key is truncated (e.g. v.jp → v), any\n // sibling KVs that were children of the old implicit table\n // (e.g. v.e4.c6) must be removed — v is no longer a table.\n const truncatedPrefix = existing.key.value;\n if (containerParent && (isTable(containerParent) || isDocument(containerParent) || isTableArray(containerParent))) {\n // Snapshot: removeMember below splices the live items array, so\n // iterating it directly would read `undefined` past the shrunk\n // end (fuzz seed 31662).\n const parentItems = [...(containerParent as Table | Document | TableArray).items] as Block[];\n for (let si = parentItems.length - 1; si >= 0; si--) {\n const sibling = parentItems[si];\n if (sibling === existing) continue;\n // >= (not just >): a sibling holding the exact same key\n // (`\"\" = {…}` next to `\"\".x = 1`) duplicates the truncated\n // key once it becomes a scalar and fails the re-parse with\n // \"Value already defined\" (fuzz seed 3607). Section\n // siblings ([table]/[[array]] extending the prefix) conflict\n // the same way and are removed too.\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length >= truncatedPrefix.length\n && arraysEqual(siblingKey.slice(0, truncatedPrefix.length), truncatedPrefix)) {\n removeMember(original, containerParent, sibling);\n }\n }\n }\n removeDocumentItemsExtendingPath(original, change.path, existing);\n }\n }\n\n // A single-segment key whose value becomes a non-block-table while a\n // sibling dotted-key or section still extends its prefix (e.g.\n // `\"\" = <date>` next to `\"\".x = 1` collapsing to `\"\" = \"str\"`) must\n // drop those siblings — neither a leaf, an array, nor an inline table\n // can hold them, and leaving them in place re-defines the key on\n // re-parse (\"Value already defined\" for scalars, fuzz seed 32801;\n // \"Cannot add to static array\" for arrays, fuzz seed 39363; \"Cannot\n // extend inline table\" for inline tables, fuzz seed 80004). In this\n // branch `replacement` is always a KeyValue, so its value can never be\n // a block Table/TableArray — every value shape needs the sibling sweep.\n if (!keyTruncated && isKeyValue(replacement)) {\n if (containerParent && (isTable(containerParent) || isDocument(containerParent) || isTableArray(containerParent))) {\n removeSiblingsExtendingPrefix(original, containerParent as Table | Document | TableArray, existing.key.value, existing);\n }\n }\n \n preserveFormatting(existing.value, replacement.value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n if (containerParent) {\n preserveAlignedInlineCommentColumn(containerParent, existing, existing.value, replacement.value);\n }\n \n parent = existing;\n existing = existing.value;\n replacement = replacement.value;\n\n // When the key was truncated, the replacement value from the updated CST\n // carries stale coordinate-system data that corrupts applyWrites' offset\n // resolution. Regenerate a fresh value through a TOML round-trip for\n // clean loc values, and re-apply formatting preservation on the fresh node.\n if (keyTruncated && rawUpdated !== undefined) {\n let jsValue: any = rawUpdated;\n for (const k of change.path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const freshValue = regenerateValue(jsValue, format);\n if (freshValue !== undefined) {\n replacement = freshValue;\n preserveFormatting(existing as Value, replacement as Value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n }\n }\n }\n } else if (isKeyValue(existing) && isInlineItem(replacement) && isKeyValue(replacement.item)) {\n // Truncate the existing key if the path matched via prefix (same\n // logic as the isKeyValue && isKeyValue branch above).\n let keyTruncated = false;\n if (existing.key.value.length > 1) {\n const absPath = absolutePathOf(existing);\n const matchLen = truncationMatchLen(\n change.path,\n existing.key.value,\n absPath ? absPath.length - existing.key.value.length : 0\n );\n if (matchLen > 0 && matchLen < existing.key.value.length) {\n existing.key.value = existing.key.value.slice(0, matchLen);\n existing.key.raw = generateKey(existing.key.value).raw;\n // The key is now shorter — shift key loc, equals, and the\n // existing value's loc so the writer moves the replacement\n // to the correct position.\n const oldEndCol = existing.key.loc.end.column;\n const newEndCol = existing.key.loc.start.column + existing.key.raw.length;\n const delta = newEndCol - oldEndCol;\n existing.key.loc.end.column = newEndCol;\n existing.equals += delta;\n existing.value.loc.start.column += delta;\n if (existing.value.loc.end.line === existing.value.loc.start.line) existing.value.loc.end.column += delta;\n if (existing.loc.end.line === existing.loc.start.line) existing.loc.end.column += delta;\n keyTruncated = true;\n\n // Remove sibling KVs that were children of the old implicit table.\n const truncatedPrefix = existing.key.value;\n if (containerParent && (isTable(containerParent) || isDocument(containerParent) || isTableArray(containerParent))) {\n // Snapshot: removeMember below splices the live items array\n // (fuzz seed 31662).\n const parentItems = [...(containerParent as Table | Document | TableArray).items] as Block[];\n for (let si = parentItems.length - 1; si >= 0; si--) {\n const sibling = parentItems[si];\n if (sibling === existing) continue;\n // >= (not just >), and sections count too — see the\n // isKeyValue/isKeyValue branch above (fuzz seed 3607).\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length >= truncatedPrefix.length\n && arraysEqual(siblingKey.slice(0, truncatedPrefix.length), truncatedPrefix)) {\n removeMember(original, containerParent, sibling);\n }\n }\n }\n removeDocumentItemsExtendingPath(original, change.path, existing);\n }\n }\n\n // Single-segment key collapsing to a non-block-table with siblings\n // extending its prefix (fuzz seeds 32801, 39363, 80004) — same as the\n // isKeyValue/isKeyValue branch; every value shape in this branch\n // (leaf, array, inline table) must drop prefix-extending siblings.\n if (!keyTruncated && isKeyValue(replacement.item)) {\n if (containerParent && (isTable(containerParent) || isDocument(containerParent) || isTableArray(containerParent))) {\n removeSiblingsExtendingPrefix(original, containerParent as Table | Document | TableArray, existing.key.value, existing);\n }\n }\n\n parent = existing;\n existing = existing.value;\n replacement = replacement.item.value;\n\n // When the key was truncated, regenerate the replacement value with clean\n // loc values through a TOML round-trip to avoid applyWrites corruption\n // from stale updated-CST coordinate-system data.\n if (keyTruncated && rawUpdated !== undefined) {\n let jsValue: any = rawUpdated;\n for (const k of change.path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const freshValue = regenerateValue(jsValue, format);\n if (freshValue !== undefined) replacement = freshValue;\n }\n }\n } else if (isInlineItem(existing) && isKeyValue(existing.item) && isKeyValue(replacement)) {\n // Editing inline table item: existing is InlineItem, replacement is a block-style KeyValue.\n // Preserve the InlineItem's formatting (alignment, equals position) by only swapping the value,\n // not the whole KeyValue — otherwise alignment spaces for the key are lost (as well as the trailing comma).\n const existingKeyValue = existing.item;\n\n // If the path matched via prefix (shorter than the existing dotted\n // key), truncate the key — same logic as the branches above\n // (fuzz seed 137: `u3chwmmvk.g{…}.oe1zht` → `u3chwmmvk = []`).\n let keyTruncated = false;\n if (existingKeyValue.key.value.length > 1) {\n const absPath = absolutePathOf(existingKeyValue);\n const matchLen = truncationMatchLen(\n change.path,\n existingKeyValue.key.value,\n absPath ? absPath.length - existingKeyValue.key.value.length : 0\n );\n if (matchLen > 0 && matchLen < existingKeyValue.key.value.length) {\n existingKeyValue.key.value = existingKeyValue.key.value.slice(0, matchLen);\n existingKeyValue.key.raw = generateKey(existingKeyValue.key.value, format.escapeSequenceUpperCase).raw;\n const oldEndCol = existingKeyValue.key.loc.end.column;\n const newEndCol = existingKeyValue.key.loc.start.column + existingKeyValue.key.raw.length;\n const delta = newEndCol - oldEndCol;\n existingKeyValue.key.loc.end.column = newEndCol;\n existingKeyValue.equals += delta;\n existingKeyValue.value.loc.start.column += delta;\n if (existingKeyValue.value.loc.end.line === existingKeyValue.value.loc.start.line) existingKeyValue.value.loc.end.column += delta;\n if (existingKeyValue.loc.end.line === existingKeyValue.loc.start.line) existingKeyValue.loc.end.column += delta;\n // Record an exit offset at the KV so applyWrites shifts\n // everything after it (sibling items, closing brace) by the\n // key-size delta — but only for a single-line KV: for a\n // multiline value the exit offset would land on the KV's END\n // line, whose content columns did not move (fuzz seed 139).\n if (existingKeyValue.loc.end.line === existingKeyValue.loc.start.line) {\n addExitOffset(original, existingKeyValue, { lines: 0, columns: delta });\n }\n keyTruncated = true;\n\n // A surviving sibling row extending the truncated prefix still\n // re-defines the (now collapsed) key on re-parse — e.g. `\"\" = \"s\"`\n // left next to `\"\".e-0cxz9.\";\" = …` inside an inline table\n // (fuzz seed 82825). Remove those rows, mirroring the 3607/11799\n // discipline (InlineItem row keys included).\n const truncatedPrefix = existingKeyValue.key.value;\n let scanParent = containerParent;\n if (scanParent && isInlineItem(scanParent)) scanParent = scanParent.item;\n if (scanParent && isKeyValue(scanParent)) scanParent = scanParent.value;\n if (scanParent && hasItems(scanParent)) {\n const parentItems = [...(scanParent as { items: TreeNode[] }).items];\n for (let si = parentItems.length - 1; si >= 0; si--) {\n const sibling = parentItems[si];\n if (sibling === existing) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isInlineItem(sibling) && isKeyValue(sibling.item)\n ? sibling.item.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length >= truncatedPrefix.length\n && arraysEqual(siblingKey.slice(0, truncatedPrefix.length), truncatedPrefix)) {\n removeMember(original, scanParent, sibling);\n }\n }\n }\n }\n }\n\n preserveFormatting(existingKeyValue.value, replacement.value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n parent = existingKeyValue;\n existing = existingKeyValue.value;\n replacement = replacement.value;\n\n // Same regenerate discipline as the truncation paths above.\n if (keyTruncated && rawUpdated !== undefined) {\n let jsValue: any = rawUpdated;\n for (const k of change.path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const freshValue = regenerateValue(jsValue, format);\n if (freshValue !== undefined) {\n replacement = freshValue;\n preserveFormatting(existing as Value, replacement as Value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n }\n }\n }\n } else if (isInlineItem(existing) && isInlineItem(replacement) && isKeyValue(existing.item) && isKeyValue(replacement.item)) {\n // Both are InlineItems wrapping KeyValues (nested inline table edits).\n \n // If the path matched via prefix (shorter than the existing dotted key),\n // truncate the key. Same logic as the isKeyValue branches above.\n let keyTruncated = false;\n const existingKV = existing.item;\n if (existingKV.key.value.length > 1) {\n const absPath = absolutePathOf(existingKV);\n const matchLen = truncationMatchLen(\n change.path,\n existingKV.key.value,\n absPath ? absPath.length - existingKV.key.value.length : 0\n );\n if (matchLen > 0 && matchLen < existingKV.key.value.length) {\n existingKV.key.value = existingKV.key.value.slice(0, matchLen);\n existingKV.key.raw = generateKey(existingKV.key.value, format.escapeSequenceUpperCase).raw;\n const oldEndCol = existingKV.key.loc.end.column;\n const newEndCol = existingKV.key.loc.start.column + existingKV.key.raw.length;\n const delta = newEndCol - oldEndCol;\n existingKV.key.loc.end.column = newEndCol;\n existingKV.equals += delta;\n existingKV.value.loc.start.column += delta;\n if (existingKV.value.loc.end.line === existingKV.value.loc.start.line) existingKV.value.loc.end.column += delta;\n if (existingKV.loc.end.line === existingKV.loc.start.line) existingKV.loc.end.column += delta;\n // Record an exit offset at the KV so applyWrites shifts\n // everything after the KV (sibling items, closing brace) by\n // the key-size delta — single-line KVs only (see the\n // InlineItem-KV branch, fuzz seed 139).\n if (existingKV.loc.end.line === existingKV.loc.start.line) {\n addExitOffset(original, existingKV, { lines: 0, columns: delta });\n }\n keyTruncated = true;\n\n // Remove sibling rows extending the truncated prefix — a\n // surviving `\"\".2U]0!Rr([{` next to the new scalar `\"\"`\n // duplicates the key on re-parse (fuzz seed 11799). Same\n // discipline as the isKeyValue branches (fuzz seed 3607),\n // with InlineItem row keys included for inline-table\n // containers.\n const truncatedPrefix = existingKV.key.value;\n // The parent may be the InlineItem wrapper around the inline\n // table holding the rows (fuzz seeds 11627, 11799), or a\n // dotted-key KV whose value IS the inline table (fuzz seed\n // 11480) — unwrap either so the sibling scan sees the rows.\n let scanParent = containerParent;\n if (scanParent && isInlineItem(scanParent)) scanParent = scanParent.item;\n if (scanParent && isKeyValue(scanParent)) scanParent = scanParent.value;\n if (scanParent && hasItems(scanParent)) {\n // Snapshot: removeMember below splices the live items array\n // (fuzz seed 31662).\n const parentItems = [...(scanParent as { items: TreeNode[] }).items];\n for (let si = parentItems.length - 1; si >= 0; si--) {\n const sibling = parentItems[si];\n if (sibling === existing) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isInlineItem(sibling) && isKeyValue(sibling.item)\n ? sibling.item.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length >= truncatedPrefix.length\n && arraysEqual(siblingKey.slice(0, truncatedPrefix.length), truncatedPrefix)) {\n removeMember(original, scanParent, sibling);\n }\n }\n }\n }\n }\n\n // Preserve formatting and edit the value within\n preserveFormatting(existingKV.value, replacement.item.value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n parent = existingKV;\n existing = existingKV.value;\n replacement = replacement.item.value;\n\n // When the key was truncated, regenerate the replacement value with clean\n // loc values through a TOML round-trip to avoid applyWrites corruption\n // from stale updated-CST coordinate-system data, and re-apply formatting\n // preservation on the fresh node.\n if (keyTruncated && rawUpdated !== undefined) {\n let jsValue: any = rawUpdated;\n for (const k of change.path) jsValue = jsValue?.[k];\n if (jsValue !== undefined) {\n const freshValue = regenerateValue(jsValue, format);\n if (freshValue !== undefined) {\n replacement = freshValue;\n preserveFormatting(existing as Value, replacement as Value, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n }\n }\n }\n } else if (isTable(existing)) {\n // Type change: a block table section (e.g: [x.y.z.w]) is being replaced by a scalar value.\n // The diff produces an Edit at path e.g. ['x','y','z','w'], where `existing` is the Table\n // node and `replacement` (from the updated document) may be an InlineItem or KV that does\n // not carry the full scope. Simply splicing it into the Document would lose the scope.\n // Get the JS value at change.path and regenerate a fresh KV + parent table from scratch.\n const updated_js = convertedUpdated;\n let jsValue: any = updated_js;\n for (const key of change.path) {\n jsValue = jsValue?.[key];\n }\n\n if (jsValue !== undefined) {\n const existingTableKey = (existing as Table).key.item.value;\n const lastSegment = existingTableKey.slice(-1);\n const parentKey = existingTableKey.slice(0, -1);\n // Path-based parent resolution can land on an unrelated sibling: the\n // path prefix (e.g. ['']) prefix-matches an EARLIER dotted key-value\n // (e.g. `\"\".nfh`), and replacing through it would overwrite that KV's\n // value instead of swapping the table (fuzz seed 6803). Prefer the\n // node's actual structural container.\n const tableParent = findStructuralParent(original, existing) ?? findParent(original, change.path);\n const aotOwner = findAotEntryForPath(original, change.path);\n\n const explicitParent = findDeepestExplicitTable(\n original,\n existingTableKey,\n aotOwner?.key.item.value.length ?? 0,\n aotOwner\n );\n if (explicitParent) {\n const relativeKey = existingTableKey.slice(explicitParent.key.item.value.length);\n const hasImplicitParent = relativeKey.length > 1 &&\n (explicitParent.items as TreeNode[]).some(item =>\n isKeyValue(item) &&\n item.key.value.length > 1 &&\n item.key.value[0] === relativeKey[0]\n );\n if (hasImplicitParent && replaceBelowExplicitTable(\n original, explicitParent, existingTableKey, jsValue, format, commentEligibleNodes, aotOwner\n )) {\n return;\n }\n }\n\n // The table's key can be a strict prefix of OTHER document sections\n // (e.g. `[\"\"]` collapsing to a scalar while `[\"\".hv8lx]` is also a\n // document-level section extending that prefix). Those sections\n // re-define the key on re-parse and fail with \"Value already defined\"\n // (fuzz seed 22772). Remove them before the table becomes a scalar.\n if (isDocument(tableParent)) {\n const sectionedSiblings = (aotOwner\n ? findAotScopedDocumentItems(original, existingTableKey, aotOwner)\n : findDocumentItemsByKeyPrefix(original, existingTableKey))\n .filter(n => n !== existing && (isTable(n) || isTableArray(n)));\n for (const sibling of sectionedSiblings) {\n removeMember(original, tableParent, sibling);\n }\n }\n\n // Regenerate a fresh KV using parseJS on just the single key-value\n const freshDoc = parseJS({ [lastSegment[0]]: jsValue }, format);\n const freshKV = freshDoc.items[0] as KeyValue;\n\n // Sub-tables of a table-array entry are document siblings in the CST,\n // but a scalar replacement belongs in the owning entry's items. Keep\n // the replacement scoped to that entry instead of binding it to the\n // preceding AOT entry on re-parse.\n if (isKeyValue(freshKV) && aotOwner && keyStartsWith(parentKey, aotOwner.key.item.value)) {\n const scalarParent: Table | TableArray | undefined = arraysEqual(parentKey, aotOwner.key.item.value)\n ? aotOwner\n : findAotScopedDocumentItems(original, parentKey, aotOwner)\n .find(item => isTable(item) && arraysEqual((item as Table).key.item.value, parentKey)) as Table | undefined;\n if (scalarParent) {\n removeMember(original, tableParent, existing);\n insert(original, scalarParent, freshKV, undefined);\n commentEligibleNodes.add(freshKV);\n return;\n }\n\n const relativeParentKey = parentKey.slice(aotOwner.key.item.value.length);\n const hasImplicitAotParent = relativeParentKey.length > 0 &&\n (aotOwner.items as TreeNode[]).some(item =>\n isKeyValue(item) &&\n item.key.value.length > relativeParentKey.length &&\n keyStartsWith(item.key.value, relativeParentKey)\n );\n if (hasImplicitAotParent) {\n const relativeKey = existingTableKey.slice(aotOwner.key.item.value.length);\n const scopedRow = generateExplicitParentRow(relativeKey, jsValue, format);\n if (scopedRow) {\n removeMember(original, tableParent, existing);\n insert(original, aotOwner, scopedRow, undefined);\n commentEligibleNodes.add(scopedRow);\n return;\n }\n }\n }\n\n if (parentKey.length > 0) {\n // The regenerated `freshKV` is a Table/TableArray (not a KeyValue)\n // when `jsValue` is an object or an array of objects. Emitting it\n // with only the last key segment under a `[parentKey]` header\n // fragments the section into an empty `[parentKey]` + a stray\n // top-level section (fuzz seed 41613). Extend the section's key\n // with the parent prefix and swap it in for the old node directly.\n if (isTable(freshKV) || isTableArray(freshKV)) {\n extendSectionKeyWithParentAndReplace(freshKV, parentKey, existing, tableParent);\n commentEligibleNodes.add(freshKV);\n } else {\n // The parent key may be purely implicit (dotted key-values) —\n // emitting a literal header would fail the re-parse (fuzz seed\n // 6803). Extend the KV's key with the prefix instead.\n const hasImplicitParent = findDocumentItemsByKeyPrefix(original, parentKey).some(isKeyValue);\n if (hasImplicitParent) {\n extendKeyWithParentAndReplace(freshKV, parentKey, existing, tableParent);\n commentEligibleNodes.add(freshKV);\n } else {\n // The parent key may already be an EXPLICIT section (a\n // `[parentKey]` header that survives unrelated to this edit,\n // e.g. `[\"\"].i3asc2k3y` collapsing while a separate `[\"\"]`\n // table lives on — fuzz seed 78079). Generating a fresh\n // `[parentKey]` header would duplicate it and fail the\n // re-parse with \"Table already defined\". Merge the fresh KV\n // into the surviving section instead.\n const survivingParent = (original.items as TreeNode[]).find(n =>\n n !== existing\n && (isTable(n) || isTableArray(n))\n && arraysEqual((n as Table | TableArray).key.item.value, parentKey));\n if (survivingParent) {\n const parentSection = (survivingParent as Table | TableArray);\n // freshKV's key is the single last segment; inside `[parentKey]`\n // it lands as a plain child row.\n insert(original, parentSection, freshKV, undefined);\n removeMember(original, tableParent, existing);\n commentEligibleNodes.add(freshKV);\n } else {\n const newTable = generateTable(parentKey, format.escapeSequenceUpperCase);\n materialisedTables.add(newTable);\n insert(original, newTable, freshKV, 0);\n replace(original, tableParent, existing, newTable);\n // newTable stands in for the pre-existing `existing` table, so it should stay\n // eligible for the leading comment block `existing` would have owned via R2.\n commentEligibleNodes.add(newTable);\n }\n }\n }\n } else {\n // Single-segment table [w] — KV belongs directly in the Document.\n // Replace the table with the KV, then reposition the KV to before\n // the first table header so it lands in the implicit root table\n // rather than inside a preceding section.\n replace(original, tableParent, existing, freshKV);\n // Same reasoning as newTable above: freshKV replaces `existing`, not a new entry.\n commentEligibleNodes.add(freshKV);\n\n hoistRootKeyValueAboveTables(original, freshKV);\n }\n\n // A table replaced by an array of objects becomes an array-of-tables:\n // parseJS renders each array element as its own `[[key]]` section, so\n // `freshDoc.items` holds more than one entry. The block above only\n // placed `freshKV` (entry 0); the remaining `[[key]]` sections must be\n // inserted right after it or they are silently dropped (fuzz seed\n // 460447 — the appended entry vanished).\n if (freshDoc.items.length > 1) {\n for (let i = 1; i < freshDoc.items.length; i++) {\n const extraEntry = freshDoc.items[i] as Table | TableArray;\n if (parentKey.length > 0) {\n extendSectionKeyInPlace(extraEntry, parentKey);\n }\n // Insert after the entry just placed (freshKV for the first, the\n // previous extra entry for the rest).\n const prev = (i === 1 ? freshKV : freshDoc.items[i - 1]) as TreeNode;\n const prevIndex = (tableParent as Document).items.indexOf(prev as Block);\n insert(original, tableParent, extraEntry, prevIndex + 1);\n commentEligibleNodes.add(extraEntry);\n }\n }\n return; // handled; skip the generic replace() below\n }\n\n // Could not resolve the JS value — fall back to generic handling\n parent = findParent(original, change.path);\n } else if (isTableArray(existing)) {\n // Same situation as the isTable branch above, but for an array-of-tables:\n // the diff edits the entry (path [..., 0]), and the replacement — an\n // InlineItem from the updated doc — carries no key. Splicing it in for\n // the [[a]] node emits a bare value with no key at all (fuzz seed 3333).\n // Regenerate the array as a fresh KV instead.\n const updated_js = convertedUpdated;\n const existingAotKey = (existing as TableArray).key.item.value;\n let jsValue: any = updated_js;\n // Navigate to the array's JS value. When the edit targets an AOT\n // entry the path ends in that entry's numeric index ([..., 0]), which\n // is not part of the array's key; drop it. A whole-array edit's path\n // ends in the key itself (fuzz seed 136865: `ng.tll = [obj, -4619]`),\n // and has no trailing index — navigate the path as-is. Using a fixed\n // `existingAotKey.length` misaligns when the AOT is itself nested\n // inside another AOT entry, because the path then interleaves numeric\n // entry indices with string key segments (fuzz seed 129645).\n const navPath = typeof change.path[change.path.length - 1] === 'number'\n ? change.path.slice(0, -1)\n : change.path;\n for (const key of navPath) {\n jsValue = jsValue?.[key];\n }\n\n if (jsValue !== undefined) {\n const lastSegment = existingAotKey.slice(-1);\n const parentKey = existingAotKey.slice(0, -1);\n // Same structural-parent discipline as the isTable branch above\n // (fuzz seed 6803): the path prefix can prefix-match an unrelated\n // earlier dotted key-value.\n const tableParent = findStructuralParent(original, existing) ?? findParent(original, change.path);\n const aotOwner = findAotEntryForPath(original, navPath);\n\n // Regenerate a fresh KV using parseJS on just the single key-value\n const freshDoc = parseJS({ [lastSegment[0]]: jsValue }, format);\n const freshKV = freshDoc.items[0] as KeyValue;\n\n // When the whole AOT collapsed to an array that no longer holds\n // only plain objects (`[[hc8v]]` with `hc8v[0] = -1937`), `freshKV`\n // carries the ENTIRE array value. Replacing only `existing` (entry\n // 0) leaves the remaining sibling `[[key]]` entries behind, which\n // then collide with the rebuilt KV and fail the re-parse (fuzz seed\n // 299772). Drop every other entry with the same key first.\n if (Array.isArray(jsValue) && !jsValue.every(v => isObject(v))) {\n // The AOT's key can be a strict prefix of OTHER document sections\n // (e.g. `[[\"\"]]` collapsing to a static array while\n // `[\"\".c47eko_.bog8_vy3w]` is a non-contiguous sub-table extending\n // that prefix). Those prefix-extended sub-tables/sub-AOTs would\n // re-define the key on re-parse and fail with \"Cannot add to\n // static array\" (fuzz seed 1285105). Match them by key prefix,\n // not just exact key equality.\n const siblingEntries = (aotOwner\n ? findAotScopedDocumentItems(original, existingAotKey, aotOwner)\n : findDocumentItemsByKeyPrefix(original, existingAotKey))\n .filter(n => n !== existing && (isTable(n) || isTableArray(n)));\n for (const sibling of siblingEntries) {\n removeMember(original, original, sibling);\n }\n }\n\n if (parentKey.length > 0) {\n if (isKeyValue(freshKV) && aotOwner && keyStartsWith(parentKey, aotOwner.key.item.value)) {\n const replacementParent: Table | TableArray | undefined = arraysEqual(parentKey, aotOwner.key.item.value)\n ? aotOwner\n : findAotScopedDocumentItems(original, parentKey, aotOwner)\n .find(item => isTable(item) && arraysEqual((item as Table).key.item.value, parentKey)) as Table | undefined;\n if (replacementParent) {\n removeMember(original, tableParent, existing);\n insert(original, replacementParent, freshKV, undefined);\n commentEligibleNodes.add(freshKV);\n return;\n }\n }\n\n // The regenerated `freshKV` is a Table/TableArray (not a KeyValue)\n // when `jsValue` is an object or an array of objects. Emitting it\n // with only the last key segment under a `[parentKey]` header\n // fragments the section: a `[[qbvzp4p]]` child of `[e.j9a8-tra]`\n // re-renders as a TOP-LEVEL AOT, splitting `[[e.j9a8-tra.qbvzp4p]]`\n // into an empty `[e.j9a8-tra]` + a stray `[[qbvzp4p]]` (fuzz seed\n // 41613). Extend the section's key with the parent prefix and swap\n // it in for the old node directly instead.\n if (isTable(freshKV) || isTableArray(freshKV)) {\n extendSectionKeyWithParentAndReplace(freshKV, parentKey, existing, tableParent);\n commentEligibleNodes.add(freshKV);\n } else {\n // If an explicit parent table already exists (`[\"\"]` plus\n // `[[\"\".u60ke_j3]]`), reuse it and insert the rebuilt key\n // there. Creating a new `[parentKey]` duplicates the table\n // header and re-parse fails with \"Table already defined\"\n // (fuzz seed 1947810).\n const existingParentTable = isDocument(tableParent)\n ? (tableParent.items as TreeNode[]).find(item =>\n isTable(item) && arraysEqual((item as Table).key.item.value, parentKey)\n ) as Table | undefined\n : undefined;\n if (existingParentTable) {\n const existingRow = (existingParentTable.items as TreeNode[]).find(row =>\n isKeyValue(row) && arraysEqual((row as KeyValue).key.value, freshKV.key.value)\n ) as KeyValue | undefined;\n if (existingRow) {\n replace(original, existingParentTable, existingRow, freshKV);\n } else {\n insert(original, existingParentTable, freshKV, undefined);\n }\n removeMember(original, tableParent as Document, existing);\n commentEligibleNodes.add(existingParentTable);\n return; // handled; skip generic replace below\n }\n\n // Same implicit-parent handling as the isTable branch above\n // (fuzz seed 6803).\n const hasImplicitParent = findDocumentItemsByKeyPrefix(original, parentKey).some(isKeyValue);\n if (hasImplicitParent) {\n extendKeyWithParentAndReplace(freshKV, parentKey, existing, tableParent);\n commentEligibleNodes.add(freshKV);\n } else {\n const newTable = generateTable(parentKey, format.escapeSequenceUpperCase);\n materialisedTables.add(newTable);\n insert(original, newTable, freshKV, 0);\n replace(original, tableParent, existing, newTable);\n // newTable stands in for the pre-existing `existing` AOT, so it should stay\n // eligible for the leading comment block `existing` would have owned via R2.\n commentEligibleNodes.add(newTable);\n }\n }\n } else {\n // Single-segment [[w]] — KV belongs directly in the Document.\n replace(original, tableParent, existing, freshKV);\n // Same reasoning as newTable above: freshKV replaces `existing`, not a new entry.\n commentEligibleNodes.add(freshKV);\n\n hoistRootKeyValueAboveTables(original, freshKV);\n }\n return; // handled; skip the generic replace() below\n }\n\n // Could not resolve the JS value — fall back to generic handling\n parent = findParent(original, change.path);\n } else {\n parent = findParent(original, change.path);\n // Unwrap InlineItem parents to the actual container\n // (mirrors the Add handler unwrapping at L690-698).\n // For nested arrays, findParent returns the InlineArrayItem\n // wrapper; we need the inner InlineArray so replace() splices\n // into .items instead of overwriting .item.\n if (isKeyValue(parent)) {\n const parentPath = change.path.slice(0, -1);\n const arrayNode = findByPath(original, parentPath);\n if (isKeyValue(arrayNode) && isInlineArray(arrayNode.value)) {\n parent = arrayNode.value;\n }\n } else if (isInlineItem(parent) && isKeyValue(parent.item)) {\n parent = parent.item.value;\n } else if (isInlineItem(parent) && isInlineTable(parent.item)) {\n parent = parent.item;\n } else if (isInlineItem(parent) && isInlineArray(parent.item)) {\n parent = parent.item;\n }\n }\n\n // When replacing an InlineItem that wraps a scalar (e.g. editing a\n // string inside a nested array), preserve the existing item's comma\n // flag so the replacement doesn't introduce an unwanted trailing comma.\n if (isInlineItem(existing) && isInlineItem(replacement)) {\n if (isString(existing.item) && isString(replacement.item)) {\n preserveFormatting(existing.item, replacement.item, format.escapeSequenceUpperCase, format.minimumTimeDecimals ?? 0);\n replacement.loc = {\n start: { ...replacement.item.loc.start },\n end: { ...replacement.item.loc.end }\n };\n }\n replacement.comma = existing.comma;\n }\n\n if (inlineTableRowContext) {\n const existingSpan = getSpan(existing.loc);\n const replacementSpan = getSpan(replacement.loc);\n const deltaColumns = replacementSpan.columns - existingSpan.columns;\n if (deltaColumns !== 0) {\n recordInlineTableCommentDelta(inlineTableRowContext.container, inlineTableRowContext.row, deltaColumns);\n }\n }\n\n replacement = regenerateInlineReplacement(existing, replacement, change.path);\n\n replace(original, parent, existing, replacement);\n if (isInlineArray(replacement)) replacedInlineArrays.add(replacement);\n if (isInlineArray(replacement) || isInlineTable(replacement)) {\n applyWrites(original);\n normalizeGeneratedInlineContainerRows(replacement, format.indentWidth);\n replacedInlineContainers.push({ owner: parent, container: replacement });\n }\n\n // A section header captures every key-value that follows it, so an\n // edit that turns a root-level KV into a Table must not leave root\n // KVs after the new header (fuzz seed 590: `g86 = \"str\"` → `[g86]`\n // while `fofc`/`y3n`/`\"<w\"` followed it — they were swallowed into\n // the new table). Sink the new section below the root-table scope.\n if (isDocument(parent) && isKeyValue(existing) &&\n (isTable(replacement) || isTableArray(replacement))) {\n sinkTableBelowRootKeyValues(original, replacement);\n }\n } else if (isRemove(change)) {\n const node = tryFindByPath(original, change.path);\n\n if (!node) {\n // The path likely refers to all entries of a TableArray sequence\n // (e.g. path ['tasks'] when the CST stores entries at ['tasks',0], ['tasks',1]…),\n // or is a strict prefix of a longer AOT key (e.g. path ['a','b'] when\n // the entry key is ['a','b','c'] — fuzz seed 176).\n // Remove all entries by repeatedly pulling the next matching one.\n const nextAotEntry = (): TreeNode | undefined => {\n const direct = tryFindByPath(original, change.path.concat(0));\n if (direct) return direct;\n const prefixed = findDocumentItemsByKeyPrefix(original, change.path)\n .filter(isTableArray) as TableArray[];\n return prefixed[0];\n };\n const first = nextAotEntry();\n if (first) {\n const firstIndex = (original.items as TreeNode[]).indexOf(first);\n\n // R2 extension: when the AOT entries are the sole children of an\n // implicit parent, convert the first entry in place to a Table so\n // comments preceding it in Document.items are preserved.\n let materialiseAotInPlace = false;\n if (change.path.length > 1 && rawUpdated !== undefined) {\n const parentPath = change.path.slice(0, -1);\n const cstParentPath = stripAotEntryIndices(original, parentPath);\n const owner = findAotEntryForPath(original, change.path);\n const allSiblings = owner\n ? findAotScopedDocumentItems(original, cstParentPath, owner)\n : findDocumentItemsByKeyPrefix(original, cstParentPath);\n const otherSiblings = allSiblings.filter(s =>\n s !== first &&\n !(isTableArray(s) && arraysEqual((s as TableArray).key.item.value, stripAotEntryIndices(original, change.path)))\n );\n if (otherSiblings.length === 0 &&\n !(owner && arraysEqual(cstParentPath, owner.key.item.value))) {\n let value: any = rawUpdated;\n for (const k of parentPath) value = value?.[k];\n if (isObject(value) && Object.keys(value).length === 0) {\n // Convert first entry: clear items, rename key, change type.\n const aotNode = first as TableArray;\n const aotKeyHolder = aotNode.key;\n while (aotNode.items.length > 0) {\n removeMember(original, aotNode, last(aotNode.items as TreeNode[])!);\n }\n // The item removals above left pending line offsets on the\n // entry's key. Shrinking loc.end against pre-offset\n // positions — and leaving the offsets to bleed through the\n // entry into later sections — corrupts everything below\n // (fuzz seed 7379). Resolve first.\n applyWrites(original);\n (aotNode as any).type = NodeType.Table;\n // Also change the key type so toTOML renders [a] not [[a]].\n (aotKeyHolder as any).type = NodeType.TableKey;\n // Rename the key in place (preserving original loc.start).\n const aotKey = hasItem(aotKeyHolder) ? aotKeyHolder.item : aotKeyHolder;\n aotKey.value = cstParentPath as string[];\n aotKey.raw = preserveEscapedKeyRaw(aotKey.raw, aotKey.value, format.escapeSequenceUpperCase);\n aotKey.loc.end.column = aotKey.loc.start.column + aotKey.raw.length;\n aotKeyHolder.loc.end.column = aotKeyHolder.loc.start.column + aotKey.raw.length + 2;\n // Shrink loc.end to the header-only span.\n (aotNode as any).loc.end.line = aotKeyHolder.loc.end.line;\n (aotNode as any).loc.end.column = aotKeyHolder.loc.end.column;\n // Track for blank-line fixup if preceded by an R2-adjacent comment.\n trackAdjacentComment(aotNode as any as Table);\n materialiseAotInPlace = true;\n }\n }\n }\n\n // Remove remaining AOT entries. If the first was converted in place\n // it no longer matches change.path, so the loop naturally skips it.\n const cstPath = stripAotEntryIndices(original, change.path);\n const indexedOwner = findAotEntryForPath(original, change.path);\n let entry: TreeNode | undefined;\n while ((entry = nextAotEntry())) {\n if (isTableArray(entry)) {\n const ownedItems = findAotEntryScopeItems(original, entry)\n .filter(item => isTable(item) || isTableArray(item))\n .filter(item => keyStartsWith(itemKey(item), cstPath));\n for (const ownedItem of ownedItems) {\n removeMember(original, original, ownedItem);\n }\n }\n removeMember(original, original, entry);\n }\n // For an unindexed root-level removal, extending tables can precede\n // the AOT entries and must still be removed with the shared prefix.\n if (!indexedOwner) {\n for (const tableNode of findDocumentItemsByKeyPrefix(original, cstPath).filter(isTable)) {\n removeMember(original, original, tableNode);\n }\n }\n // After removing all AOT entries, insert an empty inline array key-value so the\n // key isn't lost (e.g. b = []), but only when the caller still wants the key.\n // \"Emptied to []\" and \"deleted outright\" both arrive here as a Remove of every\n // entry; re-materialising unconditionally put back a key the caller had deleted.\n if (tryFindByPath(updated, change.path)) {\n const aotPath = change.path;\n emptiedAotKeys.set(stableStringify(aotPath), aotPath);\n }\n\n // When the AOT entries were the sole children of an implicit parent\n // (e.g. [[a.b]] -> { a: {} }), the parent disappears. Materialise it\n // as an empty table if the caller still wants the parent key.\n // Skip if already materialised in place above.\n if (!materialiseAotInPlace &&\n change.path.length > 1 && rawUpdated !== undefined) {\n const parentPath = change.path.slice(0, -1);\n const cstParentPath = stripAotEntryIndices(original, parentPath);\n const owner = findAotEntryForPath(original, change.path);\n const remainingSiblings = findAotScopedDocumentItems(original, cstParentPath, owner);\n if (remainingSiblings.length === 0 &&\n !(owner && arraysEqual(cstParentPath, owner.key.item.value))) {\n let value: any = rawUpdated;\n for (const k of parentPath) value = value?.[k];\n if (isObject(value) && Object.keys(value).length === 0) {\n const emptyTable = generateTable(cstParentPath as string[], format.escapeSequenceUpperCase);\n materialisedTables.add(emptyTable);\n // The removals above already spliced the document items, so a\n // stale index (e.g. the removed entry was the last item) must\n // be clamped — inserting past the end leaves the generated\n // header at its (1,0) origin, corrupting line 1 (fuzz seed\n // 11605).\n const ownerIndex = owner && keyStartsWith(cstParentPath as string[], owner.key.item.value)\n ? (original.items as TreeNode[]).indexOf(owner)\n : -1;\n const insertIdx = ownerIndex >= 0\n ? ownerIndex + 1\n : firstIndex >= 0\n ? Math.min(firstIndex, original.items.length)\n : original.items.length;\n // Same pending-offset hazard as the implicit-key branch\n // below: insert after the removals are resolved so the new\n // header can't absorb the document's enter offset (fuzz\n // seed 1172).\n applyWrites(original);\n insert(original, original, emptyTable, insertIdx);\n if (ownerIndex >= 0) {\n applyWrites(original);\n const owner = original.items[ownerIndex];\n const gap = emptyTable.loc.start.line - owner.loc.end.line - 1;\n if (gap > 0) {\n for (const item of (original.items as TreeNode[]).slice(ownerIndex + 1)) {\n shiftNode(item, { lines: -gap, columns: 0 });\n }\n }\n }\n }\n }\n }\n } else {\n // The path might be an implicit intermediate key — a key that is a\n // prefix of a dotted table key but has no CST node of its own.\n // For example, [references.VBIDE] creates a Table with key\n // [\"references\", \"VBIDE\"], so a Remove at path [\"references\"] has\n // no exact node match. Find all document-level items whose key\n // starts with the change path and remove them. The path is in\n // JS-object coordinates, so strip numeric AOT entry indices first —\n // `delete obj[\"\"][0][\"-vX`\"]` has path `[\"\", 0, \"-vX`\"]` but the\n // CST sub-table is keyed `[\"\", \"-vX`\"]` (fuzz seed 1428499).\n const cstPath = stripAotEntryIndices(original, change.path);\n const owner = findAotEntryForPath(original, change.path);\n const prefixNodes = findAotScopedDocumentItems(original, cstPath, owner);\n if (prefixNodes.length > 0) {\n const firstPrefixIndex = (original.items as TreeNode[]).indexOf(prefixNodes[0]);\n for (const prefixNode of prefixNodes) {\n removeMember(original, original, prefixNode);\n }\n // When the removed prefix items were the sole children of an\n // implicit parent (e.g. [mhv6z.hpd_iu9zs5.\"2<w\"] removed at\n // path [mhv6z, hpd_iu9zs5] -> { mhv6z: {} }), materialise the\n // parent as an empty table so the key isn't dropped (seed 176).\n if (cstPath.length > 1 && rawUpdated !== undefined) {\n const cstParentPath = cstPath.slice(0, -1);\n const remainingSiblings = findAotScopedDocumentItems(original, cstParentPath, owner);\n if (remainingSiblings.length === 0 &&\n !(owner && arraysEqual(cstParentPath, owner.key.item.value))) {\n // `rawUpdated` is the JS object, so walk the ORIGINAL\n // (indexed) path — not the index-stripped CST path.\n let value: any = rawUpdated;\n for (const k of change.path.slice(0, -1)) value = value?.[k];\n if (isObject(value) && Object.keys(value).length === 0) {\n const emptyTable = generateTable(cstParentPath as string[], format.escapeSequenceUpperCase);\n materialisedTables.add(emptyTable);\n // Clamp to the post-removal items length — a stale last-item\n // index inserts past the end and strands the generated\n // header at its (1,0) origin, corrupting line 1 (fuzz seed\n // 11605).\n const insertIdx = firstPrefixIndex >= 0\n ? Math.min(firstPrefixIndex, original.items.length)\n : original.items.length;\n // The removals above left pending offsets on the document\n // (or a preceding item). Inserting before resolving them\n // lets the new header absorb the document's pending enter\n // offset and land above line 1 (fuzz seed 1172).\n applyWrites(original);\n insert(original, original, emptyTable, insertIdx);\n }\n }\n }\n } else {\n // Not a table array or implicit key — let findByPath throw the descriptive error.\n findByPath(original, change.path);\n }\n }\n } else {\n let parent = findParent(original, change.path);\n // When findParent returns the node itself via dotted-key prefix\n // matching (e.g. path ['t','a','b'] matching key ['a','b']),\n // re-resolve from one segment higher so we get the actual\n // container (the Table/Document) rather than the KV's value.\n if (parent === node) {\n parent = findParent(original, change.path.slice(0, -1));\n }\n // Every prefix of the path can itself match a dotted key (e.g.\n // removing the last segment of `z0ncoh.y.eam` inside an AOT entry),\n // in which case both resolutions above return the node itself.\n // Fall back to the node's structural container instead.\n if (parent === node) {\n const host = findHostContainer(original, node);\n if (host) parent = host;\n }\n if (isKeyValue(parent)) {\n parent = parent.value;\n }\n // When the parent is an InlineItem wrapping a KeyValue (nested inline table), unwrap to the\n // inner InlineTable so `remove` receives a node type that `hasItems` accepts.\n if (isInlineItem(parent) && isKeyValue((parent as InlineItem).item)) {\n parent = ((parent as InlineItem).item as KeyValue).value;\n }\n // When the parent is an InlineItem wrapping an InlineTable (an object inside an inline\n // array, e.g. `items = [{ name = \"x\", color = \"y\" }]`), unwrap to the InlineTable so\n // `remove` receives a node type that `hasItems` accepts.\n if (isInlineItem(parent) && isInlineTable((parent as InlineItem).item)) {\n parent = (parent as InlineItem).item;\n }\n // When the parent is an InlineItem wrapping an InlineArray (a nested array inside an\n // inline array, e.g. `a = [ [ 1, 2, 3 ] ]`), unwrap to the inner InlineArray so\n // `remove` receives a node type that `hasItems` accepts.\n if (isInlineItem(parent) && isInlineArray((parent as InlineItem).item)) {\n parent = (parent as InlineItem).item;\n }\n // The logical (JS-object) parent may differ from the CST parent.\n // For example, [server.tls] lives in document.items, not [server].items.\n // Fall back to the node's structural container when the parent doesn't\n // contain it (keeps document-sibling behaviour, and handles inline\n // containers nested inside values). This also covers resolution\n // landing on an unrelated sibling: removing `\"\".tvbin` resolves its\n // prefix [\"\"] to the FIRST key starting with \"\" (e.g. `\"\".vf = true`),\n // whose unwrapped value is a Boolean — not a container at all\n // (fuzz seed 185).\n if (!hasItems(parent) || !(parent.items as TreeNode[]).includes(node)) {\n const structural = findStructuralParent(original, node);\n parent = structural ?? (hasItems(parent) ? original : findHostContainer(original, node) ?? original);\n }\n\n // R2 extension: when the last child of an implicit parent is removed,\n // materialise the parent in place (rename key, clear items) so that\n // comments preceding the child in Document.items are preserved.\n let materialisedInPlace = false;\n if (change.path.length > 1 && isTable(node) && rawUpdated !== undefined) {\n const parentPath = change.path.slice(0, -1);\n // `change.path` is in JS-object coordinates (numeric AOT index after\n // the AOT key, e.g. `[\"\", 0, \"fv\"]` for CST `[\"\", \"fv\"]`). The\n // sibling scan and in-place key rename must use the CST key, else\n // the index leaks into the header `[\"\".0.fv]` (fuzz seed 1020868).\n const cstParentPath = (node as Table).key.item.value.slice(0, -1);\n const owner = findAotEntryForPath(original, change.path);\n const remainingSiblings = (owner\n ? findAotScopedDocumentItems(original, cstParentPath, owner)\n : findDocumentItemsByKeyPrefix(original, cstParentPath))\n .filter(s => s !== node);\n if (remainingSiblings.length === 0 &&\n !(owner && arraysEqual(cstParentPath, owner.key.item.value))) {\n let value: any = rawUpdated;\n for (const k of parentPath) value = value?.[k];\n if (isObject(value) && Object.keys(value).length === 0) {\n const table = node as Table;\n while (table.items.length > 0) {\n remove(original, table, last(table.items as TreeNode[])!);\n }\n // Same pending-offset discipline as materialiseAotInPlace\n // above (fuzz seed 7379).\n applyWrites(original);\n const keyHolder = table.key;\n const key = hasItem(keyHolder) ? keyHolder.item : keyHolder;\n key.value = cstParentPath as string[];\n key.raw = preserveEscapedKeyRaw(key.raw, key.value, format.escapeSequenceUpperCase);\n key.loc.end.column = key.loc.start.column + key.raw.length;\n keyHolder.loc.end.column = keyHolder.loc.start.column + key.raw.length + 2;\n // The body is gone — shrink table.loc to the header only.\n table.loc.end.line = keyHolder.loc.end.line;\n table.loc.end.column = keyHolder.loc.end.column;\n // Only track for blank-line fixup if the preceding comment\n // is R2-adjacent. A blank line (R3) severs ownership and\n // the gap is intentional.\n trackAdjacentComment(table);\n materialisedInPlace = true;\n }\n }\n }\n\n // Capture the node's index before removal so the materialised table\n // can be inserted at the original position (preserving blank-line\n // spacing with preceding comments).\n const nodeIndex = isDocument(parent) && hasItems(parent)\n ? (parent.items as TreeNode[]).indexOf(node)\n : -1;\n const containerItemIndex = hasItems(parent) && !isDocument(parent)\n ? (parent.items as TreeNode[]).indexOf(node)\n : -1;\n const removedInlineComma = isInlineItem(node) ? (node as InlineItem).comma : undefined;\n if (isInlineItem(node) && (isInlineArray(parent) || isInlineTable(parent))) {\n setInlineIndentColumn(parent, node.loc.start.column);\n }\n if (isInlineItem(node) && (isInlineArray(parent) || isInlineTable(parent)) &&\n containerItemIndex === parent.items.length - 1 &&\n removedInlineComma !== undefined) {\n removedInlineTrailingCommas.set(parent, removedInlineComma);\n }\n // The bracket gap of a multiline inline container, captured BEFORE the\n // removal: removeMember flushes pending offsets for multiline inline\n // containers, so the post-removal fixup below can no longer measure\n // the original end-to-bracket gap from the container's own loc (fuzz\n // seed 10469).\n const bracketGapBefore =\n isInlineItem(node) && (isInlineArray(parent) || isInlineTable(parent)) &&\n node.loc.end.line === parent.loc.end.line\n ? parent.loc.end.column - node.loc.end.column\n : undefined;\n // Absolute lookup path of the node (or its inner KV for InlineItems),\n // captured while it is still in the tree — the materialisation block\n // below runs AFTER the removal and needs it to derive the emptied\n // parent's prefix relative to an inline-table container (seed 128).\n const nodeAbsolutePath = absolutePathOf(\n isInlineItem(node) && isKeyValue(node.item) ? node.item : node\n );\n\n // When the probe path matched a dotted key by PREFIX (the key is\n // longer than the path), removing only that KV leaves the key's\n // other segments behind. E.g. deleting `l` when the CST holds\n // `l.l` and `l.utc.xme7` must remove both, or the re-parse revives\n // `l` from the surviving sibling (fuzz seed 2926).\n const removePrefixKv = isKeyValue(node)\n ? node as KeyValue\n : isInlineItem(node) && isKeyValue(node.item)\n ? node.item as KeyValue\n : undefined;\n if (removePrefixKv && nodeAbsolutePath && hasItems(parent)) {\n const stringNodePath = nodeAbsolutePath.filter(\n (segment): segment is string => typeof segment === 'string'\n );\n const containerAbsLen = stringNodePath.length - removePrefixKv.key.value.length;\n const relativePrefix = change.path\n .filter((segment): segment is string => typeof segment === 'string')\n .slice(containerAbsLen) as Path;\n if (relativePrefix.length > 0 && relativePrefix.length < removePrefixKv.key.value.length) {\n const siblings = (parent as { items: TreeNode[] }).items;\n // Collect matches first, then remove by identity: removeMember\n // splices the live array (member + its leading comments), so\n // mutating it inside the scan loop corrupts the indices.\n // Table/TableArray sections extending the same prefix count too —\n // a root `\"\"` holds both `\"\".x = 1` and `[[\"\".y]]` (fuzz seed 3392).\n const toRemove: TreeNode[] = [];\n for (const sibling of siblings) {\n if (sibling === node) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isInlineItem(sibling) && isKeyValue(sibling.item)\n ? sibling.item.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length > relativePrefix.length\n && arraysEqual(siblingKey.slice(0, relativePrefix.length), relativePrefix)) {\n toRemove.push(sibling);\n }\n }\n for (const sibling of toRemove) {\n removeMember(original, parent, sibling);\n }\n removeDocumentItemsExtendingPath(original, change.path, node);\n }\n }\n\n // When a key at this path is removed outright (the path exactly\n // matches the node's key), any sibling whose key EXTENDS this prefix\n // (a longer dotted key or a [table]/[[array]] section) re-defines\n // the key on re-parse. E.g. `q = <date>` alongside `q.\"X\".y = true`\n // and `[q.\"Z\"]` (a leniently-accepted collision) leaves those\n // extensions behind when only `q = <date>` is removed, and the\n // re-parse revives `q` as a table (fuzz seed 79938). Drop them too.\n if (removePrefixKv && nodeAbsolutePath && hasItems(parent)) {\n const key = removePrefixKv.key.value;\n const siblings = (parent as { items: TreeNode[] }).items;\n const extending: TreeNode[] = [];\n for (const sibling of siblings) {\n if (sibling === node) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isInlineItem(sibling) && isKeyValue(sibling.item)\n ? sibling.item.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length > key.length\n && arraysEqual(siblingKey.slice(0, key.length), key)) {\n extending.push(sibling);\n }\n }\n for (const sibling of extending) {\n removeMember(original, parent, sibling);\n }\n }\n\n // Same repair for a removed SECTION header ([table]/[[array]]). When\n // `[x]` is deleted while a sibling `[[x.y]]` (or `x.z = …`) still\n // extends the `x` prefix, removing only the header leaves the section\n // behind and the re-parse revives `x` from it (fuzz seed 136292).\n if ((isTable(node) || isTableArray(node)) && hasItems(parent)) {\n const key = (node as Table | TableArray).key.item.value;\n const siblings = (parent as { items: TreeNode[] }).items;\n const extending: TreeNode[] = [];\n // A sub-table belongs to the nearest [[x]] entry above it, so an\n // entry owns only the siblings up to the next entry of its own\n // array or of an ancestor array ([[x]] ends an [[x.y]] entry too).\n const nodeIndex = siblings.indexOf(node);\n let aotOwner: TableArray | undefined;\n if (isTableArray(node)) {\n aotOwner = node;\n } else {\n for (let i = nodeIndex - 1; i >= 0; i--) {\n const sibling = siblings[i];\n if (!isTableArray(sibling)) continue;\n const siblingKey = sibling.key.item.value;\n if (key.length > siblingKey.length && arraysEqual(key.slice(0, siblingKey.length), siblingKey)) {\n aotOwner = sibling;\n break;\n }\n }\n }\n const aotEntry = aotOwner !== undefined;\n const ownStart = aotOwner ? siblings.indexOf(aotOwner) : nodeIndex;\n let ownEnd = siblings.length;\n if (aotEntry) {\n const ownerKey = aotOwner!.key.item.value;\n for (let i = ownStart + 1; i < siblings.length; i++) {\n const s = siblings[i];\n if (!isTableArray(s)) continue;\n const sKey = s.key.item.value;\n if (sKey.length <= ownerKey.length && arraysEqual(sKey, ownerKey.slice(0, sKey.length))) {\n ownEnd = i;\n break;\n }\n }\n }\n for (const [index, sibling] of siblings.entries()) {\n if (sibling === node) continue;\n if (aotEntry && (index < ownStart || index >= ownEnd)) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length > key.length\n && arraysEqual(siblingKey.slice(0, key.length), key)) {\n extending.push(sibling);\n }\n }\n for (const sibling of extending) {\n removeMember(original, parent, sibling);\n }\n }\n\n // A dotted key inside an AOT entry can prefix-match the removed path\n // while deeper sub-tables for the same path remain as document-level\n // siblings. Remove those sections from the owning entry's scope too.\n if (removePrefixKv && nodeAbsolutePath) {\n const owner = isTableArray(parent) ? parent : findAotEntryForPath(original, change.path);\n if (owner) {\n const cstPrefix = stripAotEntryIndices(original, change.path);\n const scopedSections = findAotScopedDocumentItems(original, cstPrefix, owner)\n .filter(item => item !== node && (isTable(item) || isTableArray(item)))\n .filter(item => keyStartsWith(itemKey(item), cstPrefix));\n for (const section of scopedSections) {\n removeMember(original, original, section);\n }\n }\n }\n\n if (!materialisedInPlace) {\n removeMember(original, parent, node);\n }\n\n // Removing the LAST item of a single-line inline container while an\n // earlier edit left a pending exit offset on the new last item makes\n // the writer's column arithmetic go stale: the container's end (and\n // thus the closing bracket) ends up inside the surviving item's span\n // (fuzz seed 3780: `[[], true, -3125, 755_394]` edited and truncated\n // emitted `-312,` with `]` eating the last digit). Flush the pending\n // offsets, then fix the end from the surviving item, preserving the\n // original gap to the bracket.\n // The same hazard applies to a MULTILINE container when the removed\n // item ends on the bracket row: the bracket slides before the\n // surviving tail (fuzz seed 10469).\n if (isInlineItem(node) && (isInlineArray(parent) || isInlineTable(parent)) &&\n node.loc.end.line === parent.loc.end.line) {\n const remaining = (parent as InlineArray | InlineTable).items as TreeNode[];\n const isSingleLineContainer = parent.loc.end.line === parent.loc.start.line;\n // Only for the LAST item. For a single-line container the whole\n // remaining content must be single-line: a multiline child (e.g. a\n // multiline string) keeps its own lines below the container's\n // line, and the column fixup would corrupt that layout (fuzz seed\n // 1841). For a multiline container only the bracket-row tail\n // matters — earlier items sit on their own lines above.\n const tailOnBracketRow = isSingleLineContainer\n ? remaining.every(item => item.loc.end.line === parent.loc.start.line)\n : remaining.length > 0 && last(remaining)!.loc.end.line === parent.loc.end.line;\n if (remaining.length > 0 && containerItemIndex === remaining.length &&\n tailOnBracketRow) {\n // For a multiline container the pending offsets were already\n // flushed by removeMember, so the container's end is stale and\n // the gap must come from the pre-removal capture (fuzz seed\n // 10469); the single-line path still measures live.\n const gap = bracketGapBefore ?? (parent.loc.end.column - node.loc.end.column);\n applyWrites(original);\n const targetEnd = last(remaining)!.loc.end.column + gap;\n if (parent.loc.end.column !== targetEnd) {\n parent.loc.end.column = targetEnd;\n }\n // The owning KV's end mirrors the value's end; without it the\n // KV's own row comma (inside an enclosing inline table) is\n // written at the stale column, overwriting the value's tail.\n let owner: KeyValue | undefined;\n const findOwner = (n: TreeNode): KeyValue | undefined => {\n if (isKeyValue(n)) {\n if (n.value === parent) return n;\n return findOwner(n.value);\n }\n if (isInlineItem(n)) return findOwner(n.item);\n if (!hasItems(n)) return undefined;\n for (const item of n.items as TreeNode[]) {\n const found = findOwner(isInlineItem(item) ? item.item : item);\n if (found) return found;\n }\n return undefined;\n };\n owner = findOwner(original);\n if (owner && owner.loc.end.line === parent.loc.end.line) {\n owner.loc.end.column = parent.loc.end.column;\n // The InlineItem row wrapping the KV carries the row's comma;\n // its end must track the KV's end too.\n const findWrapper = (n: TreeNode): InlineItem | undefined => {\n if (isKeyValue(n)) return findWrapper(n.value);\n if (isInlineItem(n)) {\n if (n.item === owner) return n;\n return findWrapper(n.item);\n }\n if (!hasItems(n)) return undefined;\n for (const item of n.items as TreeNode[]) {\n const found = findWrapper(item);\n if (found) return found;\n }\n return undefined;\n };\n const wrapper = findWrapper(original);\n if (wrapper) {\n // Register the row's growth as an exit offset so the next\n // row of the enclosing table shifts past the comma+space,\n // and resolve it immediately — the earlier flush cleared\n // the dirty flag, so the final applyWrites would skip it.\n const delta = parent.loc.end.column - wrapper.loc.end.column;\n wrapper.loc.end.column = parent.loc.end.column;\n if (delta !== 0) {\n addExitOffset(original, wrapper, { lines: 0, columns: delta });\n markDirty(original);\n applyWrites(original);\n }\n }\n }\n }\n }\n\n // When removing a node whose key has an implicit parent, check whether\n // the parent should survive as an empty table header. Table nodes are\n // handled in-place above; only TableArray falls through to generate+insert.\n if (!materialisedInPlace &&\n change.path.length > 1 && (isTable(node) || isTableArray(node)) && rawUpdated !== undefined) {\n const parentPath = change.path.slice(0, -1);\n // `change.path` is in JS-object coordinates, which interleave a\n // numeric AOT entry index after the AOT key (e.g. `[\"\", 0, \"fv\"]`\n // for the CST key `[\"\", \"fv\"]`). The sibling scan and generated\n // header must use the CST key (no index), else the index leaks into\n // the header as `[\"\".0.fv]` and the re-parse nests `fv` under a key\n // literally named \"0\" (fuzz seed 1020868). The value walk below\n // keeps the JS coordinates.\n const cstParentKey = (node as Table | TableArray).key.item.value.slice(0, -1);\n const remainingSiblings = findDocumentItemsByKeyPrefix(original, cstParentKey);\n if (remainingSiblings.length === 0) {\n let value: any = rawUpdated;\n for (const k of parentPath) value = value?.[k];\n if (isObject(value) && Object.keys(value).length === 0) {\n const emptyTable = generateTable(cstParentKey as string[], format.escapeSequenceUpperCase);\n materialisedTables.add(emptyTable);\n // Insert at the original position so preceding comments\n // stay adjacent without a spurious blank line. Clamp to the\n // post-removal length — a stale last-item index strands the\n // generated header at its (1,0) origin (fuzz seed 11605).\n const insertIdx = nodeIndex >= 0\n ? Math.min(nodeIndex, original.items.length)\n : original.items.length;\n // Resolve the removal's pending offsets first — an insert at\n // index 0 otherwise absorbs the document's enter offset and\n // lands above line 1 (fuzz seed 1172).\n applyWrites(original);\n insert(original, original, emptyTable, insertIdx);\n }\n }\n }\n\n // Dotted-key KeyValues follow the same implicit-parent materialisation\n // rule: when removing the last segment of a dotted key (e.g. y.ic83\n // → y), and no other items share the parent prefix, materialise the\n // parent as an empty table header (or empty inline table, for dotted\n // keys inside an inline table) so the key isn't silently dropped.\n if (!materialisedInPlace && change.path.length > 1 && rawUpdated !== undefined) {\n const kv = isKeyValue(node)\n ? node as KeyValue\n : isInlineItem(node) && isKeyValue(node.item)\n ? node.item as KeyValue\n : undefined;\n // Only for dotted keys with 2+ segments.\n if (kv && kv.key.value.length > 1) {\n const parentPath = change.path.slice(0, -1);\n // Search the node's own container (Table / Document / AOT entry /\n // InlineTable) for remaining siblings whose key starts with the\n // parent prefix.\n const container = isDocument(parent) || isTable(parent) || isTableArray(parent) || isInlineTable(parent)\n ? parent\n : original;\n if (hasItems(container)) {\n // The prefix relative to the container: strip the container's own\n // key from the path. For an AOT entry the numeric entry index is\n // also stripped. Deriving it from parentPath (not kv.key.value)\n // matters when a middle segment of the dotted key was removed\n // (e.g. deleting `booay` from `6U.booay.o563zkr` must leave the\n // prefix `6U`, not `6U.booay` — fuzz seed 128).\n let relativePrefix: string[];\n if (isTable(container) || isTableArray(container)) {\n // Strip the container's own key from parentPath, skipping\n // any numeric AOT entry indexes that appear between its\n // segments — the absolute path of a table nested inside an\n // array-of-tables entry interleaves them (e.g. [y, 0, sl4,\n // m{sHnZ, vk] against the container key [y, sl4, m{sHnZ]),\n // and slicing by the key length alone leaves the extra\n // segment behind (fuzz seed 10533).\n const containerKey = (container as Table | TableArray).key.item.value;\n let offset = 0;\n let matched = 0;\n for (let k = 0; k < containerKey.length && offset < parentPath.length; k++) {\n while (offset < parentPath.length && typeof parentPath[offset] === 'number') offset++;\n if (offset >= parentPath.length || parentPath[offset] !== containerKey[k]) break;\n matched++;\n offset++;\n }\n while (offset < parentPath.length && typeof parentPath[offset] === 'number') offset++;\n if (matched === containerKey.length) {\n relativePrefix = parentPath.slice(offset) as string[];\n } else {\n // Fall back to the historical key-length slice.\n relativePrefix = parentPath.slice(\n containerKey.length + (isTableArray(container) ? 1 : 0)\n ) as string[];\n }\n } else if (isInlineTable(container)) {\n // InlineTable items are relative to the table itself; the\n // table's own key path is the node's absolute path minus its\n // key segments (captured before the removal). But the change\n // coordinates (`parentPath`) can interleave a numeric AOT\n // entry index that the CST path lacks — the JS object sees\n // `[\"\"]` as an array-of-tables (so `obj[\"\"].o96` -> path\n // `[\"\", 0, \"o96\", …]`) while the CST stores `o96` as a\n // sibling `[\"\".\"o96\"]` table (absolute path `[\"\", \"o96\", …]`).\n // Slicing parentPath by the CST length then over-includes the\n // enclosing segment and re-emits `GD64qOzFQn.x = {}` instead\n // of `x = {}` (fuzz seed 224081). Align by skipping numeric\n // indices while matching the container's string segments.\n if (nodeAbsolutePath) {\n const containerSegs = nodeAbsolutePath.slice(0, nodeAbsolutePath.length - kv.key.value.length);\n let offset = 0;\n let matched = 0;\n while (matched < containerSegs.length && offset < parentPath.length) {\n while (offset < parentPath.length && typeof parentPath[offset] === 'number') offset++;\n if (offset >= parentPath.length || parentPath[offset] !== containerSegs[matched]) break;\n matched++;\n offset++;\n }\n while (offset < parentPath.length && typeof parentPath[offset] === 'number') offset++;\n if (matched === containerSegs.length) {\n relativePrefix = parentPath.slice(offset) as string[];\n } else {\n relativePrefix = parentPath.slice(containerSegs.length) as string[];\n }\n } else {\n relativePrefix = parentPath.slice(parentPath.length - (kv.key.value.length - 1)) as string[];\n }\n } else {\n relativePrefix = parentPath as string[];\n }\n // `relativePrefix` is a TOML key path. `parentPath` comes from\n // JS-object coordinates and can include array indices (numbers),\n // which must never be emitted as key segments.\n relativePrefix = relativePrefix.filter((seg): seg is string => typeof seg === 'string');\n const remaining = (container.items as TreeNode[]).filter(item => {\n const key = isKeyValue(item)\n ? (item as KeyValue).key.value\n : isInlineItem(item) && isKeyValue(item.item)\n ? item.item.key.value\n : undefined;\n if (!key) return false;\n return arraysEqual(key.slice(0, relativePrefix.length), relativePrefix);\n });\n // An AOT entry can also own sub-tables stored as document-level\n // siblings whose keys extend the entry's own key.\n const isAotEntry = isTableArray(container);\n let docSiblings: TreeNode[] = [];\n if (isAotEntry && remaining.length === 0) {\n docSiblings = findAotScopedDocumentItems(\n original,\n (container as TableArray).key.item.value.concat(relativePrefix),\n container as TableArray\n );\n }\n // When the removed dotted key sits directly inside an explicit\n // [table] (or [[entry]]) header, that header already IS the\n // materialised parent — generating another one duplicates it\n // and the re-parse fails with \"Table already defined\" (fuzz\n // seed 1098). Nothing to do; the emptied header stays.\n // Same for an inline table: when the parent prefix equals the\n // inline table's own key, the (now empty) inline table already\n // renders the emptied object — re-emitting an empty key would\n // parse `${''} = {}` and crash (fuzz seed 2726).\n const containerAlreadyIsParent =\n relativePrefix.length === 0 &&\n (isTable(container) || isTableArray(container) || isInlineTable(container));\n if (remaining.length === 0 && docSiblings.length === 0 && !containerAlreadyIsParent) {\n let value: any = rawUpdated;\n for (const k of parentPath) value = value?.[k];\n if (isObject(value) && Object.keys(value).every(key => value[key] === undefined)) {\n if (isInlineTable(container)) {\n // Emptied dotted prefix inside an inline table: re-emit it\n // as `prefix = {}` at the removed item's position, keeping\n // the comma setting the removed item carried (fuzz seed 22).\n // parseJS strips empty objects, so regenerateValue() can't\n // build the value — parse a literal instead, which yields\n // proper single-line locs for the empty inline table.\n const freshKey = relativePrefix\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const freshKv = Array.from(parseTOML(`${freshKey} = {}`))[0];\n if (isKeyValue(freshKv)) {\n const inlineItem = generateInlineItem(freshKv);\n inlineItem.comma = removedInlineComma ?? false;\n // The removal above left a pending enter offset on the\n // inline table (first-item removals register there),\n // which applyWrites would apply to the new item too.\n // Resolve it first so the insert positions the item\n // against final coordinates (fuzz seed 22).\n applyWrites(original);\n // The container was a MULTILINE inline table whose only\n // item (a multiline dotted key) was just removed: the\n // removal zeroed its line offset but left a stale\n // multiline end line, so insert() would place the new\n // `prefix = {}` on a phantom second line and the\n // enclosing table's trailing siblings would be pulled\n // inside this one (fuzz seed 863085). Collapse the end\n // to the bracket row first, mirroring the Add handler\n // (fuzz seed 272851).\n if (hasInlineContainerNeedingTighten(container) &&\n container.loc.end.line > container.loc.start.line) {\n container.loc.end.line = container.loc.start.line;\n }\n insert(original, container, inlineItem, containerItemIndex >= 0 ? containerItemIndex : undefined);\n // insert() reserves one column for the opening-brace\n // space; with bracket spacing enabled that column is\n // already the space after `{`, so align the item with\n // the original bracket style.\n if (format.bracketSpacing) {\n shiftNode(inlineItem, { lines: 0, columns: 1 });\n }\n // An earlier materialisation in the same batch can\n // occupy the removed row's original slot, so the new\n // row starts LATER than the removed one and insert()'s\n // exit offset (span + separator, folded against the\n // previous row's pending offsets) no longer puts the\n // tail rows exactly after it. Re-derive the exact\n // displacement to just past the new row's comma.\n const tailRow = (container as InlineTable).items[containerItemIndex + 1] as TreeNode | undefined;\n const pendingInsertOffset = getExitOffsets(original).get(inlineItem);\n if (tailRow && pendingInsertOffset && tailRow.loc.start.line === inlineItem.loc.end.line) {\n pendingInsertOffset.columns = inlineItem.loc.end.column + 2 - tailRow.loc.start.column;\n }\n }\n return;\n }\n // A dotted-key parent inside a block table remains a value\n // in that table, so preserve it as an empty inline table.\n // Explicit table sections are handled above and remain\n // headers when their contents are removed.\n if (isTable(container) || isTableArray(container)) {\n const freshKey = relativePrefix\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const freshKv = Array.from(parseTOML(`${freshKey} = {}`))[0];\n if (isKeyValue(freshKv)) {\n applyWrites(original);\n const insertIndex = containerItemIndex >= 0\n ? Math.min(containerItemIndex, container.items.length)\n : container.items.length;\n const leadingLines = container.items.length === 0 && isTable(container) ? 0 : undefined;\n insert(original, container, freshKv, insertIndex, undefined, undefined, leadingLines);\n }\n return;\n }\n\n // Table key: container key + relative prefix. For a root\n // KV that's just the relative prefix.\n const tableKey = isAotEntry\n ? (container as TableArray).key.item.value.concat(relativePrefix)\n : relativePrefix;\n const emptyTable = generateTable(tableKey as string[], format.escapeSequenceUpperCase);\n materialisedTables.add(emptyTable);\n let insertIdx = nodeIndex >= 0 ? nodeIndex : original.items.length;\n if (isAotEntry) {\n // Insert right after the entry so the sub-table stays in\n // the entry's scope.\n const entryIdx = (original.items as TreeNode[]).indexOf(container);\n insertIdx = entryIdx >= 0 ? entryIdx + 1 : original.items.length;\n } else if (isTable(container)) {\n // Same hazard for a [table] container: a sub-table header\n // appended at the document end can be pulled up into the\n // parent's rows by a later removal's exit offset, and the\n // header then captures those rows (fuzz seed 4402).\n // Insert directly after the parent so the header stays\n // below the parent's own rows.\n const parentIdx = (original.items as TreeNode[]).indexOf(container);\n insertIdx = parentIdx >= 0 ? parentIdx + 1 : original.items.length;\n } else if (isDocument(container)) {\n // Root-scope materialisation: a [table] header claims every\n // key-value below it, so it must land after all root KVs —\n // before the first existing section, or at the very end —\n // never at the removed KV's index (fuzz seed 11).\n insertIdx = rootKeyValueInsertIndex(original) ?? original.items.length;\n }\n // The removal above registered its line/column offset on\n // the parent (or a preceding item). insert() measures\n // against sibling locs, not pending offsets, so an insert\n // at index 0 would absorb the document's pending enter\n // offset and land above line 1 (fuzz seed 1028). Resolve\n // first, like every other just-in-time flush in this file.\n applyWrites(original);\n insert(original, original, emptyTable, insertIdx);\n }\n }\n }\n }\n }\n\n // Track AOT keys whose entries may have been fully removed — again only when the\n // caller still wants the key, so deleting it outright doesn't bring it back as `[]`.\n if (isTableArray(node)) {\n const aotPath = change.path.slice(0, -1);\n const stillExists = tryFindByPath(original, aotPath.concat(0));\n if (!stillExists && tryFindByPath(updated, aotPath)) {\n emptiedAotKeys.set(stableStringify(aotPath), aotPath);\n }\n }\n }\n } else if (isMove(change)) {\n // A document-level object Move has path === [] — tryFindByPath resolves an empty path\n // to `original` itself, which has items, so this check MUST come first or every\n // document-level key reorder would fall into the array-Move handling below instead.\n if (change.key !== undefined) {\n objectMoves.push(change);\n return;\n }\n\n let parent = tryFindByPath(original, change.path);\n if (parent) {\n if (hasItem(parent)) parent = parent.item;\n if (isKeyValue(parent)) parent = parent.value;\n\n // A Move's from/to are simulation coordinates from the diff walk;\n // when an in-place Remove earlier in the same array was reordered\n // ahead of it, the source index can be past the array's end. The\n // remaining elements are already in place then — the move is a\n // simulation artifact and must be skipped (fuzz seed 8138).\n if (change.from >= (parent as WithItems).items.length) return;\n\n const node = (parent as WithItems).items[change.from];\n\n moveInlineElement(original, parent, node, change.to);\n } else {\n // TableArray sequence: the path refers to a collection of [[name]] entries\n // spread across Document.items (each at an indexed sub-path).\n //\n // First, normalize: the parser's table-body loop consumes comments\n // between consecutive [[x]] entries as trailing children of the first\n // entry. Promote those to Document-level siblings and fix up loc.end\n // so resolveGroups assigns them to the correct entry.\n normalizeAotEntryComments(original);\n\n // Find source entry.\n const fromNode = findByPath(original, change.path.concat(change.from));\n\n // Move the entire group (entry + its comments) as a single unit.\n const docGroups = resolveGroups(original);\n const fromGroup = docGroups.find(s => s.member === fromNode);\n const groupItems = fromGroup ? [...fromGroup.items] : [fromNode];\n\n // Save original positions before removal so we can restore spacing.\n const groupOriginalPos = groupItems.map(item => ({\n startLine: item.loc.start.line,\n endLine: item.loc.end.line\n }));\n\n // Record original position of the document item just after the group,\n // for exit-offset compensation after insertion.\n const groupFirstIdx = original.items.indexOf((fromGroup ? fromGroup.items[0] : fromNode) as any);\n\n // Also compute the original gap between the last group item and\n // whatever comes after it in line order, for exit-offset compensation.\n const lastGroupEnd = groupOriginalPos[groupOriginalPos.length - 1].endLine;\n let originalAfterGap: number | undefined;\n for (let k = 0; k < original.items.length; k++) {\n const item = original.items[k];\n if (item.loc.start.line > lastGroupEnd) {\n originalAfterGap = item.loc.start.line - lastGroupEnd;\n break;\n }\n }\n // If no item follows in line order (group was at document end),\n // use the gap from the item just before the group to the first\n // group item — this is the spacing between the two entries that\n // should be preserved between the moved entry and what follows.\n if (originalAfterGap === undefined && groupFirstIdx > 0) {\n const beforeGroup = original.items[groupFirstIdx - 1];\n originalAfterGap = groupOriginalPos[0].startLine - beforeGroup.loc.end.line;\n }\n\n // Remove each group item from the Document (same discipline as removeMember).\n const memberIdx = fromGroup ? fromGroup.items.indexOf(fromNode) : 0;\n for (let i = 0; i <= memberIdx; i++) {\n if (!(original.items as TreeNode[]).includes(groupItems[i])) continue;\n remove(original, original, groupItems[i]);\n }\n for (let i = memberIdx + 1; i < groupItems.length; i++) {\n const idx = (original.items as TreeNode[]).indexOf(groupItems[i]);\n if (idx >= 0) (original.items as TreeNode[]).splice(idx, 1);\n }\n\n // Find insertion point. Use tryFindByPath to locate the target member.\n // If BOTH source and target groups have leading comments, insert before\n // the target group's first item so the comments stay with their members\n // after the swap. Otherwise use the member's own index.\n const toEntry = tryFindByPath(original, change.path.concat(change.to));\n let toIndex: number;\n let targetHasLeadingComment = false;\n const sourceHadLeadingComment = fromGroup && fromGroup.items[0] !== fromNode && isComment(fromGroup.items[0]);\n if (toEntry) {\n const postGroups = resolveGroups(original);\n const targetGroup = postGroups.find(s => s.member === toEntry);\n targetHasLeadingComment = !!(targetGroup && targetGroup.items[0] !== toEntry && isComment(targetGroup.items[0]));\n if (targetHasLeadingComment && sourceHadLeadingComment) {\n toIndex = original.items.indexOf(targetGroup!.items[0] as any);\n } else {\n toIndex = original.items.indexOf(toEntry as any);\n }\n } else {\n toIndex = original.items.length;\n }\n\n // Capture the original gap at the target position so we can\n // reproduce it for the first group item.\n const targetPrevEnd = toIndex > 0\n ? original.items[toIndex - 1].loc.end.line\n : 0;\n const targetFirstLine = toIndex < original.items.length\n ? original.items[toIndex].loc.start.line\n : undefined;\n\n // Insert group items in forward order at incrementing indices.\n // Compute leadingLines from the original spacing so blank lines\n // are preserved exactly as they were in the source document.\n // Only override when both groups have leading comments (a true swap\n // of commented entries); otherwise let insertOnNewLine decide.\n const isCommentedSwap = targetHasLeadingComment && sourceHadLeadingComment;\n let insertIdx = toIndex;\n for (let i = 0; i < groupItems.length; i++) {\n const item = groupItems[i];\n\n let itemLeadingLines: number | undefined;\n // Override leadingLines when the original spacing differs from\n // insert()'s defaults. This applies when:\n // a) Both groups have leading comments (a commented swap), or\n // b) The source has comments and a pinned comment sits right\n // before the insertion point (mixed blank lines case).\n const shouldOverride = isCommentedSwap || (sourceHadLeadingComment && toIndex > 0 && toIndex < original.items.length);\n if (shouldOverride && insertIdx > 0) {\n const prevEnd = i === 0 ? targetPrevEnd : groupOriginalPos[i - 1].endLine;\n const origLeading = (i === 0 && targetFirstLine !== undefined)\n ? targetFirstLine - targetPrevEnd\n : groupOriginalPos[i].startLine - prevEnd;\n const isSquare = isTable(item) || isTableArray(item);\n const defaultLeading = isSquare ? 2 : 1;\n if (origLeading !== defaultLeading) {\n itemLeadingLines = origLeading;\n }\n }\n\n insert(original, original, item, insertIdx, undefined, undefined, itemLeadingLines);\n insertIdx++;\n }\n\n // Restore the original gap between the last group item and the\n // next document item, since overriding leadingLines changes the\n // exit offset and may misposition subsequent items.\n if (originalAfterGap !== undefined) {\n applyWrites(original);\n const lastItem = groupItems[groupItems.length - 1];\n const afterStart = original.items.indexOf(lastItem as any) + 1;\n if (afterStart < original.items.length) {\n const nextItem = original.items[afterStart];\n const newGap = nextItem.loc.start.line - lastItem.loc.end.line;\n const delta = originalAfterGap - newGap;\n if (delta !== 0) {\n for (let j = afterStart; j < original.items.length; j++) {\n shiftNode(original.items[j], { lines: delta, columns: 0 });\n }\n }\n }\n }\n }\n } else if (isRename(change)) {\n const sourcePath = change.path.concat(change.from);\n let parent = tryFindByPath(original, sourcePath) as\n | KeyValue\n | Table\n | TableArray\n | InlineItem<KeyValue>\n | undefined;\n\n // When renaming a prefix segment of a dotted table key (e.g. the \"a\" in\n // [a.b] → [x.b]), the source path [\"a\"] does not match the table's full key\n // [\"a\",\"b\"]. Fall back to a key-prefix search so rename can update just the\n // matching segment in place.\n if (!parent) {\n const prefixNodes = findDocumentItemsByKeyPrefix(original, sourcePath);\n if (prefixNodes.length === 1 && (isTable(prefixNodes[0]) || isTableArray(prefixNodes[0]))) {\n const node = prefixNodes[0] as Table | TableArray;\n const keyHolder = node.key;\n const key = hasItem(keyHolder) ? keyHolder.item : keyHolder;\n const segmentIndex = sourcePath.length - 1;\n const originalRaw = key.raw;\n key.value[segmentIndex] = change.to;\n key.raw = preserveEscapedKeyRaw(key.raw, key.value, format.escapeSequenceUpperCase);\n preserveDottedKeySpacing(key, originalRaw);\n key.loc.end.column = key.loc.start.column + key.raw.length;\n return; // skip the rest of rename logic for this change\n }\n }\n\n if (!parent) parent = findByPath(original, sourcePath) as KeyValue | Table | TableArray | InlineItem<KeyValue>;\n let replacement = findByPath(updated, change.path.concat(change.to)) as\n | KeyValue\n | Table\n | TableArray\n | InlineItem<KeyValue>;\n\n if (hasItem(parent)) parent = parent.item;\n if (hasItem(replacement)) replacement = replacement.item;\n\n // A KeyValue holds its Key directly, while a [table]/[[array]] wraps it in a\n // TableKey/TableArrayKey. Reach the inner Key either way — reading `.key.value` off a\n // section gives undefined, which used to make preserveEscapedKeyRaw throw on `.map`.\n const parentHolder = parent.key;\n const replacementHolder = replacement.key;\n const parentKey = hasItem(parentHolder) ? parentHolder.item : parentHolder;\n const replacementKey = hasItem(replacementHolder) ? replacementHolder.item : replacementHolder;\n\n // Both sides must describe the same shape of key. parseJS can render the replacement\n // as a plain nested key — `z` inside `[a]` — where the document holds a dotted section\n // header `[a.b]`, and swapping one node for the other would silently drop the `a.`\n // prefix, emitting `[z]`. Refuse instead: these shapes threw before this branch\n // understood sections at all, and a clear failure beats a corrupted document.\n if (parentKey.value.length !== replacementKey.value.length) {\n const fullSourcePath = change.path.concat(change.from);\n // When the existing node is a Table/TableArray whose key shares a prefix with\n // change.path + change.from, and the replacement is a plain KeyValue, we're\n // renaming one segment of a dotted section header rather than replacing the\n // whole key (e.g. [a.b] -> [a.y]). Rename just the matching segment in place.\n if ((isTable(parent) || isTableArray(parent)) &&\n isKeyValue(replacement) &&\n arraysEqual(parentKey.value.slice(0, fullSourcePath.length), fullSourcePath)) {\n const segmentIndex = fullSourcePath.length - 1;\n const originalRaw = parentKey.raw;\n parentKey.value[segmentIndex] = change.to;\n parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value, format.escapeSequenceUpperCase);\n preserveDottedKeySpacing(parentKey, originalRaw);\n parentKey.loc.end.column = parentKey.loc.start.column + parentKey.raw.length;\n return;\n }\n\n // Same situation for a dotted KeyValue: renaming the last segment of\n // `y3.mklbjj.kb16my_18h` to `k30` renames just that segment — the KV\n // keeps the `y3.mklbjj` prefix (fuzz seed 3214).\n if (isKeyValue(parent) && isKeyValue(replacement) &&\n parentKey.value.length <= fullSourcePath.length &&\n arraysEqual(parentKey.value, fullSourcePath.slice(fullSourcePath.length - parentKey.value.length))) {\n const oldKeyRaw = parentKey.raw;\n parentKey.value[parentKey.value.length - 1] = change.to;\n parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value, format.escapeSequenceUpperCase);\n parentKey.loc.end.column = parentKey.loc.start.column + parentKey.raw.length;\n // The `=` position lives on the KeyValue, not the Key, and the value\n // keeps its own columns. A rename that GROWS the last segment widens\n // the key past `equals`, so both `equals` and the value must shift\n // right, or the value overwrites the `=` and emits `aca9djz.k75 true`\n // with no separator (fuzz seed 46522). A rename that SHRINKS the key\n // leaves `equals` where it was — the gap fills with the alignment\n // spaces the document already had (fuzz seed 3214 expects this).\n const keyWidthDelta = parentKey.raw.length - oldKeyRaw.length;\n if (keyWidthDelta > 0) {\n parent.equals += keyWidthDelta;\n shiftNode(parent.value, { lines: 0, columns: keyWidthDelta }, { first_line_only: true });\n // The width change also pushes the enclosing inline container's\n // end (and the closing bracket) right, plus anything a later\n // same-patch change inserts next to it. shiftNode only moves the\n // value node itself; register an exit offset so applyWrites shifts\n // the container end and a subsequent Add measures the settled\n // position — otherwise the tail lands on the value's last\n // character (`false` -> `fals`, fuzz seed 186384).\n addExitOffset(original, parent.value, { lines: 0, columns: keyWidthDelta });\n }\n return;\n }\n\n throw new Error(\n `Cannot rename \"${parentKey.raw}\" to \"${replacementKey.raw}\": the replacement key has ` +\n `${replacementKey.value.length} segment(s) where the existing key has ` +\n `${parentKey.value.length}, so one cannot be substituted for the other.`\n );\n }\n\n // Preserve key escape style from the original key raw when renaming.\n // Example: if the original key used \"\\\\u263A\", keep that escape form\n // instead of normalizing to the raw character (☺).\n replacementKey.raw = preserveEscapedKeyRaw(parentKey.raw, replacementKey.value, format.escapeSequenceUpperCase);\n preserveDottedKeySpacing(replacementKey, parentKey.raw);\n replacementKey.loc.end.column = replacementKey.loc.start.column + replacementKey.raw.length;\n\n // Hand replace() whichever node actually owns the Key. For a section that is the\n // TableKey wrapper: a Table's own `.items` are its rows, so passing the Table would\n // send replace() looking for the key in the wrong array.\n const keyOwner = hasItem(parentHolder) ? parentHolder : parent;\n replace(original, keyOwner, parentKey, replacementKey);\n }\n });\n\n applyWrites(original);\n\n // Fix up blank lines between comments and materialised tables. During\n // implicit-parent materialisation the table is renamed in place; after\n // applyWrites a spurious blank line can appear between a preceding comment\n // and the table header. Only fix tables tracked during this patch.\n for (let i = 1; i < (original.items as TreeNode[]).length; i++) {\n const prev = original.items[i - 1];\n const curr = original.items[i];\n if (isComment(prev) && isTable(curr) && materialisedTables.has(curr)) {\n const gap = curr.loc.start.line - prev.loc.end.line - 1;\n if (gap > 0) {\n shiftNode(curr, { lines: -gap, columns: 0 });\n }\n }\n }\n\n // Fix up blank lines after empty tables. Removing items from a table can\n // leave the offset chain short by one line (the last removal's contribution\n // is zeroed). Close the extra gap to the next section so only one blank line\n // separates them.\n const rootItems = original.items as TreeNode[];\n for (let i = 0; i < rootItems.length - 1; i++) {\n const curr = rootItems[i];\n const next = rootItems[i + 1];\n if ((isTable(curr) || isTableArray(curr)) && curr.items.length === 0\n && (isTable(next) || isTableArray(next))) {\n const gap = next.loc.start.line - curr.loc.end.line - 1;\n if (gap > 1) {\n const delta = 1 - gap;\n for (let j = i + 1; j < rootItems.length; j++) {\n shiftNode(rootItems[j], { lines: delta, columns: 0 });\n }\n }\n }\n }\n\n // Fix up InlineTables and InlineArrays that lost their only item to\n // remove(). The exit offset that carried the closing-bracket space was\n // on the removed item and is now lost. Tighten the end column and\n // reapply bracket spacing.\n //\n // Resolve pending offsets BEFORE measuring: an earlier edit may have left\n // an exit offset on the surviving last item, so the item's pre-offset\n // position isn't where it will actually render. Tightening against the\n // stale position leaves the container end inside the item's span, and the\n // closing bracket overwrites the item's content (fuzz seed 3780: an edit\n // plus a remove on the same inline array emitted `-312,` with `]` eating\n // the value's last digit).\n let needsTighten = false;\n traverse(original, {\n InlineTable: (node) => {\n if (hasInlineContainerNeedingTighten(node)) needsTighten = true;\n },\n InlineArray: (node) => {\n if (hasInlineContainerNeedingTighten(node)) needsTighten = true;\n }\n });\n if (needsTighten) applyWrites(original);\n\n let hasTightened = false;\n const tightenedInlineContainers: (InlineTable | InlineArray)[] = [];\n traverse(original, {\n InlineTable: (node) => {\n if (hasInlineContainerNeedingTighten(node)) {\n tightenedInlineContainers.push(node);\n tightenInlineContainerEnd(node);\n deleteInlineContainerNeedingTighten(node);\n applyBracketSpacing(original, node, format.bracketSpacing);\n hasTightened = true;\n }\n },\n InlineArray: (node) => {\n if (hasInlineContainerNeedingTighten(node)) {\n tightenInlineContainerEnd(node);\n deleteInlineContainerNeedingTighten(node);\n applyBracketSpacing(original, node, format.bracketSpacing);\n hasTightened = true;\n }\n }\n });\n if (hasTightened) {\n applyWrites(original);\n for (const container of tightenedInlineContainers) {\n compactInlineContainerAncestors(original, container);\n }\n // Nested inline container tightening doesn't propagate through the\n // offset system (the removed item's offset was zeroed), so parent\n // container end positions must be recalculated explicitly.\n recalcInlineContainerEnds(original);\n }\n\n // Clean up extracted comments that were orphaned when an inline array or\n // inline table was emptied. Comments inside multiline inline containers are\n // extracted to the Document level by the parser, but when the container is\n // emptied, those comments are no longer meaningful and must be removed.\n cleanupOrphanedComments(original);\n\n // Replace emptied TableArrays (array-of-tables) with inline empty arrays\n // so keys aren't silently lost (e.g. b = [] instead of disappearing).\n replaceEmptiedTableArrays(original, emptiedAotKeys, format);\n\n // updateOrder: reorder root key-values, section blocks, and table-body rows to match the\n // patched object's key order. Must run last — see the comment on objectMoves above.\n applyKeyOrderMoves(original, objectMoves, commentEligibleNodes);\n if (objectMoves.length > 0) markDirty(original);\n if (replacedInlineArrays.size > 0) {\n applyWrites(original);\n for (const array of replacedInlineArrays) {\n positionGeneratedNestedInlineTables(array, format.indentWidth);\n }\n }\n // Realign the multiline rows of replaced inline containers last: the passes\n // above move their contents, and the rows are anchored to the owning key's\n // column, so laying them out earlier would leave them offset.\n if (replacedInlineContainers.length > 0) {\n applyWrites(original);\n for (const { owner, container } of replacedInlineContainers) {\n deleteSubtreeRanges(container);\n normalizeInlineContainerRows(container, owner.loc.start.column, format.indentWidth, format.bracketSpacing);\n }\n }\n return original;\n}\n\n/**\n * Drops the `range` of a node and every descendant, so the renderer rebuilds\n * the text from the node locations instead of copying the original slice.\n *\n * Regenerated values are parsed from a standalone TOML snippet, so their ranges\n * point into that snippet. Relocating the subtree shifts the locations but not\n * the snippet's interior text: a copied slice would keep the snippet's absolute\n * indentation and ignore the new row positions (fuzz3 seed 18515).\n */\nfunction deleteSubtreeRanges(node: TreeNode): void {\n delete (node as { range?: [number, number] }).range;\n if (hasItems(node)) {\n for (const child of (node as WithItems).items as TreeNode[]) deleteSubtreeRanges(child);\n }\n if (hasItem(node)) deleteSubtreeRanges((node as { item: TreeNode }).item);\n if (isKeyValue(node)) {\n deleteSubtreeRanges(node.key);\n deleteSubtreeRanges(node.value);\n }\n}\n\n/**\n * Position of the first `[table]`/`[[array]]` header in `doc`, or -1 if there is none.\n *\n * A key-value that physically follows a section header belongs to that section, not to the\n * root table. So any path that regenerates a root-level key has to land it above the first\n * header — appending at the end of the document silently reparents it, and the value comes\n * back under the wrong key on the next parse. See\n * docs/bug-notes/comment-eligibility-on-structural-replace.md.\n */\nfunction firstSectionHeaderIndex(doc: Document): number {\n return doc.items.findIndex(item => isTable(item) || isTableArray(item));\n}\n\n/**\n * Index to insert a root key-value at so it stays in the root table: above the first section\n * header, and above the comment block R2 assigns to that header — inserting between them would\n * leave the comment introducing the new key instead (docs/Comment-Ownership.md, R2).\n */\nfunction rootKeyValueInsertIndex(doc: Document): number | undefined {\n const firstTableIndex = firstSectionHeaderIndex(doc);\n if (firstTableIndex === -1) return undefined;\n if (firstTableIndex === 0 || !isComment(doc.items[firstTableIndex - 1])) return firstTableIndex;\n\n // R2 compares line numbers, which pending removal offsets would skew.\n applyWrites(doc);\n const header = doc.items[firstTableIndex];\n const group = resolveGroups(doc).find(candidate => candidate.member === header);\n return group ? doc.items.indexOf(group.items[0] as Block) : firstTableIndex;\n}\n\n/**\n * Moves an already-inserted root-level key-value back above the first section header, for the\n * paths that place it via `replace()` (which pins it to the replaced node's position) rather\n * than choosing an index. Also tends to reunite the key with a leading comment left behind at\n * its original position.\n */\nfunction hoistRootKeyValueAboveTables(doc: Document, kv: KeyValue): void {\n const kvIndex = doc.items.indexOf(kv);\n if (kvIndex < 0) return;\n\n const firstTableIndex = firstSectionHeaderIndex(doc);\n if (firstTableIndex === -1 || firstTableIndex > kvIndex) return;\n\n remove(doc, doc, kv);\n\n // The remove() above registers a pending offset on the document, and an\n // earlier removal in the same patch (e.g. deleting the FIRST table, which\n // registers an enter offset on the document) may still be unresolved too.\n // insert() positions against the neighbouring items' loc values, which\n // carry those offsets until flushed — a stale `firstTableIndex` item then\n // drags the re-inserted KV onto a negative/phantom line and the writer\n // crashes reading `undefined.length` (fuzz seeds 358055, 362151). Resolve\n // before measuring, like every other insert that follows a removal.\n applyWrites(doc);\n\n insert(doc, doc, kv, rootKeyValueInsertIndex(doc) ?? firstTableIndex);\n}\n\n/**\n * The converse of hoistRootKeyValueAboveTables: an edit that turned a\n * root-level KeyValue into a Table section inserts a section header where\n * the KV was — and a section header captures every key-value that follows it\n * in the document. If any root KV comes after the new header (and before the\n * next section), move the table below the root-table scope (fuzz seed 590:\n * `g86 = \"str\"` became `[g86]` while `fofc`/`y3n`/`\"<w\"` followed it).\n */\nfunction sinkTableBelowRootKeyValues(doc: Document, table: Table | TableArray): void {\n const tableIndex = doc.items.indexOf(table);\n if (tableIndex < 0) return;\n\n const nextSectionIndex = doc.items.findIndex(\n (item, i) => i > tableIndex && (isTable(item) || isTableArray(item))\n );\n const hasFollowingRootKV = doc.items.some(\n (item, i) =>\n i > tableIndex &&\n isKeyValue(item) &&\n (nextSectionIndex === -1 || i < nextSectionIndex)\n );\n if (!hasFollowingRootKV) return;\n\n const target = nextSectionIndex === -1 ? doc.items.length : nextSectionIndex;\n // Flush pending offsets so the table's loc reflects its true position before\n // the remove-then-reinsert cycle; otherwise insert() measures against a stale\n // (pre-remove) anchor and can drag the table to line 0 (fuzz seed 43159).\n applyWrites(doc);\n remove(doc, doc, table);\n insert(doc, doc, table, target - 1);\n}\n\n/**\n * Handles structural edits where findByPath can't resolve the existing CST node\n * because the structure type has changed (e.g. table→scalar, AOT→scalar, array→empty).\n * Swaps the fresh key-value in for the old structural nodes.\n */\nfunction handleStructuralEdit(\n original: Document,\n updated: Document,\n change: Change,\n format: TomlFormat,\n temporal: boolean,\n commentEligibleNodes: WeakSet<TreeNode>,\n materialisedTables: Set<Table>\n): void {\n const updated_js = toJS(updated.items, '', { temporal });\n let jsValue: any = updated_js;\n for (const key of change.path) {\n jsValue = jsValue?.[key];\n }\n\n if (jsValue === undefined) return;\n\n // An object→scalar (or object→array) edit under an array-of-tables entry:\n // the path carries the entry's numeric index (e.g. ['', 0, ':h9q=2`aO']),\n // which document-level keys never do. The generic prefix scan below can't\n // find the old sub-table/[[sub-array]] entries (their keys lack the index),\n // so they survive and collide with the rebuilt value — and rebuilding from\n // the root would emit a `[\"\"]` table next to the surviving [[[\"\"]]] array,\n // failing the re-parse with \"Cannot add Array of Tables to table\"\n // (fuzz seed 6409). Handle it inside the entry instead: drop the old\n // sub-entries and insert a fresh key-value for the changed segment.\n {\n let aotIndexPos = -1;\n let entry: TableArray | undefined;\n for (let index = change.path.length - 1; index > 0; index--) {\n if (typeof change.path[index] !== 'number') continue;\n const candidate = tryFindByPath(original, change.path.slice(0, index + 1));\n if (candidate && isTableArray(candidate)) {\n aotIndexPos = index;\n entry = candidate;\n break;\n }\n }\n if (aotIndexPos > 0 && entry && change.path.slice(aotIndexPos + 1).every(seg => typeof seg === 'string')) {\n const aotEntry = entry;\n const entryKey = aotEntry.key.item.value;\n const changedKey = change.path.slice(aotIndexPos + 1) as string[];\n const fullChangedKey = entryKey.concat(changedKey);\n\n // Remove old sub-tables/[[sub-arrays]] extending entryKey + changedKey\n // (the previous object value's children), and any dotted-key rows\n // inside the entry that start with the changed segment.\n const toRemove = findAotScopedDocumentItems(original, entryKey.concat(changedKey), aotEntry);\n // Remember where the old sub-entries sat so a replacement [[section]]\n // takes their place rather than drifting below later siblings.\n const removedIndex = toRemove.length > 0 ? original.items.indexOf(toRemove[0]) : -1;\n for (const prefixNode of toRemove) {\n removeMember(original, original, prefixNode);\n }\n const entryItems = aotEntry.items as TreeNode[];\n const inlineToRemove = entryItems.filter(item => {\n const key = isKeyValue(item) ? item.key.value : undefined;\n return key\n && key.length > changedKey.length\n && arraysEqual(key.slice(0, changedKey.length), changedKey);\n });\n for (const item of inlineToRemove) {\n removeMember(original, aotEntry, item);\n }\n\n if (changedKey.length > 1) {\n const explicitParent = findDeepestExplicitTable(original, fullChangedKey, entryKey.length, aotEntry);\n if (explicitParent) {\n const relativeKey = fullChangedKey.slice(explicitParent.key.item.value.length);\n const replacementRow = !isTableArrayValue(jsValue)\n ? generateExplicitParentRow(relativeKey, jsValue, format)\n : undefined;\n if (replacementRow) {\n upsertExplicitParentRow(original, explicitParent, relativeKey, replacementRow);\n commentEligibleNodes.add(replacementRow);\n return;\n }\n }\n }\n\n // Rebuild the tail of the path as a fresh KV (or KVs) and insert\n // into the entry.\n let tail: any;\n if (isTableArrayValue(jsValue)) {\n tail = { [changedKey[changedKey.length - 1]]: jsValue };\n } else {\n tail = jsValue;\n for (let k = change.path.length - 1; k > aotIndexPos; k--) {\n tail = { [change.path[k]]: tail };\n }\n }\n const tailDoc = parseJS(tail, format);\n const tailToml = toTOML(tailDoc.items, format);\n const tailCst = Array.from(parseTOML(tailToml));\n\n let sectionInsertIndex = removedIndex >= 0\n ? removedIndex\n : ownedSectionsEndIndex(original, aotEntry, findAotEntryScopeItems(original, aotEntry));\n\n const upsertEntryKeyValue = (kv: KeyValue): void => {\n const existingRow = aotEntry.items.find(row =>\n isKeyValue(row) && arraysEqual(row.key.value, kv.key.value)\n );\n if (existingRow) {\n replace(original, aotEntry, existingRow, kv);\n } else {\n insert(original, aotEntry, kv, undefined);\n }\n };\n\n for (const item of tailCst) {\n if (isKeyValue(item)) {\n upsertEntryKeyValue(item);\n continue;\n }\n\n // parseJS may materialize the replacement tail as a Table section\n // (`[rw109]\\nkjzi = ...`) under inlineTableStart defaults. For an\n // edit scoped to a specific AOT entry, flatten section rows back to\n // dotted KVs relative to that entry (fuzz seed 1657445).\n if (isTable(item)) {\n const tableKey = (item as Table).key.item.value;\n const fullTableKey = entryKey.concat(tableKey);\n const explicitParent = findAotScopedDocumentItems(original, fullTableKey, aotEntry)\n .find(candidate => isTable(candidate)\n && arraysEqual((candidate as Table).key.item.value, fullTableKey)) as Table | undefined;\n if (explicitParent) {\n for (const row of (item as Table).items as TreeNode[]) {\n if (!isKeyValue(row)) continue;\n const existingRow = explicitParent.items.find(candidate =>\n isKeyValue(candidate) && arraysEqual(candidate.key.value, row.key.value)\n );\n if (existingRow) {\n replace(original, explicitParent, existingRow, row);\n } else {\n insert(original, explicitParent, row, undefined);\n }\n }\n continue;\n }\n for (const row of (item as Table).items as TreeNode[]) {\n if (!isKeyValue(row)) continue;\n rekeyKeyValue(row, tableKey.concat(row.key.value), format);\n upsertEntryKeyValue(row);\n }\n }\n\n if (isTableArray(item)) {\n insertReplacementTableArray(\n original, item, fullChangedKey.slice(0, -1), sectionInsertIndex++, format, commentEligibleNodes\n );\n }\n }\n return;\n }\n }\n\n // The same edit below an explicit [table] outside any array-of-tables\n // entry: rebuilding from the root would emit `route = { args = … }` (or a\n // `[route]` merge carrying `args = { … }`) while the explicit\n // `[route.args.deep]` header survives, failing the re-parse with \"Cannot\n // extend inline table\". Scope the replacement to the deepest explicit\n // parent instead.\n if (change.path.length > 1 && change.path.every(seg => typeof seg === 'string')) {\n const changedKey = change.path as string[];\n const explicitParent = findDeepestExplicitTable(original, changedKey, 0, undefined);\n if (explicitParent && replaceBelowExplicitTable(\n original, explicitParent, changedKey, jsValue, format, commentEligibleNodes\n )) {\n return;\n }\n if (!explicitParent && replaceAsRootDottedRow(original, changedKey, jsValue, format, commentEligibleNodes)) {\n return;\n }\n }\n\n // Build a nested object matching the change path.\n let nested: any = jsValue;\n for (let i = change.path.length - 1; i >= 0; i--) {\n nested = { [change.path[i]]: nested };\n }\n\n // Remove old nodes matching the key prefix.\n const prefixNodes = findDocumentItemsByKeyPrefix(original, change.path);\n for (const prefixNode of prefixNodes) {\n remove(original, original, prefixNode);\n }\n\n // Generate the replacement as CST, round-trip through TOML string to get\n // properly positioned nodes, then parse back. This avoids issues with\n // parseJS's formatting pipeline (formatEmptyLines, etc.) interacting poorly\n // with insert().\n const freshDoc = parseJS(nested, format);\n const replacementToml = toTOML(freshDoc.items, format);\n const replacementCst = Array.from(parseTOML(replacementToml));\n\n // Insert above the first remaining section header: a key-value placed after one would\n // bind to that section instead of the root table.\n const insertIndex = rootKeyValueInsertIndex(original);\n\n // Only when a header actually survives the removals. In that case the replacement is\n // prepended above it rather than appended to an emptied document, and insert() positions\n // it against its neighbours' loc values — which still carry the removals' pending offsets\n // until flushed, leaving the emitted node pointing past the end of the output buffer.\n if (insertIndex !== undefined) applyWrites(original);\n\n // parseJS can render the nested value as MORE than one root item — e.g. a\n // [section] followed by the key-values that belong to it when the depth\n // exceeds inlineTableStart (fuzz seed 724: { n: { h9nvi6w: { gfjsfiy } } }\n // came back as `[n]` + `h9nvi6w = { … }`). Insert ALL of them, in order;\n // dropping everything after the first lost the value entirely.\n let firstInserted: TreeNode | undefined;\n for (let i = 0; i < replacementCst.length; i++) {\n const item = replacementCst[i];\n // The replacement can re-render a table header whose key is ALREADY\n // present in the document: the prefix cleanup above removed a sibling\n // structure (e.g. an [[array]] header) for the same logical parent, but\n // an explicit [table] with that key survives. Inserting the rendered\n // header would duplicate it and fail the re-parse with \"Table already\n // defined\" (fuzz seed 1219). Merge the rendered rows into the\n // surviving table instead.\n const existingTable = isTable(item)\n ? (original.items as TreeNode[]).find(t =>\n isTable(t) && arraysEqual((t as Table).key.item.value, (item as Table).key.item.value))\n : undefined;\n if (existingTable) {\n for (const row of (item as Table).items as TreeNode[]) {\n insert(original, existingTable, row, undefined);\n }\n if (!firstInserted) firstInserted = existingTable;\n continue;\n }\n\n // A regenerated inline-table key-value (`n = { \"{&>*b0M\" = -3566 }`)\n // can collide with a surviving explicit `[n]` section that still owns\n // unrelated keys. Re-emitting the inline table defines `n` twice, and\n // the `[n]` header then tries to extend the inline table, failing the\n // re-parse with \"Cannot extend inline table\" (fuzz seed 37465). Merge\n // the inline table's rows into the surviving section instead.\n if (isKeyValue(item) && isInlineTable(item.value)) {\n const kvKey = item.key.value;\n const survivingTable = (original.items as TreeNode[]).find(t =>\n isTable(t) && arraysEqual((t as Table).key.item.value, kvKey));\n if (survivingTable) {\n for (const row of ((item.value as InlineTable).items as TreeNode[])) {\n // Inline-table rows arrive as InlineItem wrappers; unwrap them so\n // they land as plain KeyValues inside the block table.\n const rowNode = isInlineItem(row) ? row.item : row;\n insert(original, survivingTable, rowNode, undefined);\n }\n if (!firstInserted) firstInserted = survivingTable;\n continue;\n }\n\n // The inline table's key can also be a prefix of a surviving IMPLICIT\n // table expressed through dotted key-values (`a = { l1 = -4489 }`\n // colliding with `a.p37xq = …`): re-emitting the inline table defines\n // `a` twice and fails the re-parse with \"Table already defined\"\n // (fuzz seed 43199). Convert each inline-table row to a dotted KV\n // under that prefix and insert those at the root scope instead.\n // The implicit table can equally be expressed through a section header\n // (`\"\" = { b = 5 }` colliding with `[\"\".a]`, fuzz seed 68244), so any\n // sibling whose key extends `kvKey` counts — not just dotted key-values.\n const implicitSiblings = findDocumentItemsByKeyPrefix(original, kvKey)\n .filter(t => isKeyValue(t) || isTable(t) || isTableArray(t));\n if (implicitSiblings.length > 0) {\n for (const row of ((item.value as InlineTable).items as TreeNode[])) {\n const rowNode = isInlineItem(row) ? row.item : row;\n if (isKeyValue(rowNode)) {\n const oldRaw = rowNode.key.raw;\n const dotted = kvKey.concat(rowNode.key.value);\n rowNode.key.value = dotted;\n rowNode.key.raw = dotted\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const delta = rowNode.key.raw.length - oldRaw.length;\n rowNode.key.loc.end.column = rowNode.key.loc.start.column + rowNode.key.raw.length;\n rowNode.equals += delta;\n shiftNode(rowNode.value, { lines: 0, columns: delta }, { first_line_only: true });\n if (rowNode.loc.end.line === rowNode.loc.start.line) {\n rowNode.loc.end.column += delta;\n }\n }\n insert(original, original, rowNode, i === 0 ? insertIndex : undefined);\n if (!firstInserted) firstInserted = rowNode;\n }\n continue;\n }\n }\n\n // The rendered section may instead collide with an IMPLICIT table: the\n // document expresses that key through dotted key-values (`\"\".a = 1`\n // defines the \"\" table without a header). Re-emitting the header\n // would conflict with the implicit definition and fail the re-parse\n // with \"Implicit table already defined\" (fuzz seed 1898). Convert\n // each rendered row to a dotted KV under the same prefix and insert\n // those at the root scope instead.\n if (isTable(item)) {\n const tableKey = (item as Table).key.item.value;\n const implicitChildren = findDocumentItemsByKeyPrefix(original, tableKey)\n .filter(t => isKeyValue(t));\n if (implicitChildren.length > 0) {\n for (const row of (item as Table).items as TreeNode[]) {\n if (isKeyValue(row)) {\n const oldRaw = row.key.raw;\n const dotted = tableKey.concat(row.key.value);\n row.key.value = dotted;\n row.key.raw = dotted\n .map(part => IS_BARE_KEY.test(part) ? part : JSON.stringify(part).replace(/\\x7f/g, '\\\\u007f'))\n .join('.');\n const delta = row.key.raw.length - oldRaw.length;\n row.key.loc.end.column = row.key.loc.start.column + row.key.raw.length;\n row.equals += delta;\n // Shifting only the value's own start/end leaves its inner rows\n // (absolute columns) behind — an inline table's first row then\n // overwrites the opening brace (fuzz seed 7443). Shift the\n // whole first line of the value subtree.\n shiftNode(row.value, { lines: 0, columns: delta }, { first_line_only: true });\n if (row.loc.end.line === row.loc.start.line) {\n row.loc.end.column += delta;\n }\n }\n insert(original, original, row, i === 0 ? insertIndex : undefined);\n if (!firstInserted) firstInserted = row;\n }\n continue;\n }\n }\n\n // Subsequent key-value rows belong INSIDE the freshly inserted section\n // header, not after it at document level: appending at the end leaves\n // them past unrelated later sections, which capture them on re-parse\n // (fuzz seed 7379: `aw3axx = {…}` landed inside [[y-g]]).\n if (i > 0 && firstInserted && isTable(firstInserted) && isKeyValue(item)) {\n insert(original, firstInserted, item, undefined);\n } else {\n insert(original, original, item, i === 0 ? insertIndex : undefined);\n }\n if (!firstInserted) firstInserted = item;\n }\n\n const replacementKV = firstInserted as KeyValue;\n\n // Track for blank-line fixup after applyWrites.\n if (isTable(replacementKV)) {\n materialisedTables.add(replacementKV);\n }\n\n // replacementKV stands in for a pre-existing entry, so it keeps that entry's R2\n // eligibility for adopting an adjacent leading comment during an updateOrder reorder.\n commentEligibleNodes.add(replacementKV);\n}\n\n/**\n * Tighten the end column of a single-line InlineTable or InlineArray whose\n * only item was removed by remove(). When items remain, the end is tightened\n * to just after the last item; when empty, to start + 2 so brackets touch\n * (e.g. `[]` or `{}`). loc.end is exclusive.\n */\nfunction tightenInlineContainerEnd(node: InlineTable | InlineArray): void {\n if (node.items.length > 0) {\n const lastItem = node.items[node.items.length - 1];\n node.loc.end.column = lastItem.loc.end.column + 1;\n } else {\n // The end must land on the container's own line: a multiline container\n // that was emptied by zeroing the removal offset still carries its old\n // end line (fuzz seed 5522), and tightening only the column would leave\n // the bracket floating below the `[]`.\n node.loc.end.line = node.loc.start.line;\n node.loc.end.column = node.loc.start.column + 2;\n }\n}\n\nfunction compactInlineContainerAncestors(\n root: TreeNode,\n target: InlineTable | InlineArray\n): void {\n const path: TreeNode[] = [];\n const locate = (node: TreeNode): boolean => {\n path.push(node);\n if (node === target) return true;\n if (isKeyValue(node)) {\n if (locate(node.value)) return true;\n } else if (isInlineItem(node)) {\n if (locate(node.item)) return true;\n } else if (hasItems(node)) {\n for (const item of node.items as TreeNode[]) {\n if (locate(item)) return true;\n }\n }\n path.pop();\n return false;\n };\n\n if (!locate(root)) return;\n const enclosingRow = path.findLast(isInlineItem);\n if (!enclosingRow) return;\n const lineDelta = target.loc.end.line - enclosingRow.loc.end.line;\n if (lineDelta === 0) return;\n\n const inlineContainerIndex = path.findLastIndex(\n (node, index) => index < path.length - 1 && (isInlineTable(node) || isInlineArray(node))\n );\n if (inlineContainerIndex < 0) return;\n const inlineContainer = path[inlineContainerIndex] as InlineTable | InlineArray;\n const child = path[inlineContainerIndex + 1];\n const childIndex = inlineContainer.items.indexOf(child as never);\n const next = childIndex >= 0 ? inlineContainer.items[childIndex + 1] as TreeNode | undefined : undefined;\n if (childIndex < 0 || !next) return;\n\n const gap = next.loc.start.column - child.loc.end.column;\n const columnDelta = resolveInnerEndCol(child) + gap - next.loc.start.column;\n for (let i = childIndex + 1; i < inlineContainer.items.length; i++) {\n shiftNode(inlineContainer.items[i], { lines: lineDelta, columns: columnDelta });\n }\n inlineContainer.loc.end.column += columnDelta;\n for (const node of path) {\n if (node !== target && node.loc.end.line > target.loc.end.line) {\n node.loc.end.line += lineDelta;\n }\n }\n\n for (let i = path.length - 1; i >= 0; i--) {\n const node = path[i];\n if (isKeyValue(node)) {\n node.loc.end = { ...node.value.loc.end };\n if (node.value !== target && isInlineTable(node.value)) {\n node.loc.end.column += columnDelta;\n }\n } else if (isInlineItem(node)) {\n node.loc.end = { ...node.item.loc.end };\n }\n }\n}\n\n/**\n * After tightening a nested single-line InlineTable (whose only item was\n * removed), recalculate the end positions of any parent single-line InlineTable\n * or InlineArray containers. The remove() call zeroed the offset for the\n * removed item (single-line, no siblings), so applyWrites can't propagate the\n * shrink to ancestor containers.\n */\nfunction recalcInlineContainerEnds(root: TreeNode): void {\n traverse(root, {\n InlineTable: {\n exit: (node) => {\n if (node.items.length === 0) return;\n if (node.loc.end.line !== node.loc.start.line) return;\n const lastItem = node.items[node.items.length - 1];\n const innerEndCol = resolveInnerEndCol(lastItem);\n const originalEndCol = node.loc.end.column;\n // Preserve the original gap (bracket spacing etc.) between the\n // last item's InlineItem end and the closing brace.\n const originalGap = originalEndCol - lastItem.loc.end.column;\n const newEndCol = innerEndCol + originalGap;\n if (newEndCol !== originalEndCol) {\n node.loc.end.column = newEndCol;\n }\n }\n },\n InlineArray: {\n exit: (node) => {\n if (node.items.length === 0) return;\n if (node.loc.end.line !== node.loc.start.line) return;\n const lastItem = node.items[node.items.length - 1];\n const innerEndCol = resolveInnerEndCol(lastItem);\n const originalEndCol = node.loc.end.column;\n const originalGap = originalEndCol - lastItem.loc.end.column;\n const newEndCol = innerEndCol + originalGap;\n if (newEndCol !== originalEndCol) {\n node.loc.end.column = newEndCol;\n }\n }\n }\n });\n}\n\n/**\n * Resolve the effective end column of an InlineItem's inner value,\n * looking through KeyValue wrappers and into tightened InlineTable or\n * InlineArray containers. Returns lastItem.loc.end.column for items\n * that don't need or support look-through.\n */\nfunction resolveInnerEndCol(lastItem: TreeNode): number {\n if (!isInlineItem(lastItem)) return lastItem.loc.end.column;\n\n // InlineTable items: InlineItem<KeyValue> — look through to the value\n if (isKeyValue(lastItem.item)) {\n const v = lastItem.item.value;\n if (isInlineTable(v) || isInlineArray(v)) {\n return v.loc.end.column;\n }\n }\n\n // InlineArray items: InlineItem<InlineTable|InlineArray> — direct look-through\n if (isInlineTable(lastItem.item) || isInlineArray(lastItem.item)) {\n return lastItem.item.loc.end.column;\n }\n\n return lastItem.loc.end.column;\n}\n\n/**\n * Removes Comment nodes that were extracted from inside an InlineArray\n * when that array has been emptied.\n * \n * When a multiline inline array has interior comments (e.g. `arr = [\\n 1, # one\\n 2, # two\\n]`),\n * the parser extracts the comments to the parent Document level as siblings of the KeyValue.\n * If the array is later emptied, these comments become orphaned and must be removed\n * to produce valid TOML output.\n * \n * This does NOT apply to InlineTables, where interior comments are meaningful\n * section-level comments that should be preserved even when the table is empty.\n */\nfunction cleanupOrphanedComments(doc: Document): void {\n traverse(doc, {\n KeyValue: (kv) => {\n const value = kv.value;\n // Only clean up inline arrays, not inline tables\n if (!isInlineArray(value)) return;\n if (value.items.length > 0) return;\n\n // Find the parent container (Document or Table) that holds this KeyValue\n const parentContainer = findParent(doc, [kv.key.value[0]]);\n if (!parentContainer || !hasItems(parentContainer)) return;\n\n const kvStartLine = kv.loc.start.line;\n const kvEndLine = kv.loc.end.line;\n\n // Remove any Comment nodes in the parent that fall within the KeyValue's range\n const items = (parentContainer as WithItems).items as TreeNode[];\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (!isComment(item)) continue;\n const commentLine = item.loc.start.line;\n if (commentLine >= kvStartLine && commentLine <= kvEndLine) {\n items.splice(i, 1);\n }\n }\n }\n });\n}\n\n/**\n * Replaces emptied TableArrays with inline empty array key-values so that\n * keys aren't silently lost when all AOT entries are removed (e.g. b = []).\n */\nfunction replaceEmptiedTableArrays(doc: Document, emptiedKeys: Map<string, Path>, format: TomlFormat): void {\n if (emptiedKeys.size === 0) return;\n\n for (const path of emptiedKeys.values()) {\n // A nested AOT (e.g. `[[\"\".Lpfz,]]` emptied inside `[[\"\"]]`) must be\n // re-materialised as a row INSIDE its parent AOT entry (`Lpfz, = []`),\n // not as a root dotted key `\"\".Lpfz, = []` — that dotted key defines `\"\"`\n // as an implicit table and collides with the surviving `[[\"\"]]` header on\n // re-parse (\"Implicit table already defined\", fuzz seed 62163).\n if (path.length > 1) {\n const parentPath = path.slice(0, -1) as Path;\n const parentEntryPath = typeof parentPath[parentPath.length - 1] === 'number'\n ? parentPath\n : parentPath.concat([0]);\n const parentEntry = tryFindByPath(doc, parentEntryPath);\n if (parentEntry && isTableArray(parentEntry)) {\n const lastSegment = path[path.length - 1];\n if (typeof lastSegment !== 'string') continue;\n const emptyArrayDoc = parseJS({ [lastSegment]: [] }, format);\n const emptyKV = generateKeyValue([lastSegment], (emptyArrayDoc.items[0] as KeyValue).value);\n // The removal that emptied the array left pending line offsets on the\n // preceding siblings — flush first (same discipline as the root case,\n // fuzz seed 7379).\n applyWrites(doc);\n insert(doc, parentEntry, emptyKV);\n continue;\n }\n\n // An AOT declared inside an explicit [table] or a TableArray entry must\n // be re-materialised inside that host with a RELATIVE key. Materialising\n // it as a root dotted key can define an implicit table that collides with\n // a surviving section header on re-parse.\n let hostContainer: Table | TableArray | undefined;\n for (let len = path.length - 1; len >= 1; len--) {\n const ancestor = tryFindByPath(doc, path.slice(0, len));\n if (ancestor && (isTable(ancestor) || isTableArray(ancestor))) {\n hostContainer = ancestor;\n break;\n }\n }\n if (hostContainer) {\n const stringPath = path.filter((segment): segment is string => typeof segment === 'string');\n const relativeKey = stringPath.slice(hostContainer.key.item.value.length);\n const emptyArrayDoc = parseJS({ [relativeKey[relativeKey.length - 1]]: [] }, format);\n const emptyKV = generateKeyValue(relativeKey, (emptyArrayDoc.items[0] as KeyValue).value);\n applyWrites(doc);\n insert(doc, hostContainer, emptyKV);\n continue;\n }\n }\n\n // Build the key from its segments rather than a joined string: `parseJS({ 'a.b': [] })`\n // reads the dot as part of a single JS key and emits the quoted `\"a.b\" = []`, which is a\n // root key literally named `a.b` instead of `b` nested under `a`.\n const keyPath = path.filter((segment): segment is string => typeof segment === 'string');\n const emptyArrayDoc = parseJS({ [keyPath[keyPath.length - 1]]: [] }, format);\n const emptyKV = generateKeyValue(keyPath, (emptyArrayDoc.items[0] as KeyValue).value);\n // The removal that emptied the array left pending line offsets on the\n // preceding siblings. Inserting against their pre-offset locs and only\n // then resolving drags the new KV up past line 1 — a negative render\n // position (fuzz seed 7379). Flush first, like every other insert that\n // follows removals in the same patch.\n applyWrites(doc);\n insert(doc, doc, emptyKV, rootKeyValueInsertIndex(doc));\n }\n applyWrites(doc);\n}\n\n/**\n * Converts nested inline tables to separate table sections based on the inlineTableStart depth setting.\n * This function recursively processes a table and extracts any inline tables within it,\n * creating separate table sections with properly nested keys.\n * \n * @param table - The table to process for nested inline tables\n * @param original - The original document for inserting new items\n * @param format - The formatting options\n * @returns Array of additional tables that should be added to the document\n */\nfunction convertNestedInlineTablesToMultiline(table: Table, original: Document, format: TomlFormat): Table[] {\n const additionalTables: Table[] = [];\n \n const processTableForNestedInlines = (currentTable: Table, tablesToAdd: Table[]) => {\n for (let i = currentTable.items.length - 1; i >= 0; i--) {\n const item = currentTable.items[i];\n if (isKeyValue(item) && isInlineTable(item.value)) {\n // Calculate the depth of this nested table\n const nestedTableKey = [...currentTable.key.item.value, ...item.key.value];\n const depth = calculateTableDepth(nestedTableKey);\n \n // Only convert to separate table if depth is less than inlineTableStart\n if (depth < (format.inlineTableStart ?? 1) && format.inlineTableStart !== 0) {\n // Convert this inline table to a separate table section\n const separateTable = generateTable(nestedTableKey, format.escapeSequenceUpperCase);\n \n // Move all items from the inline table to the separate table\n for (const inlineItem of item.value.items) {\n if (isInlineItem(inlineItem) && isKeyValue(inlineItem.item)) {\n insert(original, separateTable, inlineItem.item, undefined);\n }\n }\n \n // Remove this item from the original table\n currentTable.items.splice(i, 1);\n \n // Update the parent table's end position after removal\n postInlineItemRemovalAdjustment(currentTable);\n \n // Queue this table to be added to the document\n tablesToAdd.push(separateTable);\n \n // Recursively process the new table for further nested inlines\n processTableForNestedInlines(separateTable, tablesToAdd);\n }\n }\n }\n };\n \n processTableForNestedInlines(table, additionalTables);\n return additionalTables;\n}\n\n/**\n * Converts an inline table to a separate table section when adding to an existing table.\n * This function creates a new table section with the combined key path and moves all\n * properties from the inline table to the separate table section.\n * \n * @param child - The KeyValue node with an InlineTable as its value\n * @param parent - The parent table where the KeyValue would be added\n * @param original - The original document for inserting new items\n * @param format - The formatting options\n */\nfunction convertInlineTableToSeparateSection(child: KeyValue, parent: Table, original: Document, format: TomlFormat): void {\n // Convert the inline table to a separate table section\n const baseTableKey = parent.key.item.value; // Get the parent table's key path\n const nestedTableKey = [...baseTableKey, ...child.key.value]; // Combine with the new key\n const separateTable = generateTable(nestedTableKey, format.escapeSequenceUpperCase);\n \n // We know child.value is an InlineTable from the calling context\n if (isInlineTable(child.value)) {\n // Move all items from the inline table to the separate table\n for (const inlineItem of child.value.items) {\n if (isInlineItem(inlineItem) && isKeyValue(inlineItem.item)) {\n insert(original, separateTable, inlineItem.item, undefined);\n }\n }\n }\n \n // Add the separate table to the document\n insert(original, original, separateTable, undefined);\n \n // Update the parent table's end position since we're not adding the inline table to it\n postInlineItemRemovalAdjustment(parent);\n \n // Also handle any nested inline tables within the new table\n const additionalTables = convertNestedInlineTablesToMultiline(separateTable, original, format);\n for (const table of additionalTables) {\n insert(original, original, table, undefined);\n }\n}\n\n/**\n * Regenerate a replacement Value node with clean loc values through a\n * TOML round-trip. Handles both KeyValue and Table output from parseJS\n * (formatTopLevel may convert a root-level key to a [section] when\n * inlineTableStart is 0). Returns undefined when the value cannot be\n * safely regenerated.\n */\nfunction regenerateValue(jsValue: any, format: TomlFormat): Value | undefined {\n // Always render inline: with the caller's inlineTableStart, parseJS may\n // flatten a nested object into dotted keys (`__tmp__.k28 = …`), and taking\n // the first item's value then returns the scalar instead of the object\n // (fuzz seed 735: a restored nested value collapsed to its first leaf).\n const inlineFmt = resolveTomlFormat({ ...format, inlineTableStart: 0 }, format);\n const freshDoc = parseJS({ __tmp__: jsValue }, inlineFmt);\n const replacementToml = toTOML(freshDoc.items, inlineFmt);\n const replacementCst = Array.from(parseTOML(replacementToml));\n const freshItem = replacementCst[0];\n if (isKeyValue(freshItem)) return freshItem.value;\n if (isTable(freshItem)\n && freshItem.items.length > 0\n && isKeyValue(freshItem.items[0])) return freshItem.items[0].value;\n return undefined;\n}\n\nfunction findEnclosingInlineTableRowContext(\n document: Document,\n path: Array<string | number>\n): { container: TreeNode; row: KeyValue } | undefined {\n for (let i = path.length - 1; i > 0; i--) {\n const candidate = tryFindByPath(document, path.slice(0, i));\n if (!candidate || !isKeyValue(candidate) || !isInlineTable(candidate.value)) continue;\n\n const container = tryFindByPath(document, path.slice(0, i - 1));\n if (container && hasItems(container)) {\n return { container, row: candidate };\n }\n }\n}\n\n/**\n * Finds all Document-level items whose key path starts with the given prefix.\n * This handles implicit intermediate keys — keys that are a prefix of a dotted\n * table key but have no CST node of their own (e.g. path [\"references\"] when\n * only [\"references\", \"VBIDE\"] exists in the document).\n */\nfunction findDocumentItemsByKeyPrefix(\n document: Document,\n pathPrefix: Array<string | number>\n): Block[] {\n const matchingNodes: Block[] = [];\n for (const item of document.items) {\n let key: string[] | undefined;\n if (isKeyValue(item)) {\n key = item.key.value;\n } else if (isTable(item)) {\n key = item.key.item.value;\n } else if (isTableArray(item)) {\n key = item.key.item.value;\n }\n\n if (key && arraysEqual(key.slice(0, pathPrefix.length), pathPrefix)) {\n matchingNodes.push(item);\n }\n }\n return matchingNodes;\n}\n\nfunction itemKey(item: Block): string[] | undefined {\n if (isKeyValue(item)) return item.key.value;\n if (isTable(item) || isTableArray(item)) return item.key.item.value;\n return undefined;\n}\n\nfunction keyStartsWith(key: string[] | undefined, prefix: Path): boolean {\n return key !== undefined &&\n prefix.every((segment, index) => typeof segment === 'string' && key[index] === segment);\n}\n\nfunction findAotEntryScopeItems(\n document: Document,\n entry: TableArray,\n knownStart?: number,\n sourceItems?: Block[]\n): Block[] {\n const items = sourceItems ?? document.items as Block[];\n const start = knownStart ?? items.indexOf(entry);\n if (start < 0) return [];\n\n const entryKey = entry.key.item.value;\n let end = items.length;\n for (let index = start + 1; index < items.length; index++) {\n const sibling = items[index];\n if (!isTableArray(sibling)) continue;\n const siblingKey = sibling.key.item.value;\n if (siblingKey.length <= entryKey.length && arraysEqual(siblingKey, entryKey.slice(0, siblingKey.length))) {\n end = index;\n break;\n }\n }\n return items.slice(start + 1, end);\n}\n\nfunction findAotEntryForPath(document: Document, path: Path): TableArray | undefined {\n for (let index = path.length - 1; index >= 0; index--) {\n if (typeof path[index] !== 'number') continue;\n const candidate = tryFindByPath(document, path.slice(0, index + 1));\n if (candidate && isTableArray(candidate)) return candidate;\n }\n return undefined;\n}\n\nfunction findAotScopedDocumentItems(\n document: Document,\n pathPrefix: Path,\n owner: TableArray | undefined\n): Block[] {\n const matchingNodes = findDocumentItemsByKeyPrefix(document, pathPrefix);\n if (!owner) return matchingNodes;\n const scopedItems = new Set(findAotEntryScopeItems(document, owner));\n return matchingNodes.filter(item => scopedItems.has(item));\n}\n\nfunction isTableArrayValue(value: any): value is any[] {\n return Array.isArray(value) && value.length > 0 && value.every(isObject);\n}\n\n/**\n * Finds the deepest explicit `[table]` header that is a strict ancestor of\n * `key` and longer than `minLength` segments, restricted to `owner`'s scope\n * when the key lives inside an array-of-tables entry.\n */\nfunction findDeepestExplicitTable(\n document: Document,\n key: string[],\n minLength: number,\n owner: TableArray | undefined\n): Table | undefined {\n for (let keyLength = key.length - 1; keyLength > minLength; keyLength--) {\n const parentKey = key.slice(0, keyLength);\n const parent = findAotScopedDocumentItems(document, parentKey, owner)\n .find(item => isTable(item) && arraysEqual(item.key.item.value, parentKey));\n if (parent) return parent as Table;\n }\n return undefined;\n}\n\n/**\n * Renders `key = value` as a single row for an explicit parent table. An\n * object value must stay one row: at the default inlineTableStart parseJS\n * would emit it as a `[key]` section, which can't be placed inside the parent.\n * A multi-segment key becomes a dotted row (`args.deep = …`): the\n * intermediate tables are implicit, and nesting them as `args = { deep = … }`\n * would close `args` to any surviving `[parent.args.other]` header.\n */\nfunction generateExplicitParentRow(key: string[], value: any, format: TomlFormat): KeyValue | undefined {\n const inlineFormat = resolveTomlFormat({ ...format, inlineTableStart: 0 }, format);\n const rowDoc = parseJS({ [key[key.length - 1]]: value }, inlineFormat);\n const rowItems = Array.from(parseTOML(toTOML(rowDoc.items, format)));\n if (rowItems.length !== 1 || !isKeyValue(rowItems[0])) return undefined;\n const row = rowItems[0];\n if (key.length > 1) rekeyKeyValue(row, key, format);\n return row;\n}\n\n/**\n * Rewrites a freshly parsed row's key to `key`, shifting the value along so\n * its locations still line up with the new key's width.\n */\nfunction rekeyKeyValue(row: KeyValue, key: string[], format: TomlFormat): void {\n const oldRaw = row.key.raw;\n row.key.value = key;\n row.key.raw = generateKey(key, format.escapeSequenceUpperCase).raw;\n const delta = row.key.raw.length - oldRaw.length;\n row.key.loc.end.column = row.key.loc.start.column + row.key.raw.length;\n row.equals += delta;\n shiftNode(row.value, { lines: 0, columns: delta }, { first_line_only: true });\n if (row.loc.end.line === row.loc.start.line) {\n row.loc.end.column += delta;\n }\n}\n\n/**\n * Puts `row` in place of `relativeKey` inside `parent`, dropping any dotted\n * rows that extended the old value.\n */\nfunction upsertExplicitParentRow(document: Document, parent: Table, relativeKey: string[], row: KeyValue): void {\n const oldRows = (parent.items as TreeNode[]).filter((item): item is KeyValue =>\n isKeyValue(item) && keyStartsWith(item.key.value, relativeKey)\n );\n const exactRow = oldRows.find(item => arraysEqual(item.key.value, relativeKey));\n for (const oldRow of oldRows) {\n if (oldRow !== exactRow) removeMember(document, parent, oldRow);\n }\n if (exactRow) {\n replace(document, parent, exactRow, row);\n } else {\n insert(document, parent, row, undefined);\n }\n}\n\n/**\n * Index just past `owner` and the contiguous `followers` keyed under it. Used\n * when no removed sub-entry marks the spot for a replacement section: the\n * followers can include unrelated tables (e.g. a later `[settings]`), and a\n * section placed after those would read as belonging to them.\n */\nfunction ownedSectionsEndIndex(document: Document, owner: Table | TableArray, followers: Block[]): number {\n const ownerKey = owner.key.item.value;\n let index = document.items.indexOf(owner) + 1;\n for (const item of followers) {\n const key = isTable(item) || isTableArray(item) ? item.key.item.value : undefined;\n if (!keyStartsWith(key, ownerKey)) break;\n index = document.items.indexOf(item) + 1;\n }\n return index;\n}\n\n/**\n * Re-keys a section rendered relative to `parentKey` (`[[items]]` →\n * `[[route.args.deep.items]]`) and inserts it at `index` in the document.\n */\nfunction insertReplacementTableArray(\n document: Document,\n section: Table | TableArray,\n parentKey: string[],\n index: number,\n format: TomlFormat,\n commentEligibleNodes: WeakSet<TreeNode>\n): void {\n const keyNode = section.key.item;\n const oldRaw = keyNode.raw;\n const dotted = parentKey.concat(keyNode.value);\n keyNode.value = dotted;\n keyNode.raw = generateKey(dotted, format.escapeSequenceUpperCase).raw;\n const delta = keyNode.raw.length - oldRaw.length;\n keyNode.loc.end.column = keyNode.loc.start.column + keyNode.raw.length;\n if (section.key.loc.end.line === section.key.loc.start.line) {\n section.key.loc.end.column += delta;\n }\n\n insert(document, document, section, index, undefined, undefined, 1);\n commentEligibleNodes.add(section);\n}\n\n/**\n * Replaces the value at `fullKey` below the explicit `parent` table, keeping\n * the edit inside that table: a single row for scalars, arrays and objects,\n * or `[[fullKey]]` sections at the old sub-table's position for an array of\n * tables. Returns false when the shape isn't handled here.\n */\nfunction replaceBelowExplicitTable(\n document: Document,\n parent: Table,\n fullKey: string[],\n jsValue: any,\n format: TomlFormat,\n commentEligibleNodes: WeakSet<TreeNode>,\n owner?: TableArray\n): boolean {\n const relativeKey = fullKey.slice(parent.key.item.value.length);\n\n if (isTableArrayValue(jsValue)) {\n // A `[[header]]` can't extend a table the parent defines through dotted\n // keys or an inline table (`args.deep.x = 1`, `args = { … }`).\n const parentRows = (parent.items as TreeNode[]).filter((item): item is KeyValue =>\n isKeyValue(item) && item.key.value[0] === relativeKey[0]\n );\n if (parentRows.some(row => !keyStartsWith(row.key.value, relativeKey))) return false;\n\n const leaf = fullKey[fullKey.length - 1];\n const sectionDoc = parseJS({ [leaf]: jsValue }, format);\n const sections = Array.from(parseTOML(toTOML(sectionDoc.items, format)));\n if (!sections.every(item => isTable(item) || isTableArray(item))) return false;\n\n const toRemove = findAotScopedDocumentItems(document, fullKey, owner);\n const removedIndex = toRemove.length > 0 ? document.items.indexOf(toRemove[0]) : -1;\n for (const node of toRemove) removeMember(document, document, node);\n for (const row of parentRows) removeMember(document, parent, row);\n\n let index = removedIndex >= 0\n ? removedIndex\n : ownedSectionsEndIndex(document, parent, document.items.slice(document.items.indexOf(parent) + 1));\n for (const section of sections as Array<Table | TableArray>) {\n insertReplacementTableArray(document, section, fullKey.slice(0, -1), index++, format, commentEligibleNodes);\n }\n return true;\n }\n\n const row = generateExplicitParentRow(relativeKey, jsValue, format);\n if (!row) return false;\n\n for (const node of findAotScopedDocumentItems(document, fullKey, owner)) {\n removeMember(document, document, node);\n }\n upsertExplicitParentRow(document, parent, relativeKey, row);\n commentEligibleNodes.add(row);\n return true;\n}\n\n/**\n * Replaces the value at `key` with a root dotted row when no explicit table\n * owns it but a surviving header still extends one of its implicit\n * intermediate tables (`[route.args.other]` beside `route.args.deep`): the\n * generic rebuild would emit `[route]` + `args = { … }`, which that header\n * can't extend. Returns false when nothing would collide.\n */\nfunction replaceAsRootDottedRow(\n document: Document,\n key: string[],\n jsValue: any,\n format: TomlFormat,\n commentEligibleNodes: WeakSet<TreeNode>\n): boolean {\n if (key.length < 3 || isTableArrayValue(jsValue)) return false;\n\n const intermediateKey = key.slice(0, 2);\n const extendsIntermediate = (document.items as Block[]).some(item => {\n const sectionKey = isTable(item) || isTableArray(item) ? item.key.item.value : undefined;\n return keyStartsWith(sectionKey, intermediateKey) && !keyStartsWith(sectionKey, key);\n });\n if (!extendsIntermediate) return false;\n\n const row = generateExplicitParentRow(key, jsValue, format);\n if (!row) return false;\n\n for (const node of findDocumentItemsByKeyPrefix(document, key)) {\n removeMember(document, document, node);\n }\n // See the generic rebuild: flush the removals before positioning against\n // a surviving header.\n const insertIndex = rootKeyValueInsertIndex(document);\n if (insertIndex !== undefined) applyWrites(document);\n insert(document, document, row, insertIndex);\n commentEligibleNodes.add(row);\n return true;\n}\n\n/**\n * Converts a JS-object change path into CST key coordinates by dropping the\n * numeric array-of-tables entry indices. The diff walks the JS object, so a\n * path into an AOT entry interleaves the entry's numeric index (e.g. `[\"\", 0,\n * \"fv\"]`), but CST keys carry no such index — `[[\"\"]]` entries live at the\n * document level and their sub-tables are keyed `[\"\", \"fv\"]`. A numeric\n * segment is an AOT entry index when the accumulated path is a document-level\n * TableArray key; inline-array indices (which ARE part of the CST path) never\n * resolve to a document-level TableArray.\n */\nfunction stripAotEntryIndices(original: Document, jsPath: Path): Path {\n const cstPath: Path = [];\n for (const seg of jsPath) {\n if (typeof seg === 'number') {\n const isAotIndex = findDocumentItemsByKeyPrefix(original, cstPath).some(isTableArray);\n if (isAotIndex) continue;\n }\n cstPath.push(seg);\n }\n return cstPath;\n}\n\n/**\n * Removes sibling key-values and table/table-array sections whose key extends\n * `prefix` (i.e. `prefix` is a strict prefix of the sibling's key) from\n * `container`'s items, leaving `keep` untouched. Used when a key collapses to\n * a scalar: any dotted-key or section that still nests under it would re-define\n * the key on re-parse (\"Value already defined\").\n *\n * Iterates a snapshot of the items because `removeMember` splices the live\n * array (fuzz seed 31662).\n */\nfunction removeSiblingsExtendingPrefix(\n original: Document,\n container: Table | Document | TableArray,\n prefix: Array<string | number>,\n keep: TreeNode\n): void {\n const parentItems = [...container.items] as Block[];\n for (let si = parentItems.length - 1; si >= 0; si--) {\n const sibling = parentItems[si];\n if (sibling === keep) continue;\n const siblingKey = isKeyValue(sibling)\n ? sibling.key.value\n : isTable(sibling) || isTableArray(sibling)\n ? sibling.key.item.value\n : undefined;\n if (siblingKey\n && siblingKey.length > prefix.length\n && arraysEqual(siblingKey.slice(0, prefix.length), prefix)) {\n removeMember(original, container, sibling);\n }\n }\n}\n\nfunction removeDocumentItemsExtendingPath(document: Document, path: Path, keep: TreeNode): void {\n const cstPath = stripAotEntryIndices(document, path);\n const owner = findAotEntryForPath(document, path);\n for (const item of findAotScopedDocumentItems(document, cstPath, owner)) {\n if (item !== keep) removeMember(document, document, item);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAwB,MAAM,UAAkB,SAAc,QAAmD;CAG/G,MAAM,eAAe,uBAAuB;CAC5C,MAAM,eAAe,gBAAgB,QAAQ;CAC7C,MAAM,eAAe,MAAM,KAAK,UAAU,cAAc,YAAY,CAAC;CACrE,cAAc,cAAc,YAAY;CAGxC,MAAM,qBAAqB,WAAW,wBAAwB,UAAU,YAAY;CACpF,MAAM,MAAM,kBAAkB,QAAQ,kBAAkB;CAExD,IAAI,aAAa,OAAO;EACtB,MAAM,aAAa,IAAI,YAAY,SAAS,SAAS;EACrD,QAAQ,KACN,6FACoD,YACtD;CACF;CAQA,MAAM,cAAc,SAClB,cAAc,SAAS,KAPG,kBAAkB,cAC3C,UAAU,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,aAAa,GACjD,kBAAkB,cAC7C,UAAU,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,eAAe,GAChD,kBAAkB,cAChD,UAAU,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,kBAAkB,CAGpF,CAAC,CAAC;CACF,MAAM,WAAW,SAAkB,IAAI,aAAa,SAAc,SAAS;CAC3E,OAAO,QAAQ,WAAW;AAC5B;;;;;;;;;;AAWA,SAAS,mBAAmB,YAAkB,aAAuB,iBAAiC;CACpG,MAAM,UAAU,WAAW,MAAM,eAAe;CAChD,IAAI,WAAW;CACf,MAAM,MAAM,KAAK,IAAI,QAAQ,QAAQ,YAAY,MAAM;CACvD,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