react-monaco-json-merge 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js","../node_modules/state-local/lib/es/state-local.js","../node_modules/@monaco-editor/loader/lib/es/config/index.js","../node_modules/@monaco-editor/loader/lib/es/utils/curry.js","../node_modules/@monaco-editor/loader/lib/es/utils/isObject.js","../node_modules/@monaco-editor/loader/lib/es/validators/index.js","../node_modules/@monaco-editor/loader/lib/es/utils/compose.js","../node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js","../node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js","../node_modules/@monaco-editor/loader/lib/es/loader/index.js","../src/types/index.ts","../node_modules/jsonc-parser/lib/esm/impl/scanner.js","../node_modules/jsonc-parser/lib/esm/impl/string-intern.js","../node_modules/jsonc-parser/lib/esm/impl/parser.js","../node_modules/jsonc-parser/lib/esm/main.js","../node_modules/fast-deep-equal/index.js","../src/utils/helpers.ts","../node_modules/fast-json-patch/module/helpers.mjs","../node_modules/fast-json-patch/module/core.mjs","../node_modules/fast-json-patch/module/duplex.mjs","../node_modules/fast-json-patch/index.mjs","../src/utils/schema.ts","../src/utils/jsonPatchDiff.ts","../src/utils/diffMerge.ts","../src/utils/editorDecorations.ts","../src/components/editor.tsx"],"sourcesContent":["function _arrayLikeToArray(r, a) {\n (null == a || a > r.length) && (a = r.length);\n for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n return n;\n}\nfunction _arrayWithHoles(r) {\n if (Array.isArray(r)) return r;\n}\nfunction _defineProperty(e, r, t) {\n return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: true,\n configurable: true,\n writable: true\n }) : e[r] = t, e;\n}\nfunction _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = true,\n o = false;\n try {\n if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = true, n = r;\n } finally {\n try {\n if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), true).forEach(function (r) {\n _defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}\nfunction _objectWithoutProperties(e, t) {\n if (null == e) return {};\n var o,\n r,\n i = _objectWithoutPropertiesLoose(e, t);\n if (Object.getOwnPropertySymbols) {\n var n = Object.getOwnPropertySymbols(e);\n for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);\n }\n return i;\n}\nfunction _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (-1 !== e.indexOf(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nfunction _slicedToArray(r, e) {\n return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();\n}\nfunction _toPrimitive(t, r) {\n if (\"object\" != typeof t || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r);\n if (\"object\" != typeof i) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, \"string\");\n return \"symbol\" == typeof i ? i : i + \"\";\n}\nfunction _unsupportedIterableToArray(r, a) {\n if (r) {\n if (\"string\" == typeof r) return _arrayLikeToArray(r, a);\n var t = {}.toString.call(r).slice(8, -1);\n return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;\n }\n}\n\nexport { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _defineProperty as defineProperty, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _slicedToArray as slicedToArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n if (enumerableOnly) symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n keys.push.apply(keys, symbols);\n }\n\n return keys;\n}\n\nfunction _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n\n if (i % 2) {\n ownKeys(Object(source), true).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n }\n\n return target;\n}\n\nfunction compose() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n\n return function (x) {\n return fns.reduceRight(function (y, f) {\n return f(y);\n }, x);\n };\n}\n\nfunction curry(fn) {\n return function curried() {\n var _this = this;\n\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return args.length >= fn.length ? fn.apply(this, args) : function () {\n for (var _len3 = arguments.length, nextArgs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n nextArgs[_key3] = arguments[_key3];\n }\n\n return curried.apply(_this, [].concat(args, nextArgs));\n };\n };\n}\n\nfunction isObject(value) {\n return {}.toString.call(value).includes('Object');\n}\n\nfunction isEmpty(obj) {\n return !Object.keys(obj).length;\n}\n\nfunction isFunction(value) {\n return typeof value === 'function';\n}\n\nfunction hasOwnProperty(object, property) {\n return Object.prototype.hasOwnProperty.call(object, property);\n}\n\nfunction validateChanges(initial, changes) {\n if (!isObject(changes)) errorHandler('changeType');\n if (Object.keys(changes).some(function (field) {\n return !hasOwnProperty(initial, field);\n })) errorHandler('changeField');\n return changes;\n}\n\nfunction validateSelector(selector) {\n if (!isFunction(selector)) errorHandler('selectorType');\n}\n\nfunction validateHandler(handler) {\n if (!(isFunction(handler) || isObject(handler))) errorHandler('handlerType');\n if (isObject(handler) && Object.values(handler).some(function (_handler) {\n return !isFunction(_handler);\n })) errorHandler('handlersType');\n}\n\nfunction validateInitial(initial) {\n if (!initial) errorHandler('initialIsRequired');\n if (!isObject(initial)) errorHandler('initialType');\n if (isEmpty(initial)) errorHandler('initialContent');\n}\n\nfunction throwError(errorMessages, type) {\n throw new Error(errorMessages[type] || errorMessages[\"default\"]);\n}\n\nvar errorMessages = {\n initialIsRequired: 'initial state is required',\n initialType: 'initial state should be an object',\n initialContent: 'initial state shouldn\\'t be an empty object',\n handlerType: 'handler should be an object or a function',\n handlersType: 'all handlers should be a functions',\n selectorType: 'selector should be a function',\n changeType: 'provided value of changes should be an object',\n changeField: 'it seams you want to change a field in the state which is not specified in the \"initial\" state',\n \"default\": 'an unknown error accured in `state-local` package'\n};\nvar errorHandler = curry(throwError)(errorMessages);\nvar validators = {\n changes: validateChanges,\n selector: validateSelector,\n handler: validateHandler,\n initial: validateInitial\n};\n\nfunction create(initial) {\n var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n validators.initial(initial);\n validators.handler(handler);\n var state = {\n current: initial\n };\n var didUpdate = curry(didStateUpdate)(state, handler);\n var update = curry(updateState)(state);\n var validate = curry(validators.changes)(initial);\n var getChanges = curry(extractChanges)(state);\n\n function getState() {\n var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (state) {\n return state;\n };\n validators.selector(selector);\n return selector(state.current);\n }\n\n function setState(causedChanges) {\n compose(didUpdate, update, validate, getChanges)(causedChanges);\n }\n\n return [getState, setState];\n}\n\nfunction extractChanges(state, causedChanges) {\n return isFunction(causedChanges) ? causedChanges(state.current) : causedChanges;\n}\n\nfunction updateState(state, changes) {\n state.current = _objectSpread2(_objectSpread2({}, state.current), changes);\n return changes;\n}\n\nfunction didStateUpdate(state, handler, changes) {\n isFunction(handler) ? handler(state.current) : Object.keys(changes).forEach(function (field) {\n var _handler$field;\n\n return (_handler$field = handler[field]) === null || _handler$field === void 0 ? void 0 : _handler$field.call(handler, state.current[field]);\n });\n return changes;\n}\n\nvar index = {\n create: create\n};\n\nexport default index;\n","var config = {\n paths: {\n vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.54.0/min/vs'\n }\n};\n\nexport { config as default };\n","function curry(fn) {\n return function curried() {\n var _this = this;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return args.length >= fn.length ? fn.apply(this, args) : function () {\n for (var _len2 = arguments.length, nextArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n nextArgs[_key2] = arguments[_key2];\n }\n return curried.apply(_this, [].concat(args, nextArgs));\n };\n };\n}\n\nexport { curry as default };\n","function isObject(value) {\n return {}.toString.call(value).includes('Object');\n}\n\nexport { isObject as default };\n","import curry from '../utils/curry.js';\nimport isObject from '../utils/isObject.js';\n\n/**\n * validates the configuration object and informs about deprecation\n * @param {Object} config - the configuration object \n * @return {Object} config - the validated configuration object\n */\nfunction validateConfig(config) {\n if (!config) errorHandler('configIsRequired');\n if (!isObject(config)) errorHandler('configType');\n if (config.urls) {\n informAboutDeprecation();\n return {\n paths: {\n vs: config.urls.monacoBase\n }\n };\n }\n return config;\n}\n\n/**\n * logs deprecation message\n */\nfunction informAboutDeprecation() {\n console.warn(errorMessages.deprecation);\n}\nfunction throwError(errorMessages, type) {\n throw new Error(errorMessages[type] || errorMessages[\"default\"]);\n}\nvar errorMessages = {\n configIsRequired: 'the configuration object is required',\n configType: 'the configuration object should be an object',\n \"default\": 'an unknown error accured in `@monaco-editor/loader` package',\n deprecation: \"Deprecation warning!\\n You are using deprecated way of configuration.\\n\\n Instead of using\\n monaco.config({ urls: { monacoBase: '...' } })\\n use\\n monaco.config({ paths: { vs: '...' } })\\n\\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\\n \"\n};\nvar errorHandler = curry(throwError)(errorMessages);\nvar validators = {\n config: validateConfig\n};\n\nexport { validators as default, errorHandler, errorMessages };\n","var compose = function compose() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n return function (x) {\n return fns.reduceRight(function (y, f) {\n return f(y);\n }, x);\n };\n};\n\nexport { compose as default };\n","import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';\n\nfunction merge(target, source) {\n Object.keys(source).forEach(function (key) {\n if (source[key] instanceof Object) {\n if (target[key]) {\n Object.assign(source[key], merge(target[key], source[key]));\n }\n }\n });\n return _objectSpread2(_objectSpread2({}, target), source);\n}\n\nexport { merge as default };\n","// The source (has been changed) is https://github.com/facebook/react/issues/5465#issuecomment-157888325\n\nvar CANCELATION_MESSAGE = {\n type: 'cancelation',\n msg: 'operation is manually canceled'\n};\nfunction makeCancelable(promise) {\n var hasCanceled_ = false;\n var wrappedPromise = new Promise(function (resolve, reject) {\n promise.then(function (val) {\n return hasCanceled_ ? reject(CANCELATION_MESSAGE) : resolve(val);\n });\n promise[\"catch\"](reject);\n });\n return wrappedPromise.cancel = function () {\n return hasCanceled_ = true;\n }, wrappedPromise;\n}\n\nexport { CANCELATION_MESSAGE, makeCancelable as default };\n","import { slicedToArray as _slicedToArray, objectWithoutProperties as _objectWithoutProperties } from '../_virtual/_rollupPluginBabelHelpers.js';\nimport state from 'state-local';\nimport config$1 from '../config/index.js';\nimport validators from '../validators/index.js';\nimport compose from '../utils/compose.js';\nimport merge from '../utils/deepMerge.js';\nimport makeCancelable from '../utils/makeCancelable.js';\n\nvar _excluded = [\"monaco\"];\n\n/** the local state of the module */\nvar _state$create = state.create({\n config: config$1,\n isInitialized: false,\n resolve: null,\n reject: null,\n monaco: null\n }),\n _state$create2 = _slicedToArray(_state$create, 2),\n getState = _state$create2[0],\n setState = _state$create2[1];\n\n/**\n * set the loader configuration\n * @param {Object} config - the configuration object\n */\nfunction config(globalConfig) {\n var _validators$config = validators.config(globalConfig),\n monaco = _validators$config.monaco,\n config = _objectWithoutProperties(_validators$config, _excluded);\n setState(function (state) {\n return {\n config: merge(state.config, config),\n monaco: monaco\n };\n });\n}\n\n/**\n * handles the initialization of the monaco-editor\n * @return {Promise} - returns an instance of monaco (with a cancelable promise)\n */\nfunction init() {\n var state = getState(function (_ref) {\n var monaco = _ref.monaco,\n isInitialized = _ref.isInitialized,\n resolve = _ref.resolve;\n return {\n monaco: monaco,\n isInitialized: isInitialized,\n resolve: resolve\n };\n });\n if (!state.isInitialized) {\n setState({\n isInitialized: true\n });\n if (state.monaco) {\n state.resolve(state.monaco);\n return makeCancelable(wrapperPromise);\n }\n if (window.monaco && window.monaco.editor) {\n storeMonacoInstance(window.monaco);\n state.resolve(window.monaco);\n return makeCancelable(wrapperPromise);\n }\n compose(injectScripts, getMonacoLoaderScript)(configureLoader);\n }\n return makeCancelable(wrapperPromise);\n}\n\n/**\n * injects provided scripts into the document.body\n * @param {Object} script - an HTML script element\n * @return {Object} - the injected HTML script element\n */\nfunction injectScripts(script) {\n return document.body.appendChild(script);\n}\n\n/**\n * creates an HTML script element with/without provided src\n * @param {string} [src] - the source path of the script\n * @return {Object} - the created HTML script element\n */\nfunction createScript(src) {\n var script = document.createElement('script');\n return src && (script.src = src), script;\n}\n\n/**\n * creates an HTML script element with the monaco loader src\n * @return {Object} - the created HTML script element\n */\nfunction getMonacoLoaderScript(configureLoader) {\n var state = getState(function (_ref2) {\n var config = _ref2.config,\n reject = _ref2.reject;\n return {\n config: config,\n reject: reject\n };\n });\n var loaderScript = createScript(\"\".concat(state.config.paths.vs, \"/loader.js\"));\n loaderScript.onload = function () {\n return configureLoader();\n };\n loaderScript.onerror = state.reject;\n return loaderScript;\n}\n\n/**\n * configures the monaco loader\n */\nfunction configureLoader() {\n var state = getState(function (_ref3) {\n var config = _ref3.config,\n resolve = _ref3.resolve,\n reject = _ref3.reject;\n return {\n config: config,\n resolve: resolve,\n reject: reject\n };\n });\n var require = window.require;\n require.config(state.config);\n require(['vs/editor/editor.main'], function (_ref4) {\n var monaco = _ref4.m;\n storeMonacoInstance(monaco);\n state.resolve(monaco);\n }, function (error) {\n state.reject(error);\n });\n}\n\n/**\n * store monaco instance in local state\n */\nfunction storeMonacoInstance(monaco) {\n if (!getState().monaco) {\n setState({\n monaco: monaco\n });\n }\n}\n\n/**\n * internal helper function\n * extracts stored monaco instance\n * @return {Object|null} - the monaco instance\n */\nfunction __getMonacoInstance() {\n return getState(function (_ref5) {\n var monaco = _ref5.monaco;\n return monaco;\n });\n}\nvar wrapperPromise = new Promise(function (resolve, reject) {\n return setState({\n resolve: resolve,\n reject: reject\n });\n});\nvar loader = {\n config: config,\n init: init,\n __getMonacoInstance: __getMonacoInstance\n};\n\nexport { loader as default };\n","import type { Operation as JsonPatchOperation } from \"fast-json-patch\";\nimport type * as monaco from \"monaco-editor\";\n\nexport interface JSONSchema {\n\ttype?: string | string[];\n\tproperties?: Record<string, JSONSchema>;\n\titems?: JSONSchema | JSONSchema[] | boolean;\n\tconst?: unknown;\n\toneOf?: JSONSchema[];\n\tanyOf?: JSONSchema[];\n\tallOf?: JSONSchema[];\n\tformat?: string;\n\tadditionalProperties?: boolean | JSONSchema;\n\t[key: string]: unknown;\n}\n\n// Conflict and Editor types\nexport enum InputState {\n\texcluded = 0,\n\tfirst = 1,\n\tsecond = 2,\n}\n\nexport enum ConflictType {\n\tSAME_CHANGE = \"same_change\",\n\tINPUT1_ONLY = \"input1_only\",\n\tINPUT2_ONLY = \"input2_only\",\n\tTRUE_CONFLICT = \"true_conflict\",\n}\n\nexport interface ModifiedBaseRange {\n\tid: string;\n\tpath?: string;\n\tbaseRange: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput1Range: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput2Range: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput1Diffs: unknown[];\n\tinput2Diffs: unknown[];\n\tisConflicting: boolean;\n\tconflictType: ConflictType;\n\tinput1State: InputState;\n\tinput2State: InputState;\n\thandled: boolean;\n\tfocused: boolean;\n}\n\nexport interface ConflictIssue {\n\tconflictId: string;\n\tconflictPath: string;\n\ttype: \"error\" | \"warning\" | \"smart-merge\";\n\tmessage: string;\n\tstartLine: number;\n\tendLine: number;\n}\n\nexport interface ResolutionInfo {\n\tisValid: boolean;\n\tvalidationError?: string;\n\twarnings?: string[];\n\tconflictIssues?: ConflictIssue[];\n}\n\nexport interface EditorDiffMergeProps {\n\toriginal?: string;\n\tmodified?: string;\n\tbase?: string;\n\ttheme?: string;\n\twidth?: string | number;\n\theight?: string | number;\n\tclassName?: string;\n\tloading?: React.ReactNode;\n\toptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\tonMount?: (editor: monaco.editor.IStandaloneDiffEditor, monaco: typeof import(\"monaco-editor\")) => void;\n\tonMergeResolve?: (content: string, resolution?: ResolutionInfo) => void;\n\tshowResultColumn?: boolean;\n\tbaseIndex?: 0 | 1 | 2;\n\tcomparisonMode?: \"split\" | \"sequential\";\n\tschema?: JSONSchema;\n\tpatches?: {\n\t\ttheirs?: JsonPatchOperation[];\n\t\tours?: JsonPatchOperation[];\n\t};\n\tlabels?: {\n\t\tinput1?: string;\n\t\tbase?: string;\n\t\tinput2?: string;\n\t\tresult?: string;\n\t};\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\n/**\n * Creates a JSON scanner on the given text.\n * If ignoreTrivia is set, whitespaces or comments are ignored.\n */\nexport function createScanner(text, ignoreTrivia = false) {\n const len = text.length;\n let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;\n function scanHexDigits(count, exact) {\n let digits = 0;\n let value = 0;\n while (digits < count || !exact) {\n let ch = text.charCodeAt(pos);\n if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {\n value = value * 16 + ch - 48 /* CharacterCodes._0 */;\n }\n else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {\n value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;\n }\n else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {\n value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;\n }\n else {\n break;\n }\n pos++;\n digits++;\n }\n if (digits < count) {\n value = -1;\n }\n return value;\n }\n function setPosition(newPosition) {\n pos = newPosition;\n value = '';\n tokenOffset = 0;\n token = 16 /* SyntaxKind.Unknown */;\n scanError = 0 /* ScanError.None */;\n }\n function scanNumber() {\n let start = pos;\n if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {\n pos++;\n }\n else {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n }\n if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {\n pos++;\n if (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n }\n else {\n scanError = 3 /* ScanError.UnexpectedEndOfNumber */;\n return text.substring(start, pos);\n }\n }\n let end = pos;\n if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {\n pos++;\n if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {\n pos++;\n }\n if (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n end = pos;\n }\n else {\n scanError = 3 /* ScanError.UnexpectedEndOfNumber */;\n }\n }\n return text.substring(start, end);\n }\n function scanString() {\n let result = '', start = pos;\n while (true) {\n if (pos >= len) {\n result += text.substring(start, pos);\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n const ch = text.charCodeAt(pos);\n if (ch === 34 /* CharacterCodes.doubleQuote */) {\n result += text.substring(start, pos);\n pos++;\n break;\n }\n if (ch === 92 /* CharacterCodes.backslash */) {\n result += text.substring(start, pos);\n pos++;\n if (pos >= len) {\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n const ch2 = text.charCodeAt(pos++);\n switch (ch2) {\n case 34 /* CharacterCodes.doubleQuote */:\n result += '\\\"';\n break;\n case 92 /* CharacterCodes.backslash */:\n result += '\\\\';\n break;\n case 47 /* CharacterCodes.slash */:\n result += '/';\n break;\n case 98 /* CharacterCodes.b */:\n result += '\\b';\n break;\n case 102 /* CharacterCodes.f */:\n result += '\\f';\n break;\n case 110 /* CharacterCodes.n */:\n result += '\\n';\n break;\n case 114 /* CharacterCodes.r */:\n result += '\\r';\n break;\n case 116 /* CharacterCodes.t */:\n result += '\\t';\n break;\n case 117 /* CharacterCodes.u */:\n const ch3 = scanHexDigits(4, true);\n if (ch3 >= 0) {\n result += String.fromCharCode(ch3);\n }\n else {\n scanError = 4 /* ScanError.InvalidUnicode */;\n }\n break;\n default:\n scanError = 5 /* ScanError.InvalidEscapeCharacter */;\n }\n start = pos;\n continue;\n }\n if (ch >= 0 && ch <= 0x1f) {\n if (isLineBreak(ch)) {\n result += text.substring(start, pos);\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n else {\n scanError = 6 /* ScanError.InvalidCharacter */;\n // mark as error but continue with string\n }\n }\n pos++;\n }\n return result;\n }\n function scanNext() {\n value = '';\n scanError = 0 /* ScanError.None */;\n tokenOffset = pos;\n lineStartOffset = lineNumber;\n prevTokenLineStartOffset = tokenLineStartOffset;\n if (pos >= len) {\n // at the end\n tokenOffset = len;\n return token = 17 /* SyntaxKind.EOF */;\n }\n let code = text.charCodeAt(pos);\n // trivia: whitespace\n if (isWhiteSpace(code)) {\n do {\n pos++;\n value += String.fromCharCode(code);\n code = text.charCodeAt(pos);\n } while (isWhiteSpace(code));\n return token = 15 /* SyntaxKind.Trivia */;\n }\n // trivia: newlines\n if (isLineBreak(code)) {\n pos++;\n value += String.fromCharCode(code);\n if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {\n pos++;\n value += '\\n';\n }\n lineNumber++;\n tokenLineStartOffset = pos;\n return token = 14 /* SyntaxKind.LineBreakTrivia */;\n }\n switch (code) {\n // tokens: []{}:,\n case 123 /* CharacterCodes.openBrace */:\n pos++;\n return token = 1 /* SyntaxKind.OpenBraceToken */;\n case 125 /* CharacterCodes.closeBrace */:\n pos++;\n return token = 2 /* SyntaxKind.CloseBraceToken */;\n case 91 /* CharacterCodes.openBracket */:\n pos++;\n return token = 3 /* SyntaxKind.OpenBracketToken */;\n case 93 /* CharacterCodes.closeBracket */:\n pos++;\n return token = 4 /* SyntaxKind.CloseBracketToken */;\n case 58 /* CharacterCodes.colon */:\n pos++;\n return token = 6 /* SyntaxKind.ColonToken */;\n case 44 /* CharacterCodes.comma */:\n pos++;\n return token = 5 /* SyntaxKind.CommaToken */;\n // strings\n case 34 /* CharacterCodes.doubleQuote */:\n pos++;\n value = scanString();\n return token = 10 /* SyntaxKind.StringLiteral */;\n // comments\n case 47 /* CharacterCodes.slash */:\n const start = pos - 1;\n // Single-line comment\n if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {\n pos += 2;\n while (pos < len) {\n if (isLineBreak(text.charCodeAt(pos))) {\n break;\n }\n pos++;\n }\n value = text.substring(start, pos);\n return token = 12 /* SyntaxKind.LineCommentTrivia */;\n }\n // Multi-line comment\n if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {\n pos += 2;\n const safeLength = len - 1; // For lookahead.\n let commentClosed = false;\n while (pos < safeLength) {\n const ch = text.charCodeAt(pos);\n if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {\n pos += 2;\n commentClosed = true;\n break;\n }\n pos++;\n if (isLineBreak(ch)) {\n if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {\n pos++;\n }\n lineNumber++;\n tokenLineStartOffset = pos;\n }\n }\n if (!commentClosed) {\n pos++;\n scanError = 1 /* ScanError.UnexpectedEndOfComment */;\n }\n value = text.substring(start, pos);\n return token = 13 /* SyntaxKind.BlockCommentTrivia */;\n }\n // just a single slash\n value += String.fromCharCode(code);\n pos++;\n return token = 16 /* SyntaxKind.Unknown */;\n // numbers\n case 45 /* CharacterCodes.minus */:\n value += String.fromCharCode(code);\n pos++;\n if (pos === len || !isDigit(text.charCodeAt(pos))) {\n return token = 16 /* SyntaxKind.Unknown */;\n }\n // found a minus, followed by a number so\n // we fall through to proceed with scanning\n // numbers\n case 48 /* CharacterCodes._0 */:\n case 49 /* CharacterCodes._1 */:\n case 50 /* CharacterCodes._2 */:\n case 51 /* CharacterCodes._3 */:\n case 52 /* CharacterCodes._4 */:\n case 53 /* CharacterCodes._5 */:\n case 54 /* CharacterCodes._6 */:\n case 55 /* CharacterCodes._7 */:\n case 56 /* CharacterCodes._8 */:\n case 57 /* CharacterCodes._9 */:\n value += scanNumber();\n return token = 11 /* SyntaxKind.NumericLiteral */;\n // literals and unknown symbols\n default:\n // is a literal? Read the full word.\n while (pos < len && isUnknownContentCharacter(code)) {\n pos++;\n code = text.charCodeAt(pos);\n }\n if (tokenOffset !== pos) {\n value = text.substring(tokenOffset, pos);\n // keywords: true, false, null\n switch (value) {\n case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;\n case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;\n case 'null': return token = 7 /* SyntaxKind.NullKeyword */;\n }\n return token = 16 /* SyntaxKind.Unknown */;\n }\n // some\n value += String.fromCharCode(code);\n pos++;\n return token = 16 /* SyntaxKind.Unknown */;\n }\n }\n function isUnknownContentCharacter(code) {\n if (isWhiteSpace(code) || isLineBreak(code)) {\n return false;\n }\n switch (code) {\n case 125 /* CharacterCodes.closeBrace */:\n case 93 /* CharacterCodes.closeBracket */:\n case 123 /* CharacterCodes.openBrace */:\n case 91 /* CharacterCodes.openBracket */:\n case 34 /* CharacterCodes.doubleQuote */:\n case 58 /* CharacterCodes.colon */:\n case 44 /* CharacterCodes.comma */:\n case 47 /* CharacterCodes.slash */:\n return false;\n }\n return true;\n }\n function scanNextNonTrivia() {\n let result;\n do {\n result = scanNext();\n } while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);\n return result;\n }\n return {\n setPosition: setPosition,\n getPosition: () => pos,\n scan: ignoreTrivia ? scanNextNonTrivia : scanNext,\n getToken: () => token,\n getTokenValue: () => value,\n getTokenOffset: () => tokenOffset,\n getTokenLength: () => pos - tokenOffset,\n getTokenStartLine: () => lineStartOffset,\n getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,\n getTokenError: () => scanError,\n };\n}\nfunction isWhiteSpace(ch) {\n return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;\n}\nfunction isLineBreak(ch) {\n return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;\n}\nfunction isDigit(ch) {\n return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;\n}\nvar CharacterCodes;\n(function (CharacterCodes) {\n CharacterCodes[CharacterCodes[\"lineFeed\"] = 10] = \"lineFeed\";\n CharacterCodes[CharacterCodes[\"carriageReturn\"] = 13] = \"carriageReturn\";\n CharacterCodes[CharacterCodes[\"space\"] = 32] = \"space\";\n CharacterCodes[CharacterCodes[\"_0\"] = 48] = \"_0\";\n CharacterCodes[CharacterCodes[\"_1\"] = 49] = \"_1\";\n CharacterCodes[CharacterCodes[\"_2\"] = 50] = \"_2\";\n CharacterCodes[CharacterCodes[\"_3\"] = 51] = \"_3\";\n CharacterCodes[CharacterCodes[\"_4\"] = 52] = \"_4\";\n CharacterCodes[CharacterCodes[\"_5\"] = 53] = \"_5\";\n CharacterCodes[CharacterCodes[\"_6\"] = 54] = \"_6\";\n CharacterCodes[CharacterCodes[\"_7\"] = 55] = \"_7\";\n CharacterCodes[CharacterCodes[\"_8\"] = 56] = \"_8\";\n CharacterCodes[CharacterCodes[\"_9\"] = 57] = \"_9\";\n CharacterCodes[CharacterCodes[\"a\"] = 97] = \"a\";\n CharacterCodes[CharacterCodes[\"b\"] = 98] = \"b\";\n CharacterCodes[CharacterCodes[\"c\"] = 99] = \"c\";\n CharacterCodes[CharacterCodes[\"d\"] = 100] = \"d\";\n CharacterCodes[CharacterCodes[\"e\"] = 101] = \"e\";\n CharacterCodes[CharacterCodes[\"f\"] = 102] = \"f\";\n CharacterCodes[CharacterCodes[\"g\"] = 103] = \"g\";\n CharacterCodes[CharacterCodes[\"h\"] = 104] = \"h\";\n CharacterCodes[CharacterCodes[\"i\"] = 105] = \"i\";\n CharacterCodes[CharacterCodes[\"j\"] = 106] = \"j\";\n CharacterCodes[CharacterCodes[\"k\"] = 107] = \"k\";\n CharacterCodes[CharacterCodes[\"l\"] = 108] = \"l\";\n CharacterCodes[CharacterCodes[\"m\"] = 109] = \"m\";\n CharacterCodes[CharacterCodes[\"n\"] = 110] = \"n\";\n CharacterCodes[CharacterCodes[\"o\"] = 111] = \"o\";\n CharacterCodes[CharacterCodes[\"p\"] = 112] = \"p\";\n CharacterCodes[CharacterCodes[\"q\"] = 113] = \"q\";\n CharacterCodes[CharacterCodes[\"r\"] = 114] = \"r\";\n CharacterCodes[CharacterCodes[\"s\"] = 115] = \"s\";\n CharacterCodes[CharacterCodes[\"t\"] = 116] = \"t\";\n CharacterCodes[CharacterCodes[\"u\"] = 117] = \"u\";\n CharacterCodes[CharacterCodes[\"v\"] = 118] = \"v\";\n CharacterCodes[CharacterCodes[\"w\"] = 119] = \"w\";\n CharacterCodes[CharacterCodes[\"x\"] = 120] = \"x\";\n CharacterCodes[CharacterCodes[\"y\"] = 121] = \"y\";\n CharacterCodes[CharacterCodes[\"z\"] = 122] = \"z\";\n CharacterCodes[CharacterCodes[\"A\"] = 65] = \"A\";\n CharacterCodes[CharacterCodes[\"B\"] = 66] = \"B\";\n CharacterCodes[CharacterCodes[\"C\"] = 67] = \"C\";\n CharacterCodes[CharacterCodes[\"D\"] = 68] = \"D\";\n CharacterCodes[CharacterCodes[\"E\"] = 69] = \"E\";\n CharacterCodes[CharacterCodes[\"F\"] = 70] = \"F\";\n CharacterCodes[CharacterCodes[\"G\"] = 71] = \"G\";\n CharacterCodes[CharacterCodes[\"H\"] = 72] = \"H\";\n CharacterCodes[CharacterCodes[\"I\"] = 73] = \"I\";\n CharacterCodes[CharacterCodes[\"J\"] = 74] = \"J\";\n CharacterCodes[CharacterCodes[\"K\"] = 75] = \"K\";\n CharacterCodes[CharacterCodes[\"L\"] = 76] = \"L\";\n CharacterCodes[CharacterCodes[\"M\"] = 77] = \"M\";\n CharacterCodes[CharacterCodes[\"N\"] = 78] = \"N\";\n CharacterCodes[CharacterCodes[\"O\"] = 79] = \"O\";\n CharacterCodes[CharacterCodes[\"P\"] = 80] = \"P\";\n CharacterCodes[CharacterCodes[\"Q\"] = 81] = \"Q\";\n CharacterCodes[CharacterCodes[\"R\"] = 82] = \"R\";\n CharacterCodes[CharacterCodes[\"S\"] = 83] = \"S\";\n CharacterCodes[CharacterCodes[\"T\"] = 84] = \"T\";\n CharacterCodes[CharacterCodes[\"U\"] = 85] = \"U\";\n CharacterCodes[CharacterCodes[\"V\"] = 86] = \"V\";\n CharacterCodes[CharacterCodes[\"W\"] = 87] = \"W\";\n CharacterCodes[CharacterCodes[\"X\"] = 88] = \"X\";\n CharacterCodes[CharacterCodes[\"Y\"] = 89] = \"Y\";\n CharacterCodes[CharacterCodes[\"Z\"] = 90] = \"Z\";\n CharacterCodes[CharacterCodes[\"asterisk\"] = 42] = \"asterisk\";\n CharacterCodes[CharacterCodes[\"backslash\"] = 92] = \"backslash\";\n CharacterCodes[CharacterCodes[\"closeBrace\"] = 125] = \"closeBrace\";\n CharacterCodes[CharacterCodes[\"closeBracket\"] = 93] = \"closeBracket\";\n CharacterCodes[CharacterCodes[\"colon\"] = 58] = \"colon\";\n CharacterCodes[CharacterCodes[\"comma\"] = 44] = \"comma\";\n CharacterCodes[CharacterCodes[\"dot\"] = 46] = \"dot\";\n CharacterCodes[CharacterCodes[\"doubleQuote\"] = 34] = \"doubleQuote\";\n CharacterCodes[CharacterCodes[\"minus\"] = 45] = \"minus\";\n CharacterCodes[CharacterCodes[\"openBrace\"] = 123] = \"openBrace\";\n CharacterCodes[CharacterCodes[\"openBracket\"] = 91] = \"openBracket\";\n CharacterCodes[CharacterCodes[\"plus\"] = 43] = \"plus\";\n CharacterCodes[CharacterCodes[\"slash\"] = 47] = \"slash\";\n CharacterCodes[CharacterCodes[\"formFeed\"] = 12] = \"formFeed\";\n CharacterCodes[CharacterCodes[\"tab\"] = 9] = \"tab\";\n})(CharacterCodes || (CharacterCodes = {}));\n","export const cachedSpaces = new Array(20).fill(0).map((_, index) => {\n return ' '.repeat(index);\n});\nconst maxCachedValues = 200;\nexport const cachedBreakLinesWithSpaces = {\n ' ': {\n '\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\n' + ' '.repeat(index);\n }),\n '\\r': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r' + ' '.repeat(index);\n }),\n '\\r\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r\\n' + ' '.repeat(index);\n }),\n },\n '\\t': {\n '\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\n' + '\\t'.repeat(index);\n }),\n '\\r': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r' + '\\t'.repeat(index);\n }),\n '\\r\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r\\n' + '\\t'.repeat(index);\n }),\n }\n};\nexport const supportedEols = ['\\n', '\\r', '\\r\\n'];\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\nimport { createScanner } from './scanner';\nvar ParseOptions;\n(function (ParseOptions) {\n ParseOptions.DEFAULT = {\n allowTrailingComma: false\n };\n})(ParseOptions || (ParseOptions = {}));\n/**\n * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.\n */\nexport function getLocation(text, position) {\n const segments = []; // strings or numbers\n const earlyReturnException = new Object();\n let previousNode = undefined;\n const previousNodeInst = {\n value: {},\n offset: 0,\n length: 0,\n type: 'object',\n parent: undefined\n };\n let isAtPropertyKey = false;\n function setPreviousNode(value, offset, length, type) {\n previousNodeInst.value = value;\n previousNodeInst.offset = offset;\n previousNodeInst.length = length;\n previousNodeInst.type = type;\n previousNodeInst.colonOffset = undefined;\n previousNode = previousNodeInst;\n }\n try {\n visit(text, {\n onObjectBegin: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n isAtPropertyKey = position > offset;\n segments.push(''); // push a placeholder (will be replaced)\n },\n onObjectProperty: (name, offset, length) => {\n if (position < offset) {\n throw earlyReturnException;\n }\n setPreviousNode(name, offset, length, 'property');\n segments[segments.length - 1] = name;\n if (position <= offset + length) {\n throw earlyReturnException;\n }\n },\n onObjectEnd: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.pop();\n },\n onArrayBegin: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.push(0);\n },\n onArrayEnd: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.pop();\n },\n onLiteralValue: (value, offset, length) => {\n if (position < offset) {\n throw earlyReturnException;\n }\n setPreviousNode(value, offset, length, getNodeType(value));\n if (position <= offset + length) {\n throw earlyReturnException;\n }\n },\n onSeparator: (sep, offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n if (sep === ':' && previousNode && previousNode.type === 'property') {\n previousNode.colonOffset = offset;\n isAtPropertyKey = false;\n previousNode = undefined;\n }\n else if (sep === ',') {\n const last = segments[segments.length - 1];\n if (typeof last === 'number') {\n segments[segments.length - 1] = last + 1;\n }\n else {\n isAtPropertyKey = true;\n segments[segments.length - 1] = '';\n }\n previousNode = undefined;\n }\n }\n });\n }\n catch (e) {\n if (e !== earlyReturnException) {\n throw e;\n }\n }\n return {\n path: segments,\n previousNode,\n isAtPropertyKey,\n matches: (pattern) => {\n let k = 0;\n for (let i = 0; k < pattern.length && i < segments.length; i++) {\n if (pattern[k] === segments[i] || pattern[k] === '*') {\n k++;\n }\n else if (pattern[k] !== '**') {\n return false;\n }\n }\n return k === pattern.length;\n }\n };\n}\n/**\n * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n * Therefore always check the errors list to find out if the input was valid.\n */\nexport function parse(text, errors = [], options = ParseOptions.DEFAULT) {\n let currentProperty = null;\n let currentParent = [];\n const previousParents = [];\n function onValue(value) {\n if (Array.isArray(currentParent)) {\n currentParent.push(value);\n }\n else if (currentProperty !== null) {\n currentParent[currentProperty] = value;\n }\n }\n const visitor = {\n onObjectBegin: () => {\n const object = {};\n onValue(object);\n previousParents.push(currentParent);\n currentParent = object;\n currentProperty = null;\n },\n onObjectProperty: (name) => {\n currentProperty = name;\n },\n onObjectEnd: () => {\n currentParent = previousParents.pop();\n },\n onArrayBegin: () => {\n const array = [];\n onValue(array);\n previousParents.push(currentParent);\n currentParent = array;\n currentProperty = null;\n },\n onArrayEnd: () => {\n currentParent = previousParents.pop();\n },\n onLiteralValue: onValue,\n onError: (error, offset, length) => {\n errors.push({ error, offset, length });\n }\n };\n visit(text, visitor, options);\n return currentParent[0];\n}\n/**\n * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n */\nexport function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {\n let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root\n function ensurePropertyComplete(endOffset) {\n if (currentParent.type === 'property') {\n currentParent.length = endOffset - currentParent.offset;\n currentParent = currentParent.parent;\n }\n }\n function onValue(valueNode) {\n currentParent.children.push(valueNode);\n return valueNode;\n }\n const visitor = {\n onObjectBegin: (offset) => {\n currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });\n },\n onObjectProperty: (name, offset, length) => {\n currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });\n currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });\n },\n onObjectEnd: (offset, length) => {\n ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete\n currentParent.length = offset + length - currentParent.offset;\n currentParent = currentParent.parent;\n ensurePropertyComplete(offset + length);\n },\n onArrayBegin: (offset, length) => {\n currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });\n },\n onArrayEnd: (offset, length) => {\n currentParent.length = offset + length - currentParent.offset;\n currentParent = currentParent.parent;\n ensurePropertyComplete(offset + length);\n },\n onLiteralValue: (value, offset, length) => {\n onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });\n ensurePropertyComplete(offset + length);\n },\n onSeparator: (sep, offset, length) => {\n if (currentParent.type === 'property') {\n if (sep === ':') {\n currentParent.colonOffset = offset;\n }\n else if (sep === ',') {\n ensurePropertyComplete(offset);\n }\n }\n },\n onError: (error, offset, length) => {\n errors.push({ error, offset, length });\n }\n };\n visit(text, visitor, options);\n const result = currentParent.children[0];\n if (result) {\n delete result.parent;\n }\n return result;\n}\n/**\n * Finds the node at the given path in a JSON DOM.\n */\nexport function findNodeAtLocation(root, path) {\n if (!root) {\n return undefined;\n }\n let node = root;\n for (let segment of path) {\n if (typeof segment === 'string') {\n if (node.type !== 'object' || !Array.isArray(node.children)) {\n return undefined;\n }\n let found = false;\n for (const propertyNode of node.children) {\n if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {\n node = propertyNode.children[1];\n found = true;\n break;\n }\n }\n if (!found) {\n return undefined;\n }\n }\n else {\n const index = segment;\n if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {\n return undefined;\n }\n node = node.children[index];\n }\n }\n return node;\n}\n/**\n * Gets the JSON path of the given JSON DOM node\n */\nexport function getNodePath(node) {\n if (!node.parent || !node.parent.children) {\n return [];\n }\n const path = getNodePath(node.parent);\n if (node.parent.type === 'property') {\n const key = node.parent.children[0].value;\n path.push(key);\n }\n else if (node.parent.type === 'array') {\n const index = node.parent.children.indexOf(node);\n if (index !== -1) {\n path.push(index);\n }\n }\n return path;\n}\n/**\n * Evaluates the JavaScript object of the given JSON DOM node\n */\nexport function getNodeValue(node) {\n switch (node.type) {\n case 'array':\n return node.children.map(getNodeValue);\n case 'object':\n const obj = Object.create(null);\n for (let prop of node.children) {\n const valueNode = prop.children[1];\n if (valueNode) {\n obj[prop.children[0].value] = getNodeValue(valueNode);\n }\n }\n return obj;\n case 'null':\n case 'string':\n case 'number':\n case 'boolean':\n return node.value;\n default:\n return undefined;\n }\n}\nexport function contains(node, offset, includeRightBound = false) {\n return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));\n}\n/**\n * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.\n */\nexport function findNodeAtOffset(node, offset, includeRightBound = false) {\n if (contains(node, offset, includeRightBound)) {\n const children = node.children;\n if (Array.isArray(children)) {\n for (let i = 0; i < children.length && children[i].offset <= offset; i++) {\n const item = findNodeAtOffset(children[i], offset, includeRightBound);\n if (item) {\n return item;\n }\n }\n }\n return node;\n }\n return undefined;\n}\n/**\n * Parses the given text and invokes the visitor functions for each object, array and literal reached.\n */\nexport function visit(text, visitor, options = ParseOptions.DEFAULT) {\n const _scanner = createScanner(text, false);\n // Important: Only pass copies of this to visitor functions to prevent accidental modification, and\n // to not affect visitor functions which stored a reference to a previous JSONPath\n const _jsonPath = [];\n // Depth of onXXXBegin() callbacks suppressed. onXXXEnd() decrements this if it isn't 0 already.\n // Callbacks are only called when this value is 0.\n let suppressedCallbacks = 0;\n function toNoArgVisit(visitFunction) {\n return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;\n }\n function toOneArgVisit(visitFunction) {\n return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;\n }\n function toOneArgVisitWithPath(visitFunction) {\n return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;\n }\n function toBeginVisit(visitFunction) {\n return visitFunction ?\n () => {\n if (suppressedCallbacks > 0) {\n suppressedCallbacks++;\n }\n else {\n let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());\n if (cbReturn === false) {\n suppressedCallbacks = 1;\n }\n }\n }\n : () => true;\n }\n function toEndVisit(visitFunction) {\n return visitFunction ?\n () => {\n if (suppressedCallbacks > 0) {\n suppressedCallbacks--;\n }\n if (suppressedCallbacks === 0) {\n visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());\n }\n }\n : () => true;\n }\n const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);\n const disallowComments = options && options.disallowComments;\n const allowTrailingComma = options && options.allowTrailingComma;\n function scanNext() {\n while (true) {\n const token = _scanner.scan();\n switch (_scanner.getTokenError()) {\n case 4 /* ScanError.InvalidUnicode */:\n handleError(14 /* ParseErrorCode.InvalidUnicode */);\n break;\n case 5 /* ScanError.InvalidEscapeCharacter */:\n handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);\n break;\n case 3 /* ScanError.UnexpectedEndOfNumber */:\n handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);\n break;\n case 1 /* ScanError.UnexpectedEndOfComment */:\n if (!disallowComments) {\n handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);\n }\n break;\n case 2 /* ScanError.UnexpectedEndOfString */:\n handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);\n break;\n case 6 /* ScanError.InvalidCharacter */:\n handleError(16 /* ParseErrorCode.InvalidCharacter */);\n break;\n }\n switch (token) {\n case 12 /* SyntaxKind.LineCommentTrivia */:\n case 13 /* SyntaxKind.BlockCommentTrivia */:\n if (disallowComments) {\n handleError(10 /* ParseErrorCode.InvalidCommentToken */);\n }\n else {\n onComment();\n }\n break;\n case 16 /* SyntaxKind.Unknown */:\n handleError(1 /* ParseErrorCode.InvalidSymbol */);\n break;\n case 15 /* SyntaxKind.Trivia */:\n case 14 /* SyntaxKind.LineBreakTrivia */:\n break;\n default:\n return token;\n }\n }\n }\n function handleError(error, skipUntilAfter = [], skipUntil = []) {\n onError(error);\n if (skipUntilAfter.length + skipUntil.length > 0) {\n let token = _scanner.getToken();\n while (token !== 17 /* SyntaxKind.EOF */) {\n if (skipUntilAfter.indexOf(token) !== -1) {\n scanNext();\n break;\n }\n else if (skipUntil.indexOf(token) !== -1) {\n break;\n }\n token = scanNext();\n }\n }\n }\n function parseString(isValue) {\n const value = _scanner.getTokenValue();\n if (isValue) {\n onLiteralValue(value);\n }\n else {\n onObjectProperty(value);\n // add property name afterwards\n _jsonPath.push(value);\n }\n scanNext();\n return true;\n }\n function parseLiteral() {\n switch (_scanner.getToken()) {\n case 11 /* SyntaxKind.NumericLiteral */:\n const tokenValue = _scanner.getTokenValue();\n let value = Number(tokenValue);\n if (isNaN(value)) {\n handleError(2 /* ParseErrorCode.InvalidNumberFormat */);\n value = 0;\n }\n onLiteralValue(value);\n break;\n case 7 /* SyntaxKind.NullKeyword */:\n onLiteralValue(null);\n break;\n case 8 /* SyntaxKind.TrueKeyword */:\n onLiteralValue(true);\n break;\n case 9 /* SyntaxKind.FalseKeyword */:\n onLiteralValue(false);\n break;\n default:\n return false;\n }\n scanNext();\n return true;\n }\n function parseProperty() {\n if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {\n handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n return false;\n }\n parseString(false);\n if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {\n onSeparator(':');\n scanNext(); // consume colon\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n }\n else {\n handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n _jsonPath.pop(); // remove processed property name\n return true;\n }\n function parseObject() {\n onObjectBegin();\n scanNext(); // consume open brace\n let needsComma = false;\n while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {\n if (!needsComma) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n }\n onSeparator(',');\n scanNext(); // consume comma\n if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {\n break;\n }\n }\n else if (needsComma) {\n handleError(6 /* ParseErrorCode.CommaExpected */, [], []);\n }\n if (!parseProperty()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n needsComma = true;\n }\n onObjectEnd();\n if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {\n handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);\n }\n else {\n scanNext(); // consume close brace\n }\n return true;\n }\n function parseArray() {\n onArrayBegin();\n scanNext(); // consume open bracket\n let isFirstElement = true;\n let needsComma = false;\n while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {\n if (!needsComma) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n }\n onSeparator(',');\n scanNext(); // consume comma\n if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {\n break;\n }\n }\n else if (needsComma) {\n handleError(6 /* ParseErrorCode.CommaExpected */, [], []);\n }\n if (isFirstElement) {\n _jsonPath.push(0);\n isFirstElement = false;\n }\n else {\n _jsonPath[_jsonPath.length - 1]++;\n }\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n needsComma = true;\n }\n onArrayEnd();\n if (!isFirstElement) {\n _jsonPath.pop(); // remove array index\n }\n if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {\n handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);\n }\n else {\n scanNext(); // consume close bracket\n }\n return true;\n }\n function parseValue() {\n switch (_scanner.getToken()) {\n case 3 /* SyntaxKind.OpenBracketToken */:\n return parseArray();\n case 1 /* SyntaxKind.OpenBraceToken */:\n return parseObject();\n case 10 /* SyntaxKind.StringLiteral */:\n return parseString(true);\n default:\n return parseLiteral();\n }\n }\n scanNext();\n if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {\n if (options.allowEmptyContent) {\n return true;\n }\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n return false;\n }\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n return false;\n }\n if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);\n }\n return true;\n}\n/**\n * Takes JSON with JavaScript-style comments and remove\n * them. Optionally replaces every none-newline character\n * of comments with a replaceCharacter\n */\nexport function stripComments(text, replaceCh) {\n let _scanner = createScanner(text), parts = [], kind, offset = 0, pos;\n do {\n pos = _scanner.getPosition();\n kind = _scanner.scan();\n switch (kind) {\n case 12 /* SyntaxKind.LineCommentTrivia */:\n case 13 /* SyntaxKind.BlockCommentTrivia */:\n case 17 /* SyntaxKind.EOF */:\n if (offset !== pos) {\n parts.push(text.substring(offset, pos));\n }\n if (replaceCh !== undefined) {\n parts.push(_scanner.getTokenValue().replace(/[^\\r\\n]/g, replaceCh));\n }\n offset = _scanner.getPosition();\n break;\n }\n } while (kind !== 17 /* SyntaxKind.EOF */);\n return parts.join('');\n}\nexport function getNodeType(value) {\n switch (typeof value) {\n case 'boolean': return 'boolean';\n case 'number': return 'number';\n case 'string': return 'string';\n case 'object': {\n if (!value) {\n return 'null';\n }\n else if (Array.isArray(value)) {\n return 'array';\n }\n return 'object';\n }\n default: return 'null';\n }\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\nimport * as formatter from './impl/format';\nimport * as edit from './impl/edit';\nimport * as scanner from './impl/scanner';\nimport * as parser from './impl/parser';\n/**\n * Creates a JSON scanner on the given text.\n * If ignoreTrivia is set, whitespaces or comments are ignored.\n */\nexport const createScanner = scanner.createScanner;\nexport var ScanError;\n(function (ScanError) {\n ScanError[ScanError[\"None\"] = 0] = \"None\";\n ScanError[ScanError[\"UnexpectedEndOfComment\"] = 1] = \"UnexpectedEndOfComment\";\n ScanError[ScanError[\"UnexpectedEndOfString\"] = 2] = \"UnexpectedEndOfString\";\n ScanError[ScanError[\"UnexpectedEndOfNumber\"] = 3] = \"UnexpectedEndOfNumber\";\n ScanError[ScanError[\"InvalidUnicode\"] = 4] = \"InvalidUnicode\";\n ScanError[ScanError[\"InvalidEscapeCharacter\"] = 5] = \"InvalidEscapeCharacter\";\n ScanError[ScanError[\"InvalidCharacter\"] = 6] = \"InvalidCharacter\";\n})(ScanError || (ScanError = {}));\nexport var SyntaxKind;\n(function (SyntaxKind) {\n SyntaxKind[SyntaxKind[\"OpenBraceToken\"] = 1] = \"OpenBraceToken\";\n SyntaxKind[SyntaxKind[\"CloseBraceToken\"] = 2] = \"CloseBraceToken\";\n SyntaxKind[SyntaxKind[\"OpenBracketToken\"] = 3] = \"OpenBracketToken\";\n SyntaxKind[SyntaxKind[\"CloseBracketToken\"] = 4] = \"CloseBracketToken\";\n SyntaxKind[SyntaxKind[\"CommaToken\"] = 5] = \"CommaToken\";\n SyntaxKind[SyntaxKind[\"ColonToken\"] = 6] = \"ColonToken\";\n SyntaxKind[SyntaxKind[\"NullKeyword\"] = 7] = \"NullKeyword\";\n SyntaxKind[SyntaxKind[\"TrueKeyword\"] = 8] = \"TrueKeyword\";\n SyntaxKind[SyntaxKind[\"FalseKeyword\"] = 9] = \"FalseKeyword\";\n SyntaxKind[SyntaxKind[\"StringLiteral\"] = 10] = \"StringLiteral\";\n SyntaxKind[SyntaxKind[\"NumericLiteral\"] = 11] = \"NumericLiteral\";\n SyntaxKind[SyntaxKind[\"LineCommentTrivia\"] = 12] = \"LineCommentTrivia\";\n SyntaxKind[SyntaxKind[\"BlockCommentTrivia\"] = 13] = \"BlockCommentTrivia\";\n SyntaxKind[SyntaxKind[\"LineBreakTrivia\"] = 14] = \"LineBreakTrivia\";\n SyntaxKind[SyntaxKind[\"Trivia\"] = 15] = \"Trivia\";\n SyntaxKind[SyntaxKind[\"Unknown\"] = 16] = \"Unknown\";\n SyntaxKind[SyntaxKind[\"EOF\"] = 17] = \"EOF\";\n})(SyntaxKind || (SyntaxKind = {}));\n/**\n * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.\n */\nexport const getLocation = parser.getLocation;\n/**\n * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n * Therefore, always check the errors list to find out if the input was valid.\n */\nexport const parse = parser.parse;\n/**\n * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n */\nexport const parseTree = parser.parseTree;\n/**\n * Finds the node at the given path in a JSON DOM.\n */\nexport const findNodeAtLocation = parser.findNodeAtLocation;\n/**\n * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.\n */\nexport const findNodeAtOffset = parser.findNodeAtOffset;\n/**\n * Gets the JSON path of the given JSON DOM node\n */\nexport const getNodePath = parser.getNodePath;\n/**\n * Evaluates the JavaScript object of the given JSON DOM node\n */\nexport const getNodeValue = parser.getNodeValue;\n/**\n * Parses the given text and invokes the visitor functions for each object, array and literal reached.\n */\nexport const visit = parser.visit;\n/**\n * Takes JSON with JavaScript-style comments and remove\n * them. Optionally replaces every none-newline character\n * of comments with a replaceCharacter\n */\nexport const stripComments = parser.stripComments;\nexport var ParseErrorCode;\n(function (ParseErrorCode) {\n ParseErrorCode[ParseErrorCode[\"InvalidSymbol\"] = 1] = \"InvalidSymbol\";\n ParseErrorCode[ParseErrorCode[\"InvalidNumberFormat\"] = 2] = \"InvalidNumberFormat\";\n ParseErrorCode[ParseErrorCode[\"PropertyNameExpected\"] = 3] = \"PropertyNameExpected\";\n ParseErrorCode[ParseErrorCode[\"ValueExpected\"] = 4] = \"ValueExpected\";\n ParseErrorCode[ParseErrorCode[\"ColonExpected\"] = 5] = \"ColonExpected\";\n ParseErrorCode[ParseErrorCode[\"CommaExpected\"] = 6] = \"CommaExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBraceExpected\"] = 7] = \"CloseBraceExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBracketExpected\"] = 8] = \"CloseBracketExpected\";\n ParseErrorCode[ParseErrorCode[\"EndOfFileExpected\"] = 9] = \"EndOfFileExpected\";\n ParseErrorCode[ParseErrorCode[\"InvalidCommentToken\"] = 10] = \"InvalidCommentToken\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfComment\"] = 11] = \"UnexpectedEndOfComment\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfString\"] = 12] = \"UnexpectedEndOfString\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfNumber\"] = 13] = \"UnexpectedEndOfNumber\";\n ParseErrorCode[ParseErrorCode[\"InvalidUnicode\"] = 14] = \"InvalidUnicode\";\n ParseErrorCode[ParseErrorCode[\"InvalidEscapeCharacter\"] = 15] = \"InvalidEscapeCharacter\";\n ParseErrorCode[ParseErrorCode[\"InvalidCharacter\"] = 16] = \"InvalidCharacter\";\n})(ParseErrorCode || (ParseErrorCode = {}));\nexport function printParseErrorCode(code) {\n switch (code) {\n case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';\n case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';\n case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';\n case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';\n case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';\n case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';\n case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';\n case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';\n case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';\n case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';\n case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';\n case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';\n case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';\n case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';\n case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';\n case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';\n }\n return '<unknown ParseErrorCode>';\n}\n/**\n * Computes the edit operations needed to format a JSON document.\n *\n * @param documentText The input text\n * @param range The range to format or `undefined` to format the full content\n * @param options The formatting options\n * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\nexport function format(documentText, range, options) {\n return formatter.format(documentText, range, options);\n}\n/**\n * Computes the edit operations needed to modify a value in the JSON document.\n *\n * @param documentText The input text\n * @param path The path of the value to change. The path represents either to the document root, a property or an array item.\n * If the path points to an non-existing property or item, it will be created.\n * @param value The new value for the specified property or item. If the value is undefined,\n * the property or item will be removed.\n * @param options Options\n * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\nexport function modify(text, path, value, options) {\n return edit.setProperty(text, path, value, options);\n}\n/**\n * Applies edits to an input string.\n * @param text The input text\n * @param edits Edit operations following the format described in {@linkcode EditResult}.\n * @returns The text with the applied edits.\n * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.\n */\nexport function applyEdits(text, edits) {\n let sortedEdits = edits.slice(0).sort((a, b) => {\n const diff = a.offset - b.offset;\n if (diff === 0) {\n return a.length - b.length;\n }\n return diff;\n });\n let lastModifiedOffset = text.length;\n for (let i = sortedEdits.length - 1; i >= 0; i--) {\n let e = sortedEdits[i];\n if (e.offset + e.length <= lastModifiedOffset) {\n text = edit.applyEdit(text, e);\n }\n else {\n throw new Error('Overlapping edit');\n }\n lastModifiedOffset = e.offset;\n }\n return text;\n}\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import isEqual from \"fast-deep-equal\";\nimport sortKeys from \"sort-keys\";\n\n/**\n * Get value at a path in an object\n * Supports JSON Pointer format: \"/path/to/value\" or \"/array/0/item\"\n */\nexport const getValueAtPath = <T = unknown>(obj: Record<string, unknown> | undefined, path: string): T | undefined => {\n\tif (!obj) return undefined;\n\n\t// Normalize path to array of keys\n\tconst normalizedPath = path\n\t\t.replace(/^\\//, \"\") // remove leading slash\n\t\t.replace(/\\[/g, \".\") // convert [0] to .0\n\t\t.replace(/\\]/g, \"\") // remove ]\n\t\t.split(/[./#]/) // split by dot, slash, or hash\n\t\t.filter(Boolean); // remove empty strings\n\n\tlet current: unknown = obj;\n\n\tfor (const key of normalizedPath) {\n\t\tif (!current || typeof current !== \"object\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Handle arrays with numeric indices\n\t\tif (Array.isArray(current)) {\n\t\t\tconst index = Number.parseInt(key, 10);\n\t\t\tif (Number.isNaN(index) || index < 0 || index >= current.length) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcurrent = current[index];\n\t\t}\n\t\t// Handle objects\n\t\telse if (key in current) {\n\t\t\tcurrent = (current as Record<string, unknown>)[key];\n\t\t}\n\t\t// Property doesn't exist\n\t\telse {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn current as T;\n};\n\nexport { isEqual, sortKeys };\n","/*!\n * https://github.com/Starcounter-Jack/JSON-Patch\n * (c) 2017-2022 Joachim Wester\n * MIT licensed\n */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar _hasOwnProperty = Object.prototype.hasOwnProperty;\nexport function hasOwnProperty(obj, key) {\n return _hasOwnProperty.call(obj, key);\n}\nexport function _objectKeys(obj) {\n if (Array.isArray(obj)) {\n var keys_1 = new Array(obj.length);\n for (var k = 0; k < keys_1.length; k++) {\n keys_1[k] = \"\" + k;\n }\n return keys_1;\n }\n if (Object.keys) {\n return Object.keys(obj);\n }\n var keys = [];\n for (var i in obj) {\n if (hasOwnProperty(obj, i)) {\n keys.push(i);\n }\n }\n return keys;\n}\n;\n/**\n* Deeply clone the object.\n* https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)\n* @param {any} obj value to clone\n* @return {any} cloned obj\n*/\nexport function _deepClone(obj) {\n switch (typeof obj) {\n case \"object\":\n return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5\n case \"undefined\":\n return null; //this is how JSON.stringify behaves for array items\n default:\n return obj; //no need to clone primitives\n }\n}\n//3x faster than cached /^\\d+$/.test(str)\nexport function isInteger(str) {\n var i = 0;\n var len = str.length;\n var charCode;\n while (i < len) {\n charCode = str.charCodeAt(i);\n if (charCode >= 48 && charCode <= 57) {\n i++;\n continue;\n }\n return false;\n }\n return true;\n}\n/**\n* Escapes a json pointer path\n* @param path The raw pointer\n* @return the Escaped path\n*/\nexport function escapePathComponent(path) {\n if (path.indexOf('/') === -1 && path.indexOf('~') === -1)\n return path;\n return path.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n/**\n * Unescapes a json pointer path\n * @param path The escaped pointer\n * @return The unescaped path\n */\nexport function unescapePathComponent(path) {\n return path.replace(/~1/g, '/').replace(/~0/g, '~');\n}\nexport function _getPathRecursive(root, obj) {\n var found;\n for (var key in root) {\n if (hasOwnProperty(root, key)) {\n if (root[key] === obj) {\n return escapePathComponent(key) + '/';\n }\n else if (typeof root[key] === 'object') {\n found = _getPathRecursive(root[key], obj);\n if (found != '') {\n return escapePathComponent(key) + '/' + found;\n }\n }\n }\n }\n return '';\n}\nexport function getPath(root, obj) {\n if (root === obj) {\n return '/';\n }\n var path = _getPathRecursive(root, obj);\n if (path === '') {\n throw new Error(\"Object not found in root\");\n }\n return \"/\" + path;\n}\n/**\n* Recursively checks whether an object has any undefined values inside.\n*/\nexport function hasUndefined(obj) {\n if (obj === undefined) {\n return true;\n }\n if (obj) {\n if (Array.isArray(obj)) {\n for (var i_1 = 0, len = obj.length; i_1 < len; i_1++) {\n if (hasUndefined(obj[i_1])) {\n return true;\n }\n }\n }\n else if (typeof obj === \"object\") {\n var objKeys = _objectKeys(obj);\n var objKeysLength = objKeys.length;\n for (var i = 0; i < objKeysLength; i++) {\n if (hasUndefined(obj[objKeys[i]])) {\n return true;\n }\n }\n }\n }\n return false;\n}\nfunction patchErrorMessageFormatter(message, args) {\n var messageParts = [message];\n for (var key in args) {\n var value = typeof args[key] === 'object' ? JSON.stringify(args[key], null, 2) : args[key]; // pretty print\n if (typeof value !== 'undefined') {\n messageParts.push(key + \": \" + value);\n }\n }\n return messageParts.join('\\n');\n}\nvar PatchError = /** @class */ (function (_super) {\n __extends(PatchError, _super);\n function PatchError(message, name, index, operation, tree) {\n var _newTarget = this.constructor;\n var _this = _super.call(this, patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree })) || this;\n _this.name = name;\n _this.index = index;\n _this.operation = operation;\n _this.tree = tree;\n Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain, see https://stackoverflow.com/a/48342359\n _this.message = patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree });\n return _this;\n }\n return PatchError;\n}(Error));\nexport { PatchError };\n","import { PatchError, _deepClone, isInteger, unescapePathComponent, hasUndefined } from './helpers.mjs';\nexport var JsonPatchError = PatchError;\nexport var deepClone = _deepClone;\n/* We use a Javascript hash to store each\n function. Each hash entry (property) uses\n the operation identifiers specified in rfc6902.\n In this way, we can map each patch operation\n to its dedicated function in efficient way.\n */\n/* The operations applicable to an object */\nvar objOps = {\n add: function (obj, key, document) {\n obj[key] = this.value;\n return { newDocument: document };\n },\n remove: function (obj, key, document) {\n var removed = obj[key];\n delete obj[key];\n return { newDocument: document, removed: removed };\n },\n replace: function (obj, key, document) {\n var removed = obj[key];\n obj[key] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: function (obj, key, document) {\n /* in case move target overwrites an existing value,\n return the removed value, this can be taxing performance-wise,\n and is potentially unneeded */\n var removed = getValueByPointer(document, this.path);\n if (removed) {\n removed = _deepClone(removed);\n }\n var originalValue = applyOperation(document, { op: \"remove\", path: this.from }).removed;\n applyOperation(document, { op: \"add\", path: this.path, value: originalValue });\n return { newDocument: document, removed: removed };\n },\n copy: function (obj, key, document) {\n var valueToCopy = getValueByPointer(document, this.from);\n // enforce copy by value so further operations don't affect source (see issue #177)\n applyOperation(document, { op: \"add\", path: this.path, value: _deepClone(valueToCopy) });\n return { newDocument: document };\n },\n test: function (obj, key, document) {\n return { newDocument: document, test: _areEquals(obj[key], this.value) };\n },\n _get: function (obj, key, document) {\n this.value = obj[key];\n return { newDocument: document };\n }\n};\n/* The operations applicable to an array. Many are the same as for the object */\nvar arrOps = {\n add: function (arr, i, document) {\n if (isInteger(i)) {\n arr.splice(i, 0, this.value);\n }\n else { // array props\n arr[i] = this.value;\n }\n // this may be needed when using '-' in an array\n return { newDocument: document, index: i };\n },\n remove: function (arr, i, document) {\n var removedList = arr.splice(i, 1);\n return { newDocument: document, removed: removedList[0] };\n },\n replace: function (arr, i, document) {\n var removed = arr[i];\n arr[i] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: objOps.move,\n copy: objOps.copy,\n test: objOps.test,\n _get: objOps._get\n};\n/**\n * Retrieves a value from a JSON document by a JSON pointer.\n * Returns the value.\n *\n * @param document The document to get the value from\n * @param pointer an escaped JSON pointer\n * @return The retrieved value\n */\nexport function getValueByPointer(document, pointer) {\n if (pointer == '') {\n return document;\n }\n var getOriginalDestination = { op: \"_get\", path: pointer };\n applyOperation(document, getOriginalDestination);\n return getOriginalDestination.value;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the {newDocument, result} of the operation.\n * It modifies the `document` and `operation` objects - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return `{newDocument, result}` after the operation\n */\nexport function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {\n if (validateOperation === void 0) { validateOperation = false; }\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (index === void 0) { index = 0; }\n if (validateOperation) {\n if (typeof validateOperation == 'function') {\n validateOperation(operation, 0, document, operation.path);\n }\n else {\n validator(operation, 0);\n }\n }\n /* ROOT OPERATIONS */\n if (operation.path === \"\") {\n var returnValue = { newDocument: document };\n if (operation.op === 'add') {\n returnValue.newDocument = operation.value;\n return returnValue;\n }\n else if (operation.op === 'replace') {\n returnValue.newDocument = operation.value;\n returnValue.removed = document; //document we removed\n return returnValue;\n }\n else if (operation.op === 'move' || operation.op === 'copy') { // it's a move or copy to root\n returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field\n if (operation.op === 'move') { // report removed item\n returnValue.removed = document;\n }\n return returnValue;\n }\n else if (operation.op === 'test') {\n returnValue.test = _areEquals(document, operation.value);\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n returnValue.newDocument = document;\n return returnValue;\n }\n else if (operation.op === 'remove') { // a remove on root\n returnValue.removed = document;\n returnValue.newDocument = null;\n return returnValue;\n }\n else if (operation.op === '_get') {\n operation.value = document;\n return returnValue;\n }\n else { /* bad operation */\n if (validateOperation) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else {\n return returnValue;\n }\n }\n } /* END ROOT OPERATIONS */\n else {\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var path = operation.path || \"\";\n var keys = path.split('/');\n var obj = document;\n var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift\n var len = keys.length;\n var existingPathFragment = undefined;\n var key = void 0;\n var validateFunction = void 0;\n if (typeof validateOperation == 'function') {\n validateFunction = validateOperation;\n }\n else {\n validateFunction = validator;\n }\n while (true) {\n key = keys[t];\n if (key && key.indexOf('~') != -1) {\n key = unescapePathComponent(key);\n }\n if (banPrototypeModifications &&\n (key == '__proto__' ||\n (key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {\n throw new TypeError('JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');\n }\n if (validateOperation) {\n if (existingPathFragment === undefined) {\n if (obj[key] === undefined) {\n existingPathFragment = keys.slice(0, t).join('/');\n }\n else if (t == len - 1) {\n existingPathFragment = operation.path;\n }\n if (existingPathFragment !== undefined) {\n validateFunction(operation, 0, document, existingPathFragment);\n }\n }\n }\n t++;\n if (Array.isArray(obj)) {\n if (key === '-') {\n key = obj.length;\n }\n else {\n if (validateOperation && !isInteger(key)) {\n throw new JsonPatchError(\"Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index\", \"OPERATION_PATH_ILLEGAL_ARRAY_INDEX\", index, operation, document);\n } // only parse key when it's an integer for `arr.prop` to work\n else if (isInteger(key)) {\n key = ~~key;\n }\n }\n if (t >= len) {\n if (validateOperation && operation.op === \"add\" && key > obj.length) {\n throw new JsonPatchError(\"The specified index MUST NOT be greater than the number of elements in the array\", \"OPERATION_VALUE_OUT_OF_BOUNDS\", index, operation, document);\n }\n var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n else {\n if (t >= len) {\n var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n obj = obj[key];\n // If we have more keys in the path, but the next value isn't a non-null object,\n // throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.\n if (validateOperation && t < len && (!obj || typeof obj !== \"object\")) {\n throw new JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Apply a full JSON Patch array on a JSON document.\n * Returns the {newDocument, result} of the patch.\n * It modifies the `document` object and `patch` - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.\n *\n * @param document The document to patch\n * @param patch The patch to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return An array of `{newDocument, result}` after the patch\n */\nexport function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (validateOperation) {\n if (!Array.isArray(patch)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n }\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var results = new Array(patch.length);\n for (var i = 0, length_1 = patch.length; i < length_1; i++) {\n // we don't need to pass mutateDocument argument because if it was true, we already deep cloned the object, we'll just pass `true`\n results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);\n document = results[i].newDocument; // in case root was replaced\n }\n results.newDocument = document;\n return results;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the updated document.\n * Suitable as a reducer.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @return The updated document\n */\nexport function applyReducer(document, operation, index) {\n var operationResult = applyOperation(document, operation);\n if (operationResult.test === false) { // failed test\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return operationResult.newDocument;\n}\n/**\n * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.\n * @param {object} operation - operation object (patch)\n * @param {number} index - index of operation in the sequence\n * @param {object} [document] - object where the operation is supposed to be applied\n * @param {string} [existingPathFragment] - comes along with `document`\n */\nexport function validator(operation, index, document, existingPathFragment) {\n if (typeof operation !== 'object' || operation === null || Array.isArray(operation)) {\n throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, document);\n }\n else if (!objOps[operation.op]) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else if (typeof operation.path !== 'string') {\n throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {\n // paths that aren't empty string should start with \"/\"\n throw new JsonPatchError('Operation `path` property must start with \"/\"', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {\n throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);\n }\n else if (document) {\n if (operation.op == \"add\") {\n var pathLen = operation.path.split(\"/\").length;\n var existingPathLen = existingPathFragment.split(\"/\").length;\n if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {\n throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, document);\n }\n }\n else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {\n if (operation.path !== existingPathFragment) {\n throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n else if (operation.op === 'move' || operation.op === 'copy') {\n var existingValue = { op: \"_get\", path: operation.from, value: undefined };\n var error = validate([existingValue], document);\n if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {\n throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.\n * If error is encountered, returns a JsonPatchError object\n * @param sequence\n * @param document\n * @returns {JsonPatchError|undefined}\n */\nexport function validate(sequence, document, externalValidator) {\n try {\n if (!Array.isArray(sequence)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n if (document) {\n //clone document and sequence so that we can safely try applying operations\n applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);\n }\n else {\n externalValidator = externalValidator || validator;\n for (var i = 0; i < sequence.length; i++) {\n externalValidator(sequence[i], i, document, undefined);\n }\n }\n }\n catch (e) {\n if (e instanceof JsonPatchError) {\n return e;\n }\n else {\n throw e;\n }\n }\n}\n// based on https://github.com/epoberezkin/fast-deep-equal\n// MIT License\n// Copyright (c) 2017 Evgeny Poberezkin\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nexport function _areEquals(a, b) {\n if (a === b)\n return true;\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length)\n return false;\n for (i = length; i-- !== 0;)\n if (!_areEquals(a[i], b[i]))\n return false;\n return true;\n }\n if (arrA != arrB)\n return false;\n var keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length)\n return false;\n for (i = length; i-- !== 0;)\n if (!b.hasOwnProperty(keys[i]))\n return false;\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!_areEquals(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a !== a && b !== b;\n}\n;\n","/*!\n * https://github.com/Starcounter-Jack/JSON-Patch\n * (c) 2017-2021 Joachim Wester\n * MIT license\n */\nimport { _deepClone, _objectKeys, escapePathComponent, hasOwnProperty } from './helpers.mjs';\nimport { applyPatch } from './core.mjs';\nvar beforeDict = new WeakMap();\nvar Mirror = /** @class */ (function () {\n function Mirror(obj) {\n this.observers = new Map();\n this.obj = obj;\n }\n return Mirror;\n}());\nvar ObserverInfo = /** @class */ (function () {\n function ObserverInfo(callback, observer) {\n this.callback = callback;\n this.observer = observer;\n }\n return ObserverInfo;\n}());\nfunction getMirror(obj) {\n return beforeDict.get(obj);\n}\nfunction getObserverFromMirror(mirror, callback) {\n return mirror.observers.get(callback);\n}\nfunction removeObserverFromMirror(mirror, observer) {\n mirror.observers.delete(observer.callback);\n}\n/**\n * Detach an observer from an object\n */\nexport function unobserve(root, observer) {\n observer.unobserve();\n}\n/**\n * Observes changes made to an object, which can then be retrieved using generate\n */\nexport function observe(obj, callback) {\n var patches = [];\n var observer;\n var mirror = getMirror(obj);\n if (!mirror) {\n mirror = new Mirror(obj);\n beforeDict.set(obj, mirror);\n }\n else {\n var observerInfo = getObserverFromMirror(mirror, callback);\n observer = observerInfo && observerInfo.observer;\n }\n if (observer) {\n return observer;\n }\n observer = {};\n mirror.value = _deepClone(obj);\n if (callback) {\n observer.callback = callback;\n observer.next = null;\n var dirtyCheck = function () {\n generate(observer);\n };\n var fastCheck = function () {\n clearTimeout(observer.next);\n observer.next = setTimeout(dirtyCheck);\n };\n if (typeof window !== 'undefined') { //not Node\n window.addEventListener('mouseup', fastCheck);\n window.addEventListener('keyup', fastCheck);\n window.addEventListener('mousedown', fastCheck);\n window.addEventListener('keydown', fastCheck);\n window.addEventListener('change', fastCheck);\n }\n }\n observer.patches = patches;\n observer.object = obj;\n observer.unobserve = function () {\n generate(observer);\n clearTimeout(observer.next);\n removeObserverFromMirror(mirror, observer);\n if (typeof window !== 'undefined') {\n window.removeEventListener('mouseup', fastCheck);\n window.removeEventListener('keyup', fastCheck);\n window.removeEventListener('mousedown', fastCheck);\n window.removeEventListener('keydown', fastCheck);\n window.removeEventListener('change', fastCheck);\n }\n };\n mirror.observers.set(callback, new ObserverInfo(callback, observer));\n return observer;\n}\n/**\n * Generate an array of patches from an observer\n */\nexport function generate(observer, invertible) {\n if (invertible === void 0) { invertible = false; }\n var mirror = beforeDict.get(observer.object);\n _generate(mirror.value, observer.object, observer.patches, \"\", invertible);\n if (observer.patches.length) {\n applyPatch(mirror.value, observer.patches);\n }\n var temp = observer.patches;\n if (temp.length > 0) {\n observer.patches = [];\n if (observer.callback) {\n observer.callback(temp);\n }\n }\n return temp;\n}\n// Dirty check if obj is different from mirror, generate patches and update mirror\nfunction _generate(mirror, obj, patches, path, invertible) {\n if (obj === mirror) {\n return;\n }\n if (typeof obj.toJSON === \"function\") {\n obj = obj.toJSON();\n }\n var newKeys = _objectKeys(obj);\n var oldKeys = _objectKeys(mirror);\n var changed = false;\n var deleted = false;\n //if ever \"move\" operation is implemented here, make sure this test runs OK: \"should not generate the same patch twice (move)\"\n for (var t = oldKeys.length - 1; t >= 0; t--) {\n var key = oldKeys[t];\n var oldVal = mirror[key];\n if (hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {\n var newVal = obj[key];\n if (typeof oldVal == \"object\" && oldVal != null && typeof newVal == \"object\" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {\n _generate(oldVal, newVal, patches, path + \"/\" + escapePathComponent(key), invertible);\n }\n else {\n if (oldVal !== newVal) {\n changed = true;\n if (invertible) {\n patches.push({ op: \"test\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(oldVal) });\n }\n patches.push({ op: \"replace\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(newVal) });\n }\n }\n }\n else if (Array.isArray(mirror) === Array.isArray(obj)) {\n if (invertible) {\n patches.push({ op: \"test\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(oldVal) });\n }\n patches.push({ op: \"remove\", path: path + \"/\" + escapePathComponent(key) });\n deleted = true; // property has been deleted\n }\n else {\n if (invertible) {\n patches.push({ op: \"test\", path: path, value: mirror });\n }\n patches.push({ op: \"replace\", path: path, value: obj });\n changed = true;\n }\n }\n if (!deleted && newKeys.length == oldKeys.length) {\n return;\n }\n for (var t = 0; t < newKeys.length; t++) {\n var key = newKeys[t];\n if (!hasOwnProperty(mirror, key) && obj[key] !== undefined) {\n patches.push({ op: \"add\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(obj[key]) });\n }\n }\n}\n/**\n * Create an array of patches from the differences in two objects\n */\nexport function compare(tree1, tree2, invertible) {\n if (invertible === void 0) { invertible = false; }\n var patches = [];\n _generate(tree1, tree2, patches, '', invertible);\n return patches;\n}\n","export * from './module/core.mjs';\nexport * from './module/duplex.mjs';\nexport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\n\n/**\n * Default export for backwards compat\n */\n\nimport * as core from './module/core.mjs';\nimport * as duplex from './module/duplex.mjs';\nimport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\nexport default Object.assign({}, core, duplex, {\n JsonPatchError,\n deepClone,\n escapePathComponent,\n unescapePathComponent\n});","import type { JSONSchema } from \"../types\";\n\nconst ONE_OF = \"oneOf\";\nconst ANY_OF = \"anyOf\";\nconst ALL_OF = \"allOf\";\n\nexport function hasSchemaVariants(schema: JSONSchema): boolean {\n\treturn !!(schema[ONE_OF] || schema[ANY_OF] || schema[ALL_OF]);\n}\n\nexport function getSchemaVariants(schema: JSONSchema): JSONSchema[] | undefined {\n\tconst variants = schema[ONE_OF] || schema[ANY_OF] || schema[ALL_OF];\n\treturn Array.isArray(variants) ? (variants as JSONSchema[]) : undefined;\n}\n\nexport function getSubschemaKeyword(schema: JSONSchema): string {\n\tif (schema.oneOf) return ONE_OF;\n\tif (schema.anyOf) return ANY_OF;\n\tif (schema.allOf) return ALL_OF;\n\treturn \"\";\n}\n\n/**\n * Find common discriminator field across all variants\n * Returns the field name that has const values in variants and exists in data\n */\nfunction findCommonDiscriminatorField(variants: JSONSchema[], data: unknown): { field: string; value: unknown } | null {\n\tif (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n\t\treturn null;\n\t}\n\n\tconst obj = data as Record<string, unknown>;\n\n\t// Find fields that have const values in at least one variant\n\tconst discriminatorFields = new Set<string>();\n\n\tfor (const variant of variants) {\n\t\tconst props = variant.properties;\n\t\tif (props) {\n\t\t\tfor (const [field, propSchema] of Object.entries(props)) {\n\t\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\t\tdiscriminatorFields.add(field);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check which discriminator field exists in the data\n\tfor (const field of discriminatorFields) {\n\t\tif (field in obj) {\n\t\t\treturn { field, value: obj[field] };\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Synchronous version of chooseSubschema for use in non-async contexts\n * Enhanced to handle object discriminators and const values\n */\nexport function chooseSubschemaSync(\n\tdata: unknown,\n\tvariants: JSONSchema[],\n\t_schemaKeyword: string = ONE_OF,\n): { selectedIndex: number; schema: JSONSchema } {\n\tif (variants.length === 0) {\n\t\tthrow new Error(\"No variants provided to chooseSubschemaSync\");\n\t}\n\n\t// Handle null\n\tif (data === null) {\n\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\tconst variant = variants[i];\n\t\t\tif (variant.const === null) {\n\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t}\n\t\t}\n\t}\n\n\t// For objects, try to match by discriminator fields (const properties)\n\tif (typeof data === \"object\" && data !== null && !Array.isArray(data)) {\n\t\tconst dataObj = data as Record<string, unknown>;\n\n\t\t// First pass: look for discriminator matches\n\t\tconst discriminator = findCommonDiscriminatorField(variants, data);\n\t\tif (discriminator) {\n\t\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\t\tconst variant = variants[i];\n\t\t\t\tconst variantProp = variant.properties?.[discriminator.field] as JSONSchema | undefined;\n\n\t\t\t\tif (variantProp && typeof variantProp === \"object\" && \"const\" in variantProp && variantProp.const === discriminator.value) {\n\t\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Second pass: check if object structure matches variant properties\n\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\tconst variant = variants[i];\n\t\t\tif (variant.type === \"object\" && variant.properties) {\n\t\t\t\t// Check if all required properties exist in data\n\t\t\t\tconst required = (variant.required || []) as string[];\n\t\t\t\tconst hasAllRequired = required.every((field: string) => field in dataObj);\n\n\t\t\t\tif (hasAllRequired && required.length > 0) {\n\t\t\t\t\t// Additional check: see if discriminator fields match\n\t\t\t\t\tlet discriminatorMatches = true;\n\t\t\t\t\tfor (const [field, propSchema] of Object.entries(variant.properties)) {\n\t\t\t\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\t\t\t\tconst constValue = (propSchema as JSONSchema).const;\n\t\t\t\t\t\t\tif (dataObj[field] !== constValue) {\n\t\t\t\t\t\t\t\tdiscriminatorMatches = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (discriminatorMatches) {\n\t\t\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Match by primitive const value (prioritize const over type)\n\tfor (let i = 0; i < variants.length; i++) {\n\t\tconst variant = variants[i];\n\t\tif (variant.const !== undefined && variant.const === data) {\n\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t}\n\t}\n\n\t// Match by type (after const check)\n\tfor (let i = 0; i < variants.length; i++) {\n\t\tconst variant = variants[i];\n\t\tif (variant.type) {\n\t\t\tconst dataType = Array.isArray(data) ? \"array\" : typeof data;\n\t\t\tconst variantType = Array.isArray(variant.type) ? variant.type[0] : variant.type;\n\t\t\tif (variantType === dataType) {\n\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Default to first variant (fallback)\n\treturn { selectedIndex: 0, schema: variants[0] };\n}\n","import { compare, type Operation as JsonPatchOperation } from \"fast-json-patch\";\nimport { findNodeAtLocation, parseTree } from \"jsonc-parser\";\nimport type { JSONSchema } from \"../types\";\nimport { ConflictType, InputState, type ModifiedBaseRange } from \"../types\";\nimport { getValueAtPath, isEqual, sortKeys } from \"./helpers\";\nimport { chooseSubschemaSync, getSchemaVariants, getSubschemaKeyword, hasSchemaVariants } from \"./schema\";\n\n/**\n * Represents a conflict analysis result for a JSON path\n */\nexport interface ConflictAnalysis {\n\tpath: string; // JSON Pointer path\n\tbaseValue: unknown;\n\tinput1Value: unknown; // Theirs value\n\tinput2Value: unknown; // Ours value\n\tconflictType: ConflictType;\n\tpatches1?: JsonPatchOperation[]; // Optional: patches from base to input1\n\tpatches2?: JsonPatchOperation[]; // Optional: patches from base to input2\n}\n\n/**\n * Format JSON with sorted keys (objects only, arrays unchanged)\n * @param json - JSON object to format\n * @returns Formatted JSON string with 2-space indentation\n */\nexport function formatJsonForComparison(json: unknown): string {\n\t// sortKeys only sorts object keys, arrays remain unchanged\n\tif (typeof json === \"object\" && json !== null && !Array.isArray(json)) {\n\t\tconst sorted = sortKeys(json as Record<string, unknown>, { deep: true });\n\t\treturn JSON.stringify(sorted, null, 2);\n\t}\n\treturn JSON.stringify(json, null, 2);\n}\n\n/**\n * Determine conflict type based on semantic comparison of values\n * @param base - Base value\n * @param input1 - Input1 (theirs) value\n * @param input2 - Input2 (ours) value\n * @returns Conflict type\n */\nexport function determineConflictType(base: unknown, input1: unknown, input2: unknown): ConflictType {\n\t// Use fast-deep-equal for semantic comparison (already in toolbox)\n\tconst input1Changed = !isEqual(base, input1);\n\tconst input2Changed = !isEqual(base, input2);\n\n\tif (input1Changed && input2Changed) {\n\t\t// Both changed - are they semantically equal?\n\t\tif (isEqual(input1, input2)) {\n\t\t\treturn ConflictType.SAME_CHANGE;\n\t\t}\n\t\treturn ConflictType.TRUE_CONFLICT;\n\t}\n\n\tif (input1Changed) return ConflictType.INPUT1_ONLY;\n\tif (input2Changed) return ConflictType.INPUT2_ONLY;\n\n\treturn ConflictType.SAME_CHANGE; // No change\n}\n\n/**\n * Get line numbers for a JSON node at a given path\n * @param text - Formatted JSON text\n * @param path - JSON Pointer path\n * @returns Start and end line numbers (1-indexed), or {1, 1} if not found\n */\nexport function getNodeLines(text: string, path: string): { start: number; end: number } {\n\ttry {\n\t\tconst root = parseTree(text);\n\t\tif (!root) {\n\t\t\treturn { start: 1, end: 1 };\n\t\t}\n\n\t\t// Convert path segments to proper types (numbers for array indices, strings for object keys)\n\t\tconst pathSegments = path\n\t\t\t.split(\"/\")\n\t\t\t.filter(Boolean)\n\t\t\t.map((segment) => {\n\t\t\t\t// Check if segment is a numeric array index\n\t\t\t\tconst numericValue = Number.parseInt(segment, 10);\n\t\t\t\treturn !Number.isNaN(numericValue) && String(numericValue) === segment ? numericValue : segment;\n\t\t\t});\n\n\t\tconst node = pathSegments.length === 0 ? root : findNodeAtLocation(root, pathSegments);\n\n\t\tif (!node) {\n\t\t\treturn { start: 1, end: 1 };\n\t\t}\n\n\t\tconst result = {\n\t\t\tstart: getLineNumber(text, node.offset),\n\t\t\tend: getLineNumber(text, node.offset + node.length),\n\t\t};\n\t\treturn result;\n\t} catch (_error) {\n\t\treturn { start: 1, end: 1 };\n\t}\n}\n\n/**\n * Convert character offset to line number\n * @param text - Text content\n * @param offset - Character offset\n * @returns Line number (1-indexed)\n */\nfunction getLineNumber(text: string, offset: number): number {\n\treturn text.substring(0, offset).split(\"\\n\").length;\n}\n\n/**\n * Group JSON Patch operations by their root path\n * @param patches1 - Patches from base to input1\n * @param patches2 - Patches from base to input2\n * @returns Map of root paths to their patches\n */\nfunction groupPatchesByRootPath(\n\tpatches1: JsonPatchOperation[],\n\tpatches2: JsonPatchOperation[],\n): Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }> {\n\tconst pathGroups = new Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }>();\n\n\t// Helper to get root path (first segment)\n\tconst getRootPath = (path: string): string => {\n\t\tconst segments = path.split(\"/\").filter(Boolean);\n\t\treturn segments.length > 0 ? `/${segments[0]}` : \"/\";\n\t};\n\n\t// Group patches1\n\tfor (const patch of patches1) {\n\t\tconst rootPath = getRootPath(patch.path);\n\t\tif (!pathGroups.has(rootPath)) {\n\t\t\tpathGroups.set(rootPath, { patches1: [], patches2: [] });\n\t\t}\n\t\tconst group = pathGroups.get(rootPath);\n\t\tif (group) {\n\t\t\tgroup.patches1.push(patch);\n\t\t}\n\t}\n\n\t// Group patches2\n\tfor (const patch of patches2) {\n\t\tconst rootPath = getRootPath(patch.path);\n\t\tif (!pathGroups.has(rootPath)) {\n\t\t\tpathGroups.set(rootPath, { patches1: [], patches2: [] });\n\t\t}\n\t\tconst group = pathGroups.get(rootPath);\n\t\tif (group) {\n\t\t\tgroup.patches2.push(patch);\n\t\t}\n\t}\n\n\treturn pathGroups;\n}\n\n/**\n * Schema-aware patch grouping for 3-way merge\n * Groups patches by array item identity (using schema anchors) instead of just path\n */\nfunction groupPatchesWithSchema(\n\tpatches1: JsonPatchOperation[],\n\tpatches2: JsonPatchOperation[],\n\tbase: unknown,\n\tinput1: unknown,\n\tinput2: unknown,\n\tschema: JSONSchema,\n): Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }> {\n\tconst pathGroups = new Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }>();\n\n\t// Separate array patches from non-array patches\n\tconst arrayPatchGroups1 = new Map<string, JsonPatchOperation[]>();\n\tconst arrayPatchGroups2 = new Map<string, JsonPatchOperation[]>();\n\tconst nonArrayPatches1: JsonPatchOperation[] = [];\n\tconst nonArrayPatches2: JsonPatchOperation[] = [];\n\n\t// Group patches by array path\n\tfor (const patch of patches1) {\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1];\n\t\t\tif (!arrayPatchGroups1.has(arrayPath)) {\n\t\t\t\tarrayPatchGroups1.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst group1 = arrayPatchGroups1.get(arrayPath);\n\t\t\tif (group1) {\n\t\t\t\tgroup1.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches1.push(patch);\n\t\t}\n\t}\n\n\tfor (const patch of patches2) {\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1];\n\t\t\tif (!arrayPatchGroups2.has(arrayPath)) {\n\t\t\t\tarrayPatchGroups2.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst group2 = arrayPatchGroups2.get(arrayPath);\n\t\t\tif (group2) {\n\t\t\t\tgroup2.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches2.push(patch);\n\t\t}\n\t}\n\n\t// Get all unique array paths\n\tconst allArrayPaths = new Set<string>([...arrayPatchGroups1.keys(), ...arrayPatchGroups2.keys()]);\n\n\t// Process each array with schema-aware matching\n\tfor (const arrayPath of allArrayPaths) {\n\t\tconst baseArray = getValueAtPath(base as Record<string, unknown>, arrayPath);\n\t\tconst input1Array = getValueAtPath(input1 as Record<string, unknown>, arrayPath);\n\t\tconst input2Array = getValueAtPath(input2 as Record<string, unknown>, arrayPath);\n\n\t\tif (!Array.isArray(baseArray) || !Array.isArray(input1Array) || !Array.isArray(input2Array)) {\n\t\t\t// Not arrays - fall back to index-based grouping\n\t\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\t\t\tfor (const patch of patches1) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t\t}\n\t\t\t\t\tconst itemGroup1 = pathGroups.get(itemPath);\n\t\t\t\t\tif (itemGroup1) {\n\t\t\t\t\t\titemGroup1.patches1.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const patch of patches2) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t\t}\n\t\t\t\t\tconst itemGroup2 = pathGroups.get(itemPath);\n\t\t\t\t\tif (itemGroup2) {\n\t\t\t\t\t\titemGroup2.patches2.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get schema for array items\n\t\tconst arraySchema = getSchemaAtPath(schema, arrayPath, base);\n\t\tconst itemSchemaRaw = arraySchema?.items\n\t\t\t? Array.isArray(arraySchema.items) && arraySchema.items[0]\n\t\t\t\t? arraySchema.items[0]\n\t\t\t\t: !Array.isArray(arraySchema.items)\n\t\t\t\t\t? arraySchema.items\n\t\t\t\t\t: null\n\t\t\t: null;\n\t\t// Ensure itemSchema is a valid JSONSchema (not true)\n\t\tconst itemSchema = itemSchemaRaw && typeof itemSchemaRaw === \"object\" ? itemSchemaRaw : null;\n\n\t\tif (itemSchema) {\n\t\t\t// Use 3-way schema matching\n\t\t\tconst matches = matchArrayItemsById(baseArray, input1Array, input2Array, itemSchema);\n\n\t\t\tif (matches.size > 0) {\n\t\t\t\t// Create mappings from index to key\n\t\t\t\tconst baseKeysByIndex = new Map<number, string | number>();\n\t\t\t\tconst input1KeysByIndex = new Map<number, string | number>();\n\t\t\t\tconst input2KeysByIndex = new Map<number, string | number>();\n\n\t\t\t\tfor (const [key, indices] of matches.entries()) {\n\t\t\t\t\tif (indices.base !== undefined) baseKeysByIndex.set(indices.base, key);\n\t\t\t\t\tif (indices.input1 !== undefined) input1KeysByIndex.set(indices.input1, key);\n\t\t\t\t\tif (indices.input2 !== undefined) input2KeysByIndex.set(indices.input2, key);\n\t\t\t\t}\n\n\t\t\t\t// Group patches by matched item\n\t\t\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\t\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\n\t\t\t\tfor (const patch of patches1) {\n\t\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\t\t\t\t\t\tconst key = input1KeysByIndex.get(index);\n\t\t\t\t\t\tif (key !== undefined) {\n\t\t\t\t\t\t\tconst groupKey = `${arrayPath}#${key}`;\n\t\t\t\t\t\t\tif (!pathGroups.has(groupKey)) {\n\t\t\t\t\t\t\t\tpathGroups.set(groupKey, { patches1: [], patches2: [] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst groupKey1 = pathGroups.get(groupKey);\n\t\t\t\t\t\t\tif (groupKey1) {\n\t\t\t\t\t\t\t\tgroupKey1.patches1.push(patch);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const patch of patches2) {\n\t\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\t\t\t\t\t\tconst key = input2KeysByIndex.get(index);\n\t\t\t\t\t\tif (key !== undefined) {\n\t\t\t\t\t\t\tconst groupKey = `${arrayPath}#${key}`;\n\t\t\t\t\t\t\tif (!pathGroups.has(groupKey)) {\n\t\t\t\t\t\t\t\tpathGroups.set(groupKey, { patches1: [], patches2: [] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst groupKey2 = pathGroups.get(groupKey);\n\t\t\t\t\t\t\tif (groupKey2) {\n\t\t\t\t\t\t\t\tgroupKey2.patches2.push(patch);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// No schema or no matches - fall back to index-based grouping\n\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\t\tfor (const patch of patches1) {\n\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\tif (itemMatch) {\n\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t}\n\t\t\t\tconst groupItem1 = pathGroups.get(itemPath);\n\t\t\t\tif (groupItem1) {\n\t\t\t\t\tgroupItem1.patches1.push(patch);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const patch of patches2) {\n\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\tif (itemMatch) {\n\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t}\n\t\t\t\tconst groupItem2 = pathGroups.get(itemPath);\n\t\t\t\tif (groupItem2) {\n\t\t\t\t\tgroupItem2.patches2.push(patch);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Helper: Check if a path is a child of a potential oneOf object\n\tconst getOneOfObjectPath = (patchPath: string, schema?: JSONSchema): string | null => {\n\t\tif (!schema) return null;\n\t\tconst segments = patchPath.split(\"/\").filter(Boolean);\n\t\tif (segments.length < 2) return null; // Need at least object/property\n\n\t\t// Check if parent object (e.g., /payment for /payment/type) has oneOf schema\n\t\tconst parentPath = `/${segments[0]}`;\n\t\tconst parentSchema = getSchemaAtPath(schema, parentPath);\n\t\tif (parentSchema && hasSchemaVariants(parentSchema)) {\n\t\t\treturn parentPath;\n\t\t}\n\t\treturn null;\n\t};\n\n\t// Process non-array patches\n\t// Strategy:\n\t// 1. First, group patches that belong to oneOf objects together\n\t// 2. Then, group remaining patches by full path for individual field conflicts\n\n\t// First pass: Collect all patches\n\tconst allNonArrayPatches1 = [...nonArrayPatches1];\n\tconst allNonArrayPatches2 = [...nonArrayPatches2];\n\n\t// Second pass: Group by oneOf object paths first\n\tconst oneOfObjectPaths = new Set<string>();\n\tfor (const patch of allNonArrayPatches1) {\n\t\tconst oneOfPath = getOneOfObjectPath(patch.path, schema);\n\t\tif (oneOfPath) {\n\t\t\toneOfObjectPaths.add(oneOfPath);\n\t\t}\n\t}\n\tfor (const patch of allNonArrayPatches2) {\n\t\tconst oneOfPath = getOneOfObjectPath(patch.path, schema);\n\t\tif (oneOfPath) {\n\t\t\toneOfObjectPaths.add(oneOfPath);\n\t\t}\n\t}\n\n\t// Group patches for oneOf objects\n\tfor (const oneOfPath of oneOfObjectPaths) {\n\t\tif (!pathGroups.has(oneOfPath)) {\n\t\t\tpathGroups.set(oneOfPath, { patches1: [], patches2: [] });\n\t\t}\n\t}\n\n\t// Third pass: Distribute patches\n\tfor (const patch of allNonArrayPatches1) {\n\t\tconst patchPath = patch.path;\n\t\tconst oneOfPath = getOneOfObjectPath(patchPath, schema);\n\n\t\tif (oneOfPath) {\n\t\t\t// Belongs to a oneOf object - group under object path\n\t\t\tconst group = pathGroups.get(oneOfPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches1.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\t// Regular field change - use full path for separate conflicts\n\t\t\tif (!pathGroups.has(patchPath)) {\n\t\t\t\tpathGroups.set(patchPath, { patches1: [], patches2: [] });\n\t\t\t}\n\t\t\tconst group = pathGroups.get(patchPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches1.push(patch);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const patch of allNonArrayPatches2) {\n\t\tconst patchPath = patch.path;\n\t\tconst oneOfPath = getOneOfObjectPath(patchPath, schema);\n\n\t\tif (oneOfPath) {\n\t\t\t// Belongs to a oneOf object - group under object path\n\t\t\tconst group = pathGroups.get(oneOfPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches2.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\t// Regular field change - use full path for separate conflicts\n\t\t\tif (!pathGroups.has(patchPath)) {\n\t\t\t\tpathGroups.set(patchPath, { patches1: [], patches2: [] });\n\t\t\t}\n\t\t\tconst group = pathGroups.get(patchPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches2.push(patch);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn pathGroups;\n}\n\n/**\n * Analyze conflicts using JSON Patches (RFC 6902)\n *\n * This function uses semantic JSON comparison, NOT line-based text comparison:\n * 1. Generates JSON Patch operations from base?input1 and base?input2\n * 2. Groups patches by root path (e.g., /awards/resource/0/count ? /awards)\n * 3. For each group, determines conflict type based on actual JSON values\n * 4. Returns conflicts with patch operations that will be mapped to line ranges\n *\n * The patches contain JSON Pointer paths (e.g., /resource/0/type) that reference\n * the actual JSON structure, not arbitrary text lines.\n *\n * @param base - Base JSON object\n * @param input1 - Input1 (theirs) JSON object\n * @param input2 - Input2 (ours) JSON object\n * @returns Array of conflict analyses with JSON Patch operations\n */\n/**\n * Resolve schema at a given JSON Pointer path, handling oneOf/anyOf/allOf\n * @param schema - Root JSON Schema\n * @param path - JSON Pointer path (e.g., \"/awards/resource/0/type\")\n * @param data - The actual data at the path (for oneOf/anyOf resolution)\n * @returns The resolved schema for the path, or null if not found\n */\nexport function getSchemaAtPath(schema: JSONSchema | undefined, path: string, data?: unknown): JSONSchema | null {\n\tif (!schema) {\n\t\treturn null;\n\t}\n\n\tconst segments = path.split(\"/\").filter(Boolean);\n\tif (segments.length === 0) {\n\t\treturn schema;\n\t}\n\n\tlet currentSchema: JSONSchema | null = schema;\n\tlet currentPath = \"\";\n\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst segment = segments[i];\n\t\tconst numericIndex = Number.parseInt(segment, 10);\n\t\tconst isArrayIndex = !Number.isNaN(numericIndex) && String(numericIndex) === segment;\n\n\t\t// Handle oneOf/anyOf/allOf before navigating using shared utilities\n\t\tif (currentSchema && hasSchemaVariants(currentSchema)) {\n\t\t\tconst variants = getSchemaVariants(currentSchema);\n\t\t\tconst keyword = getSubschemaKeyword(currentSchema);\n\t\t\tconst currentData = data ? getValueAtPath(data as Record<string, unknown>, currentPath || \"/\") : undefined;\n\n\t\t\tif (variants && variants.length > 0) {\n\t\t\t\tif (currentData !== undefined) {\n\t\t\t\t\t// Use shared chooseSubschemaSync for proper variant resolution\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { schema: resolvedSchema } = chooseSubschemaSync(currentData, variants, keyword);\n\t\t\t\t\t\tcurrentSchema = resolvedSchema;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tif (variants.length > 0 && variants[0]) {\n\t\t\t\t\t\t\tcurrentSchema = variants[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// No data available, use first variant as fallback\n\t\t\t\t\tif (variants.length > 0 && variants[0]) {\n\t\t\t\t\t\tcurrentSchema = variants[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!currentSchema) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Navigate to next segment\n\t\tif (isArrayIndex) {\n\t\t\t// Array index - use items schema\n\t\t\tif (currentSchema.items) {\n\t\t\t\tif (Array.isArray(currentSchema.items)) {\n\t\t\t\t\tconst itemAtIndex: unknown = numericIndex < currentSchema.items.length ? currentSchema.items[numericIndex] : null;\n\t\t\t\t\tcurrentSchema = itemAtIndex && typeof itemAtIndex === \"object\" ? (itemAtIndex as JSONSchema) : null;\n\t\t\t\t} else if (typeof currentSchema.items === \"object\") {\n\t\t\t\t\t// Ensure items is a JSONSchema object, not true\n\t\t\t\t\tcurrentSchema = currentSchema.items;\n\t\t\t\t} else {\n\t\t\t\t\tcurrentSchema = null;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn null; // No items schema defined\n\t\t\t}\n\t\t} else {\n\t\t\t// Object property\n\t\t\tif (currentSchema.properties && typeof currentSchema.properties === \"object\" && !Array.isArray(currentSchema.properties)) {\n\t\t\t\tconst properties = currentSchema.properties as Record<string, JSONSchema>;\n\t\t\t\tcurrentSchema = properties[segment] || null;\n\t\t\t} else {\n\t\t\t\treturn null; // No properties schema defined\n\t\t\t}\n\t\t}\n\n\t\tif (!currentSchema) {\n\t\t\treturn null;\n\t\t}\n\n\t\tcurrentPath = currentPath ? `${currentPath}/${segment}` : `/${segment}`;\n\t}\n\n\treturn currentSchema;\n}\n\n/**\n * Find anchor fields for array items based on schema\n * This helps match array items across versions even if their indices change\n *\n * Anchor fields can be:\n * 1. Fields with \"const\" values (discriminators in oneOf schemas)\n * 2. Common ID field names (id, uuid, _id, etc.)\n * 3. Fields marked with format: \"uuid\" or \"objectid\"\n *\n * @param schema - Schema for the array items\n * @returns Array of anchor field names, ordered by priority\n */\nfunction findItemAnchorFields(schema: JSONSchema | null): string[] {\n\tif (!schema || typeof schema !== \"object\") {\n\t\treturn [];\n\t}\n\n\tconst anchors: string[] = [];\n\n\tif (schema.properties && typeof schema.properties === \"object\" && !Array.isArray(schema.properties)) {\n\t\tconst properties = schema.properties as Record<string, JSONSchema>;\n\n\t\t// Priority 1: Fields with \"const\" values (discriminators)\n\t\tfor (const [fieldName, propSchema] of Object.entries(properties)) {\n\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\tanchors.push(fieldName);\n\t\t\t}\n\t\t}\n\n\t\t// Priority 2: Fields with UUID/ObjectID format\n\t\tfor (const [fieldName, propSchema] of Object.entries(properties)) {\n\t\t\tif (propSchema && typeof propSchema === \"object\") {\n\t\t\t\tconst format = propSchema.format;\n\t\t\t\tif (format === \"uuid\" || format === \"objectid\") {\n\t\t\t\t\tif (!anchors.includes(fieldName)) {\n\t\t\t\t\t\tanchors.push(fieldName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Priority 3: Common ID field names\n\t\tconst commonIdFields = [\"id\", \"uuid\", \"_id\", \"key\"];\n\t\tfor (const fieldName of commonIdFields) {\n\t\t\tif (fieldName in properties && !anchors.includes(fieldName)) {\n\t\t\t\tanchors.push(fieldName);\n\t\t\t}\n\t\t}\n\n\t\t// Priority 4: \"type\" field (common discriminator)\n\t\tif (\"type\" in properties && !anchors.includes(\"type\")) {\n\t\t\tanchors.push(\"type\");\n\t\t}\n\n\t\t// Priority 5: \"name\" field (fallback)\n\t\tif (\"name\" in properties && !anchors.includes(\"name\")) {\n\t\t\tanchors.push(\"name\");\n\t\t}\n\t}\n\n\treturn anchors;\n}\n\n/**\n * Find a unique identifier field for array items based on schema\n * @deprecated Use findItemAnchorFields instead for better oneOf/const support\n * @param schema - Schema for the array items\n * @returns Name of the ID field (e.g., \"id\", \"uuid\", \"_id\"), or null\n */\nfunction findItemIdField(schema: JSONSchema | null): string | null {\n\tconst anchors = findItemAnchorFields(schema);\n\treturn anchors.length > 0 ? anchors[0] : null;\n}\n\n/**\n * Match array items using multiple anchor fields from schema\n * This handles oneOf schemas with const discriminators and regular ID fields\n *\n * @param input1Array - Array from input1\n * @param input2Array - Array from input2\n * @param itemSchema - Schema for array items (may contain oneOf)\n * @returns Map of composite keys to indices: { \"type:cash|id:1\": { input1: 0, input2: 2 } }\n */\nfunction matchArrayItemsByAnchors(\n\tinput1Array: unknown[],\n\tinput2Array: unknown[],\n\titemSchema: JSONSchema | null,\n): Map<string, { input1?: number; input2?: number }> {\n\tconst matches = new Map<string, { input1?: number; input2?: number }>();\n\n\t// Get anchor fields from schema (const fields, ID fields, etc.)\n\tconst anchorFields = findItemAnchorFields(itemSchema);\n\n\tif (anchorFields.length === 0) {\n\t\t// No anchor fields - can't match items semantically\n\t\t// Removed verbose logging\n\t\treturn matches;\n\t}\n\n\t// Removed verbose logging\n\n\t// Generate a composite key from an item using available anchor fields\n\tconst getItemKey = (item: unknown): string | null => {\n\t\tif (typeof item !== \"object\" || item === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst obj = item as Record<string, unknown>;\n\t\tconst keyParts: string[] = [];\n\n\t\t// Build composite key from all available anchor fields\n\t\tfor (const field of anchorFields) {\n\t\t\tconst value = obj[field];\n\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t// Include field name to avoid collisions (e.g., type:1 vs id:1)\n\t\t\t\tkeyParts.push(`${field}:${JSON.stringify(value)}`);\n\t\t\t}\n\t\t}\n\n\t\t// Need at least one anchor value to create a key\n\t\treturn keyParts.length > 0 ? keyParts.join(\"|\") : null;\n\t};\n\n\t// Index items by composite key in each array\n\tconst indexArray = (arr: unknown[], version: \"input1\" | \"input2\") => {\n\t\tarr.forEach((item, index) => {\n\t\t\tconst key = getItemKey(item);\n\t\t\tif (key) {\n\t\t\t\tif (!matches.has(key)) {\n\t\t\t\t\tmatches.set(key, {});\n\t\t\t\t}\n\t\t\t\tconst match = matches.get(key);\n\t\t\t\tif (match) {\n\t\t\t\t\tmatch[version] = index;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\tindexArray(input1Array, \"input1\");\n\tindexArray(input2Array, \"input2\");\n\n\t// Removed verbose logging\n\n\treturn matches;\n}\n\n/**\n * Match array items across versions using schema-defined ID fields\n * This handles cases where array order changes but items are semantically the same\n * @param baseArray - Array from base version\n * @param input1Array - Array from input1\n * @param input2Array - Array from input2\n * @param itemSchema - Schema for array items\n * @returns Map of item IDs to their indices in each version: { id: { base: index, input1: index, input2: index } }\n */\nfunction matchArrayItemsById(\n\tbaseArray: unknown[],\n\tinput1Array: unknown[],\n\tinput2Array: unknown[],\n\titemSchema: JSONSchema | null,\n): Map<string | number, { base?: number; input1?: number; input2?: number }> {\n\tconst matches = new Map<string | number, { base?: number; input1?: number; input2?: number }>();\n\tconst idField = findItemIdField(itemSchema);\n\n\tif (!idField) {\n\t\t// No ID field found - can't match by ID, return empty map\n\t\treturn matches;\n\t}\n\n\t// Index items by ID in each array\n\tconst indexByArray = (arr: unknown[], version: \"base\" | \"input1\" | \"input2\") => {\n\t\tarr.forEach((item, index) => {\n\t\t\tif (typeof item === \"object\" && item !== null) {\n\t\t\t\tconst id = (item as Record<string, unknown>)[idField];\n\t\t\t\tif (id !== undefined && id !== null) {\n\t\t\t\t\tconst idKey = String(id);\n\t\t\t\t\tif (!matches.has(idKey)) {\n\t\t\t\t\t\tmatches.set(idKey, {});\n\t\t\t\t\t}\n\t\t\t\t\tconst match = matches.get(idKey);\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tmatch[version] = index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\tindexByArray(baseArray, \"base\");\n\tindexByArray(input1Array, \"input1\");\n\tindexByArray(input2Array, \"input2\");\n\n\treturn matches;\n}\n\nexport function analyzeConflicts(base: unknown, input1: unknown, input2: unknown, schema?: JSONSchema): ConflictAnalysis[] {\n\t// Generate JSON Patch operations (semantic diff, not text diff)\n\t// Each patch contains: op, path (JSON Pointer), value\n\t// fast-json-patch's compare accepts Object | any[] - ensure we pass valid types\n\tconst baseObj = (typeof base === \"object\" && base !== null) || Array.isArray(base) ? base : {};\n\tconst input1Obj = (typeof input1 === \"object\" && input1 !== null) || Array.isArray(input1) ? input1 : {};\n\tconst input2Obj = (typeof input2 === \"object\" && input2 !== null) || Array.isArray(input2) ? input2 : {};\n\n\tconst patch1 = compare(baseObj as object | unknown[], input1Obj as object | unknown[]);\n\tconst patch2 = compare(baseObj as object | unknown[], input2Obj as object | unknown[]);\n\n\t// Group patches by root path for conflict analysis\n\t// Example: /awards/resource/0/count and /awards/resource/3 ? grouped as /awards\n\tlet pathGroups = groupPatchesByRootPath(patch1, patch2);\n\n\t// If schema is provided, use it to improve path grouping for arrays and oneOf cases\n\tif (schema) {\n\t\tpathGroups = groupPatchesWithSchema(patch1, patch2, base, input1, input2, schema);\n\t}\n\n\t// Analyze each path group\n\tconst conflicts: ConflictAnalysis[] = [];\n\tconst processedPaths = new Set<string>();\n\n\t// Helper: Check if an object path has oneOf schema and if changes represent variant switch\n\tconst checkOneOfVariantChange = (path: string, baseValue: unknown, input1Value: unknown, input2Value: unknown): boolean => {\n\t\tif (!schema) return false;\n\t\tif (typeof baseValue !== \"object\" || baseValue === null || Array.isArray(baseValue)) return false;\n\t\tif (typeof input1Value !== \"object\" || input1Value === null || Array.isArray(input1Value)) return false;\n\t\tif (typeof input2Value !== \"object\" || input2Value === null || Array.isArray(input2Value)) return false;\n\n\t\tconst pathSchema = getSchemaAtPath(schema, path, baseValue);\n\t\tif (!pathSchema || !hasSchemaVariants(pathSchema)) return false;\n\n\t\tconst variants = getSchemaVariants(pathSchema);\n\t\tif (!variants || variants.length < 2) return false;\n\n\t\t// Check if base, input1, and input2 match different variants\n\t\tconst baseVariant = chooseSubschemaSync(baseValue, variants, getSubschemaKeyword(pathSchema));\n\t\tconst input1Variant = chooseSubschemaSync(input1Value, variants, getSubschemaKeyword(pathSchema));\n\t\tconst input2Variant = chooseSubschemaSync(input2Value, variants, getSubschemaKeyword(pathSchema));\n\n\t\t// If input1 and input2 match different variants (and base is different from both),\n\t\t// this is a oneOf variant conflict\n\t\treturn (\n\t\t\tinput1Variant.selectedIndex !== input2Variant.selectedIndex &&\n\t\t\t(baseVariant.selectedIndex !== input1Variant.selectedIndex || baseVariant.selectedIndex !== input2Variant.selectedIndex)\n\t\t);\n\t};\n\n\t// First, process paths with patches (changes)\n\tfor (const [groupingKey, { patches1, patches2 }] of pathGroups) {\n\t\tprocessedPaths.add(groupingKey);\n\n\t\t// Extract representative path from patches (grouping key might be ID-based like \"/path#id=1\")\n\t\t// Use the first patch path from either set, or derive from grouping key\n\t\tlet representativePath = groupingKey;\n\t\tif (patches1.length > 0) {\n\t\t\trepresentativePath = patches1[0].path;\n\t\t} else if (patches2.length > 0) {\n\t\t\trepresentativePath = patches2[0].path;\n\t\t} else if (groupingKey.includes(\"#\")) {\n\t\t\t// ID-based grouping key - extract base path before \"#\"\n\t\t\trepresentativePath = groupingKey.split(\"#\")[0];\n\t\t}\n\n\t\t// Extract the object path (parent object, without property/index segments)\n\t\t// For example: \"/payment/number\" -> \"/payment\", \"/items/0/count\" -> \"/items\"\n\t\tlet objectPath = groupingKey;\n\t\tif (groupingKey.includes(\"#\")) {\n\t\t\t// ID-based grouping: \"/items#item-1\" -> \"/items\"\n\t\t\tobjectPath = groupingKey.split(\"#\")[0];\n\t\t} else {\n\t\t\t// Extract parent path: \"/payment/number\" -> \"/payment\"\n\t\t\tconst pathSegments = groupingKey.split(\"/\").filter(Boolean);\n\t\t\tif (pathSegments.length > 1) {\n\t\t\t\tobjectPath = `/${pathSegments[0]}`;\n\t\t\t}\n\t\t}\n\n\t\t// Check if groupingKey itself is an object path (no sub-properties in patches)\n\t\tconst allPatchesAreForSameObject = [...patches1, ...patches2].every((p) => {\n\t\t\tconst patchObjectPath = p.path.split(\"/\").slice(0, 2).join(\"/\") || `/${p.path.split(\"/\")[1]}`;\n\t\t\treturn patchObjectPath === objectPath;\n\t\t});\n\n\t\t// If all patches are for properties of the same object, check for oneOf variant change\n\t\tif (allPatchesAreForSameObject && objectPath !== representativePath) {\n\t\t\tconst baseObjectValue = getValueAtPath(base as Record<string, unknown>, objectPath);\n\t\t\tconst input1ObjectValue = getValueAtPath(input1 as Record<string, unknown>, objectPath);\n\t\t\tconst input2ObjectValue = getValueAtPath(input2 as Record<string, unknown>, objectPath);\n\n\t\t\t// Check if this represents a oneOf variant change\n\t\t\tconst isOneOfVariantChange = checkOneOfVariantChange(objectPath, baseObjectValue, input1ObjectValue, input2ObjectValue);\n\n\t\t\tif (isOneOfVariantChange) {\n\t\t\t\t// Use object-level path for oneOf variant conflicts\n\t\t\t\tconst baseObjVal = baseObjectValue;\n\t\t\t\tconst input1ObjVal = input1ObjectValue;\n\t\t\t\tconst input2ObjVal = input2ObjectValue;\n\n\t\t\t\t// Determine conflict type at object level\n\t\t\t\tlet conflictType = determineConflictType(baseObjVal, input1ObjVal, input2ObjVal);\n\n\t\t\t\t// For oneOf variants, different structures mean TRUE_CONFLICT\n\t\t\t\tif (!isEqual(baseObjVal, input1ObjVal) && !isEqual(baseObjVal, input2ObjVal) && !isEqual(input1ObjVal, input2ObjVal)) {\n\t\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t\t}\n\n\t\t\t\t// For oneOf variant changes, include only patches that input1/input2 actually changed\n\t\t\t\t// Filter patches to ensure we don't highlight identical properties\n\t\t\t\tconst objectPatchesAll = [...patches1, ...patches2].filter(\n\t\t\t\t\t(p) => p.path.startsWith(`${objectPath}/`) || p.path === objectPath,\n\t\t\t\t);\n\n\t\t\t\t// Filter patches separately for input1 and input2\n\t\t\t\tconst objectPatches1: JsonPatchOperation[] = [];\n\t\t\t\tconst objectPatches2: JsonPatchOperation[] = [];\n\n\t\t\t\tfor (const patch of objectPatchesAll) {\n\t\t\t\t\tconst patchPath = patch.path;\n\t\t\t\t\tconst patchBaseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, patchPath) : undefined;\n\t\t\t\t\tconst patchInput1Value = getValueAtPath(input1 as Record<string, unknown>, patchPath);\n\t\t\t\t\tconst patchInput2Value = getValueAtPath(input2 as Record<string, unknown>, patchPath);\n\n\t\t\t\t\t// Check if input1 changed this property\n\t\t\t\t\tlet input1Changed = false;\n\t\t\t\t\tlet input2Changed = false;\n\n\t\t\t\t\tif (patch.op === \"replace\") {\n\t\t\t\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (patch.op === \"add\") {\n\t\t\t\t\t\tinput1Changed = patchBaseValue === undefined && patchInput1Value !== undefined;\n\t\t\t\t\t\tinput2Changed = patchBaseValue === undefined && patchInput2Value !== undefined;\n\t\t\t\t\t} else if (patch.op === \"remove\") {\n\t\t\t\t\t\tinput1Changed = patchBaseValue !== undefined && patchInput1Value === undefined;\n\t\t\t\t\t\tinput2Changed = patchBaseValue !== undefined && patchInput2Value === undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Don't include if the input's value is identical to base\n\t\t\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\t\t\tif (patchInput1Value !== undefined && isEqual(patchBaseValue, patchInput1Value)) {\n\t\t\t\t\t\t\tinput1Changed = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (patchInput2Value !== undefined && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\t\t\t\tinput2Changed = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (input1Changed) {\n\t\t\t\t\t\tobjectPatches1.push(patch);\n\t\t\t\t\t}\n\t\t\t\t\tif (input2Changed) {\n\t\t\t\t\t\tobjectPatches2.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconflicts.push({\n\t\t\t\t\tpath: objectPath,\n\t\t\t\t\tbaseValue: baseObjVal,\n\t\t\t\t\tinput1Value: input1ObjVal,\n\t\t\t\t\tinput2Value: input2ObjVal,\n\t\t\t\t\tconflictType,\n\t\t\t\t\tpatches1: objectPatches1,\n\t\t\t\t\tpatches2: objectPatches2,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// Get actual JSON values at the path (semantic comparison)\n\t\t// For array items matched by ID, we need to get values from each version using their actual indices\n\t\t// But for conflict analysis, we can use a representative path\n\t\tconst baseValue = getValueAtPath(base as Record<string, unknown>, representativePath);\n\t\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, representativePath);\n\t\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, representativePath);\n\n\t\t// Determine conflict type based on JSON value comparison\n\t\tlet conflictType = determineConflictType(baseValue, input1Value, input2Value);\n\n\t\t// Check if this is an item added in both inputs (not in base)\n\t\tconst existsInBase = baseValue !== undefined && baseValue !== null;\n\t\tconst existsInInput1 = input1Value !== undefined && input1Value !== null;\n\t\tconst existsInInput2 = input2Value !== undefined && input2Value !== null;\n\n\t\tif (!existsInBase && existsInInput1 && existsInInput2) {\n\t\t\t// Item added in both inputs\n\t\t\t// If they added the SAME value ? SAME_CHANGE (auto-merged, highlight blue)\n\t\t\t// If they added DIFFERENT values ? TRUE_CONFLICT (conflict, highlight orange/red)\n\t\t\tif (conflictType !== ConflictType.SAME_CHANGE) {\n\t\t\t\t// Different values added - treat as TRUE_CONFLICT so both sides are highlighted\n\t\t\t\t// We'll handle the orange highlighting in the decoration logic\n\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t}\n\t\t\t// If conflictType is already SAME_CHANGE, keep it (both added same value)\n\t\t}\n\n\t\t// Include all changes (including SAME_CHANGE for items that changed to the same value)\n\t\t// Exclude items that are completely unchanged (same as base in all versions)\n\t\tconst isCompletelyUnchanged = existsInBase && isEqual(baseValue, input1Value) && isEqual(baseValue, input2Value);\n\n\t\tif (!isCompletelyUnchanged) {\n\t\t\tconflicts.push({\n\t\t\t\tpath: representativePath, // Use representative path for conflict (actual patch paths are in patches1/patches2)\n\t\t\t\tbaseValue,\n\t\t\t\tinput1Value,\n\t\t\t\tinput2Value,\n\t\t\t\tconflictType,\n\t\t\t\tpatches1, // JSON Patch operations for base?input1 (contain actual paths with indices)\n\t\t\t\tpatches2, // JSON Patch operations for base?input2 (contain actual paths with indices)\n\t\t\t});\n\t\t}\n\t}\n\n\t// Don't create conflicts for completely unchanged items\n\t// Unchanged items should not be highlighted (they're the same in all versions)\n\n\treturn conflicts;\n}\n\n/**\n * Analyze conflicts for 2-column mode (input1 vs input2, no base)\n *\n * Uses JSON Patch comparison (semantic, not line-based):\n * - Generates patches from input1?input2\n * - Groups by root path\n * - Maps to conflict ranges\n *\n * @param input1 - Input1 JSON object (left column)\n * @param input2 - Input2 JSON object (right column)\n * @returns Array of conflict analyses with JSON Patch operations\n */\nexport function analyzeTwoWayConflicts(input1: unknown, input2: unknown, schema?: JSONSchema): ConflictAnalysis[] {\n\t// Generate JSON Patch operations from input1 to input2\n\t// This finds semantic differences (changed JSON values), not text differences\n\t// fast-json-patch's compare accepts Object | any[] - ensure we pass valid types\n\tconst input1Obj = (typeof input1 === \"object\" && input1 !== null) || Array.isArray(input1) ? input1 : {};\n\tconst input2Obj = (typeof input2 === \"object\" && input2 !== null) || Array.isArray(input2) ? input2 : {};\n\tconst patches = compare(input1Obj as object | unknown[], input2Obj as object | unknown[]);\n\n\tif (patches.length === 0) {\n\t\treturn []; // No differences\n\t}\n\n\t// Analyze each patch and determine grouping strategy\n\t// For arrays with schema, we'll use anchor-based matching\n\t// For other paths, we'll use index-based grouping\n\tconst conflicts: ConflictAnalysis[] = [];\n\tconst processedPaths = new Set<string>();\n\n\t// Group patches by array path to detect array operations\n\tconst arrayPathGroups = new Map<string, JsonPatchOperation[]>();\n\tconst nonArrayPatches: JsonPatchOperation[] = [];\n\n\tfor (const patch of patches) {\n\t\t// Check if this patch operates on an array item\n\t\t// Pattern: /path/to/array/INDEX or /path/to/array/INDEX/property\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1]; // e.g., /needResourcesAtRefresh/resource\n\t\t\tif (!arrayPathGroups.has(arrayPath)) {\n\t\t\t\tarrayPathGroups.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst arrayGroup = arrayPathGroups.get(arrayPath);\n\t\t\tif (arrayGroup) {\n\t\t\t\tarrayGroup.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches.push(patch);\n\t\t}\n\t}\n\n\t// Removed verbose logging\n\n\t// Process array patches with schema-aware matching\n\tfor (const [arrayPath, arrayPatches] of arrayPathGroups) {\n\t\t// Get the arrays from both inputs\n\t\tconst input1Array = getValueAtPath(input1 as Record<string, unknown>, arrayPath);\n\t\tconst input2Array = getValueAtPath(input2 as Record<string, unknown>, arrayPath);\n\n\t\tif (!Array.isArray(input1Array) || !Array.isArray(input2Array)) {\n\t\t\t// Removed verbose logging\n\t\t\t// Fallback: group by item index\n\t\t\tconst itemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!itemGroups.has(itemPath)) {\n\t\t\t\t\t\titemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\titemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [itemPath, itemPatches] of itemGroups) {\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get schema for array items\n\t\tconst arraySchema = schema ? getSchemaAtPath(schema, arrayPath, input1) : null;\n\t\tconst itemSchemaRaw = arraySchema?.items\n\t\t\t? Array.isArray(arraySchema.items) && arraySchema.items[0]\n\t\t\t\t? arraySchema.items[0]\n\t\t\t\t: !Array.isArray(arraySchema.items)\n\t\t\t\t\t? arraySchema.items\n\t\t\t\t\t: null\n\t\t\t: null;\n\t\t// Ensure itemSchema is a valid JSONSchema (not true)\n\t\tconst itemSchema = itemSchemaRaw && typeof itemSchemaRaw === \"object\" ? itemSchemaRaw : null;\n\n\t\t// Removed verbose logging\n\n\t\tif (itemSchema) {\n\t\t\t// Use schema-aware matching\n\t\t\tconst matches = matchArrayItemsByAnchors(input1Array, input2Array, itemSchema);\n\t\t\t// Removed verbose logging\n\n\t\t\t// Create index-to-key mapping for quick lookup\n\t\t\tconst input1KeysByIndex = new Map<number, string>();\n\t\t\tconst input2KeysByIndex = new Map<number, string>();\n\n\t\t\tfor (const [key, indices] of matches.entries()) {\n\t\t\t\tif (indices.input1 !== undefined) {\n\t\t\t\t\tinput1KeysByIndex.set(indices.input1, key);\n\t\t\t\t}\n\t\t\t\tif (indices.input2 !== undefined) {\n\t\t\t\t\tinput2KeysByIndex.set(indices.input2, key);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Group patches by matched items\n\t\t\tconst matchedItemPatches = new Map<string, JsonPatchOperation[]>();\n\t\t\tconst unmatchedPatches: JsonPatchOperation[] = [];\n\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\n\t\t\t\t\t// Determine which array this index refers to based on operation\n\t\t\t\t\tlet key: string | undefined;\n\t\t\t\t\tif (patch.op === \"add\") {\n\t\t\t\t\t\t// Add operations reference input2 indices\n\t\t\t\t\t\tkey = input2KeysByIndex.get(index);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Replace/remove operations reference input1 indices\n\t\t\t\t\t\tkey = input1KeysByIndex.get(index);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (key) {\n\t\t\t\t\t\tif (!matchedItemPatches.has(key)) {\n\t\t\t\t\t\t\tmatchedItemPatches.set(key, []);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst matchedPatches = matchedItemPatches.get(key);\n\t\t\t\t\t\tif (matchedPatches) {\n\t\t\t\t\t\t\tmatchedPatches.push(patch);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tunmatchedPatches.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Create conflicts for matched items\n\t\t\tfor (const [key, itemPatches] of matchedItemPatches) {\n\t\t\t\tconst match = matches.get(key);\n\t\t\t\tif (!match) continue;\n\t\t\t\tconst itemPath = match.input1 !== undefined ? `${arrayPath}/${match.input1}` : `${arrayPath}/${match.input2}`;\n\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\n\t\t\t// Create conflicts for unmatched items (pure adds/removes)\n\t\t\t// First, group unmatched patches by item path\n\t\t\tconst unmatchedItemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of unmatchedPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!unmatchedItemGroups.has(itemPath)) {\n\t\t\t\t\t\tunmatchedItemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\tunmatchedItemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Then create conflicts for each item path\n\t\t\tfor (const [itemPath, itemPatches] of unmatchedItemGroups) {\n\t\t\t\tif (!processedPaths.has(itemPath)) {\n\t\t\t\t\t// Removed verbose logging\n\t\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// No schema or no item schema - fall back to index-based grouping\n\t\t\t// Removed verbose logging\n\t\t\tconst itemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!itemGroups.has(itemPath)) {\n\t\t\t\t\t\titemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\titemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [itemPath, itemPatches] of itemGroups) {\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Process non-array patches (simple properties)\n\tconst propertyGroups = new Map<string, JsonPatchOperation[]>();\n\tfor (const patch of nonArrayPatches) {\n\t\tconst segments = patch.path.split(\"/\").filter(Boolean);\n\t\tconst rootPath = segments.length > 0 ? `/${segments[0]}` : \"/\";\n\n\t\tif (!propertyGroups.has(rootPath)) {\n\t\t\tpropertyGroups.set(rootPath, []);\n\t\t}\n\t\tpropertyGroups.get(rootPath)?.push(patch);\n\t}\n\n\tfor (const [path, pathPatches] of propertyGroups) {\n\t\tconflicts.push(...createConflictsForGroup(path, pathPatches, input1, input2, undefined));\n\t}\n\n\treturn conflicts;\n}\n\n/**\n * Helper function to create conflicts for a group of patches\n * Only creates conflicts for paths where values actually differ\n */\nfunction createConflictsForGroup(\n\tpath: string,\n\tpathPatches: JsonPatchOperation[],\n\tinput1: unknown,\n\tinput2: unknown,\n\tbase?: unknown,\n): ConflictAnalysis[] {\n\t// Get actual values at this path from all versions\n\tconst baseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, path) : undefined;\n\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, path);\n\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, path);\n\n\t// Filter patches separately for input1 and input2\n\t// A patch should only be in patches1 if input1 changed it, and in patches2 if input2 changed it\n\tconst filteredPatches1: JsonPatchOperation[] = [];\n\tconst filteredPatches2: JsonPatchOperation[] = [];\n\n\tfor (const patch of pathPatches) {\n\t\t// For each patch, check if the value at that path actually changed in each input\n\t\tconst patchPath = patch.path;\n\t\tconst patchBaseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, patchPath) : undefined;\n\t\tconst patchInput1Value = getValueAtPath(input1 as Record<string, unknown>, patchPath);\n\t\tconst patchInput2Value = getValueAtPath(input2 as Record<string, unknown>, patchPath);\n\n\t\t// Check if input1 changed this property\n\t\tlet input1Changed = false;\n\t\t// Check if input2 changed this property\n\t\tlet input2Changed = false;\n\n\t\tif (patch.op === \"add\") {\n\t\t\t// Add: check if input1 added it (doesn't exist in base, exists in input1)\n\t\t\tinput1Changed = patchBaseValue === undefined && patchInput1Value !== undefined;\n\t\t\t// Add: check if input2 added it\n\t\t\tinput2Changed = patchBaseValue === undefined && patchInput2Value !== undefined;\n\t\t} else if (patch.op === \"remove\") {\n\t\t\t// Remove: check if input1 removed it (exists in base, doesn't exist in input1)\n\t\t\tinput1Changed = patchBaseValue !== undefined && patchInput1Value === undefined;\n\t\t\t// Remove: check if input2 removed it\n\t\t\tinput2Changed = patchBaseValue !== undefined && patchInput2Value === undefined;\n\t\t} else if (patch.op === \"replace\") {\n\t\t\t// Replace: check if input1 changed it from base\n\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t} else {\n\t\t\t\t// Added in both (shouldn't happen with replace, but handle it)\n\t\t\t\tinput1Changed = patchInput1Value !== undefined;\n\t\t\t\tinput2Changed = patchInput2Value !== undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Special case: if this is the exact same path as the conflict path, always include\n\t\t// (this handles the case where the path itself changed)\n\t\tif (patchPath === path) {\n\t\t\t// For object-level conflicts, check which input actually changed the object\n\t\t\tif (patchBaseValue !== undefined && patchInput1Value !== undefined && patchInput2Value !== undefined) {\n\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t} else {\n\t\t\t\tinput1Changed = true;\n\t\t\t\tinput2Changed = true;\n\t\t\t}\n\t\t}\n\n\t\t// Don't include patches for properties where the input's value is identical to base\n\t\t// This ensures identical properties aren't highlighted\n\t\tif (patchBaseValue !== undefined) {\n\t\t\tif (patchInput1Value !== undefined && isEqual(patchBaseValue, patchInput1Value)) {\n\t\t\t\tinput1Changed = false; // Input1 didn't change - same as base\n\t\t\t}\n\t\t\tif (patchInput2Value !== undefined && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\tinput2Changed = false; // Input2 didn't change - same as base\n\t\t\t}\n\t\t}\n\n\t\t// Also check: don't include patches for properties where all values are identical\n\t\tif (patchBaseValue !== undefined && patchInput1Value !== undefined && patchInput2Value !== undefined) {\n\t\t\tif (isEqual(patchBaseValue, patchInput1Value) && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\tinput1Changed = false; // All identical - no change\n\t\t\t\tinput2Changed = false;\n\t\t\t}\n\t\t}\n\n\t\t// Add to appropriate filtered arrays\n\t\tif (input1Changed) {\n\t\t\tfilteredPatches1.push(patch);\n\t\t}\n\t\tif (input2Changed) {\n\t\t\tfilteredPatches2.push(patch);\n\t\t}\n\t}\n\n\t// If no patches remain after filtering, check if the path itself changed\n\tif (filteredPatches1.length === 0 && filteredPatches2.length === 0) {\n\t\t// Check if values are actually identical across all versions\n\t\t// If so, don't create a conflict (no change to highlight)\n\t\tconst allValuesIdentical =\n\t\t\tbaseValue !== undefined &&\n\t\t\tinput1Value !== undefined &&\n\t\t\tinput2Value !== undefined &&\n\t\t\tisEqual(baseValue, input1Value) &&\n\t\t\tisEqual(baseValue, input2Value);\n\n\t\tif (allValuesIdentical) {\n\t\t\t// Values are identical - no conflict to report\n\t\t\treturn [];\n\t\t}\n\t\t// If path value changed but no filtered patches, still create conflict with all patches\n\t\t// (might be an object-level change)\n\t}\n\n\t// Use filtered patches for conflict detection - use original patches if filtered are empty\n\tconst patches1ToUse = filteredPatches1.length > 0 ? filteredPatches1 : pathPatches;\n\tconst patches2ToUse = filteredPatches2.length > 0 ? filteredPatches2 : pathPatches;\n\n\t// For conflict type detection, check both sets\n\tconst patchesToUse = [...patches1ToUse, ...patches2ToUse];\n\n\tconst hasAdd = patchesToUse.some((p) => p.op === \"add\");\n\tconst hasRemove = patchesToUse.some((p) => p.op === \"remove\");\n\tconst hasReplace = patchesToUse.some((p) => p.op === \"replace\");\n\n\tif (hasAdd && !hasReplace && !hasRemove) {\n\t\t// Pure add: only highlight on the side that has the value\n\t\t// But check which input actually has the value\n\t\tif (input1Value !== undefined && input2Value === undefined) {\n\t\t\t// Added in input1 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: undefined,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value: undefined,\n\t\t\t\t\tconflictType: ConflictType.INPUT1_ONLY,\n\t\t\t\t\tpatches1: patches1ToUse, // Highlight on input1 (new content) - use filtered patches1\n\t\t\t\t\tpatches2: [], // No highlighting on input2 (doesn't exist there)\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (input2Value !== undefined && input1Value === undefined) {\n\t\t\t// Added in input2 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: undefined,\n\t\t\t\t\tinput1Value: undefined,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType: ConflictType.INPUT2_ONLY,\n\t\t\t\t\tpatches1: [], // No highlighting on input1 (doesn't exist there)\n\t\t\t\t\tpatches2: patches2ToUse, // Highlight on input2 (new content) - use filtered patches2\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\tif (hasRemove && !hasAdd && !hasReplace) {\n\t\t// Pure remove: check which input removed it\n\t\tif (input1Value !== undefined && input2Value === undefined) {\n\t\t\t// Removed in input2 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: input1Value,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value: undefined,\n\t\t\t\t\tconflictType: ConflictType.INPUT1_ONLY,\n\t\t\t\t\tpatches1: patches1ToUse, // Highlight on input1 (removed content) - use filtered patches1\n\t\t\t\t\tpatches2: [], // No highlighting on input2 (doesn't exist there)\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (input2Value !== undefined && input1Value === undefined) {\n\t\t\t// Removed in input1 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: input2Value,\n\t\t\t\t\tinput1Value: undefined,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType: ConflictType.INPUT2_ONLY,\n\t\t\t\t\tpatches1: [], // No highlighting on input1 (doesn't exist there)\n\t\t\t\t\tpatches2: patches2ToUse, // Highlight on input2 (removed content) - use filtered patches2\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\n\t// Replace or mixed operations: determine conflict type based on actual values\n\tconst conflictType = determineConflictType(baseValue, input1Value, input2Value);\n\n\t// Determine which patches to include based on conflict type\n\t// Use filtered patches (only actual changes) instead of all patches\n\tlet patches1: JsonPatchOperation[] = [];\n\tlet patches2: JsonPatchOperation[] = [];\n\n\tswitch (conflictType) {\n\t\tcase ConflictType.INPUT1_ONLY:\n\t\t\tpatches1 = patches1ToUse; // Input1 has the change - use filtered patches1\n\t\t\tpatches2 = [];\n\t\t\tbreak;\n\t\tcase ConflictType.INPUT2_ONLY:\n\t\t\tpatches1 = [];\n\t\t\tpatches2 = patches2ToUse; // Input2 has the change - use filtered patches2\n\t\t\tbreak;\n\t\tcase ConflictType.SAME_CHANGE:\n\t\t\t// Both changed to same value - highlight both with their respective filtered patches\n\t\t\tpatches1 = patches1ToUse;\n\t\t\tpatches2 = patches2ToUse;\n\t\t\tbreak;\n\t\tcase ConflictType.TRUE_CONFLICT:\n\t\t\t// Both changed to different values - highlight both with their respective filtered patches\n\t\t\tpatches1 = patches1ToUse;\n\t\t\tpatches2 = patches2ToUse;\n\t\t\tbreak;\n\t}\n\n\treturn [\n\t\t{\n\t\t\tpath,\n\t\t\tbaseValue,\n\t\t\tinput1Value,\n\t\t\tinput2Value,\n\t\t\tconflictType,\n\t\t\tpatches1,\n\t\t\tpatches2,\n\t\t},\n\t];\n}\n\n/**\n * Map conflict analyses (with JSON Patch operations) to Monaco Editor line ranges\n *\n * This function converts JSON Patch paths to line numbers:\n * 1. Takes conflicts with JSON Patch operations (e.g., /resource/0/type)\n * 2. For each patch, finds the actual JSON node in the formatted text using jsonc-parser\n * 3. Maps the node's character offset to line numbers\n * 4. Combines patch locations into line ranges for highlighting\n *\n * This is NOT line-based diff - we're using JSON structure (nodes) to find lines,\n * ensuring we highlight the exact JSON values that changed according to the patches.\n *\n * @param conflicts - Array of conflict analyses with JSON Patch operations\n * @param baseText - Formatted base JSON text (sorted keys, 2-space indent)\n * @param input1Text - Formatted input1 JSON text\n * @param input2Text - Formatted input2 JSON text\n * @returns Array of ModifiedBaseRange objects for Monaco Editor decorations\n */\n/**\n * Calculate line range that encompasses all patches in a group\n *\n * For JSON Patch diffs, we highlight based on the actual patch locations.\n * This ensures we're highlighting the exact JSON values that changed according\n * to the JSON Patch operations, not arbitrary line groups.\n *\n * Strategy:\n * 1. Find line ranges for each patch path using jsonc-parser (the exact changed JSON nodes)\n * 2. Combine ranges to encompass all affected values\n * 3. Skip patches that reference non-existent paths (they return {1,1} as \"not found\")\n */\nfunction calculatePatchLineRange(text: string, patches: JsonPatchOperation[]): { start: number; end: number } {\n\tif (!patches || patches.length === 0) {\n\t\treturn { start: 1, end: 1 };\n\t}\n\n\tlet minStart = Number.MAX_SAFE_INTEGER;\n\tlet maxEnd = 0;\n\tlet foundAnyNode = false;\n\n\tfor (const patch of patches) {\n\t\tconst lines = getNodeLines(text, patch.path);\n\t\t// Skip nodes that weren't found (defaulted to {1, 1})\n\t\t// When a path doesn't exist (e.g., array index that doesn't exist), getNodeLines returns {1,1}\n\t\t// We skip these to avoid polluting the range calculation\n\t\tif (lines.start === 1 && lines.end === 1) {\n\t\t\t// Removed verbose logging\n\t\t\tcontinue;\n\t\t}\n\n\t\tminStart = Math.min(minStart, lines.start);\n\t\tmaxEnd = Math.max(maxEnd, lines.end);\n\t\tfoundAnyNode = true;\n\t}\n\n\t// If no valid lines found, default to line 1\n\tif (!foundAnyNode || minStart === Number.MAX_SAFE_INTEGER || maxEnd === 0) {\n\t\t// Removed verbose logging\n\t\treturn { start: 1, end: 1 };\n\t}\n\n\t// Removed verbose logging\n\treturn { start: minStart, end: maxEnd };\n}\n\nexport function mapConflictsToRanges(\n\tconflicts: ConflictAnalysis[],\n\tbaseText: string,\n\tinput1Text: string,\n\tinput2Text: string,\n): ModifiedBaseRange[] {\n\tconst ranges: ModifiedBaseRange[] = [];\n\n\tfor (let i = 0; i < conflicts.length; i++) {\n\t\tconst conflict = conflicts[i];\n\n\t\t// Calculate line ranges by finding the range that encompasses all patches\n\t\t// For unchanged items (empty patches), use the path directly to get line ranges\n\t\tlet baseLines: { start: number; end: number };\n\t\tlet input1Lines: { start: number; end: number };\n\t\tlet input2Lines: { start: number; end: number };\n\n\t\tif ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - get line range directly from path\n\t\t\tbaseLines = baseText ? getNodeLines(baseText, conflict.path) : { start: 1, end: 1 };\n\t\t\tinput1Lines = getNodeLines(input1Text, conflict.path);\n\t\t\tinput2Lines = getNodeLines(input2Text, conflict.path);\n\t\t} else {\n\t\t\t// Changed item - use patches to calculate ranges\n\t\t\tbaseLines = calculatePatchLineRange(baseText, [...(conflict.patches1 || []), ...(conflict.patches2 || [])]);\n\t\t\tinput1Lines = calculatePatchLineRange(input1Text, conflict.patches1 || []);\n\t\t\tinput2Lines = calculatePatchLineRange(input2Text, conflict.patches2 || []);\n\t\t}\n\n\t\t// Determine if this is a true conflict\n\t\tconst isConflicting = conflict.conflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t// Determine default states based on conflict type\n\t\tlet input1State = InputState.excluded;\n\t\tlet input2State = InputState.excluded;\n\n\t\tswitch (conflict.conflictType) {\n\t\t\tcase ConflictType.SAME_CHANGE:\n\t\t\t\t// Both changed to the same value - accept both (they're identical)\n\t\t\t\tinput1State = InputState.first;\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.INPUT1_ONLY:\n\t\t\t\t// Only input1 changed - accept input1\n\t\t\t\tinput1State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.INPUT2_ONLY:\n\t\t\t\t// Only input2 changed - accept input2\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.TRUE_CONFLICT:\n\t\t\t\t// True conflict - default to accepting input2 (ours)\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Calculate actual line numbers for each patch (not fake line numbers)\n\t\t// This ensures decorations are applied to the correct lines based on JSON Patch paths\n\t\tconst input1Diffs: { line: number }[] = [];\n\t\tconst input2Diffs: { line: number }[] = [];\n\n\t\tif (conflict.patches1 && (conflict.patches1.length ?? 0) > 0) {\n\t\t\tfor (const patch of conflict.patches1) {\n\t\t\t\t// Skip removals - the item doesn't exist in input1, so there's nothing to highlight\n\t\t\t\t// Highlighting would show wrong lines (line numbers from base don't match input1)\n\t\t\t\tif (patch.op === \"remove\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// For non-removals, find node in input1\n\t\t\t\tconst lines = getNodeLines(input1Text, patch.path);\n\n\t\t\t\t// Only include if the node was found (not {1,1} default)\n\t\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\t\t// For additions/replacements, add ALL lines in the range (for multi-line objects/arrays)\n\t\t\t\t\tfor (let lineNum = lines.start; lineNum <= lines.end; lineNum++) {\n\t\t\t\t\t\tinput1Diffs.push({ line: lineNum });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - still need to highlight it, so add line from path\n\t\t\tconst lines = getNodeLines(input1Text, conflict.path);\n\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\tinput1Diffs.push({ line: lines.start });\n\t\t\t}\n\t\t}\n\n\t\tif (conflict.patches2 && (conflict.patches2.length ?? 0) > 0) {\n\t\t\tfor (const patch of conflict.patches2) {\n\t\t\t\t// Skip removals - the item doesn't exist in input2, so there's nothing to highlight\n\t\t\t\t// Highlighting would show wrong lines (line numbers from base don't match input2)\n\t\t\t\tif (patch.op === \"remove\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// For non-removals, find node in input2\n\t\t\t\tconst lines = getNodeLines(input2Text, patch.path);\n\n\t\t\t\t// Only include if the node was found (not {1,1} default)\n\t\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\t\t// For additions/replacements, add ALL lines in the range (for multi-line objects/arrays)\n\t\t\t\t\tfor (let lineNum = lines.start; lineNum <= lines.end; lineNum++) {\n\t\t\t\t\t\tinput2Diffs.push({ line: lineNum });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - still need to highlight it, so add line from path\n\t\t\tconst lines = getNodeLines(input2Text, conflict.path);\n\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\tinput2Diffs.push({ line: lines.start });\n\t\t\t}\n\t\t}\n\n\t\t// Removed verbose logging\n\n\t\tconst range: ModifiedBaseRange = {\n\t\t\tid: `conflict-${i}`,\n\t\t\tpath: conflict.path, // Include path for value extraction during resolution\n\t\t\tbaseRange: {\n\t\t\t\tstartLineNumber: baseLines.start,\n\t\t\t\tendLineNumberExclusive: baseLines.end + 1,\n\t\t\t},\n\t\t\tinput1Range: {\n\t\t\t\tstartLineNumber: input1Lines.start,\n\t\t\t\tendLineNumberExclusive: input1Lines.end + 1,\n\t\t\t},\n\t\t\tinput2Range: {\n\t\t\t\tstartLineNumber: input2Lines.start,\n\t\t\t\tendLineNumberExclusive: input2Lines.end + 1,\n\t\t\t},\n\t\t\tinput1Diffs,\n\t\t\tinput2Diffs,\n\t\t\tisConflicting,\n\t\t\tconflictType: conflict.conflictType,\n\t\t\tinput1State,\n\t\t\tinput2State,\n\t\t\thandled: conflict.conflictType === ConflictType.SAME_CHANGE,\n\t\t\tfocused: false,\n\t\t};\n\n\t\tranges.push(range);\n\t}\n\n\treturn ranges;\n}\n\n/**\n * Compute diffs using JSON Patch approach\n * @param baseText - Base version (JSON string, can be empty if no base)\n * @param input1Text - Input1 version (JSON string)\n * @param input2Text - Input2 version (JSON string)\n * @param options - Optional configuration\n * @param options.comparisonMode - How to compare: \"split\" or \"sequential\" (default: \"split\")\n * @param options.schema - Optional JSON Schema for schema-aware comparison\n * @param options.patches - Optional pre-computed patches (use instead of computing)\n * @returns Array of ModifiedBaseRange objects\n */\nexport function computeDiffsJsonPatch(\n\tbaseText: string,\n\tinput1Text: string,\n\tinput2Text: string,\n\toptions: {\n\t\tcomparisonMode?: \"split\" | \"sequential\";\n\t\tschema?: JSONSchema;\n\t\tpatches?: {\n\t\t\ttheirs?: JsonPatchOperation[];\n\t\t\tours?: JsonPatchOperation[];\n\t\t};\n\t} = {},\n): ModifiedBaseRange[] {\n\tconst { comparisonMode = \"split\", schema } = options;\n\n\t// Validate inputs\n\tif (!input1Text || !input2Text) {\n\t\tthrow new Error(\"JSON Patch diff requires non-empty input1 and input2 strings\");\n\t}\n\n\ttry {\n\t\t// 1. Parse JSON (with error handling)\n\t\tconst base = baseText ? JSON.parse(baseText) : undefined;\n\t\tconst input1 = JSON.parse(input1Text);\n\t\tconst input2 = JSON.parse(input2Text);\n\n\t\tlet conflicts: ConflictAnalysis[];\n\n\t\tif (base === undefined) {\n\t\t\t// 2-column mode: input1 vs input2 (no base)\n\t\t\t// Use provided patches or compute\n\t\t\tconflicts = analyzeTwoWayConflicts(input1, input2, schema);\n\t\t} else if (comparisonMode === \"split\") {\n\t\t\t// 3-column mode (split): input1 vs base, input2 vs base\n\t\t\t// Use provided patches or compute\n\t\t\tconflicts = analyzeConflicts(base, input1, input2, schema);\n\t\t} else {\n\t\t\t// 3-column mode (sequential): base ? input1 ? input2\n\t\t\t// For sequential, we compare base?input1 and input1?input2\n\t\t\t// This is a different approach - let's analyze it properly\n\t\t\tconst patch1 = compare(base, input1);\n\t\t\tconst patch2 = compare(input1, input2);\n\n\t\t\t// Combine paths from both patch sets\n\t\t\tconst allPaths = new Set<string>();\n\t\t\tpatch1.forEach((p) => {\n\t\t\t\tallPaths.add(p.path);\n\t\t\t});\n\t\t\tpatch2.forEach((p) => {\n\t\t\t\tallPaths.add(p.path);\n\t\t\t});\n\n\t\t\tconflicts = Array.from(allPaths).map((path) => {\n\t\t\t\tconst baseValue = getValueAtPath(base as Record<string, unknown>, path);\n\t\t\t\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, path);\n\t\t\t\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, path);\n\n\t\t\t\t// In sequential mode: check both transitions\n\t\t\t\tconst baseToInput1Changed = !isEqual(baseValue, input1Value);\n\t\t\t\tconst input1ToInput2Changed = !isEqual(input1Value, input2Value);\n\n\t\t\t\tlet conflictType: ConflictType;\n\n\t\t\t\tif (baseToInput1Changed && input1ToInput2Changed) {\n\t\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t\t} else if (baseToInput1Changed) {\n\t\t\t\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t\t\t\t} else if (input1ToInput2Changed) {\n\t\t\t\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t\t\t\t} else {\n\t\t\t\t\tconflictType = ConflictType.SAME_CHANGE;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType,\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\n\t\t// 3. Map to Monaco ranges\n\t\t// IMPORTANT: Use original text for line number mapping, not formatted text!\n\t\t// The Monaco editors display the original text, so line numbers must match.\n\t\treturn mapConflictsToRanges(conflicts, baseText, input1Text, input2Text);\n\t} catch (error) {\n\t\t// No fallback - re-throw with context\n\t\t// User must fix invalid JSON\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`JSON Patch diff computation failed: ${message}`);\n\t}\n}\n","import { findNodeAtLocation, parseTree } from \"jsonc-parser\";\nimport { ConflictType, InputState, type JSONSchema, type ModifiedBaseRange } from \"../types\";\nimport { getValueAtPath } from \"./helpers\";\nimport { getSchemaAtPath } from \"./jsonPatchDiff\";\n\n/**\n * Represents a single line change with detailed information\n */\ninterface LineChange {\n\tline: number;\n\tinput1Changed: boolean;\n\tinput2Changed: boolean;\n\tbaseLine: string;\n\tinput1Line: string;\n\tinput2Line: string;\n\tconflictType: ConflictType;\n}\n\n/**\n * Compute conflict type for a single line by comparing base, input1, and input2\n */\nexport function computeLineConflictType(\n\tbaseLine: string,\n\tinput1Line: string,\n\tinput2Line: string,\n): {\n\tconflictType: ConflictType;\n\tinput1Changed: boolean;\n\tinput2Changed: boolean;\n} {\n\tconst input1Changed = baseLine !== input1Line;\n\tconst input2Changed = baseLine !== input2Line;\n\n\tlet conflictType: ConflictType;\n\n\tif (input1Changed && input2Changed) {\n\t\t// Both changed - check if they have the same final value\n\t\tif (input1Line === input2Line) {\n\t\t\tconflictType = ConflictType.SAME_CHANGE;\n\t\t} else {\n\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t}\n\t} else if (input1Changed) {\n\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t} else {\n\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t}\n\n\treturn { conflictType, input1Changed, input2Changed };\n}\n\n/**\n * Compute diffs between base, input1, and input2 documents\n * Returns an array of conflict ranges with their types\n */\nexport function computeDiffs(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[] {\n\tconst baseRanges: ModifiedBaseRange[] = [];\n\n\t// Track all changes for each line with detailed comparison and conflict type\n\tconst allChanges: LineChange[] = [];\n\n\tfor (let i = 0; i < Math.max(baseLines.length, input1Lines.length, input2Lines.length); i++) {\n\t\tconst baseLine = baseLines[i] !== undefined ? baseLines[i] : \"\";\n\t\tconst input1Line = input1Lines[i] !== undefined ? input1Lines[i] : \"\";\n\t\tconst input2Line = input2Lines[i] !== undefined ? input2Lines[i] : \"\";\n\n\t\tconst { conflictType, input1Changed, input2Changed } = computeLineConflictType(baseLine, input1Line, input2Line);\n\n\t\tif (input1Changed || input2Changed) {\n\t\t\tallChanges.push({\n\t\t\t\tline: i + 1,\n\t\t\t\tinput1Changed,\n\t\t\t\tinput2Changed,\n\t\t\t\tbaseLine,\n\t\t\t\tinput1Line,\n\t\t\t\tinput2Line,\n\t\t\t\tconflictType,\n\t\t\t});\n\t\t}\n\t}\n\n\t// Group consecutive changes with the SAME conflict type into ranges\n\tif (allChanges.length === 0) {\n\t\treturn [];\n\t}\n\n\tlet rangeStart = allChanges[0]?.line ?? 1;\n\tlet currentConflictType = allChanges[0]?.conflictType;\n\tlet input1DiffsInRange: { line: number }[] = [];\n\tlet input2DiffsInRange: { line: number }[] = [];\n\n\tfor (let i = 0; i <= allChanges.length; i++) {\n\t\tconst current = allChanges[i];\n\t\tconst isLast = i === allChanges.length;\n\t\tconst isGap = !isLast && current && allChanges[i - 1] && current.line > (allChanges[i - 1]?.line ?? 0) + 1;\n\t\tconst typeChanged = !isLast && current && current.conflictType !== currentConflictType;\n\n\t\tif (isLast || isGap || typeChanged) {\n\t\t\t// End of range\n\t\t\tconst prevChange = allChanges[i - 1];\n\t\t\tconst rangeEnd = prevChange ? prevChange.line + 1 : rangeStart + 1;\n\n\t\t\tconst hasInput1Changes = input1DiffsInRange.length > 0;\n\t\t\tconst hasInput2Changes = input2DiffsInRange.length > 0;\n\t\t\tconst isConflicting = currentConflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t\tconst range: ModifiedBaseRange = {\n\t\t\t\tid: `conflict-${baseRanges.length}`,\n\t\t\t\tbaseRange: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput2Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Diffs: input1DiffsInRange,\n\t\t\t\tinput2Diffs: input2DiffsInRange,\n\t\t\t\tisConflicting,\n\t\t\t\tconflictType: currentConflictType,\n\t\t\t\t// Default: accept input2 (ours) by default, or both if same change\n\t\t\t\tinput1State: currentConflictType === ConflictType.SAME_CHANGE && hasInput1Changes ? InputState.first : InputState.excluded,\n\t\t\t\tinput2State: hasInput2Changes ? InputState.first : InputState.excluded,\n\t\t\t\thandled: currentConflictType === ConflictType.SAME_CHANGE,\n\t\t\t\tfocused: false,\n\t\t\t};\n\n\t\t\tbaseRanges.push(range);\n\n\t\t\t// Start new range\n\t\t\tif (!isLast && current) {\n\t\t\t\trangeStart = current.line;\n\t\t\t\tcurrentConflictType = current.conflictType;\n\t\t\t\tinput1DiffsInRange = [];\n\t\t\t\tinput2DiffsInRange = [];\n\t\t\t}\n\t\t}\n\n\t\tif (!isLast && current) {\n\t\t\tif (current.input1Changed) {\n\t\t\t\tinput1DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t\tif (current.input2Changed) {\n\t\t\t\tinput2DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn baseRanges;\n}\n\n/**\n * Compute diffs in sequential mode: base→input1→input2\n * In this mode, we compare base with input1, and input1 with input2\n */\nexport function computeDiffsSequential(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[] {\n\tconst baseRanges: ModifiedBaseRange[] = [];\n\n\t// Track all changes for each line\n\tconst allChanges: LineChange[] = [];\n\n\tfor (let i = 0; i < Math.max(baseLines.length, input1Lines.length, input2Lines.length); i++) {\n\t\tconst baseLine = baseLines[i] !== undefined ? baseLines[i] : \"\";\n\t\tconst input1Line = input1Lines[i] !== undefined ? input1Lines[i] : \"\";\n\t\tconst input2Line = input2Lines[i] !== undefined ? input2Lines[i] : \"\";\n\n\t\t// In sequential mode: compare base→input1 and input1→input2\n\t\tconst baseToInput1Changed = baseLine !== input1Line;\n\t\tconst input1ToInput2Changed = input1Line !== input2Line;\n\n\t\tlet conflictType: ConflictType;\n\n\t\tif (baseToInput1Changed && input1ToInput2Changed) {\n\t\t\t// Both transitions changed\n\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t} else if (baseToInput1Changed) {\n\t\t\t// Only base→input1 changed\n\t\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t\t} else if (input1ToInput2Changed) {\n\t\t\t// Only input1→input2 changed\n\t\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t\t} else {\n\t\t\t// No changes\n\t\t\tcontinue;\n\t\t}\n\n\t\tallChanges.push({\n\t\t\tline: i + 1,\n\t\t\tinput1Changed: baseToInput1Changed,\n\t\t\tinput2Changed: input1ToInput2Changed,\n\t\t\tbaseLine,\n\t\t\tinput1Line,\n\t\t\tinput2Line,\n\t\t\tconflictType,\n\t\t});\n\t}\n\n\t// Group consecutive changes with the SAME conflict type into ranges\n\tif (allChanges.length === 0) {\n\t\treturn [];\n\t}\n\n\tlet rangeStart = allChanges[0]?.line ?? 1;\n\tlet currentConflictType = allChanges[0]?.conflictType;\n\tlet input1DiffsInRange: { line: number }[] = [];\n\tlet input2DiffsInRange: { line: number }[] = [];\n\n\tfor (let i = 0; i <= allChanges.length; i++) {\n\t\tconst current = allChanges[i];\n\t\tconst isLast = i === allChanges.length;\n\t\tconst isGap = !isLast && current && allChanges[i - 1] && current.line > (allChanges[i - 1]?.line ?? 0) + 1;\n\t\tconst typeChanged = !isLast && current && current.conflictType !== currentConflictType;\n\n\t\tif (isLast || isGap || typeChanged) {\n\t\t\t// End of range\n\t\t\tconst prevChange = allChanges[i - 1];\n\t\t\tconst rangeEnd = prevChange ? prevChange.line + 1 : rangeStart + 1;\n\n\t\t\tconst hasInput1Changes = input1DiffsInRange.length > 0;\n\t\t\tconst hasInput2Changes = input2DiffsInRange.length > 0;\n\t\t\tconst isConflicting = currentConflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t\tconst range: ModifiedBaseRange = {\n\t\t\t\tid: `conflict-${baseRanges.length}`,\n\t\t\t\tbaseRange: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput2Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Diffs: input1DiffsInRange,\n\t\t\t\tinput2Diffs: input2DiffsInRange,\n\t\t\t\tisConflicting,\n\t\t\t\tconflictType: currentConflictType,\n\t\t\t\t// Default: accept input2 (final state) by default\n\t\t\t\tinput1State: hasInput1Changes ? InputState.first : InputState.excluded,\n\t\t\t\tinput2State: hasInput2Changes ? InputState.first : InputState.excluded,\n\t\t\t\thandled: false,\n\t\t\t\tfocused: false,\n\t\t\t};\n\n\t\t\tbaseRanges.push(range);\n\n\t\t\t// Start new range\n\t\t\tif (!isLast && current) {\n\t\t\t\trangeStart = current.line;\n\t\t\t\tcurrentConflictType = current.conflictType;\n\t\t\t\tinput1DiffsInRange = [];\n\t\t\t\tinput2DiffsInRange = [];\n\t\t\t}\n\t\t}\n\n\t\tif (!isLast && current) {\n\t\t\tif (current.input1Changed) {\n\t\t\t\tinput1DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t\tif (current.input2Changed) {\n\t\t\t\tinput2DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn baseRanges;\n}\n\n/**\n * Information about a conflict resolution issue\n */\nexport interface ConflictIssue {\n\tconflictId: string;\n\tconflictPath: string;\n\ttype: \"error\" | \"warning\" | \"smart-merge\";\n\tmessage: string;\n\tstartLine: number;\n\tendLine: number;\n}\n\n/**\n * Result of building merged content with validation\n */\nexport interface BuildResultContentResult {\n\tcontent: string;\n\tisValid: boolean;\n\tvalidationError?: string;\n\twarnings?: string[];\n\tconflictIssues?: ConflictIssue[];\n}\n\n/**\n * Set a value at a given JSON Pointer path in an object\n * @param obj - The object to modify\n * @param path - JSON Pointer path (e.g., \"/items/0/name\")\n * @param value - Value to set\n * @throws Error if path is invalid or types don't match\n */\nexport function setValueAtPath(obj: unknown, path: string, value: unknown): void {\n\tif (!path || path === \"/\") {\n\t\t// Setting root - replace entire object\n\t\tif (\n\t\t\ttypeof obj === \"object\" &&\n\t\t\tobj !== null &&\n\t\t\t!Array.isArray(obj) &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t!Array.isArray(value)\n\t\t) {\n\t\t\tObject.assign(obj, value);\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(`Cannot assign root value: expected object, got ${typeof value}`);\n\t}\n\n\tconst pathSegments = path.split(\"/\").filter((s) => s !== \"\");\n\tlet current: Record<string, unknown> | unknown[] = obj as Record<string, unknown> | unknown[];\n\n\tfor (let i = 0; i < pathSegments.length - 1; i++) {\n\t\tconst segment = pathSegments[i];\n\t\t// Check if segment is numeric (array index)\n\t\tconst numericIndex = Number.parseInt(segment, 10);\n\t\tif (!Number.isNaN(numericIndex) && String(numericIndex) === segment) {\n\t\t\t// Array index\n\t\t\tif (!Array.isArray(current)) {\n\t\t\t\tthrow new Error(`Path ${path}: segment ${segment} expects array but got ${typeof current}`);\n\t\t\t}\n\t\t\tcurrent = current[numericIndex] as Record<string, unknown> | unknown[];\n\t\t} else {\n\t\t\t// Object key\n\t\t\tif (!current || typeof current !== \"object\" || Array.isArray(current)) {\n\t\t\t\tthrow new Error(`Path ${path}: segment ${segment} expects object but got ${typeof current}`);\n\t\t\t}\n\t\t\tconst objCurrent = current as Record<string, unknown>;\n\t\t\tif (!(segment in objCurrent)) {\n\t\t\t\tobjCurrent[segment] = {};\n\t\t\t}\n\t\t\tcurrent = objCurrent[segment] as Record<string, unknown> | unknown[];\n\t\t}\n\t}\n\n\tconst lastSegment = pathSegments[pathSegments.length - 1];\n\tconst lastNumeric = Number.parseInt(lastSegment, 10);\n\tif (!Number.isNaN(lastNumeric) && String(lastNumeric) === lastSegment) {\n\t\t// Setting array element\n\t\tif (!Array.isArray(current)) {\n\t\t\tthrow new Error(`Path ${path}: last segment expects array but got ${typeof current}`);\n\t\t}\n\t\tcurrent[lastNumeric] = value;\n\t} else {\n\t\t// Setting object property\n\t\tif (!current || typeof current !== \"object\" || Array.isArray(current)) {\n\t\t\tthrow new Error(`Path ${path}: last segment expects object but got ${typeof current}`);\n\t\t}\n\t\t(current as Record<string, unknown>)[lastSegment] = value;\n\t}\n}\n\n/**\n * Find line numbers for a JSON path in formatted JSON text\n * @param jsonContent - Formatted JSON string\n * @param path - JSON Pointer path\n * @returns Line number range or null if path not found\n */\nexport function findLinesForPath(jsonContent: string, path: string): { startLine: number; endLine: number } | null {\n\ttry {\n\t\tconst tree = parseTree(jsonContent);\n\t\tif (!tree) return null;\n\n\t\t// Navigate to the path\n\t\tconst segments = path\n\t\t\t.split(\"/\")\n\t\t\t.filter((s) => s !== \"\")\n\t\t\t.map((segment) => {\n\t\t\t\t// Check if segment is a numeric array index\n\t\t\t\tconst numericValue = Number.parseInt(segment, 10);\n\t\t\t\treturn !Number.isNaN(numericValue) && String(numericValue) === segment ? numericValue : segment;\n\t\t\t});\n\t\tconst node = findNodeAtLocation(tree, segments);\n\n\t\tif (!node) return null;\n\n\t\tconst lines = jsonContent.substring(0, node.offset).split(\"\\n\");\n\t\tconst startLine = lines.length;\n\n\t\tconst endOffset = node.offset + node.length;\n\t\tconst endLines = jsonContent.substring(0, endOffset).split(\"\\n\");\n\t\tconst endLine = endLines.length;\n\n\t\treturn { startLine, endLine };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Attempt to smart-merge two JSON values based on their types and schema\n * Returns the merged value or null if merge is not possible\n */\nexport function smartMergeValues(value1: unknown, value2: unknown, schema?: JSONSchema, path = \"\"): unknown | null {\n\t// If values are identical, return either one\n\tif (JSON.stringify(value1) === JSON.stringify(value2)) {\n\t\treturn value1;\n\t}\n\n\t// If both are objects (not arrays), attempt deep merge\n\tif (\n\t\tvalue1 !== null &&\n\t\tvalue2 !== null &&\n\t\ttypeof value1 === \"object\" &&\n\t\ttypeof value2 === \"object\" &&\n\t\t!Array.isArray(value1) &&\n\t\t!Array.isArray(value2)\n\t) {\n\t\tconst obj1 = value1 as Record<string, unknown>;\n\t\tconst obj2 = value2 as Record<string, unknown>;\n\t\tconst merged = { ...obj1 };\n\n\t\t// Get schema for this object if available\n\t\tconst objectSchema = schema ? getSchemaAtPath(schema, path, value1) : null;\n\n\t\tconst properties =\n\t\t\tobjectSchema?.properties && typeof objectSchema.properties === \"object\" && !Array.isArray(objectSchema.properties)\n\t\t\t\t? (objectSchema.properties as Record<string, JSONSchema>)\n\t\t\t\t: undefined;\n\t\tconst additionalProperties = objectSchema?.additionalProperties;\n\n\t\tfor (const key of Object.keys(obj2)) {\n\t\t\tif (!(key in merged)) {\n\t\t\t\t// Key only in value2 - add it if allowed by schema\n\t\t\t\tconst isAllowed = additionalProperties === true || additionalProperties === undefined || properties?.[key] !== undefined;\n\n\t\t\t\tif (isAllowed) {\n\t\t\t\t\tmerged[key] = obj2[key];\n\t\t\t\t} else if (additionalProperties === false) {\n\t\t\t\t\t// Schema explicitly disallows additional properties - conflict\n\t\t\t\t\treturn null;\n\t\t\t\t} else if (typeof additionalProperties === \"object\") {\n\t\t\t\t\t// additionalProperties is a schema - allow it\n\t\t\t\t\tmerged[key] = obj2[key];\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown case - be safe and don't allow\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t} else if (JSON.stringify(merged[key]) !== JSON.stringify(obj2[key])) {\n\t\t\t\t// Key exists in both but with different values\n\t\t\t\t// Get schema for this property\n\t\t\t\tconst propertySchema = properties?.[key];\n\t\t\t\tconst nestedPath = path ? `${path}/${key}` : `/${key}`;\n\n\t\t\t\t// Try to recursively merge\n\t\t\t\tconst recursiveMerge = smartMergeValues(merged[key], obj2[key], propertySchema, nestedPath);\n\t\t\t\tif (recursiveMerge !== null) {\n\t\t\t\t\tmerged[key] = recursiveMerge;\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot merge - conflict remains\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If values are identical, keep the existing value\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\t// If both are arrays with same length, could potentially merge items\n\t// But this is complex and may not make sense without schema guidance\n\t// For now, return null to indicate merge not possible\n\n\t// Cannot merge - different types or incompatible values\n\treturn null;\n}\n\n/**\n * Build result content from conflict ranges based on their states\n * Legacy version without validation - kept for backward compatibility\n */\nexport function buildResultContent(\n\tbaseLines: string[],\n\tinput1Lines: string[],\n\tinput2Lines: string[],\n\tconflicts: ModifiedBaseRange[],\n): string {\n\tconst result = buildResultContentWithValidation(baseLines, input1Lines, input2Lines, conflicts);\n\treturn result.content;\n}\n\n/**\n * Build result content from conflict ranges based on their states\n * Returns validation information along with the merged content\n */\nexport function buildResultContentWithValidation(\n\tbaseLines: string[],\n\tinput1Lines: string[],\n\tinput2Lines: string[],\n\tconflicts: ModifiedBaseRange[],\n\tschema?: JSONSchema,\n): BuildResultContentResult {\n\tconst warnings: string[] = [];\n\tconst conflictIssues: ConflictIssue[] = [];\n\n\t// Parse full documents for semantic merging\n\tconst baseText = baseLines.join(\"\\n\");\n\tconst input1Text = input1Lines.join(\"\\n\");\n\tconst input2Text = input2Lines.join(\"\\n\");\n\n\tlet baseData: unknown;\n\tlet input1Data: unknown;\n\tlet input2Data: unknown;\n\n\ttry {\n\t\tbaseData = baseText ? JSON.parse(baseText) : {};\n\t\tinput1Data = input1Text ? JSON.parse(input1Text) : {};\n\t\tinput2Data = input2Text ? JSON.parse(input2Text) : {};\n\t} catch (e) {\n\t\treturn {\n\t\t\tcontent: baseText || \"\",\n\t\t\tisValid: false,\n\t\t\tvalidationError: `Failed to parse input JSON: ${e instanceof Error ? e.message : String(e)}`,\n\t\t\twarnings,\n\t\t};\n\t}\n\n\t// Build result JSON semantically from parsed data\n\t// Start with base and apply changes based on conflict resolution\n\tlet resultData: unknown;\n\n\t// If base is empty, start with input2 (ours) as default\n\tif (!baseData || (typeof baseData === \"object\" && baseData !== null && Object.keys(baseData).length === 0)) {\n\t\tresultData = JSON.parse(JSON.stringify(input2Data)); // Deep clone\n\t} else {\n\t\tresultData = JSON.parse(JSON.stringify(baseData)); // Deep clone base\n\t}\n\n\t// Track which paths we've already applied to avoid duplicates\n\tconst appliedPaths = new Set<string>();\n\t// Track which properties have been explicitly set (to avoid overwriting when merging parents)\n\tconst explicitlySetProperties = new Set<string>();\n\t// Track which parent paths have been merged (to avoid merging same parent multiple times)\n\tconst mergedParents = new Set<string>();\n\n\t// Helper function to find path from line range\n\tconst findPathFromLines = (_startLine: number, _endLine: number, _text: string): string | null => {\n\t\t// This is a simplified approach - for full implementation, we'd need to map lines to JSON paths\n\t\t// For now, if we can't determine path, we'll use line-based merge\n\t\treturn null;\n\t};\n\n\t// Apply each conflict resolution to the result data\n\tfor (const conflict of conflicts) {\n\t\tconst includesInput1 = conflict.input1State === InputState.first || conflict.input1State === InputState.second;\n\t\tconst includesInput2 = conflict.input2State === InputState.first || conflict.input2State === InputState.second;\n\n\t\t// If no path is available, try to infer it or use line-based merge\n\t\tlet conflictPath = conflict.path;\n\t\tif (!conflictPath) {\n\t\t\t// Try to find path from the line range\n\t\t\tconflictPath =\n\t\t\t\tfindPathFromLines(conflict.baseRange.startLineNumber, conflict.baseRange.endLineNumberExclusive, baseText) || undefined;\n\n\t\t\t// If we still don't have a path, use a fallback strategy: merge the entire document\n\t\t\t// by applying conflict resolution based on conflict type and input states\n\t\t\tif (!conflictPath) {\n\t\t\t\t// For conflicts without paths, determine which input to use based on conflict type\n\t\t\t\tif (conflict.conflictType === ConflictType.INPUT2_ONLY && includesInput2) {\n\t\t\t\t\t// INPUT2_ONLY with input2 accepted - use input2\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (conflict.conflictType === ConflictType.INPUT1_ONLY && includesInput1) {\n\t\t\t\t\t// INPUT1_ONLY with input1 accepted - use input1\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input1Data));\n\t\t\t\t} else if (conflict.conflictType === ConflictType.SAME_CHANGE && (includesInput1 || includesInput2)) {\n\t\t\t\t\t// SAME_CHANGE - both are the same, use input2\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (includesInput2) {\n\t\t\t\t\t// If input2 is accepted, prefer it\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (includesInput1) {\n\t\t\t\t\t// If input1 is accepted, use it\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input1Data));\n\t\t\t\t}\n\t\t\t\t// Otherwise keep resultData as is (base or previously set value)\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tlet valueToApply: unknown;\n\t\t\tlet pathToApply = conflictPath;\n\n\t\t\t// Detect if this conflict affects an array - check if path contains array index\n\t\t\t// Pattern: /some/path/\\d+/property or /some/path/\\d+\n\t\t\tconst arrayItemMatch = conflict.path?.match(/^(.*\\/\\d+)(?:\\/.*)?$/);\n\t\t\tlet isArrayItemConflict = false;\n\t\t\tlet arrayPath = \"\";\n\n\t\t\tif (arrayItemMatch) {\n\t\t\t\t// This is an array item conflict\n\t\t\t\t// Extract the array path (parent of the numeric index)\n\t\t\t\tconst fullItemPath = arrayItemMatch[1]; // e.g., \"/itemsLimits/item/2\"\n\t\t\t\tconst segments = fullItemPath.split(\"/\").filter((s) => s !== \"\");\n\t\t\t\tif (segments.length >= 2) {\n\t\t\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\t\t\tif (/^\\d+$/.test(lastSegment)) {\n\t\t\t\t\t\t// Last segment is numeric - this is an array item\n\t\t\t\t\t\tisArrayItemConflict = true;\n\t\t\t\t\t\tarrayPath = `/${segments.slice(0, -1).join(\"/\")}`; // e.g., \"/itemsLimits/item\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (includesInput1 && includesInput2) {\n\t\t\t\t// Both accepted\n\t\t\t\tif (conflict.conflictType === ConflictType.SAME_CHANGE) {\n\t\t\t\t\t// Same change - use input2 (or input1, they're identical)\n\t\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\t\t// Get the entire array from input2\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// TRUE_CONFLICT with both accepted - attempt smart merge\n\t\t\t\t\tconst extractPath = isArrayItemConflict ? arrayPath : conflictPath;\n\t\t\t\t\tconst input1Value = getValueAtPath(input1Data as Record<string, unknown>, extractPath);\n\t\t\t\t\tconst input2Value = getValueAtPath(input2Data as Record<string, unknown>, extractPath);\n\n\t\t\t\t\t// Get schema for this conflict path if available\n\t\t\t\t\tconst conflictSchema =\n\t\t\t\t\t\tschema && baseData && typeof baseData === \"object\"\n\t\t\t\t\t\t\t? getSchemaAtPath(schema, extractPath, baseData) || undefined\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tconst mergedValue = smartMergeValues(input1Value, input2Value, conflictSchema, extractPath);\n\n\t\t\t\t\tif (mergedValue !== null) {\n\t\t\t\t\t\tvalueToApply = mergedValue;\n\t\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t\t\twarnings.push(`Smart-merged conflict at path ${extractPath}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Merge failed - prefer input2 (ours) as default\n\t\t\t\t\t\tvalueToApply = input2Value;\n\t\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t\t\twarnings.push(`Merge failed at path ${extractPath}, using input2 value`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (includesInput1) {\n\t\t\t\t// Only input1 accepted\n\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t} else {\n\t\t\t\t\t// For nested properties, merge parent object but preserve explicitly set properties\n\t\t\t\t\tconst pathSegments = conflictPath.split(\"/\").filter(Boolean);\n\t\t\t\t\tif (pathSegments.length > 1) {\n\t\t\t\t\t\tconst parentPath = `/${pathSegments.slice(0, -1).join(\"/\")}`;\n\t\t\t\t\t\t// Only merge parent if we haven't merged it yet\n\t\t\t\t\t\tif (!mergedParents.has(parentPath)) {\n\t\t\t\t\t\t\tconst parentInInput1 = getValueAtPath(input1Data as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\tif (typeof parentInInput1 === \"object\" && parentInInput1 !== null && !Array.isArray(parentInInput1)) {\n\t\t\t\t\t\t\t\tconst currentParent = getValueAtPath(resultData as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\t\tif (typeof currentParent === \"object\" && currentParent !== null && !Array.isArray(currentParent)) {\n\t\t\t\t\t\t\t\t\t// Merge parent, but preserve properties already explicitly set\n\t\t\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(parentInInput1)) {\n\t\t\t\t\t\t\t\t\t\tconst childPath = `${parentPath}/${key}`;\n\t\t\t\t\t\t\t\t\t\tif (!explicitlySetProperties.has(childPath)) {\n\t\t\t\t\t\t\t\t\t\t\t(currentParent as Record<string, unknown>)[key] = value;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmergedParents.add(parentPath);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (includesInput2) {\n\t\t\t\t// Only input2 accepted\n\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t} else {\n\t\t\t\t\t// For nested properties, merge parent object but preserve explicitly set properties\n\t\t\t\t\tconst pathSegments = conflictPath.split(\"/\").filter(Boolean);\n\t\t\t\t\tif (pathSegments.length > 1) {\n\t\t\t\t\t\tconst parentPath = `/${pathSegments.slice(0, -1).join(\"/\")}`;\n\t\t\t\t\t\t// Only merge parent if we haven't merged it yet\n\t\t\t\t\t\tif (!mergedParents.has(parentPath)) {\n\t\t\t\t\t\t\tconst parentInInput2 = getValueAtPath(input2Data as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\tif (typeof parentInInput2 === \"object\" && parentInInput2 !== null && !Array.isArray(parentInInput2)) {\n\t\t\t\t\t\t\t\tconst currentParent = getValueAtPath(resultData as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\t\tif (typeof currentParent === \"object\" && currentParent !== null && !Array.isArray(currentParent)) {\n\t\t\t\t\t\t\t\t\t// Merge parent, but preserve properties already explicitly set\n\t\t\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(parentInInput2)) {\n\t\t\t\t\t\t\t\t\t\tconst childPath = `${parentPath}/${key}`;\n\t\t\t\t\t\t\t\t\t\tif (!explicitlySetProperties.has(childPath)) {\n\t\t\t\t\t\t\t\t\t\t\t(currentParent as Record<string, unknown>)[key] = value;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmergedParents.add(parentPath);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Neither accepted - keep base value (or remove if it was added)\n\t\t\t\tconst extractPath = isArrayItemConflict ? arrayPath : conflictPath;\n\t\t\t\tconst baseValue = getValueAtPath(baseData as Record<string, unknown>, extractPath);\n\t\t\t\tif (baseValue !== undefined) {\n\t\t\t\t\tvalueToApply = baseValue;\n\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t} else {\n\t\t\t\t\t// Property doesn't exist in base - remove it from result\n\t\t\t\t\t// For now, we'll just skip it and let the final JSON stringify handle it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply the value to result data\n\t\t\tif (valueToApply !== undefined) {\n\t\t\t\t// Always set the value at the specific path\n\t\t\t\tsetValueAtPath(resultData, pathToApply, valueToApply);\n\n\t\t\t\t// Track that we've applied this specific path\n\t\t\t\tappliedPaths.add(pathToApply);\n\t\t\t\t// Mark this property as explicitly set (so parent merges don't overwrite it)\n\t\t\t\texplicitlySetProperties.add(pathToApply);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\twarnings.push(`Failed to apply conflict at path ${conflictPath || conflict.id}: ${e instanceof Error ? e.message : String(e)}`);\n\t\t}\n\t}\n\n\t// Convert result data to JSON string\n\tconst content = JSON.stringify(resultData, null, 2);\n\n\t// Now that we have the final content, map conflict issues to line numbers\n\tfor (const conflict of conflicts) {\n\t\tconst conflictPath = conflict.path;\n\t\tif (!conflictPath) continue;\n\n\t\tconst includesInput1 = conflict.input1State === InputState.first || conflict.input1State === InputState.second;\n\t\tconst includesInput2 = conflict.input2State === InputState.first || conflict.input2State === InputState.second;\n\n\t\t// Check if this conflict has both inputs checked (potential for issues)\n\t\tif (includesInput1 && includesInput2 && conflict.conflictType === ConflictType.TRUE_CONFLICT) {\n\t\t\t// For TRUE_CONFLICT with both checkboxes checked, always show warning\n\t\t\t// because the system made an arbitrary choice and the user should review it\n\t\t\tconst lineInfo = findLinesForPath(content, conflictPath);\n\t\t\tif (lineInfo) {\n\t\t\t\tconflictIssues.push({\n\t\t\t\t\tconflictId: conflict.id,\n\t\t\t\t\tconflictPath: conflictPath,\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: \"Both conflicting changes were accepted - please review and manually resolve\",\n\t\t\t\t\tstartLine: lineInfo.startLine,\n\t\t\t\t\tendLine: lineInfo.endLine,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate the result is valid JSON\n\tlet isValid = true;\n\tlet validationError: string | undefined;\n\n\ttry {\n\t\tJSON.parse(content);\n\t} catch (e) {\n\t\tisValid = false;\n\t\tvalidationError = e instanceof Error ? e.message : \"Invalid JSON\";\n\n\t\t// Add a general error issue\n\t\tconflictIssues.push({\n\t\t\tconflictId: \"validation-error\",\n\t\t\tconflictPath: \"/\",\n\t\t\ttype: \"error\",\n\t\t\tmessage: validationError,\n\t\t\tstartLine: 1,\n\t\t\tendLine: content.split(\"\\n\").length,\n\t\t});\n\t}\n\n\treturn {\n\t\tcontent,\n\t\tisValid,\n\t\tvalidationError,\n\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\tconflictIssues: conflictIssues.length > 0 ? conflictIssues : undefined,\n\t};\n}\n","import type * as monaco from \"monaco-editor\";\nimport type { ModifiedBaseRange } from \"../types\";\nimport { ConflictType as ConflictTypeEnum } from \"../types\";\n\n/**\n * Configuration for editor decoration colors and styles\n */\nexport interface DecorationConfig {\n\tconflictColor: string;\n\tchangeColor: string;\n\tbaseColor: string;\n\tconflictOverviewColor: string;\n\tchangeOverviewColor: string;\n\tbaseOverviewColor: string;\n}\n\n/**\n * Determines CSS classes and overview colors based on conflict type\n */\nexport interface DecorationClasses {\n\tinput1Class: string;\n\tinput2Class: string;\n\tbaseClass: string;\n\tinput1OverviewColor: string;\n\tinput2OverviewColor: string;\n\tbaseOverviewColor: string;\n}\n\n/**\n * Determines the CSS classes and colors for decorations based on conflict type\n */\nexport function getDecorationClasses(conflict: ModifiedBaseRange, isTwoColumnMode: boolean, config: DecorationConfig): DecorationClasses {\n\tlet input1Class = \"\";\n\tlet input2Class = \"\";\n\tlet baseClass = \"\";\n\tlet input1OverviewColor = \"\";\n\tlet input2OverviewColor = \"\";\n\tlet baseOverviewColor = \"\";\n\n\tswitch (conflict.conflictType) {\n\t\tcase ConflictTypeEnum.SAME_CHANGE: {\n\t\t\t// Check if this is an item added in both inputs (not in base)\n\t\t\tconst isAddedInBothSame =\n\t\t\t\tconflict.baseRange.startLineNumber === 1 &&\n\t\t\t\tconflict.baseRange.endLineNumberExclusive === 2 && // Default \"not found\" range\n\t\t\t\tconflict.input1Range.startLineNumber !== 1 &&\n\t\t\t\tconflict.input2Range.startLineNumber !== 1;\n\n\t\t\tif (isAddedInBothSame) {\n\t\t\t\t// Both inputs added the same item - highlight both in blue (auto-merged)\n\t\t\t\tinput1Class = \"merge-same-change\"; // Blue for input1 (same addition)\n\t\t\t\tinput2Class = \"merge-same-change\"; // Blue for input2 (same addition)\n\t\t\t\tbaseClass = \"\"; // No base highlighting (doesn't exist in base)\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// Both made the same change to existing item:\n\t\t\t\t// - input2 (ours) should be highlighted in blue (same-change)\n\t\t\t\t// - input1 (theirs) should be highlighted in red (incoming)\n\t\t\t\tinput1Class = \"merge-change-incoming\"; // Red for theirs (input1)\n\t\t\t\tinput2Class = \"merge-same-change\"; // Blue for ours (input2)\n\t\t\t\tbaseClass = \"merge-change-base\";\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase ConflictTypeEnum.INPUT1_ONLY:\n\t\t\t// Only input1 has content (removed in input2)\n\t\t\t// In 2-column mode: highlight input1 as deletion (red)\n\t\t\t// In 3-column mode: highlight input1 and base\n\t\t\tif (isTwoColumnMode) {\n\t\t\t\t// 2-column: highlight input1 as deletion (red for removed content)\n\t\t\t\tinput1Class = \"merge-2way-deletion\"; // Red for deletions in 2-way mode\n\t\t\t\tinput2Class = \"\"; // No highlighting on input2 (doesn't exist)\n\t\t\t\tinput1OverviewColor = config.baseOverviewColor; // Red for removed content\n\t\t\t\tinput2OverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// 3-column: highlight input1 and base\n\t\t\t\tinput1Class = \"merge-change-incoming\";\n\t\t\t\tinput2Class = \"\";\n\t\t\t\tbaseClass = \"merge-change-base\";\n\t\t\t\tinput1OverviewColor = config.conflictOverviewColor; // Orange for incoming changes\n\t\t\t\tinput2OverviewColor = \"\";\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase ConflictTypeEnum.INPUT2_ONLY:\n\t\t\t// Only input2 changed (addition in input2)\n\t\t\t// In 2-column mode: only highlight input2 as addition (green)\n\t\t\t// In 3-column mode: highlight input2 and base\n\t\t\tinput1Class = \"\"; // No highlighting on input1 (doesn't exist in 2-way, or unchanged in 3-way)\n\t\t\tinput2Class = \"merge-change-current\"; // Green for additions\n\t\t\tbaseClass = isTwoColumnMode ? \"\" : \"merge-change-base\";\n\t\t\tinput1OverviewColor = \"\";\n\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\tbaseOverviewColor = isTwoColumnMode ? \"\" : config.baseOverviewColor;\n\t\t\tbreak;\n\t\tcase ConflictTypeEnum.TRUE_CONFLICT: {\n\t\t\t// Check if this is an item added in both inputs (not in base)\n\t\t\t// If so, highlight as additions (orange) instead of conflicts (red)\n\t\t\tconst isAddedInBoth =\n\t\t\t\tconflict.baseRange.startLineNumber === 1 &&\n\t\t\t\tconflict.baseRange.endLineNumberExclusive === 2 && // Default \"not found\" range\n\t\t\t\tconflict.input1Range.startLineNumber !== 1 &&\n\t\t\t\tconflict.input2Range.startLineNumber !== 1;\n\n\t\t\tif (isAddedInBoth) {\n\t\t\t\t// Item added in both inputs - highlight as additions (orange/green)\n\t\t\t\tinput1Class = \"merge-change-incoming\"; // Orange/red for input1 addition\n\t\t\t\tinput2Class = \"merge-change-current\"; // Green for input2 addition\n\t\t\t\tbaseClass = \"\"; // No base highlighting\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// True conflict - highlight all three\n\t\t\t\tinput1Class = \"merge-conflict-incoming\";\n\t\t\t\tinput2Class = \"merge-conflict-current\";\n\t\t\t\tbaseClass = \"merge-conflict-base\";\n\t\t\t\tinput1OverviewColor = config.conflictOverviewColor;\n\t\t\t\tinput2OverviewColor = config.conflictOverviewColor;\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn {\n\t\tinput1Class,\n\t\tinput2Class,\n\t\tbaseClass,\n\t\tinput1OverviewColor,\n\t\tinput2OverviewColor,\n\t\tbaseOverviewColor,\n\t};\n}\n\n/**\n * Extracts unique line numbers from diff arrays\n */\nfunction extractUniqueLines(diffs: unknown[]): number[] {\n\tconst uniqueLines = new Set<number>();\n\tfor (const diff of diffs) {\n\t\tif (diff && typeof diff === \"object\" && \"line\" in diff) {\n\t\t\tconst lineNum = (diff as { line: number }).line;\n\t\t\tif (lineNum > 0) {\n\t\t\t\tuniqueLines.add(lineNum);\n\t\t\t}\n\t\t}\n\t}\n\treturn Array.from(uniqueLines).sort((a, b) => a - b);\n}\n\n/**\n * Creates Monaco editor decorations for input1 (theirs) panel\n */\nexport function createInput1Decorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Only highlight specific lines from input1Diffs, not the entire range\n\t// This ensures we don't highlight lines with identical/unchanged properties\n\tif (conflict.input1Diffs.length > 0 && classes.input1Class) {\n\t\tconst uniqueLines = extractUniqueLines(conflict.input1Diffs);\n\n\t\t// Create a decoration for each unique line that actually changed\n\t\tfor (const lineNum of uniqueLines) {\n\t\t\tdecorations.push({\n\t\t\t\trange: new monacoInstance.Range(lineNum, 1, lineNum, Number.MAX_SAFE_INTEGER),\n\t\t\t\toptions: {\n\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\tclassName: classes.input1Class,\n\t\t\t\t\toverviewRuler: classes.input1OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input1OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminimap: classes.input1OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input1OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates Monaco editor decorations for input2 (ours) panel\n */\nexport function createInput2Decorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Only highlight specific lines from input2Diffs, not the entire range\n\t// This ensures we don't highlight lines with identical/unchanged properties\n\tif (conflict.input2Diffs.length > 0 && classes.input2Class) {\n\t\tconst uniqueLines = extractUniqueLines(conflict.input2Diffs);\n\n\t\t// Create a decoration for each unique line that actually changed\n\t\tfor (const lineNum of uniqueLines) {\n\t\t\tdecorations.push({\n\t\t\t\trange: new monacoInstance.Range(lineNum, 1, lineNum, Number.MAX_SAFE_INTEGER),\n\t\t\t\toptions: {\n\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\tclassName: classes.input2Class,\n\t\t\t\t\toverviewRuler: classes.input2OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input2OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminimap: classes.input2OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input2OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates Monaco editor decorations for base panel\n */\nexport function createBaseDecorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Color base changes - always highlight when there's any change\n\t// Skip highlighting if baseRange is the default {1, 2} - this means the item doesn't exist in base\n\tconst isDefaultRange = conflict.baseRange.startLineNumber === 1 && conflict.baseRange.endLineNumberExclusive === 2;\n\n\tif ((conflict.input1Diffs.length > 0 || conflict.input2Diffs.length > 0) && !isDefaultRange) {\n\t\tdecorations.push({\n\t\t\trange: new monacoInstance.Range(\n\t\t\t\tconflict.baseRange.startLineNumber,\n\t\t\t\t1,\n\t\t\t\tconflict.baseRange.endLineNumberExclusive - 1,\n\t\t\t\tNumber.MAX_SAFE_INTEGER,\n\t\t\t),\n\t\t\toptions: {\n\t\t\t\tisWholeLine: true,\n\t\t\t\tclassName: classes.baseClass,\n\t\t\t\toverviewRuler: {\n\t\t\t\t\tcolor: classes.baseOverviewColor,\n\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t},\n\t\t\t\tminimap: {\n\t\t\t\t\tcolor: classes.baseOverviewColor,\n\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates all decorations for a conflict (input1, input2, and base)\n */\nexport function createConflictDecorations(\n\tconflict: ModifiedBaseRange,\n\tisTwoColumnMode: boolean,\n\tconfig: DecorationConfig,\n\tmonacoInstance: typeof monaco,\n): {\n\tinput1Decorations: monaco.editor.IModelDeltaDecoration[];\n\tinput2Decorations: monaco.editor.IModelDeltaDecoration[];\n\tbaseDecorations: monaco.editor.IModelDeltaDecoration[];\n} {\n\tconst classes = getDecorationClasses(conflict, isTwoColumnMode, config);\n\n\treturn {\n\t\tinput1Decorations: createInput1Decorations(conflict, classes, monacoInstance),\n\t\tinput2Decorations: createInput2Decorations(conflict, classes, monacoInstance),\n\t\tbaseDecorations: createBaseDecorations(conflict, classes, monacoInstance),\n\t};\n}\n\n/**\n * Creates decorations for all conflicts\n */\nexport function createAllDecorations(\n\tconflicts: ModifiedBaseRange[],\n\tisTwoColumnMode: boolean,\n\tconfig: DecorationConfig,\n\tmonacoInstance: typeof monaco,\n): {\n\tinput1Decorations: monaco.editor.IModelDeltaDecoration[];\n\tinput2Decorations: monaco.editor.IModelDeltaDecoration[];\n\tbaseDecorations: monaco.editor.IModelDeltaDecoration[];\n} {\n\tconst input1Decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\tconst input2Decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\tconst baseDecorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\tfor (const conflict of conflicts) {\n\t\tconst decorations = createConflictDecorations(conflict, isTwoColumnMode, config, monacoInstance);\n\t\tinput1Decorations.push(...decorations.input1Decorations);\n\t\tinput2Decorations.push(...decorations.input2Decorations);\n\t\tbaseDecorations.push(...decorations.baseDecorations);\n\t}\n\n\treturn {\n\t\tinput1Decorations,\n\t\tinput2Decorations,\n\t\tbaseDecorations,\n\t};\n}\n","import loader from \"@monaco-editor/loader\";\nimport type * as monaco from \"monaco-editor\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { type EditorDiffMergeProps, InputState, type ModifiedBaseRange } from \"../types\";\nimport { buildResultContentWithValidation, type ConflictIssue } from \"../utils/diffMerge\";\nimport { createAllDecorations, type DecorationConfig } from \"../utils/editorDecorations\";\nimport { computeDiffsJsonPatch } from \"../utils/jsonPatchDiff\";\nimport \"../styles/editor.css\";\n\n// Default Loader component\nconst DefaultLoader = () => <div style={{ padding: \"20px\", textAlign: \"center\", color: \"#888\" }}>Loading Monaco Editor...</div>;\n\nconst ISSUE_ICON = \"⚠\";\n\ninterface ITextModelWithDecorations extends monaco.editor.ITextModel {\n\t_conflictIssueDecorations?: monaco.editor.IEditorDecorationsCollection;\n}\n\nexport function JsonDiffMergeEditor(props: EditorDiffMergeProps) {\n\tconst {\n\t\toriginal = \"\",\n\t\tmodified = \"\",\n\t\tbase = \"\",\n\t\ttheme = \"vs\",\n\t\toptions = {},\n\t\twidth = \"100%\",\n\t\theight = \"100%\",\n\t\tclassName,\n\t\tloading,\n\t\tonMount,\n\t\tonMergeResolve,\n\t\tshowResultColumn = false,\n\t\tbaseIndex = 1,\n\t\tcomparisonMode = \"split\",\n\t\tschema,\n\t\tpatches,\n\t\tlabels,\n\t} = props;\n\n\t// Hardcode language to \"json\" - this component is JSON-only\n\tconst language = \"json\";\n\n\tconst [isEditorReady, setIsEditorReady] = useState(false);\n\tconst [isMonacoMounting, setIsMonacoMounting] = useState(true);\n\tconst [conflicts, setConflicts] = useState<ModifiedBaseRange[]>([]);\n\tconst [_validationError, setValidationError] = useState<string | null>(null);\n\tconst [_validationWarnings, setValidationWarnings] = useState<string[]>([]);\n\tconst [conflictIssues, setConflictIssues] = useState<ConflictIssue[]>([]);\n\tconst [isResultManuallyEdited, setIsResultManuallyEdited] = useState(false);\n\n\t// Function to render native checkbox (simpler and more reliable than React Portal)\n\tconst renderCheckbox = useCallback((state: InputState, _inputNumber: 1 | 2, _conflictId: string, onToggle: () => void) => {\n\t\tconst container = document.createElement(\"div\");\n\t\tcontainer.className = \"native-checkbox-container\";\n\n\t\tconst checkbox = document.createElement(\"input\");\n\t\tcheckbox.type = \"checkbox\";\n\t\tcheckbox.className = \"native-checkbox\";\n\t\tcheckbox.checked = state === InputState.first || state === InputState.second;\n\t\tcheckbox.setAttribute(\"aria-label\", checkbox.checked ? \"Undo accept\" : \"Accept change\");\n\n\t\tcheckbox.addEventListener(\"click\", (e) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\t// Defer the toggle to avoid React setState warning\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tonToggle();\n\t\t\t});\n\t\t});\n\n\t\tcontainer.appendChild(checkbox);\n\t\treturn container;\n\t}, []);\n\n\tconst [_editorKey, setEditorKey] = useState(0);\n\n\tconst input1EditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst baseEditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst input2EditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst resultEditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst monacoRef = useRef<typeof monaco | null>(null);\n\tconst containerRef = useRef<HTMLDivElement | null>(null);\n\tconst preventCreation = useRef(false);\n\tconst isProgrammaticUpdate = useRef(false);\n\n\t// Gutter container refs for checkbox UI\n\tconst input1GutterRef = useRef<HTMLDivElement | null>(null);\n\tconst input2GutterRef = useRef<HTMLDivElement | null>(null);\n\tconst resultGutterRef = useRef<HTMLDivElement | null>(null);\n\tconst gutterViewsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n\tconst resultLabelRef = useRef<HTMLDivElement | null>(null);\n\n\t// Decoration collections for proper updating\n\tconst input1DecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\tconst input2DecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\tconst baseDecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\n\t// Initialize Monaco\n\tuseEffect(() => {\n\t\tlet isMounted = true;\n\t\tconst cancelable = loader.init();\n\n\t\tcancelable\n\t\t\t.then((monacoInstance: typeof monaco) => {\n\t\t\t\tif (!isMounted) return;\n\t\t\t\tmonacoRef.current = monacoInstance;\n\t\t\t\tsetIsMonacoMounting(false);\n\t\t\t\tsetIsEditorReady(true);\n\t\t\t})\n\t\t\t.catch((error: Error) => {\n\t\t\t\tif (!isMounted) return;\n\t\t\t\tif ((error as { type?: string })?.type !== \"cancelation\") {\n\t\t\t\t\tconsole.error(\"Monaco initialization: error:\", error);\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn () => {\n\t\t\tisMounted = false;\n\n\t\t\tif (!preventCreation.current) {\n\t\t\t\tcancelable.cancel();\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Compute diffs using JSON Patch approach (always)\n\tconst computeDiffs = useCallback(\n\t\t(\n\t\t\tbaseModel: monaco.editor.ITextModel | null,\n\t\t\tinput1Model: monaco.editor.ITextModel,\n\t\t\tinput2Model: monaco.editor.ITextModel,\n\t\t): ModifiedBaseRange[] => {\n\t\t\tif (!monacoRef.current) return [];\n\n\t\t\tconst baseText = baseModel?.getValue() || \"\";\n\t\t\tconst input1Text = input1Model.getValue();\n\t\t\tconst input2Text = input2Model.getValue();\n\n\t\t\ttry {\n\t\t\t\tconst startTime = performance.now();\n\t\t\t\tconst ranges = computeDiffsJsonPatch(baseText, input1Text, input2Text, {\n\t\t\t\t\tcomparisonMode,\n\t\t\t\t\tschema,\n\t\t\t\t\tpatches,\n\t\t\t\t});\n\t\t\t\tconst duration = performance.now() - startTime;\n\n\t\t\t\tif (duration > 100) {\n\t\t\t\t\tconsole.warn(`JSON Patch diff took ${duration.toFixed(2)}ms`);\n\t\t\t\t}\n\n\t\t\t\treturn ranges;\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconsole.error(\"JSON Patch diff error:\", message);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\t[comparisonMode, schema, patches],\n\t);\n\n\t// Get the position where decorations start (after line numbers)\n\tconst getDecorationsLeft = useCallback((editor: monaco.editor.IStandaloneCodeEditor): number => {\n\t\ttry {\n\t\t\tconst layoutInfo = editor.getLayoutInfo();\n\t\t\t// decorationsLeft is where the decorations area starts\n\t\t\treturn layoutInfo.decorationsLeft || 0;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}, []);\n\n\t// Get the width of the decorations area\n\tconst getDecorationsWidth = useCallback((editor: monaco.editor.IStandaloneCodeEditor): number => {\n\t\ttry {\n\t\t\tconst layoutInfo = editor.getLayoutInfo();\n\t\t\treturn layoutInfo.decorationsWidth || 0;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}, []);\n\n\t// Render conflict issue markers in result column gutter\n\tconst renderConflictIssueMarkers = useCallback(\n\t\t(issues: ConflictIssue[]) => {\n\t\t\tif (!showResultColumn || !resultEditorRef.current || !resultGutterRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\tif (!monacoInstance) return;\n\n\t\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t\t// Position the gutter container on the right side\n\t\t\tconst decorationsLeft = getDecorationsLeft(resultEditorRef.current);\n\t\t\tconst decorationsWidth = getDecorationsWidth(resultEditorRef.current);\n\n\t\t\tresultGutterRef.current.style.left = `${decorationsLeft}px`;\n\t\t\tresultGutterRef.current.style.width = `${decorationsWidth}px`;\n\n\t\t\tconst scrollTop = resultEditorRef.current.getScrollTop();\n\t\t\tconst model = resultEditorRef.current.getModel();\n\t\t\tif (!model) return;\n\n\t\t\t// Clear existing indicators\n\t\t\tresultGutterRef.current.innerHTML = \"\";\n\n\t\t\t// Render each conflict issue marker\n\t\t\tfor (const issue of issues) {\n\t\t\t\tconst startLine = issue.startLine;\n\t\t\t\tconst endLine = issue.endLine;\n\n\t\t\t\t// Calculate position for this issue\n\t\t\t\tconst topStart = resultEditorRef.current.getTopForLineNumber(startLine) - scrollTop;\n\t\t\t\tconst topEnd = resultEditorRef.current.getTopForLineNumber(endLine) - scrollTop;\n\t\t\t\tconst lineHeight = resultEditorRef.current.getOption(monacoInstance.editor.EditorOption.lineHeight);\n\n\t\t\t\t// For multi-line issues, calculate the full height and center the icon\n\t\t\t\tconst isMultiLine = endLine > startLine;\n\t\t\t\tconst fullHeight = isMultiLine ? topEnd - topStart + lineHeight : lineHeight;\n\n\t\t\t\t// Create marker div\n\t\t\t\tconst markerDiv = document.createElement(\"div\");\n\t\t\t\tmarkerDiv.className = `conflict-issue-marker conflict-issue-${issue.type}`;\n\t\t\t\tmarkerDiv.setAttribute(\"data-conflict-id\", issue.conflictId);\n\t\t\t\tmarkerDiv.setAttribute(\"data-issue-type\", issue.type);\n\t\t\t\tmarkerDiv.title = issue.message;\n\t\t\t\tmarkerDiv.style.position = \"absolute\";\n\t\t\t\tmarkerDiv.style.top = `${Math.max(0, topStart)}px`;\n\t\t\t\tmarkerDiv.style.height = `${fullHeight}px`;\n\t\t\t\tmarkerDiv.style.width = \"26px\";\n\t\t\t\tmarkerDiv.style.display = \"flex\";\n\t\t\t\tmarkerDiv.style.alignItems = \"center\";\n\t\t\t\tmarkerDiv.style.justifyContent = \"center\";\n\t\t\t\tmarkerDiv.style.cursor = \"help\";\n\t\t\t\tmarkerDiv.style.pointerEvents = \"auto\";\n\n\t\t\t\t// Add icon\n\t\t\t\tconst icon = document.createElement(\"div\");\n\t\t\t\ticon.className = \"issue-icon\";\n\t\t\t\tif (issue.type === \"error\") {\n\t\t\t\t\ticon.textContent = \"✗\";\n\t\t\t\t\ticon.style.color = isDark ? \"#ff6666\" : \"#cc0000\";\n\t\t\t\t} else if (issue.type === \"warning\") {\n\t\t\t\t\ticon.textContent = ISSUE_ICON;\n\t\t\t\t\ticon.style.color = isDark ? \"#ffaa00\" : \"#ff8800\";\n\t\t\t\t} else if (issue.type === \"smart-merge\") {\n\t\t\t\t\ticon.textContent = \"↕\";\n\t\t\t\t\ticon.style.color = isDark ? \"#0096ff\" : \"#0078d4\";\n\t\t\t\t}\n\t\t\t\ticon.style.fontSize = \"14px\";\n\t\t\t\ticon.style.fontWeight = \"bold\";\n\t\t\t\tmarkerDiv.appendChild(icon);\n\n\t\t\t\tresultGutterRef.current.appendChild(markerDiv);\n\t\t\t}\n\t\t},\n\t\t[showResultColumn, theme, getDecorationsLeft, getDecorationsWidth],\n\t);\n\n\t// Update result editor based on conflict states using extracted utility\n\tconst updateResultEditor = useCallback(\n\t\t(updatedConflicts: ModifiedBaseRange[]) => {\n\t\t\tif (!resultEditorRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't auto-update if user has manually edited the result\n\t\t\tif (isResultManuallyEdited) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst resultModel = resultEditorRef.current.getModel();\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\n\t\t\tif (!resultModel || !input1Model || !input2Model || !baseModel) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst baseLines = baseModel.getLinesContent();\n\t\t\tconst input1Lines = input1Model.getLinesContent();\n\t\t\tconst input2Lines = input2Model.getLinesContent();\n\n\t\t\t// Use enhanced utility function with validation\n\t\t\tconst result = buildResultContentWithValidation(baseLines, input1Lines, input2Lines, updatedConflicts, schema);\n\n\t\t\t// Update validation state\n\t\t\tsetValidationError(result.isValid ? null : result.validationError || \"Invalid JSON\");\n\t\t\tsetValidationWarnings(result.warnings || []);\n\t\t\tsetConflictIssues(result.conflictIssues || []);\n\n\t\t\t// Update result column header to show validation status\n\t\t\tif (resultLabelRef.current) {\n\t\t\t\tconst baseLabel = labels?.result || \"Result\";\n\t\t\t\tif (!result.isValid) {\n\t\t\t\t\tresultLabelRef.current.textContent = `${baseLabel} ${ISSUE_ICON} Invalid JSON`;\n\t\t\t\t\tresultLabelRef.current.style.color = \"#ff4444\";\n\t\t\t\t\tresultLabelRef.current.title = result.validationError || \"Invalid JSON - please fix manually\";\n\t\t\t\t} else if (result.warnings && result.warnings.length > 0) {\n\t\t\t\t\tresultLabelRef.current.textContent = `${baseLabel} ${ISSUE_ICON}`;\n\t\t\t\t\t// resultLabelRef.current.style.color = \"#ffaa00\";\n\t\t\t\t\tresultLabelRef.current.title = result.warnings.join(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tresultLabelRef.current.textContent = baseLabel;\n\t\t\t\t\tresultLabelRef.current.style.color = \"\";\n\t\t\t\t\tresultLabelRef.current.title = \"\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update result model - preserve cursor position and only update if content changed\n\t\t\tconst currentContent = resultModel.getValue();\n\t\t\tif (currentContent !== result.content) {\n\t\t\t\t// Save cursor position and selection\n\t\t\t\tconst position = resultEditorRef.current.getPosition();\n\t\t\t\tconst selection = resultEditorRef.current.getSelection();\n\n\t\t\t\t// Mark as programmatic update so onChange doesn't set manual edit flag\n\t\t\t\tisProgrammaticUpdate.current = true;\n\n\t\t\t\t// Update content\n\t\t\t\tresultModel.setValue(result.content);\n\n\t\t\t\t// Reset programmatic flag immediately\n\t\t\t\tisProgrammaticUpdate.current = false;\n\n\t\t\t\t// Restore cursor position and selection if still valid\n\t\t\t\tif (position) {\n\t\t\t\t\tconst lineCount = resultModel.getLineCount();\n\t\t\t\t\tconst lastLineLength = resultModel.getLineLength(lineCount);\n\n\t\t\t\t\t// Clamp position to valid range\n\t\t\t\t\tconst validatedPosition = {\n\t\t\t\t\t\tlineNumber: Math.min(position.lineNumber, lineCount),\n\t\t\t\t\t\tcolumn:\n\t\t\t\t\t\t\tposition.lineNumber <= lineCount\n\t\t\t\t\t\t\t\t? Math.min(position.column, resultModel.getLineLength(position.lineNumber) + 1)\n\t\t\t\t\t\t\t\t: lastLineLength + 1,\n\t\t\t\t\t};\n\n\t\t\t\t\tresultEditorRef.current.setPosition(validatedPosition);\n\n\t\t\t\t\t// Restore selection if it was a range\n\t\t\t\t\tif (selection && !selection.isEmpty()) {\n\t\t\t\t\t\tresultEditorRef.current.setSelection(selection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply error highlighting if invalid\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\t// Monaco model doesn't have _invalidDecorations in types, but we use it for cleanup\n\t\t\tconst modelWithDecorations = resultModel as monaco.editor.ITextModel & {\n\t\t\t\t_invalidDecorations?: monaco.editor.IEditorDecorationsCollection;\n\t\t\t};\n\t\t\tlet invalidDecorations = modelWithDecorations._invalidDecorations;\n\n\t\t\tif (!result.isValid && resultEditorRef.current && monacoInstance) {\n\t\t\t\tif (!invalidDecorations) {\n\t\t\t\t\tinvalidDecorations = resultEditorRef.current.createDecorationsCollection([]);\n\t\t\t\t\tmodelWithDecorations._invalidDecorations = invalidDecorations;\n\t\t\t\t}\n\t\t\t\tinvalidDecorations.set([\n\t\t\t\t\t{\n\t\t\t\t\t\trange: new monacoInstance.Range(1, 1, resultModel.getLineCount(), Number.MAX_SAFE_INTEGER),\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tisWholeLine: false,\n\t\t\t\t\t\t\tclassName: \"merge-result-invalid\",\n\t\t\t\t\t\t\thoverMessage: { value: result.validationError || \"Invalid JSON - please fix manually\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t} else if (result.isValid && invalidDecorations && resultEditorRef.current) {\n\t\t\t\t// Clear error decorations if valid\n\t\t\t\tinvalidDecorations.set([]);\n\t\t\t}\n\n\t\t\t// Render conflict issue markers in result column gutter and highlight lines\n\t\t\tif (result.conflictIssues && result.conflictIssues.length > 0) {\n\t\t\t\trenderConflictIssueMarkers(result.conflictIssues);\n\n\t\t\t\t// Apply line decorations for conflict issues\n\t\t\t\tif (resultEditorRef.current && monacoInstance) {\n\t\t\t\t\tconst modelWithDecorations = resultModel as ITextModelWithDecorations;\n\t\t\t\t\tif (!modelWithDecorations._conflictIssueDecorations) {\n\t\t\t\t\t\tconst collection: monaco.editor.IEditorDecorationsCollection = resultEditorRef.current.createDecorationsCollection(\n\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tmodelWithDecorations._conflictIssueDecorations = collection;\n\t\t\t\t\t}\n\t\t\t\t\tconst conflictIssueDecorations = modelWithDecorations._conflictIssueDecorations;\n\t\t\t\t\tconst conflictDecorations: monaco.editor.IModelDeltaDecoration[] = result.conflictIssues.map((issue) => {\n\t\t\t\t\t\tlet backgroundColor: string;\n\t\t\t\t\t\tlet borderColor: string;\n\n\t\t\t\t\t\tif (issue.type === \"error\") {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(255, 0, 0, 0.1)\" : \"rgba(255, 0, 0, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#ff6666\" : \"#cc0000\";\n\t\t\t\t\t\t} else if (issue.type === \"warning\") {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(255, 170, 0, 0.1)\" : \"rgba(255, 136, 0, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#ffaa00\" : \"#ff8800\";\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(0, 150, 255, 0.1)\" : \"rgba(0, 120, 212, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#0096ff\" : \"#0078d4\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\trange: new monacoInstance.Range(issue.startLine, 1, issue.endLine, Number.MAX_SAFE_INTEGER),\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\t\t\t\tclassName: `conflict-issue-line conflict-issue-${issue.type}`,\n\t\t\t\t\t\t\t\tlinesDecorationsClassName: `conflict-issue-line-decoration conflict-issue-${issue.type}`,\n\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\toverviewRuler: {\n\t\t\t\t\t\t\t\t\tcolor: borderColor,\n\t\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Right,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tminimap: {\n\t\t\t\t\t\t\t\t\tcolor: borderColor,\n\t\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\tconflictIssueDecorations.set(conflictDecorations);\n\t\t\t\t}\n\t\t\t} else if (resultEditorRef.current) {\n\t\t\t\t// Clear conflict issue decorations if there are none\n\t\t\t\tconst modelWithDecorations = resultModel as ITextModelWithDecorations;\n\t\t\t\tif (modelWithDecorations._conflictIssueDecorations) {\n\t\t\t\t\tmodelWithDecorations._conflictIssueDecorations.set([]);\n\t\t\t\t}\n\t\t\t\t// Also clear the gutter markers\n\t\t\t\tif (resultGutterRef.current && showResultColumn) {\n\t\t\t\t\tresultGutterRef.current.innerHTML = \"\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Callback with resolved content and resolution info (even if invalid, so parent can handle)\n\t\t\t// Defer the callback to avoid React setState warning (updating parent component during render)\n\t\t\tif (onMergeResolve) {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tonMergeResolve(result.content, {\n\t\t\t\t\t\tisValid: result.isValid,\n\t\t\t\t\t\tvalidationError: result.validationError,\n\t\t\t\t\t\twarnings: result.warnings,\n\t\t\t\t\t\tconflictIssues: result.conflictIssues,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[onMergeResolve, schema, labels, theme, renderConflictIssueMarkers, showResultColumn, isResultManuallyEdited],\n\t);\n\n\t// Toggle input state (like VSCode's checkbox toggle)\n\tconst toggleInputState = useCallback(\n\t\t(conflictId: string, inputNumber: 1 | 2) => {\n\t\t\t// Reset manual edit flag when user clicks checkbox (they want auto-calculation)\n\t\t\tsetIsResultManuallyEdited(false);\n\n\t\t\tsetConflicts((prevConflicts) => {\n\t\t\t\tconst updatedConflicts = prevConflicts.map((conflict) => {\n\t\t\t\t\tif (conflict.id !== conflictId) return conflict;\n\n\t\t\t\t\tconst currentState = inputNumber === 1 ? conflict.input1State : conflict.input2State;\n\t\t\t\t\tconst newState = currentState === InputState.excluded ? InputState.first : InputState.excluded;\n\n\t\t\t\t\t// Update the appropriate state\n\t\t\t\t\tif (inputNumber === 1) {\n\t\t\t\t\t\treturn { ...conflict, input1State: newState };\n\t\t\t\t\t}\n\t\t\t\t\treturn { ...conflict, input2State: newState };\n\t\t\t\t});\n\n\t\t\t\t// Update result editor if enabled\n\t\t\t\tif (showResultColumn && resultEditorRef.current) {\n\t\t\t\t\tupdateResultEditor(updatedConflicts);\n\t\t\t\t}\n\n\t\t\t\treturn updatedConflicts;\n\t\t\t});\n\t\t},\n\t\t[showResultColumn, updateResultEditor],\n\t);\n\n\t// Render individual checkbox gutter item\n\tconst renderCheckboxGutterItem = useCallback(\n\t\t(\n\t\t\tgutterContainer: HTMLDivElement,\n\t\t\tkey: string,\n\t\t\tconflict: ModifiedBaseRange,\n\t\t\tinputNumber: 1 | 2,\n\t\t\tscrollTop: number,\n\t\t\tviewHeight: number,\n\t\t\t_isDark: boolean,\n\t\t) => {\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\tif (!monacoInstance) return;\n\n\t\t\tconst editor = inputNumber === 1 ? input1EditorRef.current : input2EditorRef.current;\n\t\t\tif (!editor) return;\n\n\t\t\tconst range = inputNumber === 1 ? conflict.input1Range : conflict.input2Range;\n\t\t\tconst state = inputNumber === 1 ? conflict.input1State : conflict.input2State;\n\n\t\t\t// Validate range before calculating position\n\t\t\tconst model = editor.getModel();\n\t\t\tif (!model) return;\n\n\t\t\tconst lineCount = model.getLineCount();\n\t\t\tconst startLine = Math.max(1, Math.min(range.startLineNumber, lineCount));\n\t\t\tconst endLine = Math.max(1, Math.min(range.endLineNumberExclusive - 1, lineCount));\n\n\t\t\t// Skip if range is invalid\n\t\t\tif (startLine > lineCount || endLine < 1 || startLine > endLine) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Calculate position\n\t\t\tconst top = editor.getTopForLineNumber(startLine) - scrollTop;\n\t\t\tconst bottom = editor.getBottomForLineNumber(endLine) - scrollTop;\n\t\t\tconst height = bottom - top;\n\n\t\t\t// Get or create view\n\t\t\tlet viewDiv = gutterViewsRef.current.get(key);\n\t\t\tif (!viewDiv) {\n\t\t\t\tviewDiv = document.createElement(\"div\");\n\t\t\t\tviewDiv.className = \"merge-accept-gutter-marker\";\n\n\t\t\t\t// Create background\n\t\t\t\tconst background = document.createElement(\"div\");\n\t\t\t\tbackground.className = \"background\";\n\t\t\t\tviewDiv.appendChild(background);\n\n\t\t\t\t// Create checkbox container\n\t\t\t\tconst checkboxDiv = document.createElement(\"div\");\n\t\t\t\tcheckboxDiv.className = \"checkbox\";\n\n\t\t\t\t// Create checkbox background\n\t\t\t\tconst checkboxBg = document.createElement(\"div\");\n\t\t\t\tcheckboxBg.className = \"checkbox-background\";\n\n\t\t\t\t// Use the checkbox renderer\n\t\t\t\tconst checkboxBtn = renderCheckbox(state, inputNumber, conflict.id, () => toggleInputState(conflict.id, inputNumber));\n\n\t\t\t\tcheckboxBg.appendChild(checkboxBtn);\n\t\t\t\tcheckboxDiv.appendChild(checkboxBg);\n\t\t\t\tviewDiv.appendChild(checkboxDiv);\n\n\t\t\t\tgutterContainer.appendChild(viewDiv);\n\t\t\t\tgutterViewsRef.current.set(key, viewDiv);\n\t\t\t}\n\n\t\t\t// Update position\n\t\t\tviewDiv.style.top = `${top}px`;\n\t\t\tviewDiv.style.height = `${height}px`;\n\n\t\t\t// Update checkbox visual state by replacing with new renderer output\n\t\t\tconst checkboxBg = viewDiv.querySelector(\".checkbox-background\");\n\t\t\tif (checkboxBg) {\n\t\t\t\t// Clear existing checkbox\n\t\t\t\tcheckboxBg.innerHTML = \"\";\n\n\t\t\t\t// Create new checkbox with current state using the renderer\n\t\t\t\tconst newCheckboxBtn = renderCheckbox(state, inputNumber, conflict.id, () => toggleInputState(conflict.id, inputNumber));\n\n\t\t\t\tcheckboxBg.appendChild(newCheckboxBtn);\n\t\t\t}\n\n\t\t\t// Update classes based on state\n\t\t\tconst isHandled = conflict.handled;\n\t\t\tconst isFocused = conflict.focused;\n\t\t\tconst isMultiLine = height > 30;\n\n\t\t\tviewDiv.className = \"merge-accept-gutter-marker\";\n\t\t\tif (isHandled) viewDiv.classList.add(\"handled\");\n\t\t\tif (isFocused) viewDiv.classList.add(\"focused\");\n\t\t\tif (isMultiLine) viewDiv.classList.add(\"multi-line\");\n\t\t\telse viewDiv.classList.add(\"single-line\");\n\n\t\t\t// Position checkbox vertically (smart centering like VSCode)\n\t\t\tconst checkboxDiv = viewDiv.querySelector(\".checkbox\") as HTMLDivElement;\n\t\t\tif (checkboxDiv) {\n\t\t\t\tconst checkboxHeight = 24; // Fixed checkbox height\n\t\t\t\tconst middleHeight = height / 2 - checkboxHeight / 2;\n\t\t\t\tconst margin = checkboxHeight;\n\n\t\t\t\tlet effectiveCheckboxTop = middleHeight;\n\n\t\t\t\t// Preferred viewport range\n\t\t\t\tconst preferredViewPortMin = margin;\n\t\t\t\tconst preferredViewPortMax = viewHeight - margin - checkboxHeight;\n\n\t\t\t\t// Preferred parent range\n\t\t\t\tconst preferredParentMin = margin;\n\t\t\t\tconst preferredParentMax = height - checkboxHeight - margin;\n\n\t\t\t\tif (preferredParentMin < preferredParentMax) {\n\t\t\t\t\t// Clamp to viewport\n\t\t\t\t\teffectiveCheckboxTop = Math.max(preferredViewPortMin, Math.min(effectiveCheckboxTop + top, preferredViewPortMax)) - top;\n\t\t\t\t\t// Clamp to parent\n\t\t\t\t\teffectiveCheckboxTop = Math.max(preferredParentMin, Math.min(effectiveCheckboxTop, preferredParentMax));\n\t\t\t\t}\n\n\t\t\t\tcheckboxDiv.style.top = `${effectiveCheckboxTop + 5}px`;\n\t\t\t}\n\t\t},\n\t\t[toggleInputState, renderCheckbox],\n\t);\n\n\t// Render checkbox gutters\n\tconst renderCheckboxGutters = useCallback(() => {\n\t\t// Only render checkboxes when result column is visible\n\t\tif (!showResultColumn) {\n\t\t\t// Clear any existing checkboxes\n\t\t\tconst allViews = gutterViewsRef.current;\n\t\t\tfor (const [key, view] of allViews.entries()) {\n\t\t\t\tview.remove();\n\t\t\t\tallViews.delete(key);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!input1EditorRef.current || !input2EditorRef.current || !input1GutterRef.current || !input2GutterRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst monacoInstance = monacoRef.current;\n\n\t\tif (!monacoInstance) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t// Position the gutter containers in Monaco's decorations area\n\t\tconst decorationsLeft1 = getDecorationsLeft(input1EditorRef.current);\n\t\tconst decorationsWidth1 = getDecorationsWidth(input1EditorRef.current);\n\t\tconst decorationsLeft2 = getDecorationsLeft(input2EditorRef.current);\n\t\tconst decorationsWidth2 = getDecorationsWidth(input2EditorRef.current);\n\n\t\t// Position gutters in the decorations area\n\t\tinput1GutterRef.current.style.left = `${decorationsLeft1}px`;\n\t\tinput1GutterRef.current.style.width = `${decorationsWidth1}px`;\n\t\tinput2GutterRef.current.style.left = `${decorationsLeft2}px`;\n\t\tinput2GutterRef.current.style.width = `${decorationsWidth2}px`;\n\n\t\t// Get visible ranges\n\t\tconst visibleRanges = input1EditorRef.current.getVisibleRanges();\n\t\tif (!visibleRanges || visibleRanges.length === 0) return;\n\n\t\tconst scrollTop = input1EditorRef.current.getScrollTop();\n\t\tconst viewHeight = input1GutterRef.current.clientHeight;\n\n\t\t// Track which views we need to keep\n\t\tconst viewsToKeep = new Set<string>();\n\n\t\t// Render checkbox for each conflict\n\t\tfor (const conflict of conflicts) {\n\t\t\tif (conflict.input1Diffs.length === 0 && conflict.input2Diffs.length === 0) continue;\n\n\t\t\t// Render input1 checkbox\n\t\t\tif (conflict.input1Diffs.length > 0) {\n\t\t\t\tconst key = `${conflict.id}-input1`;\n\t\t\t\tviewsToKeep.add(key);\n\t\t\t\trenderCheckboxGutterItem(input1GutterRef.current, key, conflict, 1, scrollTop, viewHeight, isDark);\n\t\t\t}\n\n\t\t\t// Render input2 checkbox\n\t\t\tif (conflict.input2Diffs.length > 0) {\n\t\t\t\tconst key = `${conflict.id}-input2`;\n\t\t\t\tviewsToKeep.add(key);\n\t\t\t\trenderCheckboxGutterItem(input2GutterRef.current, key, conflict, 2, scrollTop, viewHeight, isDark);\n\t\t\t}\n\t\t}\n\n\t\t// Remove unused views\n\t\tconst allViews = gutterViewsRef.current;\n\t\tfor (const [key, view] of allViews.entries()) {\n\t\t\tif (!viewsToKeep.has(key)) {\n\t\t\t\tview.remove();\n\t\t\t\tallViews.delete(key);\n\t\t\t}\n\t\t}\n\t}, [conflicts, theme, showResultColumn, getDecorationsLeft, getDecorationsWidth, renderCheckboxGutterItem]);\n\n\t// Get theme color from Monaco's color registry\n\tconst getThemeColor = useCallback((colorKey: string, fallback: string): string => {\n\t\ttry {\n\t\t\t// Try to get from Monaco's theme definition\n\t\t\tif (monacoRef.current) {\n\t\t\t\tconst currentTheme = (monacoRef.current.editor as { getTheme?: () => { colors?: Record<string, string> } }).getTheme?.();\n\t\t\t\tif (currentTheme?.colors?.[colorKey]) {\n\t\t\t\t\treturn currentTheme.colors[colorKey];\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (_e) {\n\t\t\t// Fall through to default\n\t\t}\n\t\treturn fallback;\n\t}, []);\n\n\t// Apply decorations using Monaco theme colors\n\tconst applyDecorations = useCallback(() => {\n\t\tif (!monacoRef.current || !input1EditorRef.current || !input2EditorRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst monacoInstance = monacoRef.current;\n\n\t\t// Detect if theme is dark or light\n\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t// Use Monaco's merge editor theme colors\n\t\tconst conflictColor = getThemeColor(\"mergeEditor.change.background\", isDark ? \"rgba(255, 166, 0, 0.2)\" : \"rgba(255, 166, 0, 0.15)\");\n\n\t\tconst changeColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.2)\" : \"rgba(155, 185, 85, 0.15)\",\n\t\t);\n\n\t\tconst baseColor = getThemeColor(\n\t\t\t\"mergeEditor.changeBase.background\",\n\t\t\tisDark ? \"rgba(255, 100, 100, 0.2)\" : \"rgba(255, 100, 100, 0.15)\",\n\t\t);\n\n\t\t// Overview ruler colors - use theme colors with more opacity\n\t\tconst conflictOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.modifiedForeground\",\n\t\t\tisDark ? \"rgba(255, 166, 0, 0.8)\" : \"rgba(255, 166, 0, 1)\",\n\t\t);\n\t\tconst changeOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.addedForeground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.8)\" : \"rgba(155, 185, 85, 1)\",\n\t\t);\n\t\tconst baseOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.deletedForeground\",\n\t\t\tisDark ? \"rgba(255, 100, 100, 0.8)\" : \"rgba(255, 100, 100, 1)\",\n\t\t);\n\n\t\t// Check if we're in 2-column mode (no base)\n\t\tconst isTwoColumnMode = !baseEditorRef.current;\n\n\t\t// Create decoration configuration\n\t\tconst decorationConfig: DecorationConfig = {\n\t\t\tconflictColor,\n\t\t\tchangeColor,\n\t\t\tbaseColor,\n\t\t\tconflictOverviewColor,\n\t\t\tchangeOverviewColor,\n\t\t\tbaseOverviewColor,\n\t\t};\n\n\t\t// Create all decorations using the extracted utility functions\n\t\tconst { input1Decorations, input2Decorations, baseDecorations } = createAllDecorations(\n\t\t\tconflicts,\n\t\t\tisTwoColumnMode,\n\t\t\tdecorationConfig,\n\t\t\tmonacoInstance,\n\t\t);\n\n\t\t// Get theme colors for checkbox UI\n\t\tconst checkboxBgColor = getThemeColor(\"input.background\", isDark ? \"#3c3c3c\" : \"#f3f3f3\");\n\t\tconst checkboxBorderColor = getThemeColor(\"input.border\", isDark ? \"#6b6b6b\" : \"#c8c8c8\");\n\t\tconst checkboxFocusBorderColor = getThemeColor(\"focusBorder\", isDark ? \"#007acc\" : \"#0078d4\");\n\t\tconst checkboxCheckedColor = getThemeColor(\"inputOption.activeForeground\", isDark ? \"#3794ff\" : \"#0078d4\");\n\n\t\t// Inject CSS using theme colors\n\t\tconst styleId = \"monaco-three-way-diff-dynamic\";\n\t\tlet styleEl = document.getElementById(styleId) as HTMLStyleElement;\n\t\tif (!styleEl) {\n\t\t\tstyleEl = document.createElement(\"style\");\n\t\t\tstyleEl.id = styleId;\n\t\t\tdocument.head.appendChild(styleEl);\n\t\t}\n\n\t\t// Compute colors for different conflict types\n\t\tconst sameChangeColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(100, 100, 255, 0.15)\" : \"rgba(100, 100, 255, 0.1)\",\n\t\t);\n\n\t\t// INPUT1_ONLY means theirs added something (incoming addition that's accepted)\n\t\t// Should be green (addition color), same as input2Only\n\t\tconst input1OnlyColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.2)\" : \"rgba(155, 185, 85, 0.15)\",\n\t\t);\n\n\t\tstyleEl.textContent = `\n /* True conflict - both sides changed differently (orange/amber) */\n .monaco-editor .merge-conflict-incoming,\n .monaco-editor .merge-conflict-current {\n background-color: ${conflictColor};\n }\n\n /* Single-side change (green for input2/ours, orange for input1/theirs in 3-way) */\n .monaco-editor .merge-change-incoming {\n background-color: ${input1OnlyColor};\n }\n .monaco-editor .merge-change-current {\n background-color: ${changeColor};\n }\n\n /* 2-way diff mode: red for deletions (input1 column) */\n .monaco-editor .merge-2way-deletion {\n background-color: ${baseColor};\n }\n\n /* Same change on both sides (blue/purple) */\n .monaco-editor .merge-same-change {\n background-color: ${sameChangeColor};\n }\n\n /* Base changes */\n .monaco-editor .merge-conflict-base,\n .monaco-editor .merge-change-base {\n background-color: ${baseColor};\n }\n\n /* Invalid JSON in result column */\n .monaco-editor .merge-result-invalid {\n background-color: ${isDark ? \"rgba(255, 0, 0, 0.2)\" : \"rgba(255, 0, 0, 0.1)\"};\n outline: 1px solid ${isDark ? \"rgba(255, 100, 100, 0.5)\" : \"rgba(255, 0, 0, 0.3)\"};\n }\n\n /* VSCode-style checkbox gutter - positioned at Monaco's glyph margin */\n .merge-editor-gutter {\n position: absolute;\n height: 100%;\n top: 0;\n z-index: 10;\n pointer-events: none;\n overflow: visible;\n }\n\n .merge-accept-gutter-marker {\n position: absolute;\n pointer-events: all;\n }\n\n .merge-accept-gutter-marker .background {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n pointer-events: none;\n }\n\n .merge-accept-gutter-marker .checkbox {\n position: absolute;\n width: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n left: 6px;\n }\n\n .merge-accept-gutter-marker .checkbox-background {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 3px;\n background-color: ${checkboxBgColor};\n border: 1px solid ${checkboxBorderColor};\n }\n\n .merge-accept-gutter-marker.focused .checkbox-background {\n border-color: ${checkboxFocusBorderColor};\n border-width: 2px;\n }\n\n .merge-accept-gutter-marker.handled .checkbox-background {\n opacity: 0.6;\n }\n\n /* Native checkbox styles */\n .native-checkbox-container {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n cursor: pointer;\n }\n\n .native-checkbox {\n width: 16px;\n height: 16px;\n cursor: pointer;\n margin: 0;\n accent-color: ${checkboxCheckedColor};\n }\n\n /* Result column status indicator */\n .merge-result-status-indicator {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding-left: 4px;\n cursor: help;\n user-select: none;\n z-index: 10;\n }\n\n .merge-result-status-indicator .status-icon {\n font-weight: bold;\n line-height: 1;\n }\n\n .native-checkbox:hover {\n opacity: 0.8;\n }\n\n .native-checkbox:focus {\n outline: 2px solid ${checkboxFocusBorderColor};\n outline-offset: 2px;\n }\n `;\n\t\t// Apply decorations, replacing old ones\n\t\tif (!input1DecorationsRef.current) {\n\t\t\tinput1DecorationsRef.current = input1EditorRef.current.createDecorationsCollection([]);\n\t\t}\n\t\tinput1DecorationsRef.current.set(input1Decorations);\n\n\t\tif (!input2DecorationsRef.current) {\n\t\t\tinput2DecorationsRef.current = input2EditorRef.current.createDecorationsCollection([]);\n\t\t}\n\t\tinput2DecorationsRef.current.set(input2Decorations);\n\n\t\t// Only apply base decorations if base editor exists (3-column mode)\n\t\tif (baseEditorRef.current) {\n\t\t\tif (!baseDecorationsRef.current) {\n\t\t\t\tbaseDecorationsRef.current = baseEditorRef.current.createDecorationsCollection([]);\n\t\t\t}\n\t\t\tbaseDecorationsRef.current.set(baseDecorations);\n\t\t}\n\t}, [conflicts, theme, getThemeColor]);\n\n\tconst createEditor = useCallback(() => {\n\t\tif (!preventCreation.current && containerRef.current && monacoRef.current && !isMonacoMounting) {\n\t\t\tconst monacoInstance = monacoRef.current;\n\n\t\t\t// Clear container\n\t\t\tcontainerRef.current.innerHTML = \"\";\n\n\t\t\t// Create layout\n\t\t\tconst wrapper = document.createElement(\"div\");\n\t\t\twrapper.style.display = \"flex\";\n\t\t\twrapper.style.height = \"100%\";\n\t\t\twrapper.style.width = \"100%\";\n\n\t\t\t// Detect theme colors\n\t\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\t\t\tconst borderColor = isDark ? \"#444\" : \"#ddd\";\n\t\t\tconst foregroundColor = isDark ? \"#fff\" : \"#333\";\n\n\t\t\t// Helper to get theme colors (same as getThemeColor but local to createEditor)\n\t\t\tconst getThemeColorLocal = (colorKey: string, fallback: string): string => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentTheme = (monacoInstance.editor as { getTheme?: () => { colors?: Record<string, string> } }).getTheme?.();\n\t\t\t\t\tif (currentTheme?.colors?.[colorKey]) {\n\t\t\t\t\t\treturn currentTheme.colors[colorKey];\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {\n\t\t\t\t\t// Fall through to default\n\t\t\t\t}\n\t\t\t\treturn fallback;\n\t\t\t};\n\n\t\t\t// Get theme colors for column headers\n\t\t\tconst input1HeaderBg = getThemeColorLocal(\"mergeEditor.conflict.input1.header.background\", isDark ? \"#4B1818\" : \"#FFE6E6\");\n\t\t\tconst baseHeaderBg = getThemeColorLocal(\"editorGutter.background\", isDark ? \"#333\" : \"#f0f0f0\");\n\t\t\tconst input2HeaderBg = getThemeColorLocal(\"mergeEditor.conflict.input2.header.background\", isDark ? \"#1B4B18\" : \"#E6FFE6\");\n\t\t\tconst resultHeaderBg = getThemeColorLocal(\"mergeEditor.result.header.background\", isDark ? \"#7F5F00\" : \"#FFECB3\");\n\n\t\t\t// Create editor containers\n\t\t\tconst createEditorContainer = (label: string, color: string, withGutter = false) => {\n\t\t\t\tconst container = document.createElement(\"div\");\n\t\t\t\tcontainer.style.flex = \"1\";\n\t\t\t\tcontainer.style.display = \"flex\";\n\t\t\t\tcontainer.style.flexDirection = \"column\";\n\t\t\t\tcontainer.style.borderRight = `1px solid ${borderColor}`;\n\n\t\t\t\tconst labelDiv = document.createElement(\"div\");\n\t\t\t\tlabelDiv.textContent = label;\n\t\t\t\tlabelDiv.style.padding = \"4px 8px\";\n\t\t\t\tlabelDiv.style.fontSize = \"11px\";\n\t\t\t\tlabelDiv.style.fontWeight = \"500\";\n\t\t\t\tlabelDiv.style.backgroundColor = color;\n\t\t\t\tlabelDiv.style.color = foregroundColor;\n\t\t\t\tlabelDiv.style.borderBottom = `1px solid ${borderColor}`;\n\t\t\t\tcontainer.appendChild(labelDiv);\n\n\t\t\t\tconst editorWrapper = document.createElement(\"div\");\n\t\t\t\teditorWrapper.style.flex = \"1\";\n\t\t\t\teditorWrapper.style.position = \"relative\";\n\t\t\t\teditorWrapper.style.overflow = `hidden`;\n\n\t\t\t\tconst editorDiv = document.createElement(\"div\");\n\t\t\t\teditorDiv.style.position = \"absolute\";\n\t\t\t\teditorDiv.style.left = \"0\";\n\t\t\t\teditorDiv.style.right = \"0\";\n\t\t\t\teditorDiv.style.top = \"0\";\n\t\t\t\teditorDiv.style.bottom = \"0\";\n\t\t\t\teditorWrapper.appendChild(editorDiv);\n\n\t\t\t\tlet gutterDiv: HTMLDivElement | null = null;\n\t\t\t\tif (withGutter) {\n\t\t\t\t\tgutterDiv = document.createElement(\"div\");\n\t\t\t\t\tgutterDiv.className = \"merge-editor-gutter\";\n\t\t\t\t\teditorWrapper.appendChild(gutterDiv);\n\t\t\t\t}\n\n\t\t\t\tcontainer.appendChild(editorWrapper);\n\n\t\t\t\treturn { container, editorDiv, gutterDiv };\n\t\t\t};\n\n\t\t\tconst input1 = createEditorContainer(labels?.input1 || \"Theirs\", input1HeaderBg, showResultColumn);\n\t\t\tconst input2 = createEditorContainer(labels?.input2 || \"Ours\", input2HeaderBg, showResultColumn);\n\n\t\t\t// Save gutter refs\n\t\t\tif (input1.gutterDiv) input1GutterRef.current = input1.gutterDiv;\n\t\t\tif (input2.gutterDiv) input2GutterRef.current = input2.gutterDiv;\n\n\t\t\t// 2-column mode (no base) vs 3-column mode (with base)\n\t\t\tconst hasBase = Boolean(base);\n\t\t\tlet baseC: ReturnType<typeof createEditorContainer> | null = null;\n\n\t\t\tif (hasBase) {\n\t\t\t\t// 3-column mode: create base column\n\t\t\t\tbaseC = createEditorContainer(labels?.base || \"Base\", baseHeaderBg, false);\n\n\t\t\t\t// Arrange columns based on baseIndex\n\t\t\t\tconst orderedColumns: HTMLDivElement[] = [];\n\n\t\t\t\tif (baseIndex === 0) {\n\t\t\t\t\t// Base on left: [base, input1, input2]\n\t\t\t\t\torderedColumns.push(baseC.container, input1.container, input2.container);\n\t\t\t\t} else if (baseIndex === 1) {\n\t\t\t\t\t// Base in middle: [input1, base, input2] (default)\n\t\t\t\t\torderedColumns.push(input1.container, baseC.container, input2.container);\n\t\t\t\t} else if (baseIndex === 2) {\n\t\t\t\t\t// Base on right: [input1, input2, base]\n\t\t\t\t\torderedColumns.push(input1.container, input2.container, baseC.container);\n\t\t\t\t}\n\n\t\t\t\torderedColumns.forEach((col) => {\n\t\t\t\t\twrapper.appendChild(col);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// 2-column mode: only input1 and input2\n\t\t\t\twrapper.appendChild(input1.container);\n\t\t\t\twrapper.appendChild(input2.container);\n\t\t\t}\n\n\t\t\t// Create result column if enabled\n\t\t\tlet resultC: { container: HTMLDivElement; editorDiv: HTMLDivElement; gutterDiv: HTMLDivElement | null } | null = null;\n\t\t\tif (showResultColumn) {\n\t\t\t\tresultC = createEditorContainer(labels?.result || \"Result\", resultHeaderBg, true); // Enable gutter for error indicators\n\t\t\t\t// Store reference to result label for validation error indicators\n\t\t\t\tresultLabelRef.current = resultC.container.querySelector(\"div\") as HTMLDivElement;\n\t\t\t\t// Store reference to result gutter for error/warning indicators\n\t\t\t\tif (resultC.gutterDiv) resultGutterRef.current = resultC.gutterDiv;\n\t\t\t\twrapper.appendChild(resultC.container);\n\t\t\t}\n\n\t\t\tcontainerRef.current.appendChild(wrapper);\n\n\t\t\t// Create models\n\t\t\tconst input1Model = monacoInstance.editor.createModel(original || \"\", language);\n\t\t\tconst baseModel = hasBase ? monacoInstance.editor.createModel(base || \"\", language) : null;\n\t\t\tconst input2Model = monacoInstance.editor.createModel(modified || \"\", language);\n\n\t\t\t// Create editors\n\t\t\tinput1EditorRef.current = monacoInstance.editor.create(input1.editorDiv, {\n\t\t\t\tmodel: input1Model,\n\t\t\t\treadOnly: true,\n\t\t\t\tautomaticLayout: true,\n\t\t\t\tfolding: !showResultColumn,\n\t\t\t\tglyphMargin: false,\n\t\t\t\t...options,\n\t\t\t\tlineDecorationsWidth: showResultColumn ? 26 : 10,\n\t\t\t});\n\n\t\t\t// Only create base editor if base exists\n\t\t\tif (hasBase && baseC) {\n\t\t\t\tbaseEditorRef.current = monacoInstance.editor.create(baseC.editorDiv, {\n\t\t\t\t\tmodel: baseModel,\n\t\t\t\t\treadOnly: true,\n\t\t\t\t\tautomaticLayout: true,\n\t\t\t\t\tfolding: !showResultColumn,\n\t\t\t\t\tglyphMargin: false,\n\t\t\t\t\t...options,\n\t\t\t\t\tlineDecorationsWidth: 10,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tinput2EditorRef.current = monacoInstance.editor.create(input2.editorDiv, {\n\t\t\t\tmodel: input2Model,\n\t\t\t\treadOnly: true,\n\t\t\t\tautomaticLayout: true,\n\t\t\t\tfolding: !showResultColumn,\n\t\t\t\tglyphMargin: false,\n\t\t\t\t...options,\n\t\t\t\tlineDecorationsWidth: showResultColumn ? 26 : 10,\n\t\t\t});\n\n\t\t\t// Create result editor if enabled\n\t\t\tif (showResultColumn && resultC) {\n\t\t\t\t// Initialize result with \"ours\" (modified/input2) content\n\t\t\t\tconst resultModel = monacoInstance.editor.createModel(modified || \"\", language);\n\t\t\t\tresultEditorRef.current = monacoInstance.editor.create(resultC.editorDiv, {\n\t\t\t\t\tmodel: resultModel,\n\t\t\t\t\tautomaticLayout: true,\n\t\t\t\t\tfolding: !showResultColumn,\n\t\t\t\t\tglyphMargin: false,\n\t\t\t\t\t...options,\n\t\t\t\t\treadOnly: false,\n\t\t\t\t\tlineDecorationsWidth: 26,\n\t\t\t\t});\n\n\t\t\t\t// Add onChange listener to detect manual edits\n\t\t\t\tresultModel.onDidChangeContent(() => {\n\t\t\t\t\t// Only mark as manually edited if this wasn't a programmatic update\n\t\t\t\t\tif (!isProgrammaticUpdate.current) {\n\t\t\t\t\t\tsetIsResultManuallyEdited(true);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Set theme\n\t\t\tmonacoInstance.editor.setTheme(theme);\n\n\t\t\t// Compute conflicts\n\t\t\tconst detectedConflicts = computeDiffs(baseModel, input1Model, input2Model);\n\t\t\tsetConflicts(detectedConflicts);\n\n\t\t\tpreventCreation.current = true;\n\n\t\t\t// Call onMount\n\t\t\tif (onMount && input1EditorRef.current) {\n\t\t\t\tonMount(input1EditorRef.current as unknown as monaco.editor.IStandaloneDiffEditor, monacoInstance);\n\t\t\t}\n\t\t}\n\t}, [options, theme, original, modified, base, showResultColumn, baseIndex, isMonacoMounting, computeDiffs, onMount, labels]);\n\n\t// Detect showResultColumn, baseIndex, comparisonMode, or base changes and trigger recreation\n\tconst prevShowResultRef = useRef(showResultColumn);\n\tconst prevBaseIndexRef = useRef(baseIndex);\n\tconst prevComparisonModeRef = useRef(comparisonMode);\n\tconst prevBaseRef = useRef(base);\n\tuseEffect(() => {\n\t\tconst showResultChanged = prevShowResultRef.current !== showResultColumn;\n\t\tconst baseIndexChanged = prevBaseIndexRef.current !== baseIndex;\n\t\tconst comparisonModeChanged = prevComparisonModeRef.current !== comparisonMode;\n\t\tconst baseChanged = prevBaseRef.current !== base;\n\n\t\tif ((showResultChanged || baseIndexChanged || comparisonModeChanged || baseChanged) && preventCreation.current) {\n\t\t\tprevShowResultRef.current = showResultColumn;\n\t\t\tprevBaseIndexRef.current = baseIndex;\n\t\t\tprevComparisonModeRef.current = comparisonMode;\n\t\t\tprevBaseRef.current = base;\n\n\t\t\t// Clear gutter views\n\t\t\tgutterViewsRef.current.forEach((view) => {\n\t\t\t\tview.remove();\n\t\t\t});\n\t\t\tgutterViewsRef.current.clear();\n\n\t\t\t// Clear decoration collections before disposing\n\t\t\tinput1DecorationsRef.current?.set([]);\n\t\t\tinput2DecorationsRef.current?.set([]);\n\t\t\tbaseDecorationsRef.current?.set([]);\n\t\t\tinput1DecorationsRef.current = null;\n\t\t\tinput2DecorationsRef.current = null;\n\t\t\tbaseDecorationsRef.current = null;\n\n\t\t\t// Dispose current editors and models\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst resultModel = resultEditorRef.current?.getModel();\n\n\t\t\tinput1EditorRef.current?.dispose();\n\t\t\tbaseEditorRef.current?.dispose();\n\t\t\tinput2EditorRef.current?.dispose();\n\t\t\tresultEditorRef.current?.dispose();\n\n\t\t\tinput1Model?.dispose();\n\t\t\tbaseModel?.dispose();\n\t\t\tinput2Model?.dispose();\n\t\t\tresultModel?.dispose();\n\n\t\t\tpreventCreation.current = false;\n\t\t\tsetEditorKey((prev) => prev + 1);\n\t\t}\n\t}, [showResultColumn, baseIndex, comparisonMode, base]);\n\n\t// Create editor when ready\n\tuseEffect(() => {\n\t\tif (!isMonacoMounting && monacoRef.current && containerRef.current && !preventCreation.current) {\n\t\t\tcreateEditor();\n\t\t}\n\t}, [isMonacoMounting, createEditor]);\n\n\t// Update editor options dynamically without recreating the editor\n\tuseEffect(() => {\n\t\tif (!isEditorReady || !options) return;\n\n\t\t// Update all editor instances\n\t\tif (input1EditorRef.current) {\n\t\t\tinput1EditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tinput2EditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (baseEditorRef.current) {\n\t\t\tbaseEditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (resultEditorRef.current) {\n\t\t\tresultEditorRef.current.updateOptions(options);\n\t\t}\n\t}, [options, isEditorReady]);\n\n\t// Apply decorations when conflicts change\n\tuseEffect(() => {\n\t\tif (isEditorReady && conflicts.length > 0) {\n\t\t\tapplyDecorations();\n\t\t\t// Render checkbox gutters\n\t\t\trenderCheckboxGutters();\n\t\t}\n\t}, [isEditorReady, conflicts, applyDecorations, renderCheckboxGutters]);\n\n\t// Update result editor when conflicts or showResultColumn changes\n\tuseEffect(() => {\n\t\tif (isEditorReady && conflicts.length > 0 && showResultColumn && resultEditorRef.current) {\n\t\t\tupdateResultEditor(conflicts);\n\t\t}\n\t}, [isEditorReady, conflicts, showResultColumn, updateResultEditor]);\n\n\t// Add scroll listener for gutter updates (including result column indicators)\n\tuseEffect(() => {\n\t\tif (!isEditorReady) return;\n\n\t\t// Update result gutter indicators on scroll\n\t\tconst updateResultIndicators = () => {\n\t\t\tif (conflictIssues.length > 0) {\n\t\t\t\trenderConflictIssueMarkers(conflictIssues);\n\t\t\t}\n\t\t};\n\n\t\tconst disposables: monaco.IDisposable[] = [];\n\n\t\tconst updateGutters = () => {\n\t\t\trenderCheckboxGutters();\n\t\t};\n\n\t\t// Listen to scroll changes\n\t\tif (input1EditorRef.current) {\n\t\t\tdisposables.push(input1EditorRef.current.onDidScrollChange(updateGutters));\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tdisposables.push(input2EditorRef.current.onDidScrollChange(updateGutters));\n\t\t}\n\t\tif (resultEditorRef.current && showResultColumn) {\n\t\t\tdisposables.push(resultEditorRef.current.onDidScrollChange(updateResultIndicators));\n\t\t\tdisposables.push(resultEditorRef.current.onDidLayoutChange(updateResultIndicators));\n\t\t}\n\n\t\t// Listen to view zone changes (using onDidLayoutChange as alternative)\n\t\tif (input1EditorRef.current) {\n\t\t\tdisposables.push(input1EditorRef.current.onDidLayoutChange(updateGutters));\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tdisposables.push(input2EditorRef.current.onDidLayoutChange(updateGutters));\n\t\t}\n\n\t\treturn () => {\n\t\t\tdisposables.forEach((d) => {\n\t\t\t\td?.dispose();\n\t\t\t});\n\t\t};\n\t}, [isEditorReady, renderCheckboxGutters, renderConflictIssueMarkers, showResultColumn, conflictIssues]);\n\n\t// Scroll synchronization\n\tuseEffect(() => {\n\t\tif (!isEditorReady) return;\n\n\t\tconst editors = [input1EditorRef.current, baseEditorRef.current, input2EditorRef.current];\n\t\tif (showResultColumn && resultEditorRef.current) {\n\t\t\teditors.push(resultEditorRef.current);\n\t\t}\n\n\t\tconst disposables: monaco.IDisposable[] = [];\n\t\tlet isScrolling = false;\n\n\t\tconst syncScroll = (source: monaco.editor.IStandaloneCodeEditor) => {\n\t\t\tif (isScrolling) return;\n\t\t\tisScrolling = true;\n\t\t\tconst scrollTop = source.getScrollTop();\n\t\t\tconst scrollLeft = source.getScrollLeft();\n\t\t\teditors.forEach((editor) => {\n\t\t\t\tif (editor && editor !== source) {\n\t\t\t\t\teditor.setScrollTop(scrollTop);\n\t\t\t\t\teditor.setScrollLeft(scrollLeft);\n\t\t\t\t}\n\t\t\t});\n\t\t\tsetTimeout(() => {\n\t\t\t\tisScrolling = false;\n\t\t\t}, 10);\n\t\t};\n\n\t\teditors.forEach((editor) => {\n\t\t\tif (editor) {\n\t\t\t\tdisposables.push(\n\t\t\t\t\teditor.onDidScrollChange(() => {\n\t\t\t\t\t\tsyncScroll(editor);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\treturn () => {\n\t\t\tdisposables.forEach((d) => {\n\t\t\t\td?.dispose();\n\t\t\t});\n\t\t};\n\t}, [isEditorReady, showResultColumn]);\n\n\t// Cleanup\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\t// Clear decoration collections before disposing\n\t\t\tinput1DecorationsRef.current?.set([]);\n\t\t\tinput2DecorationsRef.current?.set([]);\n\t\t\tbaseDecorationsRef.current?.set([]);\n\n\t\t\t// Get models before disposing editors\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst resultModel = resultEditorRef.current?.getModel();\n\n\t\t\t// Dispose editors first\n\t\t\tinput1EditorRef.current?.dispose();\n\t\t\tbaseEditorRef.current?.dispose();\n\t\t\tinput2EditorRef.current?.dispose();\n\t\t\tresultEditorRef.current?.dispose();\n\n\t\t\t// Then dispose models\n\t\t\tinput1Model?.dispose();\n\t\t\tbaseModel?.dispose();\n\t\t\tinput2Model?.dispose();\n\t\t\tresultModel?.dispose();\n\n\t\t\tpreventCreation.current = false;\n\t\t\tsetIsEditorReady(false);\n\t\t};\n\t}, []);\n\n\tif (isMonacoMounting || !isEditorReady) {\n\t\treturn <>{loading ?? <DefaultLoader />}</>;\n\t}\n\n\treturn <div ref={containerRef} style={{ width, height }} className={className} />;\n}\n"],"names":["_arrayLikeToArray","r","a","e","_arrayWithHoles","_defineProperty","t","_toPropertyKey","_iterableToArrayLimit","l","n","u","f","o","_nonIterableRest","ownKeys","_objectSpread2","_objectWithoutProperties","i","_objectWithoutPropertiesLoose","_slicedToArray","_unsupportedIterableToArray","_toPrimitive","obj","key","value","object","enumerableOnly","keys","symbols","sym","target","source","compose","_len","fns","_key","x","y","curry","fn","curried","_this","_len2","args","_key2","_len3","nextArgs","_key3","isObject","isEmpty","isFunction","hasOwnProperty","property","validateChanges","initial","changes","errorHandler","field","validateSelector","selector","validateHandler","handler","_handler","validateInitial","throwError","errorMessages","type","validators","create","state","didUpdate","didStateUpdate","update","updateState","validate","getChanges","extractChanges","getState","setState","causedChanges","_handler$field","index","config","validateConfig","informAboutDeprecation","merge","CANCELATION_MESSAGE","makeCancelable","promise","hasCanceled_","wrappedPromise","resolve","reject","val","_excluded","_state$create","config$1","_state$create2","globalConfig","_validators$config","monaco","init","_ref","isInitialized","wrapperPromise","storeMonacoInstance","injectScripts","getMonacoLoaderScript","configureLoader","script","createScript","src","_ref2","loaderScript","_ref3","require","_ref4","error","__getMonacoInstance","_ref5","loader","InputState","ConflictType","createScanner","text","ignoreTrivia","len","pos","tokenOffset","token","lineNumber","lineStartOffset","tokenLineStartOffset","prevTokenLineStartOffset","scanError","scanHexDigits","count","exact","digits","ch","setPosition","newPosition","scanNumber","start","isDigit","end","scanString","result","ch3","isLineBreak","scanNext","code","isWhiteSpace","safeLength","commentClosed","isUnknownContentCharacter","scanNextNonTrivia","CharacterCodes","_","maxCachedValues","ParseOptions","parseTree","errors","options","currentParent","ensurePropertyComplete","endOffset","onValue","valueNode","visit","offset","name","length","getNodeType","sep","findNodeAtLocation","root","path","node","segment","found","propertyNode","visitor","_scanner","_jsonPath","suppressedCallbacks","toNoArgVisit","visitFunction","toOneArgVisit","arg","toOneArgVisitWithPath","toBeginVisit","toEndVisit","onObjectBegin","onObjectProperty","onObjectEnd","onArrayBegin","onArrayEnd","onLiteralValue","onSeparator","onComment","onError","disallowComments","allowTrailingComma","handleError","skipUntilAfter","skipUntil","parseString","isValue","parseLiteral","tokenValue","parseProperty","parseValue","parseObject","needsComma","parseArray","isFirstElement","ScanError","SyntaxKind","parser.parseTree","parser.findNodeAtLocation","ParseErrorCode","fastDeepEqual","equal","b","getValueAtPath","normalizedPath","current","__extends","extendStatics","d","p","__","_hasOwnProperty","_objectKeys","keys_1","k","_deepClone","isInteger","str","charCode","escapePathComponent","unescapePathComponent","hasUndefined","i_1","objKeys","objKeysLength","patchErrorMessageFormatter","message","messageParts","PatchError","_super","operation","tree","_newTarget","JsonPatchError","deepClone","objOps","document","removed","getValueByPointer","originalValue","applyOperation","valueToCopy","_areEquals","arrOps","arr","removedList","pointer","getOriginalDestination","validateOperation","mutateDocument","banPrototypeModifications","validator","returnValue","existingPathFragment","validateFunction","applyPatch","patch","results","length_1","applyReducer","operationResult","pathLen","existingPathLen","existingValue","sequence","externalValidator","arrA","arrB","beforeDict","Mirror","ObserverInfo","callback","observer","getMirror","getObserverFromMirror","mirror","removeObserverFromMirror","unobserve","observe","patches","observerInfo","dirtyCheck","generate","fastCheck","invertible","_generate","temp","newKeys","oldKeys","deleted","oldVal","newVal","compare","tree1","tree2","core","duplex","ONE_OF","ANY_OF","ALL_OF","hasSchemaVariants","schema","getSchemaVariants","variants","getSubschemaKeyword","findCommonDiscriminatorField","data","discriminatorFields","variant","props","propSchema","chooseSubschemaSync","_schemaKeyword","dataObj","discriminator","variantProp","_a","required","discriminatorMatches","constValue","dataType","determineConflictType","base","input1","input2","input1Changed","isEqual","input2Changed","getNodeLines","pathSegments","numericValue","getLineNumber","groupPatchesByRootPath","patches1","patches2","pathGroups","getRootPath","segments","rootPath","group","groupPatchesWithSchema","arrayPatchGroups1","arrayPatchGroups2","nonArrayPatches1","nonArrayPatches2","arrayItemMatch","arrayPath","group1","group2","allArrayPaths","baseArray","input1Array","input2Array","itemMatch","itemPath","itemGroup1","itemGroup2","arraySchema","getSchemaAtPath","itemSchemaRaw","itemSchema","matches","matchArrayItemsById","baseKeysByIndex","input1KeysByIndex","input2KeysByIndex","indices","itemIndexMatch","groupKey","groupKey1","groupKey2","groupItem1","groupItem2","getOneOfObjectPath","patchPath","parentPath","parentSchema","allNonArrayPatches1","allNonArrayPatches2","oneOfObjectPaths","oneOfPath","currentSchema","currentPath","numericIndex","isArrayIndex","keyword","currentData","resolvedSchema","itemAtIndex","findItemAnchorFields","anchors","properties","fieldName","format","commonIdFields","findItemIdField","matchArrayItemsByAnchors","anchorFields","getItemKey","item","keyParts","indexArray","version","match","idField","indexByArray","id","idKey","analyzeConflicts","baseObj","input1Obj","input2Obj","patch1","patch2","conflicts","processedPaths","checkOneOfVariantChange","baseValue","input1Value","input2Value","pathSchema","baseVariant","input1Variant","input2Variant","groupingKey","representativePath","objectPath","baseObjectValue","input1ObjectValue","input2ObjectValue","baseObjVal","input1ObjVal","input2ObjVal","conflictType","objectPatchesAll","objectPatches1","objectPatches2","patchBaseValue","patchInput1Value","patchInput2Value","existsInBase","existsInInput1","existsInInput2","analyzeTwoWayConflicts","arrayPathGroups","nonArrayPatches","arrayGroup","arrayPatches","itemGroups","itemPatches","createConflictsForGroup","matchedItemPatches","unmatchedPatches","matchedPatches","unmatchedItemGroups","_b","_c","propertyGroups","_d","pathPatches","filteredPatches1","filteredPatches2","patches1ToUse","patches2ToUse","patchesToUse","hasAdd","hasRemove","hasReplace","calculatePatchLineRange","minStart","maxEnd","foundAnyNode","lines","mapConflictsToRanges","baseText","input1Text","input2Text","ranges","conflict","baseLines","input1Lines","input2Lines","isConflicting","input1State","input2State","input1Diffs","input2Diffs","lineNum","_e","_f","range","computeDiffsJsonPatch","comparisonMode","allPaths","baseToInput1Changed","input1ToInput2Changed","computeLineConflictType","baseLine","input1Line","input2Line","computeDiffs","baseRanges","allChanges","rangeStart","currentConflictType","input1DiffsInRange","input2DiffsInRange","isLast","isGap","typeChanged","prevChange","rangeEnd","hasInput1Changes","hasInput2Changes","setValueAtPath","s","objCurrent","lastSegment","lastNumeric","findLinesForPath","jsonContent","startLine","endLine","smartMergeValues","value1","value2","obj1","obj2","merged","objectSchema","additionalProperties","propertySchema","nestedPath","recursiveMerge","buildResultContentWithValidation","warnings","conflictIssues","baseData","input1Data","input2Data","resultData","appliedPaths","explicitlySetProperties","mergedParents","findPathFromLines","_startLine","_endLine","_text","includesInput1","includesInput2","conflictPath","valueToApply","pathToApply","isArrayItemConflict","extractPath","conflictSchema","mergedValue","parentInInput1","childPath","parentInInput2","content","lineInfo","isValid","validationError","getDecorationClasses","isTwoColumnMode","input1Class","input2Class","baseClass","input1OverviewColor","input2OverviewColor","baseOverviewColor","ConflictTypeEnum","extractUniqueLines","diffs","uniqueLines","diff","createInput1Decorations","classes","monacoInstance","decorations","createInput2Decorations","createBaseDecorations","isDefaultRange","createConflictDecorations","createAllDecorations","input1Decorations","input2Decorations","baseDecorations","DefaultLoader","jsx","ISSUE_ICON","JsonDiffMergeEditor","original","modified","theme","width","height","className","loading","onMount","onMergeResolve","showResultColumn","baseIndex","labels","language","isEditorReady","setIsEditorReady","useState","isMonacoMounting","setIsMonacoMounting","setConflicts","_validationError","setValidationError","_validationWarnings","setValidationWarnings","setConflictIssues","isResultManuallyEdited","setIsResultManuallyEdited","renderCheckbox","useCallback","_inputNumber","_conflictId","onToggle","container","checkbox","_editorKey","setEditorKey","input1EditorRef","useRef","baseEditorRef","input2EditorRef","resultEditorRef","monacoRef","containerRef","preventCreation","isProgrammaticUpdate","input1GutterRef","input2GutterRef","resultGutterRef","gutterViewsRef","resultLabelRef","input1DecorationsRef","input2DecorationsRef","baseDecorationsRef","useEffect","isMounted","cancelable","baseModel","input1Model","input2Model","startTime","duration","getDecorationsLeft","editor","getDecorationsWidth","renderConflictIssueMarkers","issues","isDark","decorationsLeft","decorationsWidth","scrollTop","issue","topStart","topEnd","lineHeight","fullHeight","markerDiv","icon","updateResultEditor","updatedConflicts","resultModel","baseLabel","position","selection","lineCount","lastLineLength","validatedPosition","modelWithDecorations","invalidDecorations","collection","conflictIssueDecorations","conflictDecorations","backgroundColor","borderColor","toggleInputState","conflictId","inputNumber","prevConflicts","newState","renderCheckboxGutterItem","gutterContainer","viewHeight","_isDark","model","top","viewDiv","background","checkboxDiv","checkboxBg","checkboxBtn","newCheckboxBtn","isHandled","isFocused","isMultiLine","middleHeight","margin","effectiveCheckboxTop","preferredViewPortMin","preferredViewPortMax","preferredParentMin","preferredParentMax","renderCheckboxGutters","allViews","view","decorationsLeft1","decorationsWidth1","decorationsLeft2","decorationsWidth2","visibleRanges","viewsToKeep","getThemeColor","colorKey","fallback","currentTheme","applyDecorations","conflictColor","changeColor","baseColor","conflictOverviewColor","changeOverviewColor","decorationConfig","checkboxBgColor","checkboxBorderColor","checkboxFocusBorderColor","checkboxCheckedColor","styleId","styleEl","sameChangeColor","input1OnlyColor","createEditor","wrapper","foregroundColor","getThemeColorLocal","input1HeaderBg","baseHeaderBg","input2HeaderBg","resultHeaderBg","createEditorContainer","label","color","withGutter","labelDiv","editorWrapper","editorDiv","gutterDiv","hasBase","baseC","orderedColumns","col","resultC","detectedConflicts","prevShowResultRef","prevBaseIndexRef","prevComparisonModeRef","prevBaseRef","showResultChanged","baseIndexChanged","comparisonModeChanged","baseChanged","_g","_h","_i","_j","_k","prev","updateResultIndicators","disposables","updateGutters","editors","isScrolling","syncScroll","scrollLeft","Fragment"],"mappings":"yIAAA,SAASA,GAAkBC,EAAGC,EAAG,EACtBA,GAAR,MAAaA,EAAID,EAAE,UAAYC,EAAID,EAAE,QACtC,QAASE,EAAI,EAAG,EAAI,MAAMD,CAAC,EAAGC,EAAID,EAAGC,IAAK,EAAEA,CAAC,EAAIF,EAAEE,CAAC,EACpD,OAAO,CACT,CACA,SAASC,GAAgBH,EAAG,CAC1B,GAAI,MAAM,QAAQA,CAAC,EAAG,OAAOA,CAC/B,CACA,SAASI,GAAgB,EAAGJ,EAAGK,EAAG,CAChC,OAAQL,EAAIM,GAAeN,CAAC,KAAM,EAAI,OAAO,eAAe,EAAGA,EAAG,CAChE,MAAOK,EACP,WAAY,GACZ,aAAc,GACd,SAAU,EACd,CAAG,EAAI,EAAEL,CAAC,EAAIK,EAAG,CACjB,CACA,SAASE,GAAsBP,EAAGQ,EAAG,CACnC,IAAIH,EAAYL,GAAR,KAAY,KAAsB,OAAO,OAAtB,KAAgCA,EAAE,OAAO,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,EAAgB,UAAhB,MAAA+I,EAAyB,WACzBC,EAAA9I,GAAc,UAAd,MAAA8I,EAAuB,WACvBC,GAAA9I,EAAgB,UAAhB,MAAA8I,GAAyB,WACzBC,GAAA9I,EAAgB,UAAhB,MAAA8I,GAAyB,UAGzB7H,GAAA,MAAAA,EAAa,UACbD,GAAA,MAAAA,EAAW,UACXE,GAAA,MAAAA,EAAa,UACbqB,GAAA,MAAAA,EAAa,UAEbpC,GAAgB,QAAU,GAC1B5B,EAAiB,EAAK,CACvB,EACE,CAAA,CAAE,EAEDE,GAAoB,CAACH,EACjBhB,GAAAA,IAAAiM,GAAAA,SAAA,CAAG,SAAAxL,GAAWT,OAACD,GAAA,CAAA,CAAc,EAAG,EAGjCC,OAAC,OAAI,IAAK4C,GAAc,MAAO,CAAE,MAAAtC,EAAO,OAAAC,GAAU,UAAAC,EAAsB,CAChF","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,17,18,19,20]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js","../node_modules/state-local/lib/es/state-local.js","../node_modules/@monaco-editor/loader/lib/es/config/index.js","../node_modules/@monaco-editor/loader/lib/es/utils/curry.js","../node_modules/@monaco-editor/loader/lib/es/utils/isObject.js","../node_modules/@monaco-editor/loader/lib/es/validators/index.js","../node_modules/@monaco-editor/loader/lib/es/utils/compose.js","../node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js","../node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js","../node_modules/@monaco-editor/loader/lib/es/loader/index.js","../src/types/index.ts","../node_modules/jsonc-parser/lib/esm/impl/scanner.js","../node_modules/jsonc-parser/lib/esm/impl/string-intern.js","../node_modules/jsonc-parser/lib/esm/impl/parser.js","../node_modules/jsonc-parser/lib/esm/main.js","../node_modules/fast-deep-equal/index.js","../src/utils/helpers.ts","../node_modules/fast-json-patch/module/helpers.mjs","../node_modules/fast-json-patch/module/core.mjs","../node_modules/fast-json-patch/module/duplex.mjs","../node_modules/fast-json-patch/index.mjs","../src/utils/schema.ts","../src/utils/jsonPatchDiff.ts","../src/utils/diffMerge.ts","../src/utils/editorDecorations.ts","../src/components/editor.tsx"],"sourcesContent":["function _arrayLikeToArray(r, a) {\n (null == a || a > r.length) && (a = r.length);\n for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n return n;\n}\nfunction _arrayWithHoles(r) {\n if (Array.isArray(r)) return r;\n}\nfunction _defineProperty(e, r, t) {\n return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: true,\n configurable: true,\n writable: true\n }) : e[r] = t, e;\n}\nfunction _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = true,\n o = false;\n try {\n if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = true, n = r;\n } finally {\n try {\n if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), true).forEach(function (r) {\n _defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}\nfunction _objectWithoutProperties(e, t) {\n if (null == e) return {};\n var o,\n r,\n i = _objectWithoutPropertiesLoose(e, t);\n if (Object.getOwnPropertySymbols) {\n var n = Object.getOwnPropertySymbols(e);\n for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);\n }\n return i;\n}\nfunction _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (-1 !== e.indexOf(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nfunction _slicedToArray(r, e) {\n return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();\n}\nfunction _toPrimitive(t, r) {\n if (\"object\" != typeof t || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r);\n if (\"object\" != typeof i) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, \"string\");\n return \"symbol\" == typeof i ? i : i + \"\";\n}\nfunction _unsupportedIterableToArray(r, a) {\n if (r) {\n if (\"string\" == typeof r) return _arrayLikeToArray(r, a);\n var t = {}.toString.call(r).slice(8, -1);\n return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;\n }\n}\n\nexport { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _defineProperty as defineProperty, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _objectSpread2 as objectSpread2, _objectWithoutProperties as objectWithoutProperties, _objectWithoutPropertiesLoose as objectWithoutPropertiesLoose, _slicedToArray as slicedToArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n if (enumerableOnly) symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n });\n keys.push.apply(keys, symbols);\n }\n\n return keys;\n}\n\nfunction _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n\n if (i % 2) {\n ownKeys(Object(source), true).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n } else if (Object.getOwnPropertyDescriptors) {\n Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));\n } else {\n ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n }\n\n return target;\n}\n\nfunction compose() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n\n return function (x) {\n return fns.reduceRight(function (y, f) {\n return f(y);\n }, x);\n };\n}\n\nfunction curry(fn) {\n return function curried() {\n var _this = this;\n\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return args.length >= fn.length ? fn.apply(this, args) : function () {\n for (var _len3 = arguments.length, nextArgs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n nextArgs[_key3] = arguments[_key3];\n }\n\n return curried.apply(_this, [].concat(args, nextArgs));\n };\n };\n}\n\nfunction isObject(value) {\n return {}.toString.call(value).includes('Object');\n}\n\nfunction isEmpty(obj) {\n return !Object.keys(obj).length;\n}\n\nfunction isFunction(value) {\n return typeof value === 'function';\n}\n\nfunction hasOwnProperty(object, property) {\n return Object.prototype.hasOwnProperty.call(object, property);\n}\n\nfunction validateChanges(initial, changes) {\n if (!isObject(changes)) errorHandler('changeType');\n if (Object.keys(changes).some(function (field) {\n return !hasOwnProperty(initial, field);\n })) errorHandler('changeField');\n return changes;\n}\n\nfunction validateSelector(selector) {\n if (!isFunction(selector)) errorHandler('selectorType');\n}\n\nfunction validateHandler(handler) {\n if (!(isFunction(handler) || isObject(handler))) errorHandler('handlerType');\n if (isObject(handler) && Object.values(handler).some(function (_handler) {\n return !isFunction(_handler);\n })) errorHandler('handlersType');\n}\n\nfunction validateInitial(initial) {\n if (!initial) errorHandler('initialIsRequired');\n if (!isObject(initial)) errorHandler('initialType');\n if (isEmpty(initial)) errorHandler('initialContent');\n}\n\nfunction throwError(errorMessages, type) {\n throw new Error(errorMessages[type] || errorMessages[\"default\"]);\n}\n\nvar errorMessages = {\n initialIsRequired: 'initial state is required',\n initialType: 'initial state should be an object',\n initialContent: 'initial state shouldn\\'t be an empty object',\n handlerType: 'handler should be an object or a function',\n handlersType: 'all handlers should be a functions',\n selectorType: 'selector should be a function',\n changeType: 'provided value of changes should be an object',\n changeField: 'it seams you want to change a field in the state which is not specified in the \"initial\" state',\n \"default\": 'an unknown error accured in `state-local` package'\n};\nvar errorHandler = curry(throwError)(errorMessages);\nvar validators = {\n changes: validateChanges,\n selector: validateSelector,\n handler: validateHandler,\n initial: validateInitial\n};\n\nfunction create(initial) {\n var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n validators.initial(initial);\n validators.handler(handler);\n var state = {\n current: initial\n };\n var didUpdate = curry(didStateUpdate)(state, handler);\n var update = curry(updateState)(state);\n var validate = curry(validators.changes)(initial);\n var getChanges = curry(extractChanges)(state);\n\n function getState() {\n var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (state) {\n return state;\n };\n validators.selector(selector);\n return selector(state.current);\n }\n\n function setState(causedChanges) {\n compose(didUpdate, update, validate, getChanges)(causedChanges);\n }\n\n return [getState, setState];\n}\n\nfunction extractChanges(state, causedChanges) {\n return isFunction(causedChanges) ? causedChanges(state.current) : causedChanges;\n}\n\nfunction updateState(state, changes) {\n state.current = _objectSpread2(_objectSpread2({}, state.current), changes);\n return changes;\n}\n\nfunction didStateUpdate(state, handler, changes) {\n isFunction(handler) ? handler(state.current) : Object.keys(changes).forEach(function (field) {\n var _handler$field;\n\n return (_handler$field = handler[field]) === null || _handler$field === void 0 ? void 0 : _handler$field.call(handler, state.current[field]);\n });\n return changes;\n}\n\nvar index = {\n create: create\n};\n\nexport default index;\n","var config = {\n paths: {\n vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.54.0/min/vs'\n }\n};\n\nexport { config as default };\n","function curry(fn) {\n return function curried() {\n var _this = this;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return args.length >= fn.length ? fn.apply(this, args) : function () {\n for (var _len2 = arguments.length, nextArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n nextArgs[_key2] = arguments[_key2];\n }\n return curried.apply(_this, [].concat(args, nextArgs));\n };\n };\n}\n\nexport { curry as default };\n","function isObject(value) {\n return {}.toString.call(value).includes('Object');\n}\n\nexport { isObject as default };\n","import curry from '../utils/curry.js';\nimport isObject from '../utils/isObject.js';\n\n/**\n * validates the configuration object and informs about deprecation\n * @param {Object} config - the configuration object \n * @return {Object} config - the validated configuration object\n */\nfunction validateConfig(config) {\n if (!config) errorHandler('configIsRequired');\n if (!isObject(config)) errorHandler('configType');\n if (config.urls) {\n informAboutDeprecation();\n return {\n paths: {\n vs: config.urls.monacoBase\n }\n };\n }\n return config;\n}\n\n/**\n * logs deprecation message\n */\nfunction informAboutDeprecation() {\n console.warn(errorMessages.deprecation);\n}\nfunction throwError(errorMessages, type) {\n throw new Error(errorMessages[type] || errorMessages[\"default\"]);\n}\nvar errorMessages = {\n configIsRequired: 'the configuration object is required',\n configType: 'the configuration object should be an object',\n \"default\": 'an unknown error accured in `@monaco-editor/loader` package',\n deprecation: \"Deprecation warning!\\n You are using deprecated way of configuration.\\n\\n Instead of using\\n monaco.config({ urls: { monacoBase: '...' } })\\n use\\n monaco.config({ paths: { vs: '...' } })\\n\\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\\n \"\n};\nvar errorHandler = curry(throwError)(errorMessages);\nvar validators = {\n config: validateConfig\n};\n\nexport { validators as default, errorHandler, errorMessages };\n","var compose = function compose() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n return function (x) {\n return fns.reduceRight(function (y, f) {\n return f(y);\n }, x);\n };\n};\n\nexport { compose as default };\n","import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';\n\nfunction merge(target, source) {\n Object.keys(source).forEach(function (key) {\n if (source[key] instanceof Object) {\n if (target[key]) {\n Object.assign(source[key], merge(target[key], source[key]));\n }\n }\n });\n return _objectSpread2(_objectSpread2({}, target), source);\n}\n\nexport { merge as default };\n","// The source (has been changed) is https://github.com/facebook/react/issues/5465#issuecomment-157888325\n\nvar CANCELATION_MESSAGE = {\n type: 'cancelation',\n msg: 'operation is manually canceled'\n};\nfunction makeCancelable(promise) {\n var hasCanceled_ = false;\n var wrappedPromise = new Promise(function (resolve, reject) {\n promise.then(function (val) {\n return hasCanceled_ ? reject(CANCELATION_MESSAGE) : resolve(val);\n });\n promise[\"catch\"](reject);\n });\n return wrappedPromise.cancel = function () {\n return hasCanceled_ = true;\n }, wrappedPromise;\n}\n\nexport { CANCELATION_MESSAGE, makeCancelable as default };\n","import { slicedToArray as _slicedToArray, objectWithoutProperties as _objectWithoutProperties } from '../_virtual/_rollupPluginBabelHelpers.js';\nimport state from 'state-local';\nimport config$1 from '../config/index.js';\nimport validators from '../validators/index.js';\nimport compose from '../utils/compose.js';\nimport merge from '../utils/deepMerge.js';\nimport makeCancelable from '../utils/makeCancelable.js';\n\nvar _excluded = [\"monaco\"];\n\n/** the local state of the module */\nvar _state$create = state.create({\n config: config$1,\n isInitialized: false,\n resolve: null,\n reject: null,\n monaco: null\n }),\n _state$create2 = _slicedToArray(_state$create, 2),\n getState = _state$create2[0],\n setState = _state$create2[1];\n\n/**\n * set the loader configuration\n * @param {Object} config - the configuration object\n */\nfunction config(globalConfig) {\n var _validators$config = validators.config(globalConfig),\n monaco = _validators$config.monaco,\n config = _objectWithoutProperties(_validators$config, _excluded);\n setState(function (state) {\n return {\n config: merge(state.config, config),\n monaco: monaco\n };\n });\n}\n\n/**\n * handles the initialization of the monaco-editor\n * @return {Promise} - returns an instance of monaco (with a cancelable promise)\n */\nfunction init() {\n var state = getState(function (_ref) {\n var monaco = _ref.monaco,\n isInitialized = _ref.isInitialized,\n resolve = _ref.resolve;\n return {\n monaco: monaco,\n isInitialized: isInitialized,\n resolve: resolve\n };\n });\n if (!state.isInitialized) {\n setState({\n isInitialized: true\n });\n if (state.monaco) {\n state.resolve(state.monaco);\n return makeCancelable(wrapperPromise);\n }\n if (window.monaco && window.monaco.editor) {\n storeMonacoInstance(window.monaco);\n state.resolve(window.monaco);\n return makeCancelable(wrapperPromise);\n }\n compose(injectScripts, getMonacoLoaderScript)(configureLoader);\n }\n return makeCancelable(wrapperPromise);\n}\n\n/**\n * injects provided scripts into the document.body\n * @param {Object} script - an HTML script element\n * @return {Object} - the injected HTML script element\n */\nfunction injectScripts(script) {\n return document.body.appendChild(script);\n}\n\n/**\n * creates an HTML script element with/without provided src\n * @param {string} [src] - the source path of the script\n * @return {Object} - the created HTML script element\n */\nfunction createScript(src) {\n var script = document.createElement('script');\n return src && (script.src = src), script;\n}\n\n/**\n * creates an HTML script element with the monaco loader src\n * @return {Object} - the created HTML script element\n */\nfunction getMonacoLoaderScript(configureLoader) {\n var state = getState(function (_ref2) {\n var config = _ref2.config,\n reject = _ref2.reject;\n return {\n config: config,\n reject: reject\n };\n });\n var loaderScript = createScript(\"\".concat(state.config.paths.vs, \"/loader.js\"));\n loaderScript.onload = function () {\n return configureLoader();\n };\n loaderScript.onerror = state.reject;\n return loaderScript;\n}\n\n/**\n * configures the monaco loader\n */\nfunction configureLoader() {\n var state = getState(function (_ref3) {\n var config = _ref3.config,\n resolve = _ref3.resolve,\n reject = _ref3.reject;\n return {\n config: config,\n resolve: resolve,\n reject: reject\n };\n });\n var require = window.require;\n require.config(state.config);\n require(['vs/editor/editor.main'], function (_ref4) {\n var monaco = _ref4.m;\n storeMonacoInstance(monaco);\n state.resolve(monaco);\n }, function (error) {\n state.reject(error);\n });\n}\n\n/**\n * store monaco instance in local state\n */\nfunction storeMonacoInstance(monaco) {\n if (!getState().monaco) {\n setState({\n monaco: monaco\n });\n }\n}\n\n/**\n * internal helper function\n * extracts stored monaco instance\n * @return {Object|null} - the monaco instance\n */\nfunction __getMonacoInstance() {\n return getState(function (_ref5) {\n var monaco = _ref5.monaco;\n return monaco;\n });\n}\nvar wrapperPromise = new Promise(function (resolve, reject) {\n return setState({\n resolve: resolve,\n reject: reject\n });\n});\nvar loader = {\n config: config,\n init: init,\n __getMonacoInstance: __getMonacoInstance\n};\n\nexport { loader as default };\n","import type { Operation as JsonPatchOperation } from \"fast-json-patch\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport type * as monaco from \"monaco-editor\";\n\nexport type JSONSchema = JSONSchema7;\n\n// Conflict and Editor types\nexport enum InputState {\n\texcluded = 0,\n\tfirst = 1,\n\tsecond = 2,\n}\n\nexport enum ConflictType {\n\tSAME_CHANGE = \"same_change\",\n\tINPUT1_ONLY = \"input1_only\",\n\tINPUT2_ONLY = \"input2_only\",\n\tTRUE_CONFLICT = \"true_conflict\",\n}\n\nexport interface ModifiedBaseRange {\n\tid: string;\n\tpath?: string;\n\tbaseRange: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput1Range: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput2Range: { startLineNumber: number; endLineNumberExclusive: number };\n\tinput1Diffs: unknown[];\n\tinput2Diffs: unknown[];\n\tisConflicting: boolean;\n\tconflictType: ConflictType;\n\tinput1State: InputState;\n\tinput2State: InputState;\n\thandled: boolean;\n\tfocused: boolean;\n}\n\nexport interface ConflictIssue {\n\tconflictId: string;\n\tconflictPath: string;\n\ttype: \"error\" | \"warning\" | \"smart-merge\";\n\tmessage: string;\n\tstartLine: number;\n\tendLine: number;\n}\n\nexport interface ResolutionInfo {\n\tisValid: boolean;\n\tvalidationError?: string;\n\twarnings?: string[];\n\tconflictIssues?: ConflictIssue[];\n}\n\nexport interface EditorDiffMergeProps {\n\toriginal?: string;\n\tmodified?: string;\n\tbase?: string;\n\ttheme?: string;\n\twidth?: string | number;\n\theight?: string | number;\n\tclassName?: string;\n\tloading?: React.ReactNode;\n\toptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n\tonMount?: (editor: monaco.editor.IStandaloneDiffEditor, monaco: typeof import(\"monaco-editor\")) => void;\n\tonMergeResolve?: (content: string, resolution?: ResolutionInfo) => void;\n\tshowResultColumn?: boolean;\n\tbaseIndex?: 0 | 1 | 2;\n\tcomparisonMode?: \"split\" | \"sequential\";\n\tschema?: JSONSchema;\n\tpatches?: {\n\t\ttheirs?: JsonPatchOperation[];\n\t\tours?: JsonPatchOperation[];\n\t};\n\tlabels?: {\n\t\tinput1?: string;\n\t\tbase?: string;\n\t\tinput2?: string;\n\t\tresult?: string;\n\t};\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\n/**\n * Creates a JSON scanner on the given text.\n * If ignoreTrivia is set, whitespaces or comments are ignored.\n */\nexport function createScanner(text, ignoreTrivia = false) {\n const len = text.length;\n let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;\n function scanHexDigits(count, exact) {\n let digits = 0;\n let value = 0;\n while (digits < count || !exact) {\n let ch = text.charCodeAt(pos);\n if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {\n value = value * 16 + ch - 48 /* CharacterCodes._0 */;\n }\n else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {\n value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;\n }\n else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {\n value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;\n }\n else {\n break;\n }\n pos++;\n digits++;\n }\n if (digits < count) {\n value = -1;\n }\n return value;\n }\n function setPosition(newPosition) {\n pos = newPosition;\n value = '';\n tokenOffset = 0;\n token = 16 /* SyntaxKind.Unknown */;\n scanError = 0 /* ScanError.None */;\n }\n function scanNumber() {\n let start = pos;\n if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {\n pos++;\n }\n else {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n }\n if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {\n pos++;\n if (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n }\n else {\n scanError = 3 /* ScanError.UnexpectedEndOfNumber */;\n return text.substring(start, pos);\n }\n }\n let end = pos;\n if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {\n pos++;\n if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {\n pos++;\n }\n if (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n while (pos < text.length && isDigit(text.charCodeAt(pos))) {\n pos++;\n }\n end = pos;\n }\n else {\n scanError = 3 /* ScanError.UnexpectedEndOfNumber */;\n }\n }\n return text.substring(start, end);\n }\n function scanString() {\n let result = '', start = pos;\n while (true) {\n if (pos >= len) {\n result += text.substring(start, pos);\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n const ch = text.charCodeAt(pos);\n if (ch === 34 /* CharacterCodes.doubleQuote */) {\n result += text.substring(start, pos);\n pos++;\n break;\n }\n if (ch === 92 /* CharacterCodes.backslash */) {\n result += text.substring(start, pos);\n pos++;\n if (pos >= len) {\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n const ch2 = text.charCodeAt(pos++);\n switch (ch2) {\n case 34 /* CharacterCodes.doubleQuote */:\n result += '\\\"';\n break;\n case 92 /* CharacterCodes.backslash */:\n result += '\\\\';\n break;\n case 47 /* CharacterCodes.slash */:\n result += '/';\n break;\n case 98 /* CharacterCodes.b */:\n result += '\\b';\n break;\n case 102 /* CharacterCodes.f */:\n result += '\\f';\n break;\n case 110 /* CharacterCodes.n */:\n result += '\\n';\n break;\n case 114 /* CharacterCodes.r */:\n result += '\\r';\n break;\n case 116 /* CharacterCodes.t */:\n result += '\\t';\n break;\n case 117 /* CharacterCodes.u */:\n const ch3 = scanHexDigits(4, true);\n if (ch3 >= 0) {\n result += String.fromCharCode(ch3);\n }\n else {\n scanError = 4 /* ScanError.InvalidUnicode */;\n }\n break;\n default:\n scanError = 5 /* ScanError.InvalidEscapeCharacter */;\n }\n start = pos;\n continue;\n }\n if (ch >= 0 && ch <= 0x1f) {\n if (isLineBreak(ch)) {\n result += text.substring(start, pos);\n scanError = 2 /* ScanError.UnexpectedEndOfString */;\n break;\n }\n else {\n scanError = 6 /* ScanError.InvalidCharacter */;\n // mark as error but continue with string\n }\n }\n pos++;\n }\n return result;\n }\n function scanNext() {\n value = '';\n scanError = 0 /* ScanError.None */;\n tokenOffset = pos;\n lineStartOffset = lineNumber;\n prevTokenLineStartOffset = tokenLineStartOffset;\n if (pos >= len) {\n // at the end\n tokenOffset = len;\n return token = 17 /* SyntaxKind.EOF */;\n }\n let code = text.charCodeAt(pos);\n // trivia: whitespace\n if (isWhiteSpace(code)) {\n do {\n pos++;\n value += String.fromCharCode(code);\n code = text.charCodeAt(pos);\n } while (isWhiteSpace(code));\n return token = 15 /* SyntaxKind.Trivia */;\n }\n // trivia: newlines\n if (isLineBreak(code)) {\n pos++;\n value += String.fromCharCode(code);\n if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {\n pos++;\n value += '\\n';\n }\n lineNumber++;\n tokenLineStartOffset = pos;\n return token = 14 /* SyntaxKind.LineBreakTrivia */;\n }\n switch (code) {\n // tokens: []{}:,\n case 123 /* CharacterCodes.openBrace */:\n pos++;\n return token = 1 /* SyntaxKind.OpenBraceToken */;\n case 125 /* CharacterCodes.closeBrace */:\n pos++;\n return token = 2 /* SyntaxKind.CloseBraceToken */;\n case 91 /* CharacterCodes.openBracket */:\n pos++;\n return token = 3 /* SyntaxKind.OpenBracketToken */;\n case 93 /* CharacterCodes.closeBracket */:\n pos++;\n return token = 4 /* SyntaxKind.CloseBracketToken */;\n case 58 /* CharacterCodes.colon */:\n pos++;\n return token = 6 /* SyntaxKind.ColonToken */;\n case 44 /* CharacterCodes.comma */:\n pos++;\n return token = 5 /* SyntaxKind.CommaToken */;\n // strings\n case 34 /* CharacterCodes.doubleQuote */:\n pos++;\n value = scanString();\n return token = 10 /* SyntaxKind.StringLiteral */;\n // comments\n case 47 /* CharacterCodes.slash */:\n const start = pos - 1;\n // Single-line comment\n if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {\n pos += 2;\n while (pos < len) {\n if (isLineBreak(text.charCodeAt(pos))) {\n break;\n }\n pos++;\n }\n value = text.substring(start, pos);\n return token = 12 /* SyntaxKind.LineCommentTrivia */;\n }\n // Multi-line comment\n if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {\n pos += 2;\n const safeLength = len - 1; // For lookahead.\n let commentClosed = false;\n while (pos < safeLength) {\n const ch = text.charCodeAt(pos);\n if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {\n pos += 2;\n commentClosed = true;\n break;\n }\n pos++;\n if (isLineBreak(ch)) {\n if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {\n pos++;\n }\n lineNumber++;\n tokenLineStartOffset = pos;\n }\n }\n if (!commentClosed) {\n pos++;\n scanError = 1 /* ScanError.UnexpectedEndOfComment */;\n }\n value = text.substring(start, pos);\n return token = 13 /* SyntaxKind.BlockCommentTrivia */;\n }\n // just a single slash\n value += String.fromCharCode(code);\n pos++;\n return token = 16 /* SyntaxKind.Unknown */;\n // numbers\n case 45 /* CharacterCodes.minus */:\n value += String.fromCharCode(code);\n pos++;\n if (pos === len || !isDigit(text.charCodeAt(pos))) {\n return token = 16 /* SyntaxKind.Unknown */;\n }\n // found a minus, followed by a number so\n // we fall through to proceed with scanning\n // numbers\n case 48 /* CharacterCodes._0 */:\n case 49 /* CharacterCodes._1 */:\n case 50 /* CharacterCodes._2 */:\n case 51 /* CharacterCodes._3 */:\n case 52 /* CharacterCodes._4 */:\n case 53 /* CharacterCodes._5 */:\n case 54 /* CharacterCodes._6 */:\n case 55 /* CharacterCodes._7 */:\n case 56 /* CharacterCodes._8 */:\n case 57 /* CharacterCodes._9 */:\n value += scanNumber();\n return token = 11 /* SyntaxKind.NumericLiteral */;\n // literals and unknown symbols\n default:\n // is a literal? Read the full word.\n while (pos < len && isUnknownContentCharacter(code)) {\n pos++;\n code = text.charCodeAt(pos);\n }\n if (tokenOffset !== pos) {\n value = text.substring(tokenOffset, pos);\n // keywords: true, false, null\n switch (value) {\n case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;\n case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;\n case 'null': return token = 7 /* SyntaxKind.NullKeyword */;\n }\n return token = 16 /* SyntaxKind.Unknown */;\n }\n // some\n value += String.fromCharCode(code);\n pos++;\n return token = 16 /* SyntaxKind.Unknown */;\n }\n }\n function isUnknownContentCharacter(code) {\n if (isWhiteSpace(code) || isLineBreak(code)) {\n return false;\n }\n switch (code) {\n case 125 /* CharacterCodes.closeBrace */:\n case 93 /* CharacterCodes.closeBracket */:\n case 123 /* CharacterCodes.openBrace */:\n case 91 /* CharacterCodes.openBracket */:\n case 34 /* CharacterCodes.doubleQuote */:\n case 58 /* CharacterCodes.colon */:\n case 44 /* CharacterCodes.comma */:\n case 47 /* CharacterCodes.slash */:\n return false;\n }\n return true;\n }\n function scanNextNonTrivia() {\n let result;\n do {\n result = scanNext();\n } while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);\n return result;\n }\n return {\n setPosition: setPosition,\n getPosition: () => pos,\n scan: ignoreTrivia ? scanNextNonTrivia : scanNext,\n getToken: () => token,\n getTokenValue: () => value,\n getTokenOffset: () => tokenOffset,\n getTokenLength: () => pos - tokenOffset,\n getTokenStartLine: () => lineStartOffset,\n getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,\n getTokenError: () => scanError,\n };\n}\nfunction isWhiteSpace(ch) {\n return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;\n}\nfunction isLineBreak(ch) {\n return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;\n}\nfunction isDigit(ch) {\n return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;\n}\nvar CharacterCodes;\n(function (CharacterCodes) {\n CharacterCodes[CharacterCodes[\"lineFeed\"] = 10] = \"lineFeed\";\n CharacterCodes[CharacterCodes[\"carriageReturn\"] = 13] = \"carriageReturn\";\n CharacterCodes[CharacterCodes[\"space\"] = 32] = \"space\";\n CharacterCodes[CharacterCodes[\"_0\"] = 48] = \"_0\";\n CharacterCodes[CharacterCodes[\"_1\"] = 49] = \"_1\";\n CharacterCodes[CharacterCodes[\"_2\"] = 50] = \"_2\";\n CharacterCodes[CharacterCodes[\"_3\"] = 51] = \"_3\";\n CharacterCodes[CharacterCodes[\"_4\"] = 52] = \"_4\";\n CharacterCodes[CharacterCodes[\"_5\"] = 53] = \"_5\";\n CharacterCodes[CharacterCodes[\"_6\"] = 54] = \"_6\";\n CharacterCodes[CharacterCodes[\"_7\"] = 55] = \"_7\";\n CharacterCodes[CharacterCodes[\"_8\"] = 56] = \"_8\";\n CharacterCodes[CharacterCodes[\"_9\"] = 57] = \"_9\";\n CharacterCodes[CharacterCodes[\"a\"] = 97] = \"a\";\n CharacterCodes[CharacterCodes[\"b\"] = 98] = \"b\";\n CharacterCodes[CharacterCodes[\"c\"] = 99] = \"c\";\n CharacterCodes[CharacterCodes[\"d\"] = 100] = \"d\";\n CharacterCodes[CharacterCodes[\"e\"] = 101] = \"e\";\n CharacterCodes[CharacterCodes[\"f\"] = 102] = \"f\";\n CharacterCodes[CharacterCodes[\"g\"] = 103] = \"g\";\n CharacterCodes[CharacterCodes[\"h\"] = 104] = \"h\";\n CharacterCodes[CharacterCodes[\"i\"] = 105] = \"i\";\n CharacterCodes[CharacterCodes[\"j\"] = 106] = \"j\";\n CharacterCodes[CharacterCodes[\"k\"] = 107] = \"k\";\n CharacterCodes[CharacterCodes[\"l\"] = 108] = \"l\";\n CharacterCodes[CharacterCodes[\"m\"] = 109] = \"m\";\n CharacterCodes[CharacterCodes[\"n\"] = 110] = \"n\";\n CharacterCodes[CharacterCodes[\"o\"] = 111] = \"o\";\n CharacterCodes[CharacterCodes[\"p\"] = 112] = \"p\";\n CharacterCodes[CharacterCodes[\"q\"] = 113] = \"q\";\n CharacterCodes[CharacterCodes[\"r\"] = 114] = \"r\";\n CharacterCodes[CharacterCodes[\"s\"] = 115] = \"s\";\n CharacterCodes[CharacterCodes[\"t\"] = 116] = \"t\";\n CharacterCodes[CharacterCodes[\"u\"] = 117] = \"u\";\n CharacterCodes[CharacterCodes[\"v\"] = 118] = \"v\";\n CharacterCodes[CharacterCodes[\"w\"] = 119] = \"w\";\n CharacterCodes[CharacterCodes[\"x\"] = 120] = \"x\";\n CharacterCodes[CharacterCodes[\"y\"] = 121] = \"y\";\n CharacterCodes[CharacterCodes[\"z\"] = 122] = \"z\";\n CharacterCodes[CharacterCodes[\"A\"] = 65] = \"A\";\n CharacterCodes[CharacterCodes[\"B\"] = 66] = \"B\";\n CharacterCodes[CharacterCodes[\"C\"] = 67] = \"C\";\n CharacterCodes[CharacterCodes[\"D\"] = 68] = \"D\";\n CharacterCodes[CharacterCodes[\"E\"] = 69] = \"E\";\n CharacterCodes[CharacterCodes[\"F\"] = 70] = \"F\";\n CharacterCodes[CharacterCodes[\"G\"] = 71] = \"G\";\n CharacterCodes[CharacterCodes[\"H\"] = 72] = \"H\";\n CharacterCodes[CharacterCodes[\"I\"] = 73] = \"I\";\n CharacterCodes[CharacterCodes[\"J\"] = 74] = \"J\";\n CharacterCodes[CharacterCodes[\"K\"] = 75] = \"K\";\n CharacterCodes[CharacterCodes[\"L\"] = 76] = \"L\";\n CharacterCodes[CharacterCodes[\"M\"] = 77] = \"M\";\n CharacterCodes[CharacterCodes[\"N\"] = 78] = \"N\";\n CharacterCodes[CharacterCodes[\"O\"] = 79] = \"O\";\n CharacterCodes[CharacterCodes[\"P\"] = 80] = \"P\";\n CharacterCodes[CharacterCodes[\"Q\"] = 81] = \"Q\";\n CharacterCodes[CharacterCodes[\"R\"] = 82] = \"R\";\n CharacterCodes[CharacterCodes[\"S\"] = 83] = \"S\";\n CharacterCodes[CharacterCodes[\"T\"] = 84] = \"T\";\n CharacterCodes[CharacterCodes[\"U\"] = 85] = \"U\";\n CharacterCodes[CharacterCodes[\"V\"] = 86] = \"V\";\n CharacterCodes[CharacterCodes[\"W\"] = 87] = \"W\";\n CharacterCodes[CharacterCodes[\"X\"] = 88] = \"X\";\n CharacterCodes[CharacterCodes[\"Y\"] = 89] = \"Y\";\n CharacterCodes[CharacterCodes[\"Z\"] = 90] = \"Z\";\n CharacterCodes[CharacterCodes[\"asterisk\"] = 42] = \"asterisk\";\n CharacterCodes[CharacterCodes[\"backslash\"] = 92] = \"backslash\";\n CharacterCodes[CharacterCodes[\"closeBrace\"] = 125] = \"closeBrace\";\n CharacterCodes[CharacterCodes[\"closeBracket\"] = 93] = \"closeBracket\";\n CharacterCodes[CharacterCodes[\"colon\"] = 58] = \"colon\";\n CharacterCodes[CharacterCodes[\"comma\"] = 44] = \"comma\";\n CharacterCodes[CharacterCodes[\"dot\"] = 46] = \"dot\";\n CharacterCodes[CharacterCodes[\"doubleQuote\"] = 34] = \"doubleQuote\";\n CharacterCodes[CharacterCodes[\"minus\"] = 45] = \"minus\";\n CharacterCodes[CharacterCodes[\"openBrace\"] = 123] = \"openBrace\";\n CharacterCodes[CharacterCodes[\"openBracket\"] = 91] = \"openBracket\";\n CharacterCodes[CharacterCodes[\"plus\"] = 43] = \"plus\";\n CharacterCodes[CharacterCodes[\"slash\"] = 47] = \"slash\";\n CharacterCodes[CharacterCodes[\"formFeed\"] = 12] = \"formFeed\";\n CharacterCodes[CharacterCodes[\"tab\"] = 9] = \"tab\";\n})(CharacterCodes || (CharacterCodes = {}));\n","export const cachedSpaces = new Array(20).fill(0).map((_, index) => {\n return ' '.repeat(index);\n});\nconst maxCachedValues = 200;\nexport const cachedBreakLinesWithSpaces = {\n ' ': {\n '\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\n' + ' '.repeat(index);\n }),\n '\\r': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r' + ' '.repeat(index);\n }),\n '\\r\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r\\n' + ' '.repeat(index);\n }),\n },\n '\\t': {\n '\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\n' + '\\t'.repeat(index);\n }),\n '\\r': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r' + '\\t'.repeat(index);\n }),\n '\\r\\n': new Array(maxCachedValues).fill(0).map((_, index) => {\n return '\\r\\n' + '\\t'.repeat(index);\n }),\n }\n};\nexport const supportedEols = ['\\n', '\\r', '\\r\\n'];\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\nimport { createScanner } from './scanner';\nvar ParseOptions;\n(function (ParseOptions) {\n ParseOptions.DEFAULT = {\n allowTrailingComma: false\n };\n})(ParseOptions || (ParseOptions = {}));\n/**\n * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.\n */\nexport function getLocation(text, position) {\n const segments = []; // strings or numbers\n const earlyReturnException = new Object();\n let previousNode = undefined;\n const previousNodeInst = {\n value: {},\n offset: 0,\n length: 0,\n type: 'object',\n parent: undefined\n };\n let isAtPropertyKey = false;\n function setPreviousNode(value, offset, length, type) {\n previousNodeInst.value = value;\n previousNodeInst.offset = offset;\n previousNodeInst.length = length;\n previousNodeInst.type = type;\n previousNodeInst.colonOffset = undefined;\n previousNode = previousNodeInst;\n }\n try {\n visit(text, {\n onObjectBegin: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n isAtPropertyKey = position > offset;\n segments.push(''); // push a placeholder (will be replaced)\n },\n onObjectProperty: (name, offset, length) => {\n if (position < offset) {\n throw earlyReturnException;\n }\n setPreviousNode(name, offset, length, 'property');\n segments[segments.length - 1] = name;\n if (position <= offset + length) {\n throw earlyReturnException;\n }\n },\n onObjectEnd: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.pop();\n },\n onArrayBegin: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.push(0);\n },\n onArrayEnd: (offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n previousNode = undefined;\n segments.pop();\n },\n onLiteralValue: (value, offset, length) => {\n if (position < offset) {\n throw earlyReturnException;\n }\n setPreviousNode(value, offset, length, getNodeType(value));\n if (position <= offset + length) {\n throw earlyReturnException;\n }\n },\n onSeparator: (sep, offset, length) => {\n if (position <= offset) {\n throw earlyReturnException;\n }\n if (sep === ':' && previousNode && previousNode.type === 'property') {\n previousNode.colonOffset = offset;\n isAtPropertyKey = false;\n previousNode = undefined;\n }\n else if (sep === ',') {\n const last = segments[segments.length - 1];\n if (typeof last === 'number') {\n segments[segments.length - 1] = last + 1;\n }\n else {\n isAtPropertyKey = true;\n segments[segments.length - 1] = '';\n }\n previousNode = undefined;\n }\n }\n });\n }\n catch (e) {\n if (e !== earlyReturnException) {\n throw e;\n }\n }\n return {\n path: segments,\n previousNode,\n isAtPropertyKey,\n matches: (pattern) => {\n let k = 0;\n for (let i = 0; k < pattern.length && i < segments.length; i++) {\n if (pattern[k] === segments[i] || pattern[k] === '*') {\n k++;\n }\n else if (pattern[k] !== '**') {\n return false;\n }\n }\n return k === pattern.length;\n }\n };\n}\n/**\n * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n * Therefore always check the errors list to find out if the input was valid.\n */\nexport function parse(text, errors = [], options = ParseOptions.DEFAULT) {\n let currentProperty = null;\n let currentParent = [];\n const previousParents = [];\n function onValue(value) {\n if (Array.isArray(currentParent)) {\n currentParent.push(value);\n }\n else if (currentProperty !== null) {\n currentParent[currentProperty] = value;\n }\n }\n const visitor = {\n onObjectBegin: () => {\n const object = {};\n onValue(object);\n previousParents.push(currentParent);\n currentParent = object;\n currentProperty = null;\n },\n onObjectProperty: (name) => {\n currentProperty = name;\n },\n onObjectEnd: () => {\n currentParent = previousParents.pop();\n },\n onArrayBegin: () => {\n const array = [];\n onValue(array);\n previousParents.push(currentParent);\n currentParent = array;\n currentProperty = null;\n },\n onArrayEnd: () => {\n currentParent = previousParents.pop();\n },\n onLiteralValue: onValue,\n onError: (error, offset, length) => {\n errors.push({ error, offset, length });\n }\n };\n visit(text, visitor, options);\n return currentParent[0];\n}\n/**\n * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n */\nexport function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {\n let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root\n function ensurePropertyComplete(endOffset) {\n if (currentParent.type === 'property') {\n currentParent.length = endOffset - currentParent.offset;\n currentParent = currentParent.parent;\n }\n }\n function onValue(valueNode) {\n currentParent.children.push(valueNode);\n return valueNode;\n }\n const visitor = {\n onObjectBegin: (offset) => {\n currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });\n },\n onObjectProperty: (name, offset, length) => {\n currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });\n currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });\n },\n onObjectEnd: (offset, length) => {\n ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete\n currentParent.length = offset + length - currentParent.offset;\n currentParent = currentParent.parent;\n ensurePropertyComplete(offset + length);\n },\n onArrayBegin: (offset, length) => {\n currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });\n },\n onArrayEnd: (offset, length) => {\n currentParent.length = offset + length - currentParent.offset;\n currentParent = currentParent.parent;\n ensurePropertyComplete(offset + length);\n },\n onLiteralValue: (value, offset, length) => {\n onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });\n ensurePropertyComplete(offset + length);\n },\n onSeparator: (sep, offset, length) => {\n if (currentParent.type === 'property') {\n if (sep === ':') {\n currentParent.colonOffset = offset;\n }\n else if (sep === ',') {\n ensurePropertyComplete(offset);\n }\n }\n },\n onError: (error, offset, length) => {\n errors.push({ error, offset, length });\n }\n };\n visit(text, visitor, options);\n const result = currentParent.children[0];\n if (result) {\n delete result.parent;\n }\n return result;\n}\n/**\n * Finds the node at the given path in a JSON DOM.\n */\nexport function findNodeAtLocation(root, path) {\n if (!root) {\n return undefined;\n }\n let node = root;\n for (let segment of path) {\n if (typeof segment === 'string') {\n if (node.type !== 'object' || !Array.isArray(node.children)) {\n return undefined;\n }\n let found = false;\n for (const propertyNode of node.children) {\n if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {\n node = propertyNode.children[1];\n found = true;\n break;\n }\n }\n if (!found) {\n return undefined;\n }\n }\n else {\n const index = segment;\n if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {\n return undefined;\n }\n node = node.children[index];\n }\n }\n return node;\n}\n/**\n * Gets the JSON path of the given JSON DOM node\n */\nexport function getNodePath(node) {\n if (!node.parent || !node.parent.children) {\n return [];\n }\n const path = getNodePath(node.parent);\n if (node.parent.type === 'property') {\n const key = node.parent.children[0].value;\n path.push(key);\n }\n else if (node.parent.type === 'array') {\n const index = node.parent.children.indexOf(node);\n if (index !== -1) {\n path.push(index);\n }\n }\n return path;\n}\n/**\n * Evaluates the JavaScript object of the given JSON DOM node\n */\nexport function getNodeValue(node) {\n switch (node.type) {\n case 'array':\n return node.children.map(getNodeValue);\n case 'object':\n const obj = Object.create(null);\n for (let prop of node.children) {\n const valueNode = prop.children[1];\n if (valueNode) {\n obj[prop.children[0].value] = getNodeValue(valueNode);\n }\n }\n return obj;\n case 'null':\n case 'string':\n case 'number':\n case 'boolean':\n return node.value;\n default:\n return undefined;\n }\n}\nexport function contains(node, offset, includeRightBound = false) {\n return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));\n}\n/**\n * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.\n */\nexport function findNodeAtOffset(node, offset, includeRightBound = false) {\n if (contains(node, offset, includeRightBound)) {\n const children = node.children;\n if (Array.isArray(children)) {\n for (let i = 0; i < children.length && children[i].offset <= offset; i++) {\n const item = findNodeAtOffset(children[i], offset, includeRightBound);\n if (item) {\n return item;\n }\n }\n }\n return node;\n }\n return undefined;\n}\n/**\n * Parses the given text and invokes the visitor functions for each object, array and literal reached.\n */\nexport function visit(text, visitor, options = ParseOptions.DEFAULT) {\n const _scanner = createScanner(text, false);\n // Important: Only pass copies of this to visitor functions to prevent accidental modification, and\n // to not affect visitor functions which stored a reference to a previous JSONPath\n const _jsonPath = [];\n // Depth of onXXXBegin() callbacks suppressed. onXXXEnd() decrements this if it isn't 0 already.\n // Callbacks are only called when this value is 0.\n let suppressedCallbacks = 0;\n function toNoArgVisit(visitFunction) {\n return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;\n }\n function toOneArgVisit(visitFunction) {\n return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;\n }\n function toOneArgVisitWithPath(visitFunction) {\n return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;\n }\n function toBeginVisit(visitFunction) {\n return visitFunction ?\n () => {\n if (suppressedCallbacks > 0) {\n suppressedCallbacks++;\n }\n else {\n let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());\n if (cbReturn === false) {\n suppressedCallbacks = 1;\n }\n }\n }\n : () => true;\n }\n function toEndVisit(visitFunction) {\n return visitFunction ?\n () => {\n if (suppressedCallbacks > 0) {\n suppressedCallbacks--;\n }\n if (suppressedCallbacks === 0) {\n visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());\n }\n }\n : () => true;\n }\n const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);\n const disallowComments = options && options.disallowComments;\n const allowTrailingComma = options && options.allowTrailingComma;\n function scanNext() {\n while (true) {\n const token = _scanner.scan();\n switch (_scanner.getTokenError()) {\n case 4 /* ScanError.InvalidUnicode */:\n handleError(14 /* ParseErrorCode.InvalidUnicode */);\n break;\n case 5 /* ScanError.InvalidEscapeCharacter */:\n handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);\n break;\n case 3 /* ScanError.UnexpectedEndOfNumber */:\n handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);\n break;\n case 1 /* ScanError.UnexpectedEndOfComment */:\n if (!disallowComments) {\n handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);\n }\n break;\n case 2 /* ScanError.UnexpectedEndOfString */:\n handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);\n break;\n case 6 /* ScanError.InvalidCharacter */:\n handleError(16 /* ParseErrorCode.InvalidCharacter */);\n break;\n }\n switch (token) {\n case 12 /* SyntaxKind.LineCommentTrivia */:\n case 13 /* SyntaxKind.BlockCommentTrivia */:\n if (disallowComments) {\n handleError(10 /* ParseErrorCode.InvalidCommentToken */);\n }\n else {\n onComment();\n }\n break;\n case 16 /* SyntaxKind.Unknown */:\n handleError(1 /* ParseErrorCode.InvalidSymbol */);\n break;\n case 15 /* SyntaxKind.Trivia */:\n case 14 /* SyntaxKind.LineBreakTrivia */:\n break;\n default:\n return token;\n }\n }\n }\n function handleError(error, skipUntilAfter = [], skipUntil = []) {\n onError(error);\n if (skipUntilAfter.length + skipUntil.length > 0) {\n let token = _scanner.getToken();\n while (token !== 17 /* SyntaxKind.EOF */) {\n if (skipUntilAfter.indexOf(token) !== -1) {\n scanNext();\n break;\n }\n else if (skipUntil.indexOf(token) !== -1) {\n break;\n }\n token = scanNext();\n }\n }\n }\n function parseString(isValue) {\n const value = _scanner.getTokenValue();\n if (isValue) {\n onLiteralValue(value);\n }\n else {\n onObjectProperty(value);\n // add property name afterwards\n _jsonPath.push(value);\n }\n scanNext();\n return true;\n }\n function parseLiteral() {\n switch (_scanner.getToken()) {\n case 11 /* SyntaxKind.NumericLiteral */:\n const tokenValue = _scanner.getTokenValue();\n let value = Number(tokenValue);\n if (isNaN(value)) {\n handleError(2 /* ParseErrorCode.InvalidNumberFormat */);\n value = 0;\n }\n onLiteralValue(value);\n break;\n case 7 /* SyntaxKind.NullKeyword */:\n onLiteralValue(null);\n break;\n case 8 /* SyntaxKind.TrueKeyword */:\n onLiteralValue(true);\n break;\n case 9 /* SyntaxKind.FalseKeyword */:\n onLiteralValue(false);\n break;\n default:\n return false;\n }\n scanNext();\n return true;\n }\n function parseProperty() {\n if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {\n handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n return false;\n }\n parseString(false);\n if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {\n onSeparator(':');\n scanNext(); // consume colon\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n }\n else {\n handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n _jsonPath.pop(); // remove processed property name\n return true;\n }\n function parseObject() {\n onObjectBegin();\n scanNext(); // consume open brace\n let needsComma = false;\n while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {\n if (!needsComma) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n }\n onSeparator(',');\n scanNext(); // consume comma\n if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {\n break;\n }\n }\n else if (needsComma) {\n handleError(6 /* ParseErrorCode.CommaExpected */, [], []);\n }\n if (!parseProperty()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n needsComma = true;\n }\n onObjectEnd();\n if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {\n handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);\n }\n else {\n scanNext(); // consume close brace\n }\n return true;\n }\n function parseArray() {\n onArrayBegin();\n scanNext(); // consume open bracket\n let isFirstElement = true;\n let needsComma = false;\n while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {\n if (!needsComma) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n }\n onSeparator(',');\n scanNext(); // consume comma\n if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {\n break;\n }\n }\n else if (needsComma) {\n handleError(6 /* ParseErrorCode.CommaExpected */, [], []);\n }\n if (isFirstElement) {\n _jsonPath.push(0);\n isFirstElement = false;\n }\n else {\n _jsonPath[_jsonPath.length - 1]++;\n }\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);\n }\n needsComma = true;\n }\n onArrayEnd();\n if (!isFirstElement) {\n _jsonPath.pop(); // remove array index\n }\n if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {\n handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);\n }\n else {\n scanNext(); // consume close bracket\n }\n return true;\n }\n function parseValue() {\n switch (_scanner.getToken()) {\n case 3 /* SyntaxKind.OpenBracketToken */:\n return parseArray();\n case 1 /* SyntaxKind.OpenBraceToken */:\n return parseObject();\n case 10 /* SyntaxKind.StringLiteral */:\n return parseString(true);\n default:\n return parseLiteral();\n }\n }\n scanNext();\n if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {\n if (options.allowEmptyContent) {\n return true;\n }\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n return false;\n }\n if (!parseValue()) {\n handleError(4 /* ParseErrorCode.ValueExpected */, [], []);\n return false;\n }\n if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {\n handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);\n }\n return true;\n}\n/**\n * Takes JSON with JavaScript-style comments and remove\n * them. Optionally replaces every none-newline character\n * of comments with a replaceCharacter\n */\nexport function stripComments(text, replaceCh) {\n let _scanner = createScanner(text), parts = [], kind, offset = 0, pos;\n do {\n pos = _scanner.getPosition();\n kind = _scanner.scan();\n switch (kind) {\n case 12 /* SyntaxKind.LineCommentTrivia */:\n case 13 /* SyntaxKind.BlockCommentTrivia */:\n case 17 /* SyntaxKind.EOF */:\n if (offset !== pos) {\n parts.push(text.substring(offset, pos));\n }\n if (replaceCh !== undefined) {\n parts.push(_scanner.getTokenValue().replace(/[^\\r\\n]/g, replaceCh));\n }\n offset = _scanner.getPosition();\n break;\n }\n } while (kind !== 17 /* SyntaxKind.EOF */);\n return parts.join('');\n}\nexport function getNodeType(value) {\n switch (typeof value) {\n case 'boolean': return 'boolean';\n case 'number': return 'number';\n case 'string': return 'string';\n case 'object': {\n if (!value) {\n return 'null';\n }\n else if (Array.isArray(value)) {\n return 'array';\n }\n return 'object';\n }\n default: return 'null';\n }\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n'use strict';\nimport * as formatter from './impl/format';\nimport * as edit from './impl/edit';\nimport * as scanner from './impl/scanner';\nimport * as parser from './impl/parser';\n/**\n * Creates a JSON scanner on the given text.\n * If ignoreTrivia is set, whitespaces or comments are ignored.\n */\nexport const createScanner = scanner.createScanner;\nexport var ScanError;\n(function (ScanError) {\n ScanError[ScanError[\"None\"] = 0] = \"None\";\n ScanError[ScanError[\"UnexpectedEndOfComment\"] = 1] = \"UnexpectedEndOfComment\";\n ScanError[ScanError[\"UnexpectedEndOfString\"] = 2] = \"UnexpectedEndOfString\";\n ScanError[ScanError[\"UnexpectedEndOfNumber\"] = 3] = \"UnexpectedEndOfNumber\";\n ScanError[ScanError[\"InvalidUnicode\"] = 4] = \"InvalidUnicode\";\n ScanError[ScanError[\"InvalidEscapeCharacter\"] = 5] = \"InvalidEscapeCharacter\";\n ScanError[ScanError[\"InvalidCharacter\"] = 6] = \"InvalidCharacter\";\n})(ScanError || (ScanError = {}));\nexport var SyntaxKind;\n(function (SyntaxKind) {\n SyntaxKind[SyntaxKind[\"OpenBraceToken\"] = 1] = \"OpenBraceToken\";\n SyntaxKind[SyntaxKind[\"CloseBraceToken\"] = 2] = \"CloseBraceToken\";\n SyntaxKind[SyntaxKind[\"OpenBracketToken\"] = 3] = \"OpenBracketToken\";\n SyntaxKind[SyntaxKind[\"CloseBracketToken\"] = 4] = \"CloseBracketToken\";\n SyntaxKind[SyntaxKind[\"CommaToken\"] = 5] = \"CommaToken\";\n SyntaxKind[SyntaxKind[\"ColonToken\"] = 6] = \"ColonToken\";\n SyntaxKind[SyntaxKind[\"NullKeyword\"] = 7] = \"NullKeyword\";\n SyntaxKind[SyntaxKind[\"TrueKeyword\"] = 8] = \"TrueKeyword\";\n SyntaxKind[SyntaxKind[\"FalseKeyword\"] = 9] = \"FalseKeyword\";\n SyntaxKind[SyntaxKind[\"StringLiteral\"] = 10] = \"StringLiteral\";\n SyntaxKind[SyntaxKind[\"NumericLiteral\"] = 11] = \"NumericLiteral\";\n SyntaxKind[SyntaxKind[\"LineCommentTrivia\"] = 12] = \"LineCommentTrivia\";\n SyntaxKind[SyntaxKind[\"BlockCommentTrivia\"] = 13] = \"BlockCommentTrivia\";\n SyntaxKind[SyntaxKind[\"LineBreakTrivia\"] = 14] = \"LineBreakTrivia\";\n SyntaxKind[SyntaxKind[\"Trivia\"] = 15] = \"Trivia\";\n SyntaxKind[SyntaxKind[\"Unknown\"] = 16] = \"Unknown\";\n SyntaxKind[SyntaxKind[\"EOF\"] = 17] = \"EOF\";\n})(SyntaxKind || (SyntaxKind = {}));\n/**\n * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.\n */\nexport const getLocation = parser.getLocation;\n/**\n * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n * Therefore, always check the errors list to find out if the input was valid.\n */\nexport const parse = parser.parse;\n/**\n * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n */\nexport const parseTree = parser.parseTree;\n/**\n * Finds the node at the given path in a JSON DOM.\n */\nexport const findNodeAtLocation = parser.findNodeAtLocation;\n/**\n * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.\n */\nexport const findNodeAtOffset = parser.findNodeAtOffset;\n/**\n * Gets the JSON path of the given JSON DOM node\n */\nexport const getNodePath = parser.getNodePath;\n/**\n * Evaluates the JavaScript object of the given JSON DOM node\n */\nexport const getNodeValue = parser.getNodeValue;\n/**\n * Parses the given text and invokes the visitor functions for each object, array and literal reached.\n */\nexport const visit = parser.visit;\n/**\n * Takes JSON with JavaScript-style comments and remove\n * them. Optionally replaces every none-newline character\n * of comments with a replaceCharacter\n */\nexport const stripComments = parser.stripComments;\nexport var ParseErrorCode;\n(function (ParseErrorCode) {\n ParseErrorCode[ParseErrorCode[\"InvalidSymbol\"] = 1] = \"InvalidSymbol\";\n ParseErrorCode[ParseErrorCode[\"InvalidNumberFormat\"] = 2] = \"InvalidNumberFormat\";\n ParseErrorCode[ParseErrorCode[\"PropertyNameExpected\"] = 3] = \"PropertyNameExpected\";\n ParseErrorCode[ParseErrorCode[\"ValueExpected\"] = 4] = \"ValueExpected\";\n ParseErrorCode[ParseErrorCode[\"ColonExpected\"] = 5] = \"ColonExpected\";\n ParseErrorCode[ParseErrorCode[\"CommaExpected\"] = 6] = \"CommaExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBraceExpected\"] = 7] = \"CloseBraceExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBracketExpected\"] = 8] = \"CloseBracketExpected\";\n ParseErrorCode[ParseErrorCode[\"EndOfFileExpected\"] = 9] = \"EndOfFileExpected\";\n ParseErrorCode[ParseErrorCode[\"InvalidCommentToken\"] = 10] = \"InvalidCommentToken\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfComment\"] = 11] = \"UnexpectedEndOfComment\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfString\"] = 12] = \"UnexpectedEndOfString\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfNumber\"] = 13] = \"UnexpectedEndOfNumber\";\n ParseErrorCode[ParseErrorCode[\"InvalidUnicode\"] = 14] = \"InvalidUnicode\";\n ParseErrorCode[ParseErrorCode[\"InvalidEscapeCharacter\"] = 15] = \"InvalidEscapeCharacter\";\n ParseErrorCode[ParseErrorCode[\"InvalidCharacter\"] = 16] = \"InvalidCharacter\";\n})(ParseErrorCode || (ParseErrorCode = {}));\nexport function printParseErrorCode(code) {\n switch (code) {\n case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';\n case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';\n case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';\n case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';\n case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';\n case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';\n case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';\n case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';\n case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';\n case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';\n case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';\n case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';\n case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';\n case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';\n case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';\n case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';\n }\n return '<unknown ParseErrorCode>';\n}\n/**\n * Computes the edit operations needed to format a JSON document.\n *\n * @param documentText The input text\n * @param range The range to format or `undefined` to format the full content\n * @param options The formatting options\n * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\nexport function format(documentText, range, options) {\n return formatter.format(documentText, range, options);\n}\n/**\n * Computes the edit operations needed to modify a value in the JSON document.\n *\n * @param documentText The input text\n * @param path The path of the value to change. The path represents either to the document root, a property or an array item.\n * If the path points to an non-existing property or item, it will be created.\n * @param value The new value for the specified property or item. If the value is undefined,\n * the property or item will be removed.\n * @param options Options\n * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\nexport function modify(text, path, value, options) {\n return edit.setProperty(text, path, value, options);\n}\n/**\n * Applies edits to an input string.\n * @param text The input text\n * @param edits Edit operations following the format described in {@linkcode EditResult}.\n * @returns The text with the applied edits.\n * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.\n */\nexport function applyEdits(text, edits) {\n let sortedEdits = edits.slice(0).sort((a, b) => {\n const diff = a.offset - b.offset;\n if (diff === 0) {\n return a.length - b.length;\n }\n return diff;\n });\n let lastModifiedOffset = text.length;\n for (let i = sortedEdits.length - 1; i >= 0; i--) {\n let e = sortedEdits[i];\n if (e.offset + e.length <= lastModifiedOffset) {\n text = edit.applyEdit(text, e);\n }\n else {\n throw new Error('Overlapping edit');\n }\n lastModifiedOffset = e.offset;\n }\n return text;\n}\n","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n","import isEqual from \"fast-deep-equal\";\nimport sortKeys from \"sort-keys\";\n\n/**\n * Get value at a path in an object\n * Supports JSON Pointer format: \"/path/to/value\" or \"/array/0/item\"\n */\nexport const getValueAtPath = <T = unknown>(obj: Record<string, unknown> | undefined, path: string): T | undefined => {\n\tif (!obj) return undefined;\n\n\t// Normalize path to array of keys\n\tconst normalizedPath = path\n\t\t.replace(/^\\//, \"\") // remove leading slash\n\t\t.replace(/\\[/g, \".\") // convert [0] to .0\n\t\t.replace(/\\]/g, \"\") // remove ]\n\t\t.split(/[./#]/) // split by dot, slash, or hash\n\t\t.filter(Boolean); // remove empty strings\n\n\tlet current: unknown = obj;\n\n\tfor (const key of normalizedPath) {\n\t\tif (!current || typeof current !== \"object\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Handle arrays with numeric indices\n\t\tif (Array.isArray(current)) {\n\t\t\tconst index = Number.parseInt(key, 10);\n\t\t\tif (Number.isNaN(index) || index < 0 || index >= current.length) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tcurrent = current[index];\n\t\t}\n\t\t// Handle objects\n\t\telse if (key in current) {\n\t\t\tcurrent = (current as Record<string, unknown>)[key];\n\t\t}\n\t\t// Property doesn't exist\n\t\telse {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn current as T;\n};\n\nexport { isEqual, sortKeys };\n","/*!\n * https://github.com/Starcounter-Jack/JSON-Patch\n * (c) 2017-2022 Joachim Wester\n * MIT licensed\n */\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar _hasOwnProperty = Object.prototype.hasOwnProperty;\nexport function hasOwnProperty(obj, key) {\n return _hasOwnProperty.call(obj, key);\n}\nexport function _objectKeys(obj) {\n if (Array.isArray(obj)) {\n var keys_1 = new Array(obj.length);\n for (var k = 0; k < keys_1.length; k++) {\n keys_1[k] = \"\" + k;\n }\n return keys_1;\n }\n if (Object.keys) {\n return Object.keys(obj);\n }\n var keys = [];\n for (var i in obj) {\n if (hasOwnProperty(obj, i)) {\n keys.push(i);\n }\n }\n return keys;\n}\n;\n/**\n* Deeply clone the object.\n* https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)\n* @param {any} obj value to clone\n* @return {any} cloned obj\n*/\nexport function _deepClone(obj) {\n switch (typeof obj) {\n case \"object\":\n return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5\n case \"undefined\":\n return null; //this is how JSON.stringify behaves for array items\n default:\n return obj; //no need to clone primitives\n }\n}\n//3x faster than cached /^\\d+$/.test(str)\nexport function isInteger(str) {\n var i = 0;\n var len = str.length;\n var charCode;\n while (i < len) {\n charCode = str.charCodeAt(i);\n if (charCode >= 48 && charCode <= 57) {\n i++;\n continue;\n }\n return false;\n }\n return true;\n}\n/**\n* Escapes a json pointer path\n* @param path The raw pointer\n* @return the Escaped path\n*/\nexport function escapePathComponent(path) {\n if (path.indexOf('/') === -1 && path.indexOf('~') === -1)\n return path;\n return path.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n/**\n * Unescapes a json pointer path\n * @param path The escaped pointer\n * @return The unescaped path\n */\nexport function unescapePathComponent(path) {\n return path.replace(/~1/g, '/').replace(/~0/g, '~');\n}\nexport function _getPathRecursive(root, obj) {\n var found;\n for (var key in root) {\n if (hasOwnProperty(root, key)) {\n if (root[key] === obj) {\n return escapePathComponent(key) + '/';\n }\n else if (typeof root[key] === 'object') {\n found = _getPathRecursive(root[key], obj);\n if (found != '') {\n return escapePathComponent(key) + '/' + found;\n }\n }\n }\n }\n return '';\n}\nexport function getPath(root, obj) {\n if (root === obj) {\n return '/';\n }\n var path = _getPathRecursive(root, obj);\n if (path === '') {\n throw new Error(\"Object not found in root\");\n }\n return \"/\" + path;\n}\n/**\n* Recursively checks whether an object has any undefined values inside.\n*/\nexport function hasUndefined(obj) {\n if (obj === undefined) {\n return true;\n }\n if (obj) {\n if (Array.isArray(obj)) {\n for (var i_1 = 0, len = obj.length; i_1 < len; i_1++) {\n if (hasUndefined(obj[i_1])) {\n return true;\n }\n }\n }\n else if (typeof obj === \"object\") {\n var objKeys = _objectKeys(obj);\n var objKeysLength = objKeys.length;\n for (var i = 0; i < objKeysLength; i++) {\n if (hasUndefined(obj[objKeys[i]])) {\n return true;\n }\n }\n }\n }\n return false;\n}\nfunction patchErrorMessageFormatter(message, args) {\n var messageParts = [message];\n for (var key in args) {\n var value = typeof args[key] === 'object' ? JSON.stringify(args[key], null, 2) : args[key]; // pretty print\n if (typeof value !== 'undefined') {\n messageParts.push(key + \": \" + value);\n }\n }\n return messageParts.join('\\n');\n}\nvar PatchError = /** @class */ (function (_super) {\n __extends(PatchError, _super);\n function PatchError(message, name, index, operation, tree) {\n var _newTarget = this.constructor;\n var _this = _super.call(this, patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree })) || this;\n _this.name = name;\n _this.index = index;\n _this.operation = operation;\n _this.tree = tree;\n Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain, see https://stackoverflow.com/a/48342359\n _this.message = patchErrorMessageFormatter(message, { name: name, index: index, operation: operation, tree: tree });\n return _this;\n }\n return PatchError;\n}(Error));\nexport { PatchError };\n","import { PatchError, _deepClone, isInteger, unescapePathComponent, hasUndefined } from './helpers.mjs';\nexport var JsonPatchError = PatchError;\nexport var deepClone = _deepClone;\n/* We use a Javascript hash to store each\n function. Each hash entry (property) uses\n the operation identifiers specified in rfc6902.\n In this way, we can map each patch operation\n to its dedicated function in efficient way.\n */\n/* The operations applicable to an object */\nvar objOps = {\n add: function (obj, key, document) {\n obj[key] = this.value;\n return { newDocument: document };\n },\n remove: function (obj, key, document) {\n var removed = obj[key];\n delete obj[key];\n return { newDocument: document, removed: removed };\n },\n replace: function (obj, key, document) {\n var removed = obj[key];\n obj[key] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: function (obj, key, document) {\n /* in case move target overwrites an existing value,\n return the removed value, this can be taxing performance-wise,\n and is potentially unneeded */\n var removed = getValueByPointer(document, this.path);\n if (removed) {\n removed = _deepClone(removed);\n }\n var originalValue = applyOperation(document, { op: \"remove\", path: this.from }).removed;\n applyOperation(document, { op: \"add\", path: this.path, value: originalValue });\n return { newDocument: document, removed: removed };\n },\n copy: function (obj, key, document) {\n var valueToCopy = getValueByPointer(document, this.from);\n // enforce copy by value so further operations don't affect source (see issue #177)\n applyOperation(document, { op: \"add\", path: this.path, value: _deepClone(valueToCopy) });\n return { newDocument: document };\n },\n test: function (obj, key, document) {\n return { newDocument: document, test: _areEquals(obj[key], this.value) };\n },\n _get: function (obj, key, document) {\n this.value = obj[key];\n return { newDocument: document };\n }\n};\n/* The operations applicable to an array. Many are the same as for the object */\nvar arrOps = {\n add: function (arr, i, document) {\n if (isInteger(i)) {\n arr.splice(i, 0, this.value);\n }\n else { // array props\n arr[i] = this.value;\n }\n // this may be needed when using '-' in an array\n return { newDocument: document, index: i };\n },\n remove: function (arr, i, document) {\n var removedList = arr.splice(i, 1);\n return { newDocument: document, removed: removedList[0] };\n },\n replace: function (arr, i, document) {\n var removed = arr[i];\n arr[i] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: objOps.move,\n copy: objOps.copy,\n test: objOps.test,\n _get: objOps._get\n};\n/**\n * Retrieves a value from a JSON document by a JSON pointer.\n * Returns the value.\n *\n * @param document The document to get the value from\n * @param pointer an escaped JSON pointer\n * @return The retrieved value\n */\nexport function getValueByPointer(document, pointer) {\n if (pointer == '') {\n return document;\n }\n var getOriginalDestination = { op: \"_get\", path: pointer };\n applyOperation(document, getOriginalDestination);\n return getOriginalDestination.value;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the {newDocument, result} of the operation.\n * It modifies the `document` and `operation` objects - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return `{newDocument, result}` after the operation\n */\nexport function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {\n if (validateOperation === void 0) { validateOperation = false; }\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (index === void 0) { index = 0; }\n if (validateOperation) {\n if (typeof validateOperation == 'function') {\n validateOperation(operation, 0, document, operation.path);\n }\n else {\n validator(operation, 0);\n }\n }\n /* ROOT OPERATIONS */\n if (operation.path === \"\") {\n var returnValue = { newDocument: document };\n if (operation.op === 'add') {\n returnValue.newDocument = operation.value;\n return returnValue;\n }\n else if (operation.op === 'replace') {\n returnValue.newDocument = operation.value;\n returnValue.removed = document; //document we removed\n return returnValue;\n }\n else if (operation.op === 'move' || operation.op === 'copy') { // it's a move or copy to root\n returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field\n if (operation.op === 'move') { // report removed item\n returnValue.removed = document;\n }\n return returnValue;\n }\n else if (operation.op === 'test') {\n returnValue.test = _areEquals(document, operation.value);\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n returnValue.newDocument = document;\n return returnValue;\n }\n else if (operation.op === 'remove') { // a remove on root\n returnValue.removed = document;\n returnValue.newDocument = null;\n return returnValue;\n }\n else if (operation.op === '_get') {\n operation.value = document;\n return returnValue;\n }\n else { /* bad operation */\n if (validateOperation) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else {\n return returnValue;\n }\n }\n } /* END ROOT OPERATIONS */\n else {\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var path = operation.path || \"\";\n var keys = path.split('/');\n var obj = document;\n var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift\n var len = keys.length;\n var existingPathFragment = undefined;\n var key = void 0;\n var validateFunction = void 0;\n if (typeof validateOperation == 'function') {\n validateFunction = validateOperation;\n }\n else {\n validateFunction = validator;\n }\n while (true) {\n key = keys[t];\n if (key && key.indexOf('~') != -1) {\n key = unescapePathComponent(key);\n }\n if (banPrototypeModifications &&\n (key == '__proto__' ||\n (key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {\n throw new TypeError('JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');\n }\n if (validateOperation) {\n if (existingPathFragment === undefined) {\n if (obj[key] === undefined) {\n existingPathFragment = keys.slice(0, t).join('/');\n }\n else if (t == len - 1) {\n existingPathFragment = operation.path;\n }\n if (existingPathFragment !== undefined) {\n validateFunction(operation, 0, document, existingPathFragment);\n }\n }\n }\n t++;\n if (Array.isArray(obj)) {\n if (key === '-') {\n key = obj.length;\n }\n else {\n if (validateOperation && !isInteger(key)) {\n throw new JsonPatchError(\"Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index\", \"OPERATION_PATH_ILLEGAL_ARRAY_INDEX\", index, operation, document);\n } // only parse key when it's an integer for `arr.prop` to work\n else if (isInteger(key)) {\n key = ~~key;\n }\n }\n if (t >= len) {\n if (validateOperation && operation.op === \"add\" && key > obj.length) {\n throw new JsonPatchError(\"The specified index MUST NOT be greater than the number of elements in the array\", \"OPERATION_VALUE_OUT_OF_BOUNDS\", index, operation, document);\n }\n var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n else {\n if (t >= len) {\n var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n obj = obj[key];\n // If we have more keys in the path, but the next value isn't a non-null object,\n // throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.\n if (validateOperation && t < len && (!obj || typeof obj !== \"object\")) {\n throw new JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Apply a full JSON Patch array on a JSON document.\n * Returns the {newDocument, result} of the patch.\n * It modifies the `document` object and `patch` - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.\n *\n * @param document The document to patch\n * @param patch The patch to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return An array of `{newDocument, result}` after the patch\n */\nexport function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (validateOperation) {\n if (!Array.isArray(patch)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n }\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var results = new Array(patch.length);\n for (var i = 0, length_1 = patch.length; i < length_1; i++) {\n // we don't need to pass mutateDocument argument because if it was true, we already deep cloned the object, we'll just pass `true`\n results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);\n document = results[i].newDocument; // in case root was replaced\n }\n results.newDocument = document;\n return results;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the updated document.\n * Suitable as a reducer.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @return The updated document\n */\nexport function applyReducer(document, operation, index) {\n var operationResult = applyOperation(document, operation);\n if (operationResult.test === false) { // failed test\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return operationResult.newDocument;\n}\n/**\n * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.\n * @param {object} operation - operation object (patch)\n * @param {number} index - index of operation in the sequence\n * @param {object} [document] - object where the operation is supposed to be applied\n * @param {string} [existingPathFragment] - comes along with `document`\n */\nexport function validator(operation, index, document, existingPathFragment) {\n if (typeof operation !== 'object' || operation === null || Array.isArray(operation)) {\n throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, document);\n }\n else if (!objOps[operation.op]) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else if (typeof operation.path !== 'string') {\n throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {\n // paths that aren't empty string should start with \"/\"\n throw new JsonPatchError('Operation `path` property must start with \"/\"', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {\n throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);\n }\n else if (document) {\n if (operation.op == \"add\") {\n var pathLen = operation.path.split(\"/\").length;\n var existingPathLen = existingPathFragment.split(\"/\").length;\n if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {\n throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, document);\n }\n }\n else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {\n if (operation.path !== existingPathFragment) {\n throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n else if (operation.op === 'move' || operation.op === 'copy') {\n var existingValue = { op: \"_get\", path: operation.from, value: undefined };\n var error = validate([existingValue], document);\n if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {\n throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.\n * If error is encountered, returns a JsonPatchError object\n * @param sequence\n * @param document\n * @returns {JsonPatchError|undefined}\n */\nexport function validate(sequence, document, externalValidator) {\n try {\n if (!Array.isArray(sequence)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n if (document) {\n //clone document and sequence so that we can safely try applying operations\n applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);\n }\n else {\n externalValidator = externalValidator || validator;\n for (var i = 0; i < sequence.length; i++) {\n externalValidator(sequence[i], i, document, undefined);\n }\n }\n }\n catch (e) {\n if (e instanceof JsonPatchError) {\n return e;\n }\n else {\n throw e;\n }\n }\n}\n// based on https://github.com/epoberezkin/fast-deep-equal\n// MIT License\n// Copyright (c) 2017 Evgeny Poberezkin\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nexport function _areEquals(a, b) {\n if (a === b)\n return true;\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length)\n return false;\n for (i = length; i-- !== 0;)\n if (!_areEquals(a[i], b[i]))\n return false;\n return true;\n }\n if (arrA != arrB)\n return false;\n var keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length)\n return false;\n for (i = length; i-- !== 0;)\n if (!b.hasOwnProperty(keys[i]))\n return false;\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!_areEquals(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a !== a && b !== b;\n}\n;\n","/*!\n * https://github.com/Starcounter-Jack/JSON-Patch\n * (c) 2017-2021 Joachim Wester\n * MIT license\n */\nimport { _deepClone, _objectKeys, escapePathComponent, hasOwnProperty } from './helpers.mjs';\nimport { applyPatch } from './core.mjs';\nvar beforeDict = new WeakMap();\nvar Mirror = /** @class */ (function () {\n function Mirror(obj) {\n this.observers = new Map();\n this.obj = obj;\n }\n return Mirror;\n}());\nvar ObserverInfo = /** @class */ (function () {\n function ObserverInfo(callback, observer) {\n this.callback = callback;\n this.observer = observer;\n }\n return ObserverInfo;\n}());\nfunction getMirror(obj) {\n return beforeDict.get(obj);\n}\nfunction getObserverFromMirror(mirror, callback) {\n return mirror.observers.get(callback);\n}\nfunction removeObserverFromMirror(mirror, observer) {\n mirror.observers.delete(observer.callback);\n}\n/**\n * Detach an observer from an object\n */\nexport function unobserve(root, observer) {\n observer.unobserve();\n}\n/**\n * Observes changes made to an object, which can then be retrieved using generate\n */\nexport function observe(obj, callback) {\n var patches = [];\n var observer;\n var mirror = getMirror(obj);\n if (!mirror) {\n mirror = new Mirror(obj);\n beforeDict.set(obj, mirror);\n }\n else {\n var observerInfo = getObserverFromMirror(mirror, callback);\n observer = observerInfo && observerInfo.observer;\n }\n if (observer) {\n return observer;\n }\n observer = {};\n mirror.value = _deepClone(obj);\n if (callback) {\n observer.callback = callback;\n observer.next = null;\n var dirtyCheck = function () {\n generate(observer);\n };\n var fastCheck = function () {\n clearTimeout(observer.next);\n observer.next = setTimeout(dirtyCheck);\n };\n if (typeof window !== 'undefined') { //not Node\n window.addEventListener('mouseup', fastCheck);\n window.addEventListener('keyup', fastCheck);\n window.addEventListener('mousedown', fastCheck);\n window.addEventListener('keydown', fastCheck);\n window.addEventListener('change', fastCheck);\n }\n }\n observer.patches = patches;\n observer.object = obj;\n observer.unobserve = function () {\n generate(observer);\n clearTimeout(observer.next);\n removeObserverFromMirror(mirror, observer);\n if (typeof window !== 'undefined') {\n window.removeEventListener('mouseup', fastCheck);\n window.removeEventListener('keyup', fastCheck);\n window.removeEventListener('mousedown', fastCheck);\n window.removeEventListener('keydown', fastCheck);\n window.removeEventListener('change', fastCheck);\n }\n };\n mirror.observers.set(callback, new ObserverInfo(callback, observer));\n return observer;\n}\n/**\n * Generate an array of patches from an observer\n */\nexport function generate(observer, invertible) {\n if (invertible === void 0) { invertible = false; }\n var mirror = beforeDict.get(observer.object);\n _generate(mirror.value, observer.object, observer.patches, \"\", invertible);\n if (observer.patches.length) {\n applyPatch(mirror.value, observer.patches);\n }\n var temp = observer.patches;\n if (temp.length > 0) {\n observer.patches = [];\n if (observer.callback) {\n observer.callback(temp);\n }\n }\n return temp;\n}\n// Dirty check if obj is different from mirror, generate patches and update mirror\nfunction _generate(mirror, obj, patches, path, invertible) {\n if (obj === mirror) {\n return;\n }\n if (typeof obj.toJSON === \"function\") {\n obj = obj.toJSON();\n }\n var newKeys = _objectKeys(obj);\n var oldKeys = _objectKeys(mirror);\n var changed = false;\n var deleted = false;\n //if ever \"move\" operation is implemented here, make sure this test runs OK: \"should not generate the same patch twice (move)\"\n for (var t = oldKeys.length - 1; t >= 0; t--) {\n var key = oldKeys[t];\n var oldVal = mirror[key];\n if (hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {\n var newVal = obj[key];\n if (typeof oldVal == \"object\" && oldVal != null && typeof newVal == \"object\" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {\n _generate(oldVal, newVal, patches, path + \"/\" + escapePathComponent(key), invertible);\n }\n else {\n if (oldVal !== newVal) {\n changed = true;\n if (invertible) {\n patches.push({ op: \"test\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(oldVal) });\n }\n patches.push({ op: \"replace\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(newVal) });\n }\n }\n }\n else if (Array.isArray(mirror) === Array.isArray(obj)) {\n if (invertible) {\n patches.push({ op: \"test\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(oldVal) });\n }\n patches.push({ op: \"remove\", path: path + \"/\" + escapePathComponent(key) });\n deleted = true; // property has been deleted\n }\n else {\n if (invertible) {\n patches.push({ op: \"test\", path: path, value: mirror });\n }\n patches.push({ op: \"replace\", path: path, value: obj });\n changed = true;\n }\n }\n if (!deleted && newKeys.length == oldKeys.length) {\n return;\n }\n for (var t = 0; t < newKeys.length; t++) {\n var key = newKeys[t];\n if (!hasOwnProperty(mirror, key) && obj[key] !== undefined) {\n patches.push({ op: \"add\", path: path + \"/\" + escapePathComponent(key), value: _deepClone(obj[key]) });\n }\n }\n}\n/**\n * Create an array of patches from the differences in two objects\n */\nexport function compare(tree1, tree2, invertible) {\n if (invertible === void 0) { invertible = false; }\n var patches = [];\n _generate(tree1, tree2, patches, '', invertible);\n return patches;\n}\n","export * from './module/core.mjs';\nexport * from './module/duplex.mjs';\nexport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\n\n/**\n * Default export for backwards compat\n */\n\nimport * as core from './module/core.mjs';\nimport * as duplex from './module/duplex.mjs';\nimport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\nexport default Object.assign({}, core, duplex, {\n JsonPatchError,\n deepClone,\n escapePathComponent,\n unescapePathComponent\n});","import type { JSONSchema } from \"../types\";\n\nconst ONE_OF = \"oneOf\";\nconst ANY_OF = \"anyOf\";\nconst ALL_OF = \"allOf\";\n\nexport function hasSchemaVariants(schema: JSONSchema): boolean {\n\treturn !!(schema[ONE_OF] || schema[ANY_OF] || schema[ALL_OF]);\n}\n\nexport function getSchemaVariants(schema: JSONSchema): JSONSchema[] | undefined {\n\tconst variants = schema[ONE_OF] || schema[ANY_OF] || schema[ALL_OF];\n\treturn Array.isArray(variants) ? (variants as JSONSchema[]) : undefined;\n}\n\nexport function getSubschemaKeyword(schema: JSONSchema): string {\n\tif (schema.oneOf) return ONE_OF;\n\tif (schema.anyOf) return ANY_OF;\n\tif (schema.allOf) return ALL_OF;\n\treturn \"\";\n}\n\n/**\n * Find common discriminator field across all variants\n * Returns the field name that has const values in variants and exists in data\n */\nfunction findCommonDiscriminatorField(variants: JSONSchema[], data: unknown): { field: string; value: unknown } | null {\n\tif (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n\t\treturn null;\n\t}\n\n\tconst obj = data as Record<string, unknown>;\n\n\t// Find fields that have const values in at least one variant\n\tconst discriminatorFields = new Set<string>();\n\n\tfor (const variant of variants) {\n\t\tconst props = variant.properties;\n\t\tif (props) {\n\t\t\tfor (const [field, propSchema] of Object.entries(props)) {\n\t\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\t\tdiscriminatorFields.add(field);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check which discriminator field exists in the data\n\tfor (const field of discriminatorFields) {\n\t\tif (field in obj) {\n\t\t\treturn { field, value: obj[field] };\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Synchronous version of chooseSubschema for use in non-async contexts\n * Enhanced to handle object discriminators and const values\n */\nexport function chooseSubschemaSync(\n\tdata: unknown,\n\tvariants: JSONSchema[],\n\t_schemaKeyword: string = ONE_OF,\n): { selectedIndex: number; schema: JSONSchema } {\n\tif (variants.length === 0) {\n\t\tthrow new Error(\"No variants provided to chooseSubschemaSync\");\n\t}\n\n\t// Handle null\n\tif (data === null) {\n\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\tconst variant = variants[i];\n\t\t\tif (variant.const === null) {\n\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t}\n\t\t}\n\t}\n\n\t// For objects, try to match by discriminator fields (const properties)\n\tif (typeof data === \"object\" && data !== null && !Array.isArray(data)) {\n\t\tconst dataObj = data as Record<string, unknown>;\n\n\t\t// First pass: look for discriminator matches\n\t\tconst discriminator = findCommonDiscriminatorField(variants, data);\n\t\tif (discriminator) {\n\t\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\t\tconst variant = variants[i];\n\t\t\t\tconst variantProp = variant.properties?.[discriminator.field] as JSONSchema | undefined;\n\n\t\t\t\tif (variantProp && typeof variantProp === \"object\" && \"const\" in variantProp && variantProp.const === discriminator.value) {\n\t\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Second pass: check if object structure matches variant properties\n\t\tfor (let i = 0; i < variants.length; i++) {\n\t\t\tconst variant = variants[i];\n\t\t\tif (variant.type === \"object\" && variant.properties) {\n\t\t\t\t// Check if all required properties exist in data\n\t\t\t\tconst required = (variant.required || []) as string[];\n\t\t\t\tconst hasAllRequired = required.every((field: string) => field in dataObj);\n\n\t\t\t\tif (hasAllRequired && required.length > 0) {\n\t\t\t\t\t// Additional check: see if discriminator fields match\n\t\t\t\t\tlet discriminatorMatches = true;\n\t\t\t\t\tfor (const [field, propSchema] of Object.entries(variant.properties)) {\n\t\t\t\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\t\t\t\tconst constValue = (propSchema as JSONSchema).const;\n\t\t\t\t\t\t\tif (dataObj[field] !== constValue) {\n\t\t\t\t\t\t\t\tdiscriminatorMatches = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (discriminatorMatches) {\n\t\t\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Match by primitive const value (prioritize const over type)\n\tfor (let i = 0; i < variants.length; i++) {\n\t\tconst variant = variants[i];\n\t\tif (variant.const !== undefined && variant.const === data) {\n\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t}\n\t}\n\n\t// Match by type (after const check)\n\tfor (let i = 0; i < variants.length; i++) {\n\t\tconst variant = variants[i];\n\t\tif (variant.type) {\n\t\t\tconst dataType = Array.isArray(data) ? \"array\" : typeof data;\n\t\t\tconst variantType = Array.isArray(variant.type) ? variant.type[0] : variant.type;\n\t\t\tif (variantType === dataType) {\n\t\t\t\treturn { selectedIndex: i, schema: variant };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Default to first variant (fallback)\n\treturn { selectedIndex: 0, schema: variants[0] };\n}\n","import { compare, type Operation as JsonPatchOperation } from \"fast-json-patch\";\nimport { findNodeAtLocation, parseTree } from \"jsonc-parser\";\nimport type { JSONSchema } from \"../types\";\nimport { ConflictType, InputState, type ModifiedBaseRange } from \"../types\";\nimport { getValueAtPath, isEqual, sortKeys } from \"./helpers\";\nimport { chooseSubschemaSync, getSchemaVariants, getSubschemaKeyword, hasSchemaVariants } from \"./schema\";\n\n/**\n * Represents a conflict analysis result for a JSON path\n */\nexport interface ConflictAnalysis {\n\tpath: string; // JSON Pointer path\n\tbaseValue: unknown;\n\tinput1Value: unknown; // Theirs value\n\tinput2Value: unknown; // Ours value\n\tconflictType: ConflictType;\n\tpatches1?: JsonPatchOperation[]; // Optional: patches from base to input1\n\tpatches2?: JsonPatchOperation[]; // Optional: patches from base to input2\n}\n\n/**\n * Format JSON with sorted keys (objects only, arrays unchanged)\n * @param json - JSON object to format\n * @returns Formatted JSON string with 2-space indentation\n */\nexport function formatJsonForComparison(json: unknown): string {\n\t// sortKeys only sorts object keys, arrays remain unchanged\n\tif (typeof json === \"object\" && json !== null && !Array.isArray(json)) {\n\t\tconst sorted = sortKeys(json as Record<string, unknown>, { deep: true });\n\t\treturn JSON.stringify(sorted, null, 2);\n\t}\n\treturn JSON.stringify(json, null, 2);\n}\n\n/**\n * Determine conflict type based on semantic comparison of values\n * @param base - Base value\n * @param input1 - Input1 (theirs) value\n * @param input2 - Input2 (ours) value\n * @returns Conflict type\n */\nexport function determineConflictType(base: unknown, input1: unknown, input2: unknown): ConflictType {\n\t// Use fast-deep-equal for semantic comparison (already in toolbox)\n\tconst input1Changed = !isEqual(base, input1);\n\tconst input2Changed = !isEqual(base, input2);\n\n\tif (input1Changed && input2Changed) {\n\t\t// Both changed - are they semantically equal?\n\t\tif (isEqual(input1, input2)) {\n\t\t\treturn ConflictType.SAME_CHANGE;\n\t\t}\n\t\treturn ConflictType.TRUE_CONFLICT;\n\t}\n\n\tif (input1Changed) return ConflictType.INPUT1_ONLY;\n\tif (input2Changed) return ConflictType.INPUT2_ONLY;\n\n\treturn ConflictType.SAME_CHANGE; // No change\n}\n\n/**\n * Get line numbers for a JSON node at a given path\n * @param text - Formatted JSON text\n * @param path - JSON Pointer path\n * @returns Start and end line numbers (1-indexed), or {1, 1} if not found\n */\nexport function getNodeLines(text: string, path: string): { start: number; end: number } {\n\ttry {\n\t\tconst root = parseTree(text);\n\t\tif (!root) {\n\t\t\treturn { start: 1, end: 1 };\n\t\t}\n\n\t\t// Convert path segments to proper types (numbers for array indices, strings for object keys)\n\t\tconst pathSegments = path\n\t\t\t.split(\"/\")\n\t\t\t.filter(Boolean)\n\t\t\t.map((segment) => {\n\t\t\t\t// Check if segment is a numeric array index\n\t\t\t\tconst numericValue = Number.parseInt(segment, 10);\n\t\t\t\treturn !Number.isNaN(numericValue) && String(numericValue) === segment ? numericValue : segment;\n\t\t\t});\n\n\t\tconst node = pathSegments.length === 0 ? root : findNodeAtLocation(root, pathSegments);\n\n\t\tif (!node) {\n\t\t\treturn { start: 1, end: 1 };\n\t\t}\n\n\t\tconst result = {\n\t\t\tstart: getLineNumber(text, node.offset),\n\t\t\tend: getLineNumber(text, node.offset + node.length),\n\t\t};\n\t\treturn result;\n\t} catch (_error) {\n\t\treturn { start: 1, end: 1 };\n\t}\n}\n\n/**\n * Convert character offset to line number\n * @param text - Text content\n * @param offset - Character offset\n * @returns Line number (1-indexed)\n */\nfunction getLineNumber(text: string, offset: number): number {\n\treturn text.substring(0, offset).split(\"\\n\").length;\n}\n\n/**\n * Group JSON Patch operations by their root path\n * @param patches1 - Patches from base to input1\n * @param patches2 - Patches from base to input2\n * @returns Map of root paths to their patches\n */\nfunction groupPatchesByRootPath(\n\tpatches1: JsonPatchOperation[],\n\tpatches2: JsonPatchOperation[],\n): Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }> {\n\tconst pathGroups = new Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }>();\n\n\t// Helper to get root path (first segment)\n\tconst getRootPath = (path: string): string => {\n\t\tconst segments = path.split(\"/\").filter(Boolean);\n\t\treturn segments.length > 0 ? `/${segments[0]}` : \"/\";\n\t};\n\n\t// Group patches1\n\tfor (const patch of patches1) {\n\t\tconst rootPath = getRootPath(patch.path);\n\t\tif (!pathGroups.has(rootPath)) {\n\t\t\tpathGroups.set(rootPath, { patches1: [], patches2: [] });\n\t\t}\n\t\tconst group = pathGroups.get(rootPath);\n\t\tif (group) {\n\t\t\tgroup.patches1.push(patch);\n\t\t}\n\t}\n\n\t// Group patches2\n\tfor (const patch of patches2) {\n\t\tconst rootPath = getRootPath(patch.path);\n\t\tif (!pathGroups.has(rootPath)) {\n\t\t\tpathGroups.set(rootPath, { patches1: [], patches2: [] });\n\t\t}\n\t\tconst group = pathGroups.get(rootPath);\n\t\tif (group) {\n\t\t\tgroup.patches2.push(patch);\n\t\t}\n\t}\n\n\treturn pathGroups;\n}\n\n/**\n * Schema-aware patch grouping for 3-way merge\n * Groups patches by array item identity (using schema anchors) instead of just path\n */\nfunction groupPatchesWithSchema(\n\tpatches1: JsonPatchOperation[],\n\tpatches2: JsonPatchOperation[],\n\tbase: unknown,\n\tinput1: unknown,\n\tinput2: unknown,\n\tschema: JSONSchema,\n): Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }> {\n\tconst pathGroups = new Map<string, { patches1: JsonPatchOperation[]; patches2: JsonPatchOperation[] }>();\n\n\t// Separate array patches from non-array patches\n\tconst arrayPatchGroups1 = new Map<string, JsonPatchOperation[]>();\n\tconst arrayPatchGroups2 = new Map<string, JsonPatchOperation[]>();\n\tconst nonArrayPatches1: JsonPatchOperation[] = [];\n\tconst nonArrayPatches2: JsonPatchOperation[] = [];\n\n\t// Group patches by array path\n\tfor (const patch of patches1) {\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1];\n\t\t\tif (!arrayPatchGroups1.has(arrayPath)) {\n\t\t\t\tarrayPatchGroups1.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst group1 = arrayPatchGroups1.get(arrayPath);\n\t\t\tif (group1) {\n\t\t\t\tgroup1.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches1.push(patch);\n\t\t}\n\t}\n\n\tfor (const patch of patches2) {\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1];\n\t\t\tif (!arrayPatchGroups2.has(arrayPath)) {\n\t\t\t\tarrayPatchGroups2.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst group2 = arrayPatchGroups2.get(arrayPath);\n\t\t\tif (group2) {\n\t\t\t\tgroup2.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches2.push(patch);\n\t\t}\n\t}\n\n\t// Get all unique array paths\n\tconst allArrayPaths = new Set<string>([...arrayPatchGroups1.keys(), ...arrayPatchGroups2.keys()]);\n\n\t// Process each array with schema-aware matching\n\tfor (const arrayPath of allArrayPaths) {\n\t\tconst baseArray = getValueAtPath(base as Record<string, unknown>, arrayPath);\n\t\tconst input1Array = getValueAtPath(input1 as Record<string, unknown>, arrayPath);\n\t\tconst input2Array = getValueAtPath(input2 as Record<string, unknown>, arrayPath);\n\n\t\tif (!Array.isArray(baseArray) || !Array.isArray(input1Array) || !Array.isArray(input2Array)) {\n\t\t\t// Not arrays - fall back to index-based grouping\n\t\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\t\t\tfor (const patch of patches1) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t\t}\n\t\t\t\t\tconst itemGroup1 = pathGroups.get(itemPath);\n\t\t\t\t\tif (itemGroup1) {\n\t\t\t\t\t\titemGroup1.patches1.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const patch of patches2) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t\t}\n\t\t\t\t\tconst itemGroup2 = pathGroups.get(itemPath);\n\t\t\t\t\tif (itemGroup2) {\n\t\t\t\t\t\titemGroup2.patches2.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get schema for array items\n\t\tconst arraySchema = getSchemaAtPath(schema, arrayPath, base);\n\t\tconst itemSchemaRaw = arraySchema?.items\n\t\t\t? Array.isArray(arraySchema.items) && arraySchema.items[0]\n\t\t\t\t? arraySchema.items[0]\n\t\t\t\t: !Array.isArray(arraySchema.items)\n\t\t\t\t\t? arraySchema.items\n\t\t\t\t\t: null\n\t\t\t: null;\n\t\t// Ensure itemSchema is a valid JSONSchema (not true)\n\t\tconst itemSchema = itemSchemaRaw && typeof itemSchemaRaw === \"object\" ? itemSchemaRaw : null;\n\n\t\tif (itemSchema) {\n\t\t\t// Use 3-way schema matching\n\t\t\tconst matches = matchArrayItemsById(baseArray, input1Array, input2Array, itemSchema);\n\n\t\t\tif (matches.size > 0) {\n\t\t\t\t// Create mappings from index to key\n\t\t\t\tconst baseKeysByIndex = new Map<number, string | number>();\n\t\t\t\tconst input1KeysByIndex = new Map<number, string | number>();\n\t\t\t\tconst input2KeysByIndex = new Map<number, string | number>();\n\n\t\t\t\tfor (const [key, indices] of matches.entries()) {\n\t\t\t\t\tif (indices.base !== undefined) baseKeysByIndex.set(indices.base, key);\n\t\t\t\t\tif (indices.input1 !== undefined) input1KeysByIndex.set(indices.input1, key);\n\t\t\t\t\tif (indices.input2 !== undefined) input2KeysByIndex.set(indices.input2, key);\n\t\t\t\t}\n\n\t\t\t\t// Group patches by matched item\n\t\t\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\t\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\n\t\t\t\tfor (const patch of patches1) {\n\t\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\t\t\t\t\t\tconst key = input1KeysByIndex.get(index);\n\t\t\t\t\t\tif (key !== undefined) {\n\t\t\t\t\t\t\tconst groupKey = `${arrayPath}#${key}`;\n\t\t\t\t\t\t\tif (!pathGroups.has(groupKey)) {\n\t\t\t\t\t\t\t\tpathGroups.set(groupKey, { patches1: [], patches2: [] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst groupKey1 = pathGroups.get(groupKey);\n\t\t\t\t\t\t\tif (groupKey1) {\n\t\t\t\t\t\t\t\tgroupKey1.patches1.push(patch);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const patch of patches2) {\n\t\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\t\t\t\t\t\tconst key = input2KeysByIndex.get(index);\n\t\t\t\t\t\tif (key !== undefined) {\n\t\t\t\t\t\t\tconst groupKey = `${arrayPath}#${key}`;\n\t\t\t\t\t\t\tif (!pathGroups.has(groupKey)) {\n\t\t\t\t\t\t\t\tpathGroups.set(groupKey, { patches1: [], patches2: [] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst groupKey2 = pathGroups.get(groupKey);\n\t\t\t\t\t\t\tif (groupKey2) {\n\t\t\t\t\t\t\t\tgroupKey2.patches2.push(patch);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// No schema or no matches - fall back to index-based grouping\n\t\tconst patches1 = arrayPatchGroups1.get(arrayPath) || [];\n\t\tconst patches2 = arrayPatchGroups2.get(arrayPath) || [];\n\t\tfor (const patch of patches1) {\n\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\tif (itemMatch) {\n\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t}\n\t\t\t\tconst groupItem1 = pathGroups.get(itemPath);\n\t\t\t\tif (groupItem1) {\n\t\t\t\t\tgroupItem1.patches1.push(patch);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const patch of patches2) {\n\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\tif (itemMatch) {\n\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\tif (!pathGroups.has(itemPath)) {\n\t\t\t\t\tpathGroups.set(itemPath, { patches1: [], patches2: [] });\n\t\t\t\t}\n\t\t\t\tconst groupItem2 = pathGroups.get(itemPath);\n\t\t\t\tif (groupItem2) {\n\t\t\t\t\tgroupItem2.patches2.push(patch);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Helper: Check if a path is a child of a potential oneOf object\n\tconst getOneOfObjectPath = (patchPath: string, schema?: JSONSchema): string | null => {\n\t\tif (!schema) return null;\n\t\tconst segments = patchPath.split(\"/\").filter(Boolean);\n\t\tif (segments.length < 2) return null; // Need at least object/property\n\n\t\t// Check if parent object (e.g., /payment for /payment/type) has oneOf schema\n\t\tconst parentPath = `/${segments[0]}`;\n\t\tconst parentSchema = getSchemaAtPath(schema, parentPath);\n\t\tif (parentSchema && hasSchemaVariants(parentSchema)) {\n\t\t\treturn parentPath;\n\t\t}\n\t\treturn null;\n\t};\n\n\t// Process non-array patches\n\t// Strategy:\n\t// 1. First, group patches that belong to oneOf objects together\n\t// 2. Then, group remaining patches by full path for individual field conflicts\n\n\t// First pass: Collect all patches\n\tconst allNonArrayPatches1 = [...nonArrayPatches1];\n\tconst allNonArrayPatches2 = [...nonArrayPatches2];\n\n\t// Second pass: Group by oneOf object paths first\n\tconst oneOfObjectPaths = new Set<string>();\n\tfor (const patch of allNonArrayPatches1) {\n\t\tconst oneOfPath = getOneOfObjectPath(patch.path, schema);\n\t\tif (oneOfPath) {\n\t\t\toneOfObjectPaths.add(oneOfPath);\n\t\t}\n\t}\n\tfor (const patch of allNonArrayPatches2) {\n\t\tconst oneOfPath = getOneOfObjectPath(patch.path, schema);\n\t\tif (oneOfPath) {\n\t\t\toneOfObjectPaths.add(oneOfPath);\n\t\t}\n\t}\n\n\t// Group patches for oneOf objects\n\tfor (const oneOfPath of oneOfObjectPaths) {\n\t\tif (!pathGroups.has(oneOfPath)) {\n\t\t\tpathGroups.set(oneOfPath, { patches1: [], patches2: [] });\n\t\t}\n\t}\n\n\t// Third pass: Distribute patches\n\tfor (const patch of allNonArrayPatches1) {\n\t\tconst patchPath = patch.path;\n\t\tconst oneOfPath = getOneOfObjectPath(patchPath, schema);\n\n\t\tif (oneOfPath) {\n\t\t\t// Belongs to a oneOf object - group under object path\n\t\t\tconst group = pathGroups.get(oneOfPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches1.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\t// Regular field change - use full path for separate conflicts\n\t\t\tif (!pathGroups.has(patchPath)) {\n\t\t\t\tpathGroups.set(patchPath, { patches1: [], patches2: [] });\n\t\t\t}\n\t\t\tconst group = pathGroups.get(patchPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches1.push(patch);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const patch of allNonArrayPatches2) {\n\t\tconst patchPath = patch.path;\n\t\tconst oneOfPath = getOneOfObjectPath(patchPath, schema);\n\n\t\tif (oneOfPath) {\n\t\t\t// Belongs to a oneOf object - group under object path\n\t\t\tconst group = pathGroups.get(oneOfPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches2.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\t// Regular field change - use full path for separate conflicts\n\t\t\tif (!pathGroups.has(patchPath)) {\n\t\t\t\tpathGroups.set(patchPath, { patches1: [], patches2: [] });\n\t\t\t}\n\t\t\tconst group = pathGroups.get(patchPath);\n\t\t\tif (group) {\n\t\t\t\tgroup.patches2.push(patch);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn pathGroups;\n}\n\n/**\n * Analyze conflicts using JSON Patches (RFC 6902)\n *\n * This function uses semantic JSON comparison, NOT line-based text comparison:\n * 1. Generates JSON Patch operations from base?input1 and base?input2\n * 2. Groups patches by root path (e.g., /awards/resource/0/count ? /awards)\n * 3. For each group, determines conflict type based on actual JSON values\n * 4. Returns conflicts with patch operations that will be mapped to line ranges\n *\n * The patches contain JSON Pointer paths (e.g., /resource/0/type) that reference\n * the actual JSON structure, not arbitrary text lines.\n *\n * @param base - Base JSON object\n * @param input1 - Input1 (theirs) JSON object\n * @param input2 - Input2 (ours) JSON object\n * @returns Array of conflict analyses with JSON Patch operations\n */\n/**\n * Resolve schema at a given JSON Pointer path, handling oneOf/anyOf/allOf\n * @param schema - Root JSON Schema\n * @param path - JSON Pointer path (e.g., \"/awards/resource/0/type\")\n * @param data - The actual data at the path (for oneOf/anyOf resolution)\n * @returns The resolved schema for the path, or null if not found\n */\nexport function getSchemaAtPath(schema: JSONSchema | undefined, path: string, data?: unknown): JSONSchema | null {\n\tif (!schema) {\n\t\treturn null;\n\t}\n\n\tconst segments = path.split(\"/\").filter(Boolean);\n\tif (segments.length === 0) {\n\t\treturn schema;\n\t}\n\n\tlet currentSchema: JSONSchema | null = schema;\n\tlet currentPath = \"\";\n\n\tfor (let i = 0; i < segments.length; i++) {\n\t\tconst segment = segments[i];\n\t\tconst numericIndex = Number.parseInt(segment, 10);\n\t\tconst isArrayIndex = !Number.isNaN(numericIndex) && String(numericIndex) === segment;\n\n\t\t// Handle oneOf/anyOf/allOf before navigating using shared utilities\n\t\tif (currentSchema && hasSchemaVariants(currentSchema)) {\n\t\t\tconst variants = getSchemaVariants(currentSchema);\n\t\t\tconst keyword = getSubschemaKeyword(currentSchema);\n\t\t\tconst currentData = data ? getValueAtPath(data as Record<string, unknown>, currentPath || \"/\") : undefined;\n\n\t\t\tif (variants && variants.length > 0) {\n\t\t\t\tif (currentData !== undefined) {\n\t\t\t\t\t// Use shared chooseSubschemaSync for proper variant resolution\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst { schema: resolvedSchema } = chooseSubschemaSync(currentData, variants, keyword);\n\t\t\t\t\t\tcurrentSchema = resolvedSchema;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tif (variants.length > 0 && variants[0]) {\n\t\t\t\t\t\t\tcurrentSchema = variants[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// No data available, use first variant as fallback\n\t\t\t\t\tif (variants.length > 0 && variants[0]) {\n\t\t\t\t\t\tcurrentSchema = variants[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!currentSchema) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Navigate to next segment\n\t\tif (isArrayIndex) {\n\t\t\t// Array index - use items schema\n\t\t\tif (currentSchema.items) {\n\t\t\t\tif (Array.isArray(currentSchema.items)) {\n\t\t\t\t\tconst itemAtIndex: unknown = numericIndex < currentSchema.items.length ? currentSchema.items[numericIndex] : null;\n\t\t\t\t\tcurrentSchema = itemAtIndex && typeof itemAtIndex === \"object\" ? (itemAtIndex as JSONSchema) : null;\n\t\t\t\t} else if (typeof currentSchema.items === \"object\") {\n\t\t\t\t\t// Ensure items is a JSONSchema object, not true\n\t\t\t\t\tcurrentSchema = currentSchema.items;\n\t\t\t\t} else {\n\t\t\t\t\tcurrentSchema = null;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn null; // No items schema defined\n\t\t\t}\n\t\t} else {\n\t\t\t// Object property\n\t\t\tif (currentSchema.properties && typeof currentSchema.properties === \"object\" && !Array.isArray(currentSchema.properties)) {\n\t\t\t\tconst properties = currentSchema.properties as Record<string, JSONSchema>;\n\t\t\t\tcurrentSchema = properties[segment] || null;\n\t\t\t} else {\n\t\t\t\treturn null; // No properties schema defined\n\t\t\t}\n\t\t}\n\n\t\tif (!currentSchema) {\n\t\t\treturn null;\n\t\t}\n\n\t\tcurrentPath = currentPath ? `${currentPath}/${segment}` : `/${segment}`;\n\t}\n\n\treturn currentSchema;\n}\n\n/**\n * Find anchor fields for array items based on schema\n * This helps match array items across versions even if their indices change\n *\n * Anchor fields can be:\n * 1. Fields with \"const\" values (discriminators in oneOf schemas)\n * 2. Common ID field names (id, uuid, _id, etc.)\n * 3. Fields marked with format: \"uuid\" or \"objectid\"\n *\n * @param schema - Schema for the array items\n * @returns Array of anchor field names, ordered by priority\n */\nfunction findItemAnchorFields(schema: JSONSchema | null): string[] {\n\tif (!schema || typeof schema !== \"object\") {\n\t\treturn [];\n\t}\n\n\tconst anchors: string[] = [];\n\n\tif (schema.properties && typeof schema.properties === \"object\" && !Array.isArray(schema.properties)) {\n\t\tconst properties = schema.properties as Record<string, JSONSchema>;\n\n\t\t// Priority 1: Fields with \"const\" values (discriminators)\n\t\tfor (const [fieldName, propSchema] of Object.entries(properties)) {\n\t\t\tif (propSchema && typeof propSchema === \"object\" && \"const\" in propSchema) {\n\t\t\t\tanchors.push(fieldName);\n\t\t\t}\n\t\t}\n\n\t\t// Priority 2: Fields with UUID/ObjectID format\n\t\tfor (const [fieldName, propSchema] of Object.entries(properties)) {\n\t\t\tif (propSchema && typeof propSchema === \"object\") {\n\t\t\t\tconst format = propSchema.format;\n\t\t\t\tif (format === \"uuid\" || format === \"objectid\") {\n\t\t\t\t\tif (!anchors.includes(fieldName)) {\n\t\t\t\t\t\tanchors.push(fieldName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Priority 3: Common ID field names\n\t\tconst commonIdFields = [\"id\", \"uuid\", \"_id\", \"key\"];\n\t\tfor (const fieldName of commonIdFields) {\n\t\t\tif (fieldName in properties && !anchors.includes(fieldName)) {\n\t\t\t\tanchors.push(fieldName);\n\t\t\t}\n\t\t}\n\n\t\t// Priority 4: \"type\" field (common discriminator)\n\t\tif (\"type\" in properties && !anchors.includes(\"type\")) {\n\t\t\tanchors.push(\"type\");\n\t\t}\n\n\t\t// Priority 5: \"name\" field (fallback)\n\t\tif (\"name\" in properties && !anchors.includes(\"name\")) {\n\t\t\tanchors.push(\"name\");\n\t\t}\n\t}\n\n\treturn anchors;\n}\n\n/**\n * Find a unique identifier field for array items based on schema\n * @deprecated Use findItemAnchorFields instead for better oneOf/const support\n * @param schema - Schema for the array items\n * @returns Name of the ID field (e.g., \"id\", \"uuid\", \"_id\"), or null\n */\nfunction findItemIdField(schema: JSONSchema | null): string | null {\n\tconst anchors = findItemAnchorFields(schema);\n\treturn anchors.length > 0 ? anchors[0] : null;\n}\n\n/**\n * Match array items using multiple anchor fields from schema\n * This handles oneOf schemas with const discriminators and regular ID fields\n *\n * @param input1Array - Array from input1\n * @param input2Array - Array from input2\n * @param itemSchema - Schema for array items (may contain oneOf)\n * @returns Map of composite keys to indices: { \"type:cash|id:1\": { input1: 0, input2: 2 } }\n */\nfunction matchArrayItemsByAnchors(\n\tinput1Array: unknown[],\n\tinput2Array: unknown[],\n\titemSchema: JSONSchema | null,\n): Map<string, { input1?: number; input2?: number }> {\n\tconst matches = new Map<string, { input1?: number; input2?: number }>();\n\n\t// Get anchor fields from schema (const fields, ID fields, etc.)\n\tconst anchorFields = findItemAnchorFields(itemSchema);\n\n\tif (anchorFields.length === 0) {\n\t\t// No anchor fields - can't match items semantically\n\t\t// Removed verbose logging\n\t\treturn matches;\n\t}\n\n\t// Removed verbose logging\n\n\t// Generate a composite key from an item using available anchor fields\n\tconst getItemKey = (item: unknown): string | null => {\n\t\tif (typeof item !== \"object\" || item === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst obj = item as Record<string, unknown>;\n\t\tconst keyParts: string[] = [];\n\n\t\t// Build composite key from all available anchor fields\n\t\tfor (const field of anchorFields) {\n\t\t\tconst value = obj[field];\n\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t// Include field name to avoid collisions (e.g., type:1 vs id:1)\n\t\t\t\tkeyParts.push(`${field}:${JSON.stringify(value)}`);\n\t\t\t}\n\t\t}\n\n\t\t// Need at least one anchor value to create a key\n\t\treturn keyParts.length > 0 ? keyParts.join(\"|\") : null;\n\t};\n\n\t// Index items by composite key in each array\n\tconst indexArray = (arr: unknown[], version: \"input1\" | \"input2\") => {\n\t\tarr.forEach((item, index) => {\n\t\t\tconst key = getItemKey(item);\n\t\t\tif (key) {\n\t\t\t\tif (!matches.has(key)) {\n\t\t\t\t\tmatches.set(key, {});\n\t\t\t\t}\n\t\t\t\tconst match = matches.get(key);\n\t\t\t\tif (match) {\n\t\t\t\t\tmatch[version] = index;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\tindexArray(input1Array, \"input1\");\n\tindexArray(input2Array, \"input2\");\n\n\t// Removed verbose logging\n\n\treturn matches;\n}\n\n/**\n * Match array items across versions using schema-defined ID fields\n * This handles cases where array order changes but items are semantically the same\n * @param baseArray - Array from base version\n * @param input1Array - Array from input1\n * @param input2Array - Array from input2\n * @param itemSchema - Schema for array items\n * @returns Map of item IDs to their indices in each version: { id: { base: index, input1: index, input2: index } }\n */\nfunction matchArrayItemsById(\n\tbaseArray: unknown[],\n\tinput1Array: unknown[],\n\tinput2Array: unknown[],\n\titemSchema: JSONSchema | null,\n): Map<string | number, { base?: number; input1?: number; input2?: number }> {\n\tconst matches = new Map<string | number, { base?: number; input1?: number; input2?: number }>();\n\tconst idField = findItemIdField(itemSchema);\n\n\tif (!idField) {\n\t\t// No ID field found - can't match by ID, return empty map\n\t\treturn matches;\n\t}\n\n\t// Index items by ID in each array\n\tconst indexByArray = (arr: unknown[], version: \"base\" | \"input1\" | \"input2\") => {\n\t\tarr.forEach((item, index) => {\n\t\t\tif (typeof item === \"object\" && item !== null) {\n\t\t\t\tconst id = (item as Record<string, unknown>)[idField];\n\t\t\t\tif (id !== undefined && id !== null) {\n\t\t\t\t\tconst idKey = String(id);\n\t\t\t\t\tif (!matches.has(idKey)) {\n\t\t\t\t\t\tmatches.set(idKey, {});\n\t\t\t\t\t}\n\t\t\t\t\tconst match = matches.get(idKey);\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tmatch[version] = index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\tindexByArray(baseArray, \"base\");\n\tindexByArray(input1Array, \"input1\");\n\tindexByArray(input2Array, \"input2\");\n\n\treturn matches;\n}\n\nexport function analyzeConflicts(base: unknown, input1: unknown, input2: unknown, schema?: JSONSchema): ConflictAnalysis[] {\n\t// Generate JSON Patch operations (semantic diff, not text diff)\n\t// Each patch contains: op, path (JSON Pointer), value\n\t// fast-json-patch's compare accepts Object | any[] - ensure we pass valid types\n\tconst baseObj = (typeof base === \"object\" && base !== null) || Array.isArray(base) ? base : {};\n\tconst input1Obj = (typeof input1 === \"object\" && input1 !== null) || Array.isArray(input1) ? input1 : {};\n\tconst input2Obj = (typeof input2 === \"object\" && input2 !== null) || Array.isArray(input2) ? input2 : {};\n\n\tconst patch1 = compare(baseObj as object | unknown[], input1Obj as object | unknown[]);\n\tconst patch2 = compare(baseObj as object | unknown[], input2Obj as object | unknown[]);\n\n\t// Group patches by root path for conflict analysis\n\t// Example: /awards/resource/0/count and /awards/resource/3 ? grouped as /awards\n\tlet pathGroups = groupPatchesByRootPath(patch1, patch2);\n\n\t// If schema is provided, use it to improve path grouping for arrays and oneOf cases\n\tif (schema) {\n\t\tpathGroups = groupPatchesWithSchema(patch1, patch2, base, input1, input2, schema);\n\t}\n\n\t// Analyze each path group\n\tconst conflicts: ConflictAnalysis[] = [];\n\tconst processedPaths = new Set<string>();\n\n\t// Helper: Check if an object path has oneOf schema and if changes represent variant switch\n\tconst checkOneOfVariantChange = (path: string, baseValue: unknown, input1Value: unknown, input2Value: unknown): boolean => {\n\t\tif (!schema) return false;\n\t\tif (typeof baseValue !== \"object\" || baseValue === null || Array.isArray(baseValue)) return false;\n\t\tif (typeof input1Value !== \"object\" || input1Value === null || Array.isArray(input1Value)) return false;\n\t\tif (typeof input2Value !== \"object\" || input2Value === null || Array.isArray(input2Value)) return false;\n\n\t\tconst pathSchema = getSchemaAtPath(schema, path, baseValue);\n\t\tif (!pathSchema || !hasSchemaVariants(pathSchema)) return false;\n\n\t\tconst variants = getSchemaVariants(pathSchema);\n\t\tif (!variants || variants.length < 2) return false;\n\n\t\t// Check if base, input1, and input2 match different variants\n\t\tconst baseVariant = chooseSubschemaSync(baseValue, variants, getSubschemaKeyword(pathSchema));\n\t\tconst input1Variant = chooseSubschemaSync(input1Value, variants, getSubschemaKeyword(pathSchema));\n\t\tconst input2Variant = chooseSubschemaSync(input2Value, variants, getSubschemaKeyword(pathSchema));\n\n\t\t// If input1 and input2 match different variants (and base is different from both),\n\t\t// this is a oneOf variant conflict\n\t\treturn (\n\t\t\tinput1Variant.selectedIndex !== input2Variant.selectedIndex &&\n\t\t\t(baseVariant.selectedIndex !== input1Variant.selectedIndex || baseVariant.selectedIndex !== input2Variant.selectedIndex)\n\t\t);\n\t};\n\n\t// First, process paths with patches (changes)\n\tfor (const [groupingKey, { patches1, patches2 }] of pathGroups) {\n\t\tprocessedPaths.add(groupingKey);\n\n\t\t// Extract representative path from patches (grouping key might be ID-based like \"/path#id=1\")\n\t\t// Use the first patch path from either set, or derive from grouping key\n\t\tlet representativePath = groupingKey;\n\t\tif (patches1.length > 0) {\n\t\t\trepresentativePath = patches1[0].path;\n\t\t} else if (patches2.length > 0) {\n\t\t\trepresentativePath = patches2[0].path;\n\t\t} else if (groupingKey.includes(\"#\")) {\n\t\t\t// ID-based grouping key - extract base path before \"#\"\n\t\t\trepresentativePath = groupingKey.split(\"#\")[0];\n\t\t}\n\n\t\t// Extract the object path (parent object, without property/index segments)\n\t\t// For example: \"/payment/number\" -> \"/payment\", \"/items/0/count\" -> \"/items\"\n\t\tlet objectPath = groupingKey;\n\t\tif (groupingKey.includes(\"#\")) {\n\t\t\t// ID-based grouping: \"/items#item-1\" -> \"/items\"\n\t\t\tobjectPath = groupingKey.split(\"#\")[0];\n\t\t} else {\n\t\t\t// Extract parent path: \"/payment/number\" -> \"/payment\"\n\t\t\tconst pathSegments = groupingKey.split(\"/\").filter(Boolean);\n\t\t\tif (pathSegments.length > 1) {\n\t\t\t\tobjectPath = `/${pathSegments[0]}`;\n\t\t\t}\n\t\t}\n\n\t\t// Check if groupingKey itself is an object path (no sub-properties in patches)\n\t\tconst allPatchesAreForSameObject = [...patches1, ...patches2].every((p) => {\n\t\t\tconst patchObjectPath = p.path.split(\"/\").slice(0, 2).join(\"/\") || `/${p.path.split(\"/\")[1]}`;\n\t\t\treturn patchObjectPath === objectPath;\n\t\t});\n\n\t\t// If all patches are for properties of the same object, check for oneOf variant change\n\t\tif (allPatchesAreForSameObject && objectPath !== representativePath) {\n\t\t\tconst baseObjectValue = getValueAtPath(base as Record<string, unknown>, objectPath);\n\t\t\tconst input1ObjectValue = getValueAtPath(input1 as Record<string, unknown>, objectPath);\n\t\t\tconst input2ObjectValue = getValueAtPath(input2 as Record<string, unknown>, objectPath);\n\n\t\t\t// Check if this represents a oneOf variant change\n\t\t\tconst isOneOfVariantChange = checkOneOfVariantChange(objectPath, baseObjectValue, input1ObjectValue, input2ObjectValue);\n\n\t\t\tif (isOneOfVariantChange) {\n\t\t\t\t// Use object-level path for oneOf variant conflicts\n\t\t\t\tconst baseObjVal = baseObjectValue;\n\t\t\t\tconst input1ObjVal = input1ObjectValue;\n\t\t\t\tconst input2ObjVal = input2ObjectValue;\n\n\t\t\t\t// Determine conflict type at object level\n\t\t\t\tlet conflictType = determineConflictType(baseObjVal, input1ObjVal, input2ObjVal);\n\n\t\t\t\t// For oneOf variants, different structures mean TRUE_CONFLICT\n\t\t\t\tif (!isEqual(baseObjVal, input1ObjVal) && !isEqual(baseObjVal, input2ObjVal) && !isEqual(input1ObjVal, input2ObjVal)) {\n\t\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t\t}\n\n\t\t\t\t// For oneOf variant changes, include only patches that input1/input2 actually changed\n\t\t\t\t// Filter patches to ensure we don't highlight identical properties\n\t\t\t\tconst objectPatchesAll = [...patches1, ...patches2].filter(\n\t\t\t\t\t(p) => p.path.startsWith(`${objectPath}/`) || p.path === objectPath,\n\t\t\t\t);\n\n\t\t\t\t// Filter patches separately for input1 and input2\n\t\t\t\tconst objectPatches1: JsonPatchOperation[] = [];\n\t\t\t\tconst objectPatches2: JsonPatchOperation[] = [];\n\n\t\t\t\tfor (const patch of objectPatchesAll) {\n\t\t\t\t\tconst patchPath = patch.path;\n\t\t\t\t\tconst patchBaseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, patchPath) : undefined;\n\t\t\t\t\tconst patchInput1Value = getValueAtPath(input1 as Record<string, unknown>, patchPath);\n\t\t\t\t\tconst patchInput2Value = getValueAtPath(input2 as Record<string, unknown>, patchPath);\n\n\t\t\t\t\t// Check if input1 changed this property\n\t\t\t\t\tlet input1Changed = false;\n\t\t\t\t\tlet input2Changed = false;\n\n\t\t\t\t\tif (patch.op === \"replace\") {\n\t\t\t\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (patch.op === \"add\") {\n\t\t\t\t\t\tinput1Changed = patchBaseValue === undefined && patchInput1Value !== undefined;\n\t\t\t\t\t\tinput2Changed = patchBaseValue === undefined && patchInput2Value !== undefined;\n\t\t\t\t\t} else if (patch.op === \"remove\") {\n\t\t\t\t\t\tinput1Changed = patchBaseValue !== undefined && patchInput1Value === undefined;\n\t\t\t\t\t\tinput2Changed = patchBaseValue !== undefined && patchInput2Value === undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Don't include if the input's value is identical to base\n\t\t\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\t\t\tif (patchInput1Value !== undefined && isEqual(patchBaseValue, patchInput1Value)) {\n\t\t\t\t\t\t\tinput1Changed = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (patchInput2Value !== undefined && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\t\t\t\tinput2Changed = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (input1Changed) {\n\t\t\t\t\t\tobjectPatches1.push(patch);\n\t\t\t\t\t}\n\t\t\t\t\tif (input2Changed) {\n\t\t\t\t\t\tobjectPatches2.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconflicts.push({\n\t\t\t\t\tpath: objectPath,\n\t\t\t\t\tbaseValue: baseObjVal,\n\t\t\t\t\tinput1Value: input1ObjVal,\n\t\t\t\t\tinput2Value: input2ObjVal,\n\t\t\t\t\tconflictType,\n\t\t\t\t\tpatches1: objectPatches1,\n\t\t\t\t\tpatches2: objectPatches2,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// Get actual JSON values at the path (semantic comparison)\n\t\t// For array items matched by ID, we need to get values from each version using their actual indices\n\t\t// But for conflict analysis, we can use a representative path\n\t\tconst baseValue = getValueAtPath(base as Record<string, unknown>, representativePath);\n\t\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, representativePath);\n\t\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, representativePath);\n\n\t\t// Determine conflict type based on JSON value comparison\n\t\tlet conflictType = determineConflictType(baseValue, input1Value, input2Value);\n\n\t\t// Check if this is an item added in both inputs (not in base)\n\t\tconst existsInBase = baseValue !== undefined && baseValue !== null;\n\t\tconst existsInInput1 = input1Value !== undefined && input1Value !== null;\n\t\tconst existsInInput2 = input2Value !== undefined && input2Value !== null;\n\n\t\tif (!existsInBase && existsInInput1 && existsInInput2) {\n\t\t\t// Item added in both inputs\n\t\t\t// If they added the SAME value ? SAME_CHANGE (auto-merged, highlight blue)\n\t\t\t// If they added DIFFERENT values ? TRUE_CONFLICT (conflict, highlight orange/red)\n\t\t\tif (conflictType !== ConflictType.SAME_CHANGE) {\n\t\t\t\t// Different values added - treat as TRUE_CONFLICT so both sides are highlighted\n\t\t\t\t// We'll handle the orange highlighting in the decoration logic\n\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t}\n\t\t\t// If conflictType is already SAME_CHANGE, keep it (both added same value)\n\t\t}\n\n\t\t// Include all changes (including SAME_CHANGE for items that changed to the same value)\n\t\t// Exclude items that are completely unchanged (same as base in all versions)\n\t\tconst isCompletelyUnchanged = existsInBase && isEqual(baseValue, input1Value) && isEqual(baseValue, input2Value);\n\n\t\tif (!isCompletelyUnchanged) {\n\t\t\tconflicts.push({\n\t\t\t\tpath: representativePath, // Use representative path for conflict (actual patch paths are in patches1/patches2)\n\t\t\t\tbaseValue,\n\t\t\t\tinput1Value,\n\t\t\t\tinput2Value,\n\t\t\t\tconflictType,\n\t\t\t\tpatches1, // JSON Patch operations for base?input1 (contain actual paths with indices)\n\t\t\t\tpatches2, // JSON Patch operations for base?input2 (contain actual paths with indices)\n\t\t\t});\n\t\t}\n\t}\n\n\t// Don't create conflicts for completely unchanged items\n\t// Unchanged items should not be highlighted (they're the same in all versions)\n\n\treturn conflicts;\n}\n\n/**\n * Analyze conflicts for 2-column mode (input1 vs input2, no base)\n *\n * Uses JSON Patch comparison (semantic, not line-based):\n * - Generates patches from input1?input2\n * - Groups by root path\n * - Maps to conflict ranges\n *\n * @param input1 - Input1 JSON object (left column)\n * @param input2 - Input2 JSON object (right column)\n * @returns Array of conflict analyses with JSON Patch operations\n */\nexport function analyzeTwoWayConflicts(input1: unknown, input2: unknown, schema?: JSONSchema): ConflictAnalysis[] {\n\t// Generate JSON Patch operations from input1 to input2\n\t// This finds semantic differences (changed JSON values), not text differences\n\t// fast-json-patch's compare accepts Object | any[] - ensure we pass valid types\n\tconst input1Obj = (typeof input1 === \"object\" && input1 !== null) || Array.isArray(input1) ? input1 : {};\n\tconst input2Obj = (typeof input2 === \"object\" && input2 !== null) || Array.isArray(input2) ? input2 : {};\n\tconst patches = compare(input1Obj as object | unknown[], input2Obj as object | unknown[]);\n\n\tif (patches.length === 0) {\n\t\treturn []; // No differences\n\t}\n\n\t// Analyze each patch and determine grouping strategy\n\t// For arrays with schema, we'll use anchor-based matching\n\t// For other paths, we'll use index-based grouping\n\tconst conflicts: ConflictAnalysis[] = [];\n\tconst processedPaths = new Set<string>();\n\n\t// Group patches by array path to detect array operations\n\tconst arrayPathGroups = new Map<string, JsonPatchOperation[]>();\n\tconst nonArrayPatches: JsonPatchOperation[] = [];\n\n\tfor (const patch of patches) {\n\t\t// Check if this patch operates on an array item\n\t\t// Pattern: /path/to/array/INDEX or /path/to/array/INDEX/property\n\t\tconst arrayItemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*)\\/(\\d+)(?:\\/|$)/);\n\n\t\tif (arrayItemMatch) {\n\t\t\tconst arrayPath = arrayItemMatch[1]; // e.g., /needResourcesAtRefresh/resource\n\t\t\tif (!arrayPathGroups.has(arrayPath)) {\n\t\t\t\tarrayPathGroups.set(arrayPath, []);\n\t\t\t}\n\t\t\tconst arrayGroup = arrayPathGroups.get(arrayPath);\n\t\t\tif (arrayGroup) {\n\t\t\t\tarrayGroup.push(patch);\n\t\t\t}\n\t\t} else {\n\t\t\tnonArrayPatches.push(patch);\n\t\t}\n\t}\n\n\t// Removed verbose logging\n\n\t// Process array patches with schema-aware matching\n\tfor (const [arrayPath, arrayPatches] of arrayPathGroups) {\n\t\t// Get the arrays from both inputs\n\t\tconst input1Array = getValueAtPath(input1 as Record<string, unknown>, arrayPath);\n\t\tconst input2Array = getValueAtPath(input2 as Record<string, unknown>, arrayPath);\n\n\t\tif (!Array.isArray(input1Array) || !Array.isArray(input2Array)) {\n\t\t\t// Removed verbose logging\n\t\t\t// Fallback: group by item index\n\t\t\tconst itemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!itemGroups.has(itemPath)) {\n\t\t\t\t\t\titemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\titemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [itemPath, itemPatches] of itemGroups) {\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get schema for array items\n\t\tconst arraySchema = schema ? getSchemaAtPath(schema, arrayPath, input1) : null;\n\t\tconst itemSchemaRaw = arraySchema?.items\n\t\t\t? Array.isArray(arraySchema.items) && arraySchema.items[0]\n\t\t\t\t? arraySchema.items[0]\n\t\t\t\t: !Array.isArray(arraySchema.items)\n\t\t\t\t\t? arraySchema.items\n\t\t\t\t\t: null\n\t\t\t: null;\n\t\t// Ensure itemSchema is a valid JSONSchema (not true)\n\t\tconst itemSchema = itemSchemaRaw && typeof itemSchemaRaw === \"object\" ? itemSchemaRaw : null;\n\n\t\t// Removed verbose logging\n\n\t\tif (itemSchema) {\n\t\t\t// Use schema-aware matching\n\t\t\tconst matches = matchArrayItemsByAnchors(input1Array, input2Array, itemSchema);\n\t\t\t// Removed verbose logging\n\n\t\t\t// Create index-to-key mapping for quick lookup\n\t\t\tconst input1KeysByIndex = new Map<number, string>();\n\t\t\tconst input2KeysByIndex = new Map<number, string>();\n\n\t\t\tfor (const [key, indices] of matches.entries()) {\n\t\t\t\tif (indices.input1 !== undefined) {\n\t\t\t\t\tinput1KeysByIndex.set(indices.input1, key);\n\t\t\t\t}\n\t\t\t\tif (indices.input2 !== undefined) {\n\t\t\t\t\tinput2KeysByIndex.set(indices.input2, key);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Group patches by matched items\n\t\t\tconst matchedItemPatches = new Map<string, JsonPatchOperation[]>();\n\t\t\tconst unmatchedPatches: JsonPatchOperation[] = [];\n\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemIndexMatch = patch.path.match(/^\\/[^/]+(?:\\/[^/]+)*\\/(\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemIndexMatch) {\n\t\t\t\t\tconst index = Number.parseInt(itemIndexMatch[1], 10);\n\n\t\t\t\t\t// Determine which array this index refers to based on operation\n\t\t\t\t\tlet key: string | undefined;\n\t\t\t\t\tif (patch.op === \"add\") {\n\t\t\t\t\t\t// Add operations reference input2 indices\n\t\t\t\t\t\tkey = input2KeysByIndex.get(index);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Replace/remove operations reference input1 indices\n\t\t\t\t\t\tkey = input1KeysByIndex.get(index);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (key) {\n\t\t\t\t\t\tif (!matchedItemPatches.has(key)) {\n\t\t\t\t\t\t\tmatchedItemPatches.set(key, []);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst matchedPatches = matchedItemPatches.get(key);\n\t\t\t\t\t\tif (matchedPatches) {\n\t\t\t\t\t\t\tmatchedPatches.push(patch);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tunmatchedPatches.push(patch);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Create conflicts for matched items\n\t\t\tfor (const [key, itemPatches] of matchedItemPatches) {\n\t\t\t\tconst match = matches.get(key);\n\t\t\t\tif (!match) continue;\n\t\t\t\tconst itemPath = match.input1 !== undefined ? `${arrayPath}/${match.input1}` : `${arrayPath}/${match.input2}`;\n\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\n\t\t\t// Create conflicts for unmatched items (pure adds/removes)\n\t\t\t// First, group unmatched patches by item path\n\t\t\tconst unmatchedItemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of unmatchedPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!unmatchedItemGroups.has(itemPath)) {\n\t\t\t\t\t\tunmatchedItemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\tunmatchedItemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Then create conflicts for each item path\n\t\t\tfor (const [itemPath, itemPatches] of unmatchedItemGroups) {\n\t\t\t\tif (!processedPaths.has(itemPath)) {\n\t\t\t\t\t// Removed verbose logging\n\t\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// No schema or no item schema - fall back to index-based grouping\n\t\t\t// Removed verbose logging\n\t\t\tconst itemGroups = new Map<string, JsonPatchOperation[]>();\n\t\t\tfor (const patch of arrayPatches) {\n\t\t\t\tconst itemMatch = patch.path.match(/^(\\/[^/]+(?:\\/[^/]+)*\\/\\d+)(?:\\/|$)/);\n\t\t\t\tif (itemMatch) {\n\t\t\t\t\tconst itemPath = itemMatch[1];\n\t\t\t\t\tif (!itemGroups.has(itemPath)) {\n\t\t\t\t\t\titemGroups.set(itemPath, []);\n\t\t\t\t\t}\n\t\t\t\t\titemGroups.get(itemPath)?.push(patch);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [itemPath, itemPatches] of itemGroups) {\n\t\t\t\tconflicts.push(...createConflictsForGroup(itemPath, itemPatches, input1, input2, undefined));\n\t\t\t\tprocessedPaths.add(itemPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Process non-array patches (simple properties)\n\tconst propertyGroups = new Map<string, JsonPatchOperation[]>();\n\tfor (const patch of nonArrayPatches) {\n\t\tconst segments = patch.path.split(\"/\").filter(Boolean);\n\t\tconst rootPath = segments.length > 0 ? `/${segments[0]}` : \"/\";\n\n\t\tif (!propertyGroups.has(rootPath)) {\n\t\t\tpropertyGroups.set(rootPath, []);\n\t\t}\n\t\tpropertyGroups.get(rootPath)?.push(patch);\n\t}\n\n\tfor (const [path, pathPatches] of propertyGroups) {\n\t\tconflicts.push(...createConflictsForGroup(path, pathPatches, input1, input2, undefined));\n\t}\n\n\treturn conflicts;\n}\n\n/**\n * Helper function to create conflicts for a group of patches\n * Only creates conflicts for paths where values actually differ\n */\nfunction createConflictsForGroup(\n\tpath: string,\n\tpathPatches: JsonPatchOperation[],\n\tinput1: unknown,\n\tinput2: unknown,\n\tbase?: unknown,\n): ConflictAnalysis[] {\n\t// Get actual values at this path from all versions\n\tconst baseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, path) : undefined;\n\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, path);\n\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, path);\n\n\t// Filter patches separately for input1 and input2\n\t// A patch should only be in patches1 if input1 changed it, and in patches2 if input2 changed it\n\tconst filteredPatches1: JsonPatchOperation[] = [];\n\tconst filteredPatches2: JsonPatchOperation[] = [];\n\n\tfor (const patch of pathPatches) {\n\t\t// For each patch, check if the value at that path actually changed in each input\n\t\tconst patchPath = patch.path;\n\t\tconst patchBaseValue = base !== undefined ? getValueAtPath(base as Record<string, unknown>, patchPath) : undefined;\n\t\tconst patchInput1Value = getValueAtPath(input1 as Record<string, unknown>, patchPath);\n\t\tconst patchInput2Value = getValueAtPath(input2 as Record<string, unknown>, patchPath);\n\n\t\t// Check if input1 changed this property\n\t\tlet input1Changed = false;\n\t\t// Check if input2 changed this property\n\t\tlet input2Changed = false;\n\n\t\tif (patch.op === \"add\") {\n\t\t\t// Add: check if input1 added it (doesn't exist in base, exists in input1)\n\t\t\tinput1Changed = patchBaseValue === undefined && patchInput1Value !== undefined;\n\t\t\t// Add: check if input2 added it\n\t\t\tinput2Changed = patchBaseValue === undefined && patchInput2Value !== undefined;\n\t\t} else if (patch.op === \"remove\") {\n\t\t\t// Remove: check if input1 removed it (exists in base, doesn't exist in input1)\n\t\t\tinput1Changed = patchBaseValue !== undefined && patchInput1Value === undefined;\n\t\t\t// Remove: check if input2 removed it\n\t\t\tinput2Changed = patchBaseValue !== undefined && patchInput2Value === undefined;\n\t\t} else if (patch.op === \"replace\") {\n\t\t\t// Replace: check if input1 changed it from base\n\t\t\tif (patchBaseValue !== undefined) {\n\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t} else {\n\t\t\t\t// Added in both (shouldn't happen with replace, but handle it)\n\t\t\t\tinput1Changed = patchInput1Value !== undefined;\n\t\t\t\tinput2Changed = patchInput2Value !== undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Special case: if this is the exact same path as the conflict path, always include\n\t\t// (this handles the case where the path itself changed)\n\t\tif (patchPath === path) {\n\t\t\t// For object-level conflicts, check which input actually changed the object\n\t\t\tif (patchBaseValue !== undefined && patchInput1Value !== undefined && patchInput2Value !== undefined) {\n\t\t\t\tinput1Changed = !isEqual(patchBaseValue, patchInput1Value);\n\t\t\t\tinput2Changed = !isEqual(patchBaseValue, patchInput2Value);\n\t\t\t} else {\n\t\t\t\tinput1Changed = true;\n\t\t\t\tinput2Changed = true;\n\t\t\t}\n\t\t}\n\n\t\t// Don't include patches for properties where the input's value is identical to base\n\t\t// This ensures identical properties aren't highlighted\n\t\tif (patchBaseValue !== undefined) {\n\t\t\tif (patchInput1Value !== undefined && isEqual(patchBaseValue, patchInput1Value)) {\n\t\t\t\tinput1Changed = false; // Input1 didn't change - same as base\n\t\t\t}\n\t\t\tif (patchInput2Value !== undefined && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\tinput2Changed = false; // Input2 didn't change - same as base\n\t\t\t}\n\t\t}\n\n\t\t// Also check: don't include patches for properties where all values are identical\n\t\tif (patchBaseValue !== undefined && patchInput1Value !== undefined && patchInput2Value !== undefined) {\n\t\t\tif (isEqual(patchBaseValue, patchInput1Value) && isEqual(patchBaseValue, patchInput2Value)) {\n\t\t\t\tinput1Changed = false; // All identical - no change\n\t\t\t\tinput2Changed = false;\n\t\t\t}\n\t\t}\n\n\t\t// Add to appropriate filtered arrays\n\t\tif (input1Changed) {\n\t\t\tfilteredPatches1.push(patch);\n\t\t}\n\t\tif (input2Changed) {\n\t\t\tfilteredPatches2.push(patch);\n\t\t}\n\t}\n\n\t// If no patches remain after filtering, check if the path itself changed\n\tif (filteredPatches1.length === 0 && filteredPatches2.length === 0) {\n\t\t// Check if values are actually identical across all versions\n\t\t// If so, don't create a conflict (no change to highlight)\n\t\tconst allValuesIdentical =\n\t\t\tbaseValue !== undefined &&\n\t\t\tinput1Value !== undefined &&\n\t\t\tinput2Value !== undefined &&\n\t\t\tisEqual(baseValue, input1Value) &&\n\t\t\tisEqual(baseValue, input2Value);\n\n\t\tif (allValuesIdentical) {\n\t\t\t// Values are identical - no conflict to report\n\t\t\treturn [];\n\t\t}\n\t\t// If path value changed but no filtered patches, still create conflict with all patches\n\t\t// (might be an object-level change)\n\t}\n\n\t// Use filtered patches for conflict detection - use original patches if filtered are empty\n\tconst patches1ToUse = filteredPatches1.length > 0 ? filteredPatches1 : pathPatches;\n\tconst patches2ToUse = filteredPatches2.length > 0 ? filteredPatches2 : pathPatches;\n\n\t// For conflict type detection, check both sets\n\tconst patchesToUse = [...patches1ToUse, ...patches2ToUse];\n\n\tconst hasAdd = patchesToUse.some((p) => p.op === \"add\");\n\tconst hasRemove = patchesToUse.some((p) => p.op === \"remove\");\n\tconst hasReplace = patchesToUse.some((p) => p.op === \"replace\");\n\n\tif (hasAdd && !hasReplace && !hasRemove) {\n\t\t// Pure add: only highlight on the side that has the value\n\t\t// But check which input actually has the value\n\t\tif (input1Value !== undefined && input2Value === undefined) {\n\t\t\t// Added in input1 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: undefined,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value: undefined,\n\t\t\t\t\tconflictType: ConflictType.INPUT1_ONLY,\n\t\t\t\t\tpatches1: patches1ToUse, // Highlight on input1 (new content) - use filtered patches1\n\t\t\t\t\tpatches2: [], // No highlighting on input2 (doesn't exist there)\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (input2Value !== undefined && input1Value === undefined) {\n\t\t\t// Added in input2 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: undefined,\n\t\t\t\t\tinput1Value: undefined,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType: ConflictType.INPUT2_ONLY,\n\t\t\t\t\tpatches1: [], // No highlighting on input1 (doesn't exist there)\n\t\t\t\t\tpatches2: patches2ToUse, // Highlight on input2 (new content) - use filtered patches2\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\tif (hasRemove && !hasAdd && !hasReplace) {\n\t\t// Pure remove: check which input removed it\n\t\tif (input1Value !== undefined && input2Value === undefined) {\n\t\t\t// Removed in input2 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: input1Value,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value: undefined,\n\t\t\t\t\tconflictType: ConflictType.INPUT1_ONLY,\n\t\t\t\t\tpatches1: patches1ToUse, // Highlight on input1 (removed content) - use filtered patches1\n\t\t\t\t\tpatches2: [], // No highlighting on input2 (doesn't exist there)\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (input2Value !== undefined && input1Value === undefined) {\n\t\t\t// Removed in input1 only\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue: input2Value,\n\t\t\t\t\tinput1Value: undefined,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType: ConflictType.INPUT2_ONLY,\n\t\t\t\t\tpatches1: [], // No highlighting on input1 (doesn't exist there)\n\t\t\t\t\tpatches2: patches2ToUse, // Highlight on input2 (removed content) - use filtered patches2\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\n\t// Replace or mixed operations: determine conflict type based on actual values\n\tconst conflictType = determineConflictType(baseValue, input1Value, input2Value);\n\n\t// Determine which patches to include based on conflict type\n\t// Use filtered patches (only actual changes) instead of all patches\n\tlet patches1: JsonPatchOperation[] = [];\n\tlet patches2: JsonPatchOperation[] = [];\n\n\tswitch (conflictType) {\n\t\tcase ConflictType.INPUT1_ONLY:\n\t\t\tpatches1 = patches1ToUse; // Input1 has the change - use filtered patches1\n\t\t\tpatches2 = [];\n\t\t\tbreak;\n\t\tcase ConflictType.INPUT2_ONLY:\n\t\t\tpatches1 = [];\n\t\t\tpatches2 = patches2ToUse; // Input2 has the change - use filtered patches2\n\t\t\tbreak;\n\t\tcase ConflictType.SAME_CHANGE:\n\t\t\t// Both changed to same value - highlight both with their respective filtered patches\n\t\t\tpatches1 = patches1ToUse;\n\t\t\tpatches2 = patches2ToUse;\n\t\t\tbreak;\n\t\tcase ConflictType.TRUE_CONFLICT:\n\t\t\t// Both changed to different values - highlight both with their respective filtered patches\n\t\t\tpatches1 = patches1ToUse;\n\t\t\tpatches2 = patches2ToUse;\n\t\t\tbreak;\n\t}\n\n\treturn [\n\t\t{\n\t\t\tpath,\n\t\t\tbaseValue,\n\t\t\tinput1Value,\n\t\t\tinput2Value,\n\t\t\tconflictType,\n\t\t\tpatches1,\n\t\t\tpatches2,\n\t\t},\n\t];\n}\n\n/**\n * Map conflict analyses (with JSON Patch operations) to Monaco Editor line ranges\n *\n * This function converts JSON Patch paths to line numbers:\n * 1. Takes conflicts with JSON Patch operations (e.g., /resource/0/type)\n * 2. For each patch, finds the actual JSON node in the formatted text using jsonc-parser\n * 3. Maps the node's character offset to line numbers\n * 4. Combines patch locations into line ranges for highlighting\n *\n * This is NOT line-based diff - we're using JSON structure (nodes) to find lines,\n * ensuring we highlight the exact JSON values that changed according to the patches.\n *\n * @param conflicts - Array of conflict analyses with JSON Patch operations\n * @param baseText - Formatted base JSON text (sorted keys, 2-space indent)\n * @param input1Text - Formatted input1 JSON text\n * @param input2Text - Formatted input2 JSON text\n * @returns Array of ModifiedBaseRange objects for Monaco Editor decorations\n */\n/**\n * Calculate line range that encompasses all patches in a group\n *\n * For JSON Patch diffs, we highlight based on the actual patch locations.\n * This ensures we're highlighting the exact JSON values that changed according\n * to the JSON Patch operations, not arbitrary line groups.\n *\n * Strategy:\n * 1. Find line ranges for each patch path using jsonc-parser (the exact changed JSON nodes)\n * 2. Combine ranges to encompass all affected values\n * 3. Skip patches that reference non-existent paths (they return {1,1} as \"not found\")\n */\nfunction calculatePatchLineRange(text: string, patches: JsonPatchOperation[]): { start: number; end: number } {\n\tif (!patches || patches.length === 0) {\n\t\treturn { start: 1, end: 1 };\n\t}\n\n\tlet minStart = Number.MAX_SAFE_INTEGER;\n\tlet maxEnd = 0;\n\tlet foundAnyNode = false;\n\n\tfor (const patch of patches) {\n\t\tconst lines = getNodeLines(text, patch.path);\n\t\t// Skip nodes that weren't found (defaulted to {1, 1})\n\t\t// When a path doesn't exist (e.g., array index that doesn't exist), getNodeLines returns {1,1}\n\t\t// We skip these to avoid polluting the range calculation\n\t\tif (lines.start === 1 && lines.end === 1) {\n\t\t\t// Removed verbose logging\n\t\t\tcontinue;\n\t\t}\n\n\t\tminStart = Math.min(minStart, lines.start);\n\t\tmaxEnd = Math.max(maxEnd, lines.end);\n\t\tfoundAnyNode = true;\n\t}\n\n\t// If no valid lines found, default to line 1\n\tif (!foundAnyNode || minStart === Number.MAX_SAFE_INTEGER || maxEnd === 0) {\n\t\t// Removed verbose logging\n\t\treturn { start: 1, end: 1 };\n\t}\n\n\t// Removed verbose logging\n\treturn { start: minStart, end: maxEnd };\n}\n\nexport function mapConflictsToRanges(\n\tconflicts: ConflictAnalysis[],\n\tbaseText: string,\n\tinput1Text: string,\n\tinput2Text: string,\n): ModifiedBaseRange[] {\n\tconst ranges: ModifiedBaseRange[] = [];\n\n\tfor (let i = 0; i < conflicts.length; i++) {\n\t\tconst conflict = conflicts[i];\n\n\t\t// Calculate line ranges by finding the range that encompasses all patches\n\t\t// For unchanged items (empty patches), use the path directly to get line ranges\n\t\tlet baseLines: { start: number; end: number };\n\t\tlet input1Lines: { start: number; end: number };\n\t\tlet input2Lines: { start: number; end: number };\n\n\t\tif ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - get line range directly from path\n\t\t\tbaseLines = baseText ? getNodeLines(baseText, conflict.path) : { start: 1, end: 1 };\n\t\t\tinput1Lines = getNodeLines(input1Text, conflict.path);\n\t\t\tinput2Lines = getNodeLines(input2Text, conflict.path);\n\t\t} else {\n\t\t\t// Changed item - use patches to calculate ranges\n\t\t\tbaseLines = calculatePatchLineRange(baseText, [...(conflict.patches1 || []), ...(conflict.patches2 || [])]);\n\t\t\tinput1Lines = calculatePatchLineRange(input1Text, conflict.patches1 || []);\n\t\t\tinput2Lines = calculatePatchLineRange(input2Text, conflict.patches2 || []);\n\t\t}\n\n\t\t// Determine if this is a true conflict\n\t\tconst isConflicting = conflict.conflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t// Determine default states based on conflict type\n\t\tlet input1State = InputState.excluded;\n\t\tlet input2State = InputState.excluded;\n\n\t\tswitch (conflict.conflictType) {\n\t\t\tcase ConflictType.SAME_CHANGE:\n\t\t\t\t// Both changed to the same value - accept both (they're identical)\n\t\t\t\tinput1State = InputState.first;\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.INPUT1_ONLY:\n\t\t\t\t// Only input1 changed - accept input1\n\t\t\t\tinput1State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.INPUT2_ONLY:\n\t\t\t\t// Only input2 changed - accept input2\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t\tcase ConflictType.TRUE_CONFLICT:\n\t\t\t\t// True conflict - default to accepting input2 (ours)\n\t\t\t\tinput2State = InputState.first;\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Calculate actual line numbers for each patch (not fake line numbers)\n\t\t// This ensures decorations are applied to the correct lines based on JSON Patch paths\n\t\tconst input1Diffs: { line: number }[] = [];\n\t\tconst input2Diffs: { line: number }[] = [];\n\n\t\tif (conflict.patches1 && (conflict.patches1.length ?? 0) > 0) {\n\t\t\tfor (const patch of conflict.patches1) {\n\t\t\t\t// Skip removals - the item doesn't exist in input1, so there's nothing to highlight\n\t\t\t\t// Highlighting would show wrong lines (line numbers from base don't match input1)\n\t\t\t\tif (patch.op === \"remove\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// For non-removals, find node in input1\n\t\t\t\tconst lines = getNodeLines(input1Text, patch.path);\n\n\t\t\t\t// Only include if the node was found (not {1,1} default)\n\t\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\t\t// For additions/replacements, add ALL lines in the range (for multi-line objects/arrays)\n\t\t\t\t\tfor (let lineNum = lines.start; lineNum <= lines.end; lineNum++) {\n\t\t\t\t\t\tinput1Diffs.push({ line: lineNum });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - still need to highlight it, so add line from path\n\t\t\tconst lines = getNodeLines(input1Text, conflict.path);\n\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\tinput1Diffs.push({ line: lines.start });\n\t\t\t}\n\t\t}\n\n\t\tif (conflict.patches2 && (conflict.patches2.length ?? 0) > 0) {\n\t\t\tfor (const patch of conflict.patches2) {\n\t\t\t\t// Skip removals - the item doesn't exist in input2, so there's nothing to highlight\n\t\t\t\t// Highlighting would show wrong lines (line numbers from base don't match input2)\n\t\t\t\tif (patch.op === \"remove\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// For non-removals, find node in input2\n\t\t\t\tconst lines = getNodeLines(input2Text, patch.path);\n\n\t\t\t\t// Only include if the node was found (not {1,1} default)\n\t\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\t\t// For additions/replacements, add ALL lines in the range (for multi-line objects/arrays)\n\t\t\t\t\tfor (let lineNum = lines.start; lineNum <= lines.end; lineNum++) {\n\t\t\t\t\t\tinput2Diffs.push({ line: lineNum });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((conflict.patches1?.length ?? 0) === 0 && (conflict.patches2?.length ?? 0) === 0) {\n\t\t\t// Unchanged item - still need to highlight it, so add line from path\n\t\t\tconst lines = getNodeLines(input2Text, conflict.path);\n\t\t\tif (lines.start !== 1 || lines.end !== 1) {\n\t\t\t\tinput2Diffs.push({ line: lines.start });\n\t\t\t}\n\t\t}\n\n\t\t// Removed verbose logging\n\n\t\tconst range: ModifiedBaseRange = {\n\t\t\tid: `conflict-${i}`,\n\t\t\tpath: conflict.path, // Include path for value extraction during resolution\n\t\t\tbaseRange: {\n\t\t\t\tstartLineNumber: baseLines.start,\n\t\t\t\tendLineNumberExclusive: baseLines.end + 1,\n\t\t\t},\n\t\t\tinput1Range: {\n\t\t\t\tstartLineNumber: input1Lines.start,\n\t\t\t\tendLineNumberExclusive: input1Lines.end + 1,\n\t\t\t},\n\t\t\tinput2Range: {\n\t\t\t\tstartLineNumber: input2Lines.start,\n\t\t\t\tendLineNumberExclusive: input2Lines.end + 1,\n\t\t\t},\n\t\t\tinput1Diffs,\n\t\t\tinput2Diffs,\n\t\t\tisConflicting,\n\t\t\tconflictType: conflict.conflictType,\n\t\t\tinput1State,\n\t\t\tinput2State,\n\t\t\thandled: conflict.conflictType === ConflictType.SAME_CHANGE,\n\t\t\tfocused: false,\n\t\t};\n\n\t\tranges.push(range);\n\t}\n\n\treturn ranges;\n}\n\n/**\n * Compute diffs using JSON Patch approach\n * @param baseText - Base version (JSON string, can be empty if no base)\n * @param input1Text - Input1 version (JSON string)\n * @param input2Text - Input2 version (JSON string)\n * @param options - Optional configuration\n * @param options.comparisonMode - How to compare: \"split\" or \"sequential\" (default: \"split\")\n * @param options.schema - Optional JSON Schema for schema-aware comparison\n * @param options.patches - Optional pre-computed patches (use instead of computing)\n * @returns Array of ModifiedBaseRange objects\n */\nexport function computeDiffsJsonPatch(\n\tbaseText: string,\n\tinput1Text: string,\n\tinput2Text: string,\n\toptions: {\n\t\tcomparisonMode?: \"split\" | \"sequential\";\n\t\tschema?: JSONSchema;\n\t\tpatches?: {\n\t\t\ttheirs?: JsonPatchOperation[];\n\t\t\tours?: JsonPatchOperation[];\n\t\t};\n\t} = {},\n): ModifiedBaseRange[] {\n\tconst { comparisonMode = \"split\", schema } = options;\n\n\t// Validate inputs\n\tif (!input1Text || !input2Text) {\n\t\tthrow new Error(\"JSON Patch diff requires non-empty input1 and input2 strings\");\n\t}\n\n\ttry {\n\t\t// 1. Parse JSON (with error handling)\n\t\tconst base = baseText ? JSON.parse(baseText) : undefined;\n\t\tconst input1 = JSON.parse(input1Text);\n\t\tconst input2 = JSON.parse(input2Text);\n\n\t\tlet conflicts: ConflictAnalysis[];\n\n\t\tif (base === undefined) {\n\t\t\t// 2-column mode: input1 vs input2 (no base)\n\t\t\t// Use provided patches or compute\n\t\t\tconflicts = analyzeTwoWayConflicts(input1, input2, schema);\n\t\t} else if (comparisonMode === \"split\") {\n\t\t\t// 3-column mode (split): input1 vs base, input2 vs base\n\t\t\t// Use provided patches or compute\n\t\t\tconflicts = analyzeConflicts(base, input1, input2, schema);\n\t\t} else {\n\t\t\t// 3-column mode (sequential): base ? input1 ? input2\n\t\t\t// For sequential, we compare base?input1 and input1?input2\n\t\t\t// This is a different approach - let's analyze it properly\n\t\t\tconst patch1 = compare(base, input1);\n\t\t\tconst patch2 = compare(input1, input2);\n\n\t\t\t// Combine paths from both patch sets\n\t\t\tconst allPaths = new Set<string>();\n\t\t\tpatch1.forEach((p) => {\n\t\t\t\tallPaths.add(p.path);\n\t\t\t});\n\t\t\tpatch2.forEach((p) => {\n\t\t\t\tallPaths.add(p.path);\n\t\t\t});\n\n\t\t\tconflicts = Array.from(allPaths).map((path) => {\n\t\t\t\tconst baseValue = getValueAtPath(base as Record<string, unknown>, path);\n\t\t\t\tconst input1Value = getValueAtPath(input1 as Record<string, unknown>, path);\n\t\t\t\tconst input2Value = getValueAtPath(input2 as Record<string, unknown>, path);\n\n\t\t\t\t// In sequential mode: check both transitions\n\t\t\t\tconst baseToInput1Changed = !isEqual(baseValue, input1Value);\n\t\t\t\tconst input1ToInput2Changed = !isEqual(input1Value, input2Value);\n\n\t\t\t\tlet conflictType: ConflictType;\n\n\t\t\t\tif (baseToInput1Changed && input1ToInput2Changed) {\n\t\t\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t\t\t} else if (baseToInput1Changed) {\n\t\t\t\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t\t\t\t} else if (input1ToInput2Changed) {\n\t\t\t\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t\t\t\t} else {\n\t\t\t\t\tconflictType = ConflictType.SAME_CHANGE;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tpath,\n\t\t\t\t\tbaseValue,\n\t\t\t\t\tinput1Value,\n\t\t\t\t\tinput2Value,\n\t\t\t\t\tconflictType,\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\n\t\t// 3. Map to Monaco ranges\n\t\t// IMPORTANT: Use original text for line number mapping, not formatted text!\n\t\t// The Monaco editors display the original text, so line numbers must match.\n\t\treturn mapConflictsToRanges(conflicts, baseText, input1Text, input2Text);\n\t} catch (error) {\n\t\t// No fallback - re-throw with context\n\t\t// User must fix invalid JSON\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`JSON Patch diff computation failed: ${message}`);\n\t}\n}\n","import { findNodeAtLocation, parseTree } from \"jsonc-parser\";\nimport { ConflictType, InputState, type JSONSchema, type ModifiedBaseRange } from \"../types\";\nimport { getValueAtPath } from \"./helpers\";\nimport { getSchemaAtPath } from \"./jsonPatchDiff\";\n\n/**\n * Represents a single line change with detailed information\n */\ninterface LineChange {\n\tline: number;\n\tinput1Changed: boolean;\n\tinput2Changed: boolean;\n\tbaseLine: string;\n\tinput1Line: string;\n\tinput2Line: string;\n\tconflictType: ConflictType;\n}\n\n/**\n * Compute conflict type for a single line by comparing base, input1, and input2\n */\nexport function computeLineConflictType(\n\tbaseLine: string,\n\tinput1Line: string,\n\tinput2Line: string,\n): {\n\tconflictType: ConflictType;\n\tinput1Changed: boolean;\n\tinput2Changed: boolean;\n} {\n\tconst input1Changed = baseLine !== input1Line;\n\tconst input2Changed = baseLine !== input2Line;\n\n\tlet conflictType: ConflictType;\n\n\tif (input1Changed && input2Changed) {\n\t\t// Both changed - check if they have the same final value\n\t\tif (input1Line === input2Line) {\n\t\t\tconflictType = ConflictType.SAME_CHANGE;\n\t\t} else {\n\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t}\n\t} else if (input1Changed) {\n\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t} else {\n\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t}\n\n\treturn { conflictType, input1Changed, input2Changed };\n}\n\n/**\n * Compute diffs between base, input1, and input2 documents\n * Returns an array of conflict ranges with their types\n */\nexport function computeDiffs(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[] {\n\tconst baseRanges: ModifiedBaseRange[] = [];\n\n\t// Track all changes for each line with detailed comparison and conflict type\n\tconst allChanges: LineChange[] = [];\n\n\tfor (let i = 0; i < Math.max(baseLines.length, input1Lines.length, input2Lines.length); i++) {\n\t\tconst baseLine = baseLines[i] !== undefined ? baseLines[i] : \"\";\n\t\tconst input1Line = input1Lines[i] !== undefined ? input1Lines[i] : \"\";\n\t\tconst input2Line = input2Lines[i] !== undefined ? input2Lines[i] : \"\";\n\n\t\tconst { conflictType, input1Changed, input2Changed } = computeLineConflictType(baseLine, input1Line, input2Line);\n\n\t\tif (input1Changed || input2Changed) {\n\t\t\tallChanges.push({\n\t\t\t\tline: i + 1,\n\t\t\t\tinput1Changed,\n\t\t\t\tinput2Changed,\n\t\t\t\tbaseLine,\n\t\t\t\tinput1Line,\n\t\t\t\tinput2Line,\n\t\t\t\tconflictType,\n\t\t\t});\n\t\t}\n\t}\n\n\t// Group consecutive changes with the SAME conflict type into ranges\n\tif (allChanges.length === 0) {\n\t\treturn [];\n\t}\n\n\tlet rangeStart = allChanges[0]?.line ?? 1;\n\tlet currentConflictType = allChanges[0]?.conflictType;\n\tlet input1DiffsInRange: { line: number }[] = [];\n\tlet input2DiffsInRange: { line: number }[] = [];\n\n\tfor (let i = 0; i <= allChanges.length; i++) {\n\t\tconst current = allChanges[i];\n\t\tconst isLast = i === allChanges.length;\n\t\tconst isGap = !isLast && current && allChanges[i - 1] && current.line > (allChanges[i - 1]?.line ?? 0) + 1;\n\t\tconst typeChanged = !isLast && current && current.conflictType !== currentConflictType;\n\n\t\tif (isLast || isGap || typeChanged) {\n\t\t\t// End of range\n\t\t\tconst prevChange = allChanges[i - 1];\n\t\t\tconst rangeEnd = prevChange ? prevChange.line + 1 : rangeStart + 1;\n\n\t\t\tconst hasInput1Changes = input1DiffsInRange.length > 0;\n\t\t\tconst hasInput2Changes = input2DiffsInRange.length > 0;\n\t\t\tconst isConflicting = currentConflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t\tconst range: ModifiedBaseRange = {\n\t\t\t\tid: `conflict-${baseRanges.length}`,\n\t\t\t\tbaseRange: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput2Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Diffs: input1DiffsInRange,\n\t\t\t\tinput2Diffs: input2DiffsInRange,\n\t\t\t\tisConflicting,\n\t\t\t\tconflictType: currentConflictType,\n\t\t\t\t// Default: accept input2 (ours) by default, or both if same change\n\t\t\t\tinput1State: currentConflictType === ConflictType.SAME_CHANGE && hasInput1Changes ? InputState.first : InputState.excluded,\n\t\t\t\tinput2State: hasInput2Changes ? InputState.first : InputState.excluded,\n\t\t\t\thandled: currentConflictType === ConflictType.SAME_CHANGE,\n\t\t\t\tfocused: false,\n\t\t\t};\n\n\t\t\tbaseRanges.push(range);\n\n\t\t\t// Start new range\n\t\t\tif (!isLast && current) {\n\t\t\t\trangeStart = current.line;\n\t\t\t\tcurrentConflictType = current.conflictType;\n\t\t\t\tinput1DiffsInRange = [];\n\t\t\t\tinput2DiffsInRange = [];\n\t\t\t}\n\t\t}\n\n\t\tif (!isLast && current) {\n\t\t\tif (current.input1Changed) {\n\t\t\t\tinput1DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t\tif (current.input2Changed) {\n\t\t\t\tinput2DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn baseRanges;\n}\n\n/**\n * Compute diffs in sequential mode: base→input1→input2\n * In this mode, we compare base with input1, and input1 with input2\n */\nexport function computeDiffsSequential(baseLines: string[], input1Lines: string[], input2Lines: string[]): ModifiedBaseRange[] {\n\tconst baseRanges: ModifiedBaseRange[] = [];\n\n\t// Track all changes for each line\n\tconst allChanges: LineChange[] = [];\n\n\tfor (let i = 0; i < Math.max(baseLines.length, input1Lines.length, input2Lines.length); i++) {\n\t\tconst baseLine = baseLines[i] !== undefined ? baseLines[i] : \"\";\n\t\tconst input1Line = input1Lines[i] !== undefined ? input1Lines[i] : \"\";\n\t\tconst input2Line = input2Lines[i] !== undefined ? input2Lines[i] : \"\";\n\n\t\t// In sequential mode: compare base→input1 and input1→input2\n\t\tconst baseToInput1Changed = baseLine !== input1Line;\n\t\tconst input1ToInput2Changed = input1Line !== input2Line;\n\n\t\tlet conflictType: ConflictType;\n\n\t\tif (baseToInput1Changed && input1ToInput2Changed) {\n\t\t\t// Both transitions changed\n\t\t\tconflictType = ConflictType.TRUE_CONFLICT;\n\t\t} else if (baseToInput1Changed) {\n\t\t\t// Only base→input1 changed\n\t\t\tconflictType = ConflictType.INPUT1_ONLY;\n\t\t} else if (input1ToInput2Changed) {\n\t\t\t// Only input1→input2 changed\n\t\t\tconflictType = ConflictType.INPUT2_ONLY;\n\t\t} else {\n\t\t\t// No changes\n\t\t\tcontinue;\n\t\t}\n\n\t\tallChanges.push({\n\t\t\tline: i + 1,\n\t\t\tinput1Changed: baseToInput1Changed,\n\t\t\tinput2Changed: input1ToInput2Changed,\n\t\t\tbaseLine,\n\t\t\tinput1Line,\n\t\t\tinput2Line,\n\t\t\tconflictType,\n\t\t});\n\t}\n\n\t// Group consecutive changes with the SAME conflict type into ranges\n\tif (allChanges.length === 0) {\n\t\treturn [];\n\t}\n\n\tlet rangeStart = allChanges[0]?.line ?? 1;\n\tlet currentConflictType = allChanges[0]?.conflictType;\n\tlet input1DiffsInRange: { line: number }[] = [];\n\tlet input2DiffsInRange: { line: number }[] = [];\n\n\tfor (let i = 0; i <= allChanges.length; i++) {\n\t\tconst current = allChanges[i];\n\t\tconst isLast = i === allChanges.length;\n\t\tconst isGap = !isLast && current && allChanges[i - 1] && current.line > (allChanges[i - 1]?.line ?? 0) + 1;\n\t\tconst typeChanged = !isLast && current && current.conflictType !== currentConflictType;\n\n\t\tif (isLast || isGap || typeChanged) {\n\t\t\t// End of range\n\t\t\tconst prevChange = allChanges[i - 1];\n\t\t\tconst rangeEnd = prevChange ? prevChange.line + 1 : rangeStart + 1;\n\n\t\t\tconst hasInput1Changes = input1DiffsInRange.length > 0;\n\t\t\tconst hasInput2Changes = input2DiffsInRange.length > 0;\n\t\t\tconst isConflicting = currentConflictType === ConflictType.TRUE_CONFLICT;\n\n\t\t\tconst range: ModifiedBaseRange = {\n\t\t\t\tid: `conflict-${baseRanges.length}`,\n\t\t\t\tbaseRange: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput2Range: {\n\t\t\t\t\tstartLineNumber: rangeStart,\n\t\t\t\t\tendLineNumberExclusive: rangeEnd,\n\t\t\t\t},\n\t\t\t\tinput1Diffs: input1DiffsInRange,\n\t\t\t\tinput2Diffs: input2DiffsInRange,\n\t\t\t\tisConflicting,\n\t\t\t\tconflictType: currentConflictType,\n\t\t\t\t// Default: accept input2 (final state) by default\n\t\t\t\tinput1State: hasInput1Changes ? InputState.first : InputState.excluded,\n\t\t\t\tinput2State: hasInput2Changes ? InputState.first : InputState.excluded,\n\t\t\t\thandled: false,\n\t\t\t\tfocused: false,\n\t\t\t};\n\n\t\t\tbaseRanges.push(range);\n\n\t\t\t// Start new range\n\t\t\tif (!isLast && current) {\n\t\t\t\trangeStart = current.line;\n\t\t\t\tcurrentConflictType = current.conflictType;\n\t\t\t\tinput1DiffsInRange = [];\n\t\t\t\tinput2DiffsInRange = [];\n\t\t\t}\n\t\t}\n\n\t\tif (!isLast && current) {\n\t\t\tif (current.input1Changed) {\n\t\t\t\tinput1DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t\tif (current.input2Changed) {\n\t\t\t\tinput2DiffsInRange.push({ line: current.line });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn baseRanges;\n}\n\n/**\n * Information about a conflict resolution issue\n */\nexport interface ConflictIssue {\n\tconflictId: string;\n\tconflictPath: string;\n\ttype: \"error\" | \"warning\" | \"smart-merge\";\n\tmessage: string;\n\tstartLine: number;\n\tendLine: number;\n}\n\n/**\n * Result of building merged content with validation\n */\nexport interface BuildResultContentResult {\n\tcontent: string;\n\tisValid: boolean;\n\tvalidationError?: string;\n\twarnings?: string[];\n\tconflictIssues?: ConflictIssue[];\n}\n\n/**\n * Set a value at a given JSON Pointer path in an object\n * @param obj - The object to modify\n * @param path - JSON Pointer path (e.g., \"/items/0/name\")\n * @param value - Value to set\n * @throws Error if path is invalid or types don't match\n */\nexport function setValueAtPath(obj: unknown, path: string, value: unknown): void {\n\tif (!path || path === \"/\") {\n\t\t// Setting root - replace entire object\n\t\tif (\n\t\t\ttypeof obj === \"object\" &&\n\t\t\tobj !== null &&\n\t\t\t!Array.isArray(obj) &&\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\t!Array.isArray(value)\n\t\t) {\n\t\t\tObject.assign(obj, value);\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(`Cannot assign root value: expected object, got ${typeof value}`);\n\t}\n\n\tconst pathSegments = path.split(\"/\").filter((s) => s !== \"\");\n\tlet current: Record<string, unknown> | unknown[] = obj as Record<string, unknown> | unknown[];\n\n\tfor (let i = 0; i < pathSegments.length - 1; i++) {\n\t\tconst segment = pathSegments[i];\n\t\t// Check if segment is numeric (array index)\n\t\tconst numericIndex = Number.parseInt(segment, 10);\n\t\tif (!Number.isNaN(numericIndex) && String(numericIndex) === segment) {\n\t\t\t// Array index\n\t\t\tif (!Array.isArray(current)) {\n\t\t\t\tthrow new Error(`Path ${path}: segment ${segment} expects array but got ${typeof current}`);\n\t\t\t}\n\t\t\tcurrent = current[numericIndex] as Record<string, unknown> | unknown[];\n\t\t} else {\n\t\t\t// Object key\n\t\t\tif (!current || typeof current !== \"object\" || Array.isArray(current)) {\n\t\t\t\tthrow new Error(`Path ${path}: segment ${segment} expects object but got ${typeof current}`);\n\t\t\t}\n\t\t\tconst objCurrent = current as Record<string, unknown>;\n\t\t\tif (!(segment in objCurrent)) {\n\t\t\t\tobjCurrent[segment] = {};\n\t\t\t}\n\t\t\tcurrent = objCurrent[segment] as Record<string, unknown> | unknown[];\n\t\t}\n\t}\n\n\tconst lastSegment = pathSegments[pathSegments.length - 1];\n\tconst lastNumeric = Number.parseInt(lastSegment, 10);\n\tif (!Number.isNaN(lastNumeric) && String(lastNumeric) === lastSegment) {\n\t\t// Setting array element\n\t\tif (!Array.isArray(current)) {\n\t\t\tthrow new Error(`Path ${path}: last segment expects array but got ${typeof current}`);\n\t\t}\n\t\tcurrent[lastNumeric] = value;\n\t} else {\n\t\t// Setting object property\n\t\tif (!current || typeof current !== \"object\" || Array.isArray(current)) {\n\t\t\tthrow new Error(`Path ${path}: last segment expects object but got ${typeof current}`);\n\t\t}\n\t\t(current as Record<string, unknown>)[lastSegment] = value;\n\t}\n}\n\n/**\n * Find line numbers for a JSON path in formatted JSON text\n * @param jsonContent - Formatted JSON string\n * @param path - JSON Pointer path\n * @returns Line number range or null if path not found\n */\nexport function findLinesForPath(jsonContent: string, path: string): { startLine: number; endLine: number } | null {\n\ttry {\n\t\tconst tree = parseTree(jsonContent);\n\t\tif (!tree) return null;\n\n\t\t// Navigate to the path\n\t\tconst segments = path\n\t\t\t.split(\"/\")\n\t\t\t.filter((s) => s !== \"\")\n\t\t\t.map((segment) => {\n\t\t\t\t// Check if segment is a numeric array index\n\t\t\t\tconst numericValue = Number.parseInt(segment, 10);\n\t\t\t\treturn !Number.isNaN(numericValue) && String(numericValue) === segment ? numericValue : segment;\n\t\t\t});\n\t\tconst node = findNodeAtLocation(tree, segments);\n\n\t\tif (!node) return null;\n\n\t\tconst lines = jsonContent.substring(0, node.offset).split(\"\\n\");\n\t\tconst startLine = lines.length;\n\n\t\tconst endOffset = node.offset + node.length;\n\t\tconst endLines = jsonContent.substring(0, endOffset).split(\"\\n\");\n\t\tconst endLine = endLines.length;\n\n\t\treturn { startLine, endLine };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Attempt to smart-merge two JSON values based on their types and schema\n * Returns the merged value or null if merge is not possible\n */\nexport function smartMergeValues(value1: unknown, value2: unknown, schema?: JSONSchema, path = \"\"): unknown | null {\n\t// If values are identical, return either one\n\tif (JSON.stringify(value1) === JSON.stringify(value2)) {\n\t\treturn value1;\n\t}\n\n\t// If both are objects (not arrays), attempt deep merge\n\tif (\n\t\tvalue1 !== null &&\n\t\tvalue2 !== null &&\n\t\ttypeof value1 === \"object\" &&\n\t\ttypeof value2 === \"object\" &&\n\t\t!Array.isArray(value1) &&\n\t\t!Array.isArray(value2)\n\t) {\n\t\tconst obj1 = value1 as Record<string, unknown>;\n\t\tconst obj2 = value2 as Record<string, unknown>;\n\t\tconst merged = { ...obj1 };\n\n\t\t// Get schema for this object if available\n\t\tconst objectSchema = schema ? getSchemaAtPath(schema, path, value1) : null;\n\n\t\tconst properties =\n\t\t\tobjectSchema?.properties && typeof objectSchema.properties === \"object\" && !Array.isArray(objectSchema.properties)\n\t\t\t\t? (objectSchema.properties as Record<string, JSONSchema>)\n\t\t\t\t: undefined;\n\t\tconst additionalProperties = objectSchema?.additionalProperties;\n\n\t\tfor (const key of Object.keys(obj2)) {\n\t\t\tif (!(key in merged)) {\n\t\t\t\t// Key only in value2 - add it if allowed by schema\n\t\t\t\tconst isAllowed = additionalProperties === true || additionalProperties === undefined || properties?.[key] !== undefined;\n\n\t\t\t\tif (isAllowed) {\n\t\t\t\t\tmerged[key] = obj2[key];\n\t\t\t\t} else if (additionalProperties === false) {\n\t\t\t\t\t// Schema explicitly disallows additional properties - conflict\n\t\t\t\t\treturn null;\n\t\t\t\t} else if (typeof additionalProperties === \"object\") {\n\t\t\t\t\t// additionalProperties is a schema - allow it\n\t\t\t\t\tmerged[key] = obj2[key];\n\t\t\t\t} else {\n\t\t\t\t\t// Unknown case - be safe and don't allow\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t} else if (JSON.stringify(merged[key]) !== JSON.stringify(obj2[key])) {\n\t\t\t\t// Key exists in both but with different values\n\t\t\t\t// Get schema for this property\n\t\t\t\tconst propertySchema = properties?.[key];\n\t\t\t\tconst nestedPath = path ? `${path}/${key}` : `/${key}`;\n\n\t\t\t\t// Try to recursively merge\n\t\t\t\tconst recursiveMerge = smartMergeValues(merged[key], obj2[key], propertySchema, nestedPath);\n\t\t\t\tif (recursiveMerge !== null) {\n\t\t\t\t\tmerged[key] = recursiveMerge;\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot merge - conflict remains\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If values are identical, keep the existing value\n\t\t}\n\n\t\treturn merged;\n\t}\n\n\t// If both are arrays with same length, could potentially merge items\n\t// But this is complex and may not make sense without schema guidance\n\t// For now, return null to indicate merge not possible\n\n\t// Cannot merge - different types or incompatible values\n\treturn null;\n}\n\n/**\n * Build result content from conflict ranges based on their states\n * Legacy version without validation - kept for backward compatibility\n */\nexport function buildResultContent(\n\tbaseLines: string[],\n\tinput1Lines: string[],\n\tinput2Lines: string[],\n\tconflicts: ModifiedBaseRange[],\n): string {\n\tconst result = buildResultContentWithValidation(baseLines, input1Lines, input2Lines, conflicts);\n\treturn result.content;\n}\n\n/**\n * Build result content from conflict ranges based on their states\n * Returns validation information along with the merged content\n */\nexport function buildResultContentWithValidation(\n\tbaseLines: string[],\n\tinput1Lines: string[],\n\tinput2Lines: string[],\n\tconflicts: ModifiedBaseRange[],\n\tschema?: JSONSchema,\n): BuildResultContentResult {\n\tconst warnings: string[] = [];\n\tconst conflictIssues: ConflictIssue[] = [];\n\n\t// Parse full documents for semantic merging\n\tconst baseText = baseLines.join(\"\\n\");\n\tconst input1Text = input1Lines.join(\"\\n\");\n\tconst input2Text = input2Lines.join(\"\\n\");\n\n\tlet baseData: unknown;\n\tlet input1Data: unknown;\n\tlet input2Data: unknown;\n\n\ttry {\n\t\tbaseData = baseText ? JSON.parse(baseText) : {};\n\t\tinput1Data = input1Text ? JSON.parse(input1Text) : {};\n\t\tinput2Data = input2Text ? JSON.parse(input2Text) : {};\n\t} catch (e) {\n\t\treturn {\n\t\t\tcontent: baseText || \"\",\n\t\t\tisValid: false,\n\t\t\tvalidationError: `Failed to parse input JSON: ${e instanceof Error ? e.message : String(e)}`,\n\t\t\twarnings,\n\t\t};\n\t}\n\n\t// Build result JSON semantically from parsed data\n\t// Start with base and apply changes based on conflict resolution\n\tlet resultData: unknown;\n\n\t// If base is empty, start with input2 (ours) as default\n\tif (!baseData || (typeof baseData === \"object\" && baseData !== null && Object.keys(baseData).length === 0)) {\n\t\tresultData = JSON.parse(JSON.stringify(input2Data)); // Deep clone\n\t} else {\n\t\tresultData = JSON.parse(JSON.stringify(baseData)); // Deep clone base\n\t}\n\n\t// Track which paths we've already applied to avoid duplicates\n\tconst appliedPaths = new Set<string>();\n\t// Track which properties have been explicitly set (to avoid overwriting when merging parents)\n\tconst explicitlySetProperties = new Set<string>();\n\t// Track which parent paths have been merged (to avoid merging same parent multiple times)\n\tconst mergedParents = new Set<string>();\n\n\t// Helper function to find path from line range\n\tconst findPathFromLines = (_startLine: number, _endLine: number, _text: string): string | null => {\n\t\t// This is a simplified approach - for full implementation, we'd need to map lines to JSON paths\n\t\t// For now, if we can't determine path, we'll use line-based merge\n\t\treturn null;\n\t};\n\n\t// Apply each conflict resolution to the result data\n\tfor (const conflict of conflicts) {\n\t\tconst includesInput1 = conflict.input1State === InputState.first || conflict.input1State === InputState.second;\n\t\tconst includesInput2 = conflict.input2State === InputState.first || conflict.input2State === InputState.second;\n\n\t\t// If no path is available, try to infer it or use line-based merge\n\t\tlet conflictPath = conflict.path;\n\t\tif (!conflictPath) {\n\t\t\t// Try to find path from the line range\n\t\t\tconflictPath =\n\t\t\t\tfindPathFromLines(conflict.baseRange.startLineNumber, conflict.baseRange.endLineNumberExclusive, baseText) || undefined;\n\n\t\t\t// If we still don't have a path, use a fallback strategy: merge the entire document\n\t\t\t// by applying conflict resolution based on conflict type and input states\n\t\t\tif (!conflictPath) {\n\t\t\t\t// For conflicts without paths, determine which input to use based on conflict type\n\t\t\t\tif (conflict.conflictType === ConflictType.INPUT2_ONLY && includesInput2) {\n\t\t\t\t\t// INPUT2_ONLY with input2 accepted - use input2\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (conflict.conflictType === ConflictType.INPUT1_ONLY && includesInput1) {\n\t\t\t\t\t// INPUT1_ONLY with input1 accepted - use input1\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input1Data));\n\t\t\t\t} else if (conflict.conflictType === ConflictType.SAME_CHANGE && (includesInput1 || includesInput2)) {\n\t\t\t\t\t// SAME_CHANGE - both are the same, use input2\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (includesInput2) {\n\t\t\t\t\t// If input2 is accepted, prefer it\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input2Data));\n\t\t\t\t} else if (includesInput1) {\n\t\t\t\t\t// If input1 is accepted, use it\n\t\t\t\t\tresultData = JSON.parse(JSON.stringify(input1Data));\n\t\t\t\t}\n\t\t\t\t// Otherwise keep resultData as is (base or previously set value)\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tlet valueToApply: unknown;\n\t\t\tlet pathToApply = conflictPath;\n\n\t\t\t// Detect if this conflict affects an array - check if path contains array index\n\t\t\t// Pattern: /some/path/\\d+/property or /some/path/\\d+\n\t\t\tconst arrayItemMatch = conflict.path?.match(/^(.*\\/\\d+)(?:\\/.*)?$/);\n\t\t\tlet isArrayItemConflict = false;\n\t\t\tlet arrayPath = \"\";\n\n\t\t\tif (arrayItemMatch) {\n\t\t\t\t// This is an array item conflict\n\t\t\t\t// Extract the array path (parent of the numeric index)\n\t\t\t\tconst fullItemPath = arrayItemMatch[1]; // e.g., \"/itemsLimits/item/2\"\n\t\t\t\tconst segments = fullItemPath.split(\"/\").filter((s) => s !== \"\");\n\t\t\t\tif (segments.length >= 2) {\n\t\t\t\t\tconst lastSegment = segments[segments.length - 1];\n\t\t\t\t\tif (/^\\d+$/.test(lastSegment)) {\n\t\t\t\t\t\t// Last segment is numeric - this is an array item\n\t\t\t\t\t\tisArrayItemConflict = true;\n\t\t\t\t\t\tarrayPath = `/${segments.slice(0, -1).join(\"/\")}`; // e.g., \"/itemsLimits/item\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (includesInput1 && includesInput2) {\n\t\t\t\t// Both accepted\n\t\t\t\tif (conflict.conflictType === ConflictType.SAME_CHANGE) {\n\t\t\t\t\t// Same change - use input2 (or input1, they're identical)\n\t\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\t\t// Get the entire array from input2\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// TRUE_CONFLICT with both accepted - attempt smart merge\n\t\t\t\t\tconst extractPath = isArrayItemConflict ? arrayPath : conflictPath;\n\t\t\t\t\tconst input1Value = getValueAtPath(input1Data as Record<string, unknown>, extractPath);\n\t\t\t\t\tconst input2Value = getValueAtPath(input2Data as Record<string, unknown>, extractPath);\n\n\t\t\t\t\t// Get schema for this conflict path if available\n\t\t\t\t\tconst conflictSchema =\n\t\t\t\t\t\tschema && baseData && typeof baseData === \"object\"\n\t\t\t\t\t\t\t? getSchemaAtPath(schema, extractPath, baseData) || undefined\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tconst mergedValue = smartMergeValues(input1Value, input2Value, conflictSchema, extractPath);\n\n\t\t\t\t\tif (mergedValue !== null) {\n\t\t\t\t\t\tvalueToApply = mergedValue;\n\t\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t\t\twarnings.push(`Smart-merged conflict at path ${extractPath}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Merge failed - prefer input2 (ours) as default\n\t\t\t\t\t\tvalueToApply = input2Value;\n\t\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t\t\twarnings.push(`Merge failed at path ${extractPath}, using input2 value`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (includesInput1) {\n\t\t\t\t// Only input1 accepted\n\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t} else {\n\t\t\t\t\t// For nested properties, merge parent object but preserve explicitly set properties\n\t\t\t\t\tconst pathSegments = conflictPath.split(\"/\").filter(Boolean);\n\t\t\t\t\tif (pathSegments.length > 1) {\n\t\t\t\t\t\tconst parentPath = `/${pathSegments.slice(0, -1).join(\"/\")}`;\n\t\t\t\t\t\t// Only merge parent if we haven't merged it yet\n\t\t\t\t\t\tif (!mergedParents.has(parentPath)) {\n\t\t\t\t\t\t\tconst parentInInput1 = getValueAtPath(input1Data as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\tif (typeof parentInInput1 === \"object\" && parentInInput1 !== null && !Array.isArray(parentInInput1)) {\n\t\t\t\t\t\t\t\tconst currentParent = getValueAtPath(resultData as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\t\tif (typeof currentParent === \"object\" && currentParent !== null && !Array.isArray(currentParent)) {\n\t\t\t\t\t\t\t\t\t// Merge parent, but preserve properties already explicitly set\n\t\t\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(parentInInput1)) {\n\t\t\t\t\t\t\t\t\t\tconst childPath = `${parentPath}/${key}`;\n\t\t\t\t\t\t\t\t\t\tif (!explicitlySetProperties.has(childPath)) {\n\t\t\t\t\t\t\t\t\t\t\t(currentParent as Record<string, unknown>)[key] = value;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmergedParents.add(parentPath);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input1Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (includesInput2) {\n\t\t\t\t// Only input2 accepted\n\t\t\t\tif (isArrayItemConflict) {\n\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, arrayPath);\n\t\t\t\t\tpathToApply = arrayPath;\n\t\t\t\t} else {\n\t\t\t\t\t// For nested properties, merge parent object but preserve explicitly set properties\n\t\t\t\t\tconst pathSegments = conflictPath.split(\"/\").filter(Boolean);\n\t\t\t\t\tif (pathSegments.length > 1) {\n\t\t\t\t\t\tconst parentPath = `/${pathSegments.slice(0, -1).join(\"/\")}`;\n\t\t\t\t\t\t// Only merge parent if we haven't merged it yet\n\t\t\t\t\t\tif (!mergedParents.has(parentPath)) {\n\t\t\t\t\t\t\tconst parentInInput2 = getValueAtPath(input2Data as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\tif (typeof parentInInput2 === \"object\" && parentInInput2 !== null && !Array.isArray(parentInInput2)) {\n\t\t\t\t\t\t\t\tconst currentParent = getValueAtPath(resultData as Record<string, unknown>, parentPath);\n\t\t\t\t\t\t\t\tif (typeof currentParent === \"object\" && currentParent !== null && !Array.isArray(currentParent)) {\n\t\t\t\t\t\t\t\t\t// Merge parent, but preserve properties already explicitly set\n\t\t\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(parentInInput2)) {\n\t\t\t\t\t\t\t\t\t\tconst childPath = `${parentPath}/${key}`;\n\t\t\t\t\t\t\t\t\t\tif (!explicitlySetProperties.has(childPath)) {\n\t\t\t\t\t\t\t\t\t\t\t(currentParent as Record<string, unknown>)[key] = value;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmergedParents.add(parentPath);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueToApply = getValueAtPath(input2Data as Record<string, unknown>, conflictPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Neither accepted - keep base value (or remove if it was added)\n\t\t\t\tconst extractPath = isArrayItemConflict ? arrayPath : conflictPath;\n\t\t\t\tconst baseValue = getValueAtPath(baseData as Record<string, unknown>, extractPath);\n\t\t\t\tif (baseValue !== undefined) {\n\t\t\t\t\tvalueToApply = baseValue;\n\t\t\t\t\tpathToApply = extractPath;\n\t\t\t\t} else {\n\t\t\t\t\t// Property doesn't exist in base - remove it from result\n\t\t\t\t\t// For now, we'll just skip it and let the final JSON stringify handle it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply the value to result data\n\t\t\tif (valueToApply !== undefined) {\n\t\t\t\t// Always set the value at the specific path\n\t\t\t\tsetValueAtPath(resultData, pathToApply, valueToApply);\n\n\t\t\t\t// Track that we've applied this specific path\n\t\t\t\tappliedPaths.add(pathToApply);\n\t\t\t\t// Mark this property as explicitly set (so parent merges don't overwrite it)\n\t\t\t\texplicitlySetProperties.add(pathToApply);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\twarnings.push(`Failed to apply conflict at path ${conflictPath || conflict.id}: ${e instanceof Error ? e.message : String(e)}`);\n\t\t}\n\t}\n\n\t// Convert result data to JSON string\n\tconst content = JSON.stringify(resultData, null, 2);\n\n\t// Now that we have the final content, map conflict issues to line numbers\n\tfor (const conflict of conflicts) {\n\t\tconst conflictPath = conflict.path;\n\t\tif (!conflictPath) continue;\n\n\t\tconst includesInput1 = conflict.input1State === InputState.first || conflict.input1State === InputState.second;\n\t\tconst includesInput2 = conflict.input2State === InputState.first || conflict.input2State === InputState.second;\n\n\t\t// Check if this conflict has both inputs checked (potential for issues)\n\t\tif (includesInput1 && includesInput2 && conflict.conflictType === ConflictType.TRUE_CONFLICT) {\n\t\t\t// For TRUE_CONFLICT with both checkboxes checked, always show warning\n\t\t\t// because the system made an arbitrary choice and the user should review it\n\t\t\tconst lineInfo = findLinesForPath(content, conflictPath);\n\t\t\tif (lineInfo) {\n\t\t\t\tconflictIssues.push({\n\t\t\t\t\tconflictId: conflict.id,\n\t\t\t\t\tconflictPath: conflictPath,\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: \"Both conflicting changes were accepted - please review and manually resolve\",\n\t\t\t\t\tstartLine: lineInfo.startLine,\n\t\t\t\t\tendLine: lineInfo.endLine,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate the result is valid JSON\n\tlet isValid = true;\n\tlet validationError: string | undefined;\n\n\ttry {\n\t\tJSON.parse(content);\n\t} catch (e) {\n\t\tisValid = false;\n\t\tvalidationError = e instanceof Error ? e.message : \"Invalid JSON\";\n\n\t\t// Add a general error issue\n\t\tconflictIssues.push({\n\t\t\tconflictId: \"validation-error\",\n\t\t\tconflictPath: \"/\",\n\t\t\ttype: \"error\",\n\t\t\tmessage: validationError,\n\t\t\tstartLine: 1,\n\t\t\tendLine: content.split(\"\\n\").length,\n\t\t});\n\t}\n\n\treturn {\n\t\tcontent,\n\t\tisValid,\n\t\tvalidationError,\n\t\twarnings: warnings.length > 0 ? warnings : undefined,\n\t\tconflictIssues: conflictIssues.length > 0 ? conflictIssues : undefined,\n\t};\n}\n","import type * as monaco from \"monaco-editor\";\nimport type { ModifiedBaseRange } from \"../types\";\nimport { ConflictType as ConflictTypeEnum } from \"../types\";\n\n/**\n * Configuration for editor decoration colors and styles\n */\nexport interface DecorationConfig {\n\tconflictColor: string;\n\tchangeColor: string;\n\tbaseColor: string;\n\tconflictOverviewColor: string;\n\tchangeOverviewColor: string;\n\tbaseOverviewColor: string;\n}\n\n/**\n * Determines CSS classes and overview colors based on conflict type\n */\nexport interface DecorationClasses {\n\tinput1Class: string;\n\tinput2Class: string;\n\tbaseClass: string;\n\tinput1OverviewColor: string;\n\tinput2OverviewColor: string;\n\tbaseOverviewColor: string;\n}\n\n/**\n * Determines the CSS classes and colors for decorations based on conflict type\n */\nexport function getDecorationClasses(conflict: ModifiedBaseRange, isTwoColumnMode: boolean, config: DecorationConfig): DecorationClasses {\n\tlet input1Class = \"\";\n\tlet input2Class = \"\";\n\tlet baseClass = \"\";\n\tlet input1OverviewColor = \"\";\n\tlet input2OverviewColor = \"\";\n\tlet baseOverviewColor = \"\";\n\n\tswitch (conflict.conflictType) {\n\t\tcase ConflictTypeEnum.SAME_CHANGE: {\n\t\t\t// Check if this is an item added in both inputs (not in base)\n\t\t\tconst isAddedInBothSame =\n\t\t\t\tconflict.baseRange.startLineNumber === 1 &&\n\t\t\t\tconflict.baseRange.endLineNumberExclusive === 2 && // Default \"not found\" range\n\t\t\t\tconflict.input1Range.startLineNumber !== 1 &&\n\t\t\t\tconflict.input2Range.startLineNumber !== 1;\n\n\t\t\tif (isAddedInBothSame) {\n\t\t\t\t// Both inputs added the same item - highlight both in blue (auto-merged)\n\t\t\t\tinput1Class = \"merge-same-change\"; // Blue for input1 (same addition)\n\t\t\t\tinput2Class = \"merge-same-change\"; // Blue for input2 (same addition)\n\t\t\t\tbaseClass = \"\"; // No base highlighting (doesn't exist in base)\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// Both made the same change to existing item:\n\t\t\t\t// - input2 (ours) should be highlighted in blue (same-change)\n\t\t\t\t// - input1 (theirs) should be highlighted in red (incoming)\n\t\t\t\tinput1Class = \"merge-change-incoming\"; // Red for theirs (input1)\n\t\t\t\tinput2Class = \"merge-same-change\"; // Blue for ours (input2)\n\t\t\t\tbaseClass = \"merge-change-base\";\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase ConflictTypeEnum.INPUT1_ONLY:\n\t\t\t// Only input1 has content (removed in input2)\n\t\t\t// In 2-column mode: highlight input1 as deletion (red)\n\t\t\t// In 3-column mode: highlight input1 and base\n\t\t\tif (isTwoColumnMode) {\n\t\t\t\t// 2-column: highlight input1 as deletion (red for removed content)\n\t\t\t\tinput1Class = \"merge-2way-deletion\"; // Red for deletions in 2-way mode\n\t\t\t\tinput2Class = \"\"; // No highlighting on input2 (doesn't exist)\n\t\t\t\tinput1OverviewColor = config.baseOverviewColor; // Red for removed content\n\t\t\t\tinput2OverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// 3-column: highlight input1 and base\n\t\t\t\tinput1Class = \"merge-change-incoming\";\n\t\t\t\tinput2Class = \"\";\n\t\t\t\tbaseClass = \"merge-change-base\";\n\t\t\t\tinput1OverviewColor = config.conflictOverviewColor; // Orange for incoming changes\n\t\t\t\tinput2OverviewColor = \"\";\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase ConflictTypeEnum.INPUT2_ONLY:\n\t\t\t// Only input2 changed (addition in input2)\n\t\t\t// In 2-column mode: only highlight input2 as addition (green)\n\t\t\t// In 3-column mode: highlight input2 and base\n\t\t\tinput1Class = \"\"; // No highlighting on input1 (doesn't exist in 2-way, or unchanged in 3-way)\n\t\t\tinput2Class = \"merge-change-current\"; // Green for additions\n\t\t\tbaseClass = isTwoColumnMode ? \"\" : \"merge-change-base\";\n\t\t\tinput1OverviewColor = \"\";\n\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\tbaseOverviewColor = isTwoColumnMode ? \"\" : config.baseOverviewColor;\n\t\t\tbreak;\n\t\tcase ConflictTypeEnum.TRUE_CONFLICT: {\n\t\t\t// Check if this is an item added in both inputs (not in base)\n\t\t\t// If so, highlight as additions (orange) instead of conflicts (red)\n\t\t\tconst isAddedInBoth =\n\t\t\t\tconflict.baseRange.startLineNumber === 1 &&\n\t\t\t\tconflict.baseRange.endLineNumberExclusive === 2 && // Default \"not found\" range\n\t\t\t\tconflict.input1Range.startLineNumber !== 1 &&\n\t\t\t\tconflict.input2Range.startLineNumber !== 1;\n\n\t\t\tif (isAddedInBoth) {\n\t\t\t\t// Item added in both inputs - highlight as additions (orange/green)\n\t\t\t\tinput1Class = \"merge-change-incoming\"; // Orange/red for input1 addition\n\t\t\t\tinput2Class = \"merge-change-current\"; // Green for input2 addition\n\t\t\t\tbaseClass = \"\"; // No base highlighting\n\t\t\t\tinput1OverviewColor = config.changeOverviewColor;\n\t\t\t\tinput2OverviewColor = config.changeOverviewColor;\n\t\t\t\tbaseOverviewColor = \"\";\n\t\t\t} else {\n\t\t\t\t// True conflict - highlight all three\n\t\t\t\tinput1Class = \"merge-conflict-incoming\";\n\t\t\t\tinput2Class = \"merge-conflict-current\";\n\t\t\t\tbaseClass = \"merge-conflict-base\";\n\t\t\t\tinput1OverviewColor = config.conflictOverviewColor;\n\t\t\t\tinput2OverviewColor = config.conflictOverviewColor;\n\t\t\t\tbaseOverviewColor = config.baseOverviewColor;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn {\n\t\tinput1Class,\n\t\tinput2Class,\n\t\tbaseClass,\n\t\tinput1OverviewColor,\n\t\tinput2OverviewColor,\n\t\tbaseOverviewColor,\n\t};\n}\n\n/**\n * Extracts unique line numbers from diff arrays\n */\nfunction extractUniqueLines(diffs: unknown[]): number[] {\n\tconst uniqueLines = new Set<number>();\n\tfor (const diff of diffs) {\n\t\tif (diff && typeof diff === \"object\" && \"line\" in diff) {\n\t\t\tconst lineNum = (diff as { line: number }).line;\n\t\t\tif (lineNum > 0) {\n\t\t\t\tuniqueLines.add(lineNum);\n\t\t\t}\n\t\t}\n\t}\n\treturn Array.from(uniqueLines).sort((a, b) => a - b);\n}\n\n/**\n * Creates Monaco editor decorations for input1 (theirs) panel\n */\nexport function createInput1Decorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Only highlight specific lines from input1Diffs, not the entire range\n\t// This ensures we don't highlight lines with identical/unchanged properties\n\tif (conflict.input1Diffs.length > 0 && classes.input1Class) {\n\t\tconst uniqueLines = extractUniqueLines(conflict.input1Diffs);\n\n\t\t// Create a decoration for each unique line that actually changed\n\t\tfor (const lineNum of uniqueLines) {\n\t\t\tdecorations.push({\n\t\t\t\trange: new monacoInstance.Range(lineNum, 1, lineNum, Number.MAX_SAFE_INTEGER),\n\t\t\t\toptions: {\n\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\tclassName: classes.input1Class,\n\t\t\t\t\toverviewRuler: classes.input1OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input1OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminimap: classes.input1OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input1OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates Monaco editor decorations for input2 (ours) panel\n */\nexport function createInput2Decorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Only highlight specific lines from input2Diffs, not the entire range\n\t// This ensures we don't highlight lines with identical/unchanged properties\n\tif (conflict.input2Diffs.length > 0 && classes.input2Class) {\n\t\tconst uniqueLines = extractUniqueLines(conflict.input2Diffs);\n\n\t\t// Create a decoration for each unique line that actually changed\n\t\tfor (const lineNum of uniqueLines) {\n\t\t\tdecorations.push({\n\t\t\t\trange: new monacoInstance.Range(lineNum, 1, lineNum, Number.MAX_SAFE_INTEGER),\n\t\t\t\toptions: {\n\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\tclassName: classes.input2Class,\n\t\t\t\t\toverviewRuler: classes.input2OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input2OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminimap: classes.input2OverviewColor\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcolor: classes.input2OverviewColor,\n\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates Monaco editor decorations for base panel\n */\nexport function createBaseDecorations(\n\tconflict: ModifiedBaseRange,\n\tclasses: DecorationClasses,\n\tmonacoInstance: typeof monaco,\n): monaco.editor.IModelDeltaDecoration[] {\n\tconst decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\t// Color base changes - always highlight when there's any change\n\t// Skip highlighting if baseRange is the default {1, 2} - this means the item doesn't exist in base\n\tconst isDefaultRange = conflict.baseRange.startLineNumber === 1 && conflict.baseRange.endLineNumberExclusive === 2;\n\n\tif ((conflict.input1Diffs.length > 0 || conflict.input2Diffs.length > 0) && !isDefaultRange) {\n\t\tdecorations.push({\n\t\t\trange: new monacoInstance.Range(\n\t\t\t\tconflict.baseRange.startLineNumber,\n\t\t\t\t1,\n\t\t\t\tconflict.baseRange.endLineNumberExclusive - 1,\n\t\t\t\tNumber.MAX_SAFE_INTEGER,\n\t\t\t),\n\t\t\toptions: {\n\t\t\t\tisWholeLine: true,\n\t\t\t\tclassName: classes.baseClass,\n\t\t\t\toverviewRuler: {\n\t\t\t\t\tcolor: classes.baseOverviewColor,\n\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Full,\n\t\t\t\t},\n\t\t\t\tminimap: {\n\t\t\t\t\tcolor: classes.baseOverviewColor,\n\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t}\n\n\treturn decorations;\n}\n\n/**\n * Creates all decorations for a conflict (input1, input2, and base)\n */\nexport function createConflictDecorations(\n\tconflict: ModifiedBaseRange,\n\tisTwoColumnMode: boolean,\n\tconfig: DecorationConfig,\n\tmonacoInstance: typeof monaco,\n): {\n\tinput1Decorations: monaco.editor.IModelDeltaDecoration[];\n\tinput2Decorations: monaco.editor.IModelDeltaDecoration[];\n\tbaseDecorations: monaco.editor.IModelDeltaDecoration[];\n} {\n\tconst classes = getDecorationClasses(conflict, isTwoColumnMode, config);\n\n\treturn {\n\t\tinput1Decorations: createInput1Decorations(conflict, classes, monacoInstance),\n\t\tinput2Decorations: createInput2Decorations(conflict, classes, monacoInstance),\n\t\tbaseDecorations: createBaseDecorations(conflict, classes, monacoInstance),\n\t};\n}\n\n/**\n * Creates decorations for all conflicts\n */\nexport function createAllDecorations(\n\tconflicts: ModifiedBaseRange[],\n\tisTwoColumnMode: boolean,\n\tconfig: DecorationConfig,\n\tmonacoInstance: typeof monaco,\n): {\n\tinput1Decorations: monaco.editor.IModelDeltaDecoration[];\n\tinput2Decorations: monaco.editor.IModelDeltaDecoration[];\n\tbaseDecorations: monaco.editor.IModelDeltaDecoration[];\n} {\n\tconst input1Decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\tconst input2Decorations: monaco.editor.IModelDeltaDecoration[] = [];\n\tconst baseDecorations: monaco.editor.IModelDeltaDecoration[] = [];\n\n\tfor (const conflict of conflicts) {\n\t\tconst decorations = createConflictDecorations(conflict, isTwoColumnMode, config, monacoInstance);\n\t\tinput1Decorations.push(...decorations.input1Decorations);\n\t\tinput2Decorations.push(...decorations.input2Decorations);\n\t\tbaseDecorations.push(...decorations.baseDecorations);\n\t}\n\n\treturn {\n\t\tinput1Decorations,\n\t\tinput2Decorations,\n\t\tbaseDecorations,\n\t};\n}\n","import loader from \"@monaco-editor/loader\";\nimport type * as monaco from \"monaco-editor\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { type EditorDiffMergeProps, InputState, type ModifiedBaseRange } from \"../types\";\nimport { buildResultContentWithValidation, type ConflictIssue } from \"../utils/diffMerge\";\nimport { createAllDecorations, type DecorationConfig } from \"../utils/editorDecorations\";\nimport { computeDiffsJsonPatch } from \"../utils/jsonPatchDiff\";\nimport \"../styles/editor.css\";\n\n// Default Loader component\nconst DefaultLoader = () => <div style={{ padding: \"20px\", textAlign: \"center\", color: \"#888\" }}>Loading Monaco Editor...</div>;\n\nconst ISSUE_ICON = \"⚠\";\n\ninterface ITextModelWithDecorations extends monaco.editor.ITextModel {\n\t_conflictIssueDecorations?: monaco.editor.IEditorDecorationsCollection;\n}\n\nexport function JsonDiffMergeEditor(props: EditorDiffMergeProps) {\n\tconst {\n\t\toriginal = \"\",\n\t\tmodified = \"\",\n\t\tbase = \"\",\n\t\ttheme = \"vs\",\n\t\toptions = {},\n\t\twidth = \"100%\",\n\t\theight = \"100%\",\n\t\tclassName,\n\t\tloading,\n\t\tonMount,\n\t\tonMergeResolve,\n\t\tshowResultColumn = false,\n\t\tbaseIndex = 1,\n\t\tcomparisonMode = \"split\",\n\t\tschema,\n\t\tpatches,\n\t\tlabels,\n\t} = props;\n\n\t// Hardcode language to \"json\" - this component is JSON-only\n\tconst language = \"json\";\n\n\tconst [isEditorReady, setIsEditorReady] = useState(false);\n\tconst [isMonacoMounting, setIsMonacoMounting] = useState(true);\n\tconst [conflicts, setConflicts] = useState<ModifiedBaseRange[]>([]);\n\tconst [_validationError, setValidationError] = useState<string | null>(null);\n\tconst [_validationWarnings, setValidationWarnings] = useState<string[]>([]);\n\tconst [conflictIssues, setConflictIssues] = useState<ConflictIssue[]>([]);\n\tconst [isResultManuallyEdited, setIsResultManuallyEdited] = useState(false);\n\n\t// Function to render native checkbox (simpler and more reliable than React Portal)\n\tconst renderCheckbox = useCallback((state: InputState, _inputNumber: 1 | 2, _conflictId: string, onToggle: () => void) => {\n\t\tconst container = document.createElement(\"div\");\n\t\tcontainer.className = \"native-checkbox-container\";\n\n\t\tconst checkbox = document.createElement(\"input\");\n\t\tcheckbox.type = \"checkbox\";\n\t\tcheckbox.className = \"native-checkbox\";\n\t\tcheckbox.checked = state === InputState.first || state === InputState.second;\n\t\tcheckbox.setAttribute(\"aria-label\", checkbox.checked ? \"Undo accept\" : \"Accept change\");\n\n\t\tcheckbox.addEventListener(\"click\", (e) => {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\t\t\t// Defer the toggle to avoid React setState warning\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tonToggle();\n\t\t\t});\n\t\t});\n\n\t\tcontainer.appendChild(checkbox);\n\t\treturn container;\n\t}, []);\n\n\tconst [_editorKey, setEditorKey] = useState(0);\n\n\tconst input1EditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst baseEditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst input2EditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst resultEditorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);\n\tconst monacoRef = useRef<typeof monaco | null>(null);\n\tconst containerRef = useRef<HTMLDivElement | null>(null);\n\tconst preventCreation = useRef(false);\n\tconst isProgrammaticUpdate = useRef(false);\n\n\t// Gutter container refs for checkbox UI\n\tconst input1GutterRef = useRef<HTMLDivElement | null>(null);\n\tconst input2GutterRef = useRef<HTMLDivElement | null>(null);\n\tconst resultGutterRef = useRef<HTMLDivElement | null>(null);\n\tconst gutterViewsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n\tconst resultLabelRef = useRef<HTMLDivElement | null>(null);\n\n\t// Decoration collections for proper updating\n\tconst input1DecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\tconst input2DecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\tconst baseDecorationsRef = useRef<monaco.editor.IEditorDecorationsCollection | null>(null);\n\n\t// Initialize Monaco\n\tuseEffect(() => {\n\t\tlet isMounted = true;\n\t\tconst cancelable = loader.init();\n\n\t\tcancelable\n\t\t\t.then((monacoInstance: typeof monaco) => {\n\t\t\t\tif (!isMounted) return;\n\t\t\t\tmonacoRef.current = monacoInstance;\n\t\t\t\tsetIsMonacoMounting(false);\n\t\t\t\tsetIsEditorReady(true);\n\t\t\t})\n\t\t\t.catch((error: Error) => {\n\t\t\t\tif (!isMounted) return;\n\t\t\t\tif ((error as { type?: string })?.type !== \"cancelation\") {\n\t\t\t\t\tconsole.error(\"Monaco initialization: error:\", error);\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn () => {\n\t\t\tisMounted = false;\n\n\t\t\tif (!preventCreation.current) {\n\t\t\t\tcancelable.cancel();\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// Compute diffs using JSON Patch approach (always)\n\tconst computeDiffs = useCallback(\n\t\t(\n\t\t\tbaseModel: monaco.editor.ITextModel | null,\n\t\t\tinput1Model: monaco.editor.ITextModel,\n\t\t\tinput2Model: monaco.editor.ITextModel,\n\t\t): ModifiedBaseRange[] => {\n\t\t\tif (!monacoRef.current) return [];\n\n\t\t\tconst baseText = baseModel?.getValue() || \"\";\n\t\t\tconst input1Text = input1Model.getValue();\n\t\t\tconst input2Text = input2Model.getValue();\n\n\t\t\ttry {\n\t\t\t\tconst startTime = performance.now();\n\t\t\t\tconst ranges = computeDiffsJsonPatch(baseText, input1Text, input2Text, {\n\t\t\t\t\tcomparisonMode,\n\t\t\t\t\tschema,\n\t\t\t\t\tpatches,\n\t\t\t\t});\n\t\t\t\tconst duration = performance.now() - startTime;\n\n\t\t\t\tif (duration > 100) {\n\t\t\t\t\tconsole.warn(`JSON Patch diff took ${duration.toFixed(2)}ms`);\n\t\t\t\t}\n\n\t\t\t\treturn ranges;\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconsole.error(\"JSON Patch diff error:\", message);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t},\n\t\t[comparisonMode, schema, patches],\n\t);\n\n\t// Get the position where decorations start (after line numbers)\n\tconst getDecorationsLeft = useCallback((editor: monaco.editor.IStandaloneCodeEditor): number => {\n\t\ttry {\n\t\t\tconst layoutInfo = editor.getLayoutInfo();\n\t\t\t// decorationsLeft is where the decorations area starts\n\t\t\treturn layoutInfo.decorationsLeft || 0;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}, []);\n\n\t// Get the width of the decorations area\n\tconst getDecorationsWidth = useCallback((editor: monaco.editor.IStandaloneCodeEditor): number => {\n\t\ttry {\n\t\t\tconst layoutInfo = editor.getLayoutInfo();\n\t\t\treturn layoutInfo.decorationsWidth || 0;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t}, []);\n\n\t// Render conflict issue markers in result column gutter\n\tconst renderConflictIssueMarkers = useCallback(\n\t\t(issues: ConflictIssue[]) => {\n\t\t\tif (!showResultColumn || !resultEditorRef.current || !resultGutterRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\tif (!monacoInstance) return;\n\n\t\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t\t// Position the gutter container on the right side\n\t\t\tconst decorationsLeft = getDecorationsLeft(resultEditorRef.current);\n\t\t\tconst decorationsWidth = getDecorationsWidth(resultEditorRef.current);\n\n\t\t\tresultGutterRef.current.style.left = `${decorationsLeft}px`;\n\t\t\tresultGutterRef.current.style.width = `${decorationsWidth}px`;\n\n\t\t\tconst scrollTop = resultEditorRef.current.getScrollTop();\n\t\t\tconst model = resultEditorRef.current.getModel();\n\t\t\tif (!model) return;\n\n\t\t\t// Clear existing indicators\n\t\t\tresultGutterRef.current.innerHTML = \"\";\n\n\t\t\t// Render each conflict issue marker\n\t\t\tfor (const issue of issues) {\n\t\t\t\tconst startLine = issue.startLine;\n\t\t\t\tconst endLine = issue.endLine;\n\n\t\t\t\t// Calculate position for this issue\n\t\t\t\tconst topStart = resultEditorRef.current.getTopForLineNumber(startLine) - scrollTop;\n\t\t\t\tconst topEnd = resultEditorRef.current.getTopForLineNumber(endLine) - scrollTop;\n\t\t\t\tconst lineHeight = resultEditorRef.current.getOption(monacoInstance.editor.EditorOption.lineHeight);\n\n\t\t\t\t// For multi-line issues, calculate the full height and center the icon\n\t\t\t\tconst isMultiLine = endLine > startLine;\n\t\t\t\tconst fullHeight = isMultiLine ? topEnd - topStart + lineHeight : lineHeight;\n\n\t\t\t\t// Create marker div\n\t\t\t\tconst markerDiv = document.createElement(\"div\");\n\t\t\t\tmarkerDiv.className = `conflict-issue-marker conflict-issue-${issue.type}`;\n\t\t\t\tmarkerDiv.setAttribute(\"data-conflict-id\", issue.conflictId);\n\t\t\t\tmarkerDiv.setAttribute(\"data-issue-type\", issue.type);\n\t\t\t\tmarkerDiv.title = issue.message;\n\t\t\t\tmarkerDiv.style.position = \"absolute\";\n\t\t\t\tmarkerDiv.style.top = `${Math.max(0, topStart)}px`;\n\t\t\t\tmarkerDiv.style.height = `${fullHeight}px`;\n\t\t\t\tmarkerDiv.style.width = \"26px\";\n\t\t\t\tmarkerDiv.style.display = \"flex\";\n\t\t\t\tmarkerDiv.style.alignItems = \"center\";\n\t\t\t\tmarkerDiv.style.justifyContent = \"center\";\n\t\t\t\tmarkerDiv.style.cursor = \"help\";\n\t\t\t\tmarkerDiv.style.pointerEvents = \"auto\";\n\n\t\t\t\t// Add icon\n\t\t\t\tconst icon = document.createElement(\"div\");\n\t\t\t\ticon.className = \"issue-icon\";\n\t\t\t\tif (issue.type === \"error\") {\n\t\t\t\t\ticon.textContent = \"✗\";\n\t\t\t\t\ticon.style.color = isDark ? \"#ff6666\" : \"#cc0000\";\n\t\t\t\t} else if (issue.type === \"warning\") {\n\t\t\t\t\ticon.textContent = ISSUE_ICON;\n\t\t\t\t\ticon.style.color = isDark ? \"#ffaa00\" : \"#ff8800\";\n\t\t\t\t} else if (issue.type === \"smart-merge\") {\n\t\t\t\t\ticon.textContent = \"↕\";\n\t\t\t\t\ticon.style.color = isDark ? \"#0096ff\" : \"#0078d4\";\n\t\t\t\t}\n\t\t\t\ticon.style.fontSize = \"14px\";\n\t\t\t\ticon.style.fontWeight = \"bold\";\n\t\t\t\tmarkerDiv.appendChild(icon);\n\n\t\t\t\tresultGutterRef.current.appendChild(markerDiv);\n\t\t\t}\n\t\t},\n\t\t[showResultColumn, theme, getDecorationsLeft, getDecorationsWidth],\n\t);\n\n\t// Update result editor based on conflict states using extracted utility\n\tconst updateResultEditor = useCallback(\n\t\t(updatedConflicts: ModifiedBaseRange[]) => {\n\t\t\tif (!resultEditorRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't auto-update if user has manually edited the result\n\t\t\tif (isResultManuallyEdited) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst resultModel = resultEditorRef.current.getModel();\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\n\t\t\tif (!resultModel || !input1Model || !input2Model || !baseModel) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst baseLines = baseModel.getLinesContent();\n\t\t\tconst input1Lines = input1Model.getLinesContent();\n\t\t\tconst input2Lines = input2Model.getLinesContent();\n\n\t\t\t// Use enhanced utility function with validation\n\t\t\tconst result = buildResultContentWithValidation(baseLines, input1Lines, input2Lines, updatedConflicts, schema);\n\n\t\t\t// Update validation state\n\t\t\tsetValidationError(result.isValid ? null : result.validationError || \"Invalid JSON\");\n\t\t\tsetValidationWarnings(result.warnings || []);\n\t\t\tsetConflictIssues(result.conflictIssues || []);\n\n\t\t\t// Update result column header to show validation status\n\t\t\tif (resultLabelRef.current) {\n\t\t\t\tconst baseLabel = labels?.result || \"Result\";\n\t\t\t\tif (!result.isValid) {\n\t\t\t\t\tresultLabelRef.current.textContent = `${baseLabel} ${ISSUE_ICON} Invalid JSON`;\n\t\t\t\t\tresultLabelRef.current.style.color = \"#ff4444\";\n\t\t\t\t\tresultLabelRef.current.title = result.validationError || \"Invalid JSON - please fix manually\";\n\t\t\t\t} else if (result.warnings && result.warnings.length > 0) {\n\t\t\t\t\tresultLabelRef.current.textContent = `${baseLabel} ${ISSUE_ICON}`;\n\t\t\t\t\t// resultLabelRef.current.style.color = \"#ffaa00\";\n\t\t\t\t\tresultLabelRef.current.title = result.warnings.join(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tresultLabelRef.current.textContent = baseLabel;\n\t\t\t\t\tresultLabelRef.current.style.color = \"\";\n\t\t\t\t\tresultLabelRef.current.title = \"\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update result model - preserve cursor position and only update if content changed\n\t\t\tconst currentContent = resultModel.getValue();\n\t\t\tif (currentContent !== result.content) {\n\t\t\t\t// Save cursor position and selection\n\t\t\t\tconst position = resultEditorRef.current.getPosition();\n\t\t\t\tconst selection = resultEditorRef.current.getSelection();\n\n\t\t\t\t// Mark as programmatic update so onChange doesn't set manual edit flag\n\t\t\t\tisProgrammaticUpdate.current = true;\n\n\t\t\t\t// Update content\n\t\t\t\tresultModel.setValue(result.content);\n\n\t\t\t\t// Reset programmatic flag immediately\n\t\t\t\tisProgrammaticUpdate.current = false;\n\n\t\t\t\t// Restore cursor position and selection if still valid\n\t\t\t\tif (position) {\n\t\t\t\t\tconst lineCount = resultModel.getLineCount();\n\t\t\t\t\tconst lastLineLength = resultModel.getLineLength(lineCount);\n\n\t\t\t\t\t// Clamp position to valid range\n\t\t\t\t\tconst validatedPosition = {\n\t\t\t\t\t\tlineNumber: Math.min(position.lineNumber, lineCount),\n\t\t\t\t\t\tcolumn:\n\t\t\t\t\t\t\tposition.lineNumber <= lineCount\n\t\t\t\t\t\t\t\t? Math.min(position.column, resultModel.getLineLength(position.lineNumber) + 1)\n\t\t\t\t\t\t\t\t: lastLineLength + 1,\n\t\t\t\t\t};\n\n\t\t\t\t\tresultEditorRef.current.setPosition(validatedPosition);\n\n\t\t\t\t\t// Restore selection if it was a range\n\t\t\t\t\tif (selection && !selection.isEmpty()) {\n\t\t\t\t\t\tresultEditorRef.current.setSelection(selection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply error highlighting if invalid\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\t// Monaco model doesn't have _invalidDecorations in types, but we use it for cleanup\n\t\t\tconst modelWithDecorations = resultModel as monaco.editor.ITextModel & {\n\t\t\t\t_invalidDecorations?: monaco.editor.IEditorDecorationsCollection;\n\t\t\t};\n\t\t\tlet invalidDecorations = modelWithDecorations._invalidDecorations;\n\n\t\t\tif (!result.isValid && resultEditorRef.current && monacoInstance) {\n\t\t\t\tif (!invalidDecorations) {\n\t\t\t\t\tinvalidDecorations = resultEditorRef.current.createDecorationsCollection([]);\n\t\t\t\t\tmodelWithDecorations._invalidDecorations = invalidDecorations;\n\t\t\t\t}\n\t\t\t\tinvalidDecorations.set([\n\t\t\t\t\t{\n\t\t\t\t\t\trange: new monacoInstance.Range(1, 1, resultModel.getLineCount(), Number.MAX_SAFE_INTEGER),\n\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\tisWholeLine: false,\n\t\t\t\t\t\t\tclassName: \"merge-result-invalid\",\n\t\t\t\t\t\t\thoverMessage: { value: result.validationError || \"Invalid JSON - please fix manually\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t} else if (result.isValid && invalidDecorations && resultEditorRef.current) {\n\t\t\t\t// Clear error decorations if valid\n\t\t\t\tinvalidDecorations.set([]);\n\t\t\t}\n\n\t\t\t// Render conflict issue markers in result column gutter and highlight lines\n\t\t\tif (result.conflictIssues && result.conflictIssues.length > 0) {\n\t\t\t\trenderConflictIssueMarkers(result.conflictIssues);\n\n\t\t\t\t// Apply line decorations for conflict issues\n\t\t\t\tif (resultEditorRef.current && monacoInstance) {\n\t\t\t\t\tconst modelWithDecorations = resultModel as ITextModelWithDecorations;\n\t\t\t\t\tif (!modelWithDecorations._conflictIssueDecorations) {\n\t\t\t\t\t\tconst collection: monaco.editor.IEditorDecorationsCollection = resultEditorRef.current.createDecorationsCollection(\n\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t);\n\t\t\t\t\t\tmodelWithDecorations._conflictIssueDecorations = collection;\n\t\t\t\t\t}\n\t\t\t\t\tconst conflictIssueDecorations = modelWithDecorations._conflictIssueDecorations;\n\t\t\t\t\tconst conflictDecorations: monaco.editor.IModelDeltaDecoration[] = result.conflictIssues.map((issue) => {\n\t\t\t\t\t\tlet backgroundColor: string;\n\t\t\t\t\t\tlet borderColor: string;\n\n\t\t\t\t\t\tif (issue.type === \"error\") {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(255, 0, 0, 0.1)\" : \"rgba(255, 0, 0, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#ff6666\" : \"#cc0000\";\n\t\t\t\t\t\t} else if (issue.type === \"warning\") {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(255, 170, 0, 0.1)\" : \"rgba(255, 136, 0, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#ffaa00\" : \"#ff8800\";\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbackgroundColor = theme === \"vs-dark\" ? \"rgba(0, 150, 255, 0.1)\" : \"rgba(0, 120, 212, 0.05)\";\n\t\t\t\t\t\t\tborderColor = theme === \"vs-dark\" ? \"#0096ff\" : \"#0078d4\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\trange: new monacoInstance.Range(issue.startLine, 1, issue.endLine, Number.MAX_SAFE_INTEGER),\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tisWholeLine: true,\n\t\t\t\t\t\t\t\tclassName: `conflict-issue-line conflict-issue-${issue.type}`,\n\t\t\t\t\t\t\t\tlinesDecorationsClassName: `conflict-issue-line-decoration conflict-issue-${issue.type}`,\n\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\toverviewRuler: {\n\t\t\t\t\t\t\t\t\tcolor: borderColor,\n\t\t\t\t\t\t\t\t\tposition: monacoInstance.editor.OverviewRulerLane.Right,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tminimap: {\n\t\t\t\t\t\t\t\t\tcolor: borderColor,\n\t\t\t\t\t\t\t\t\tposition: monacoInstance.editor.MinimapPosition.Inline,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\tconflictIssueDecorations.set(conflictDecorations);\n\t\t\t\t}\n\t\t\t} else if (resultEditorRef.current) {\n\t\t\t\t// Clear conflict issue decorations if there are none\n\t\t\t\tconst modelWithDecorations = resultModel as ITextModelWithDecorations;\n\t\t\t\tif (modelWithDecorations._conflictIssueDecorations) {\n\t\t\t\t\tmodelWithDecorations._conflictIssueDecorations.set([]);\n\t\t\t\t}\n\t\t\t\t// Also clear the gutter markers\n\t\t\t\tif (resultGutterRef.current && showResultColumn) {\n\t\t\t\t\tresultGutterRef.current.innerHTML = \"\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Callback with resolved content and resolution info (even if invalid, so parent can handle)\n\t\t\t// Defer the callback to avoid React setState warning (updating parent component during render)\n\t\t\tif (onMergeResolve) {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tonMergeResolve(result.content, {\n\t\t\t\t\t\tisValid: result.isValid,\n\t\t\t\t\t\tvalidationError: result.validationError,\n\t\t\t\t\t\twarnings: result.warnings,\n\t\t\t\t\t\tconflictIssues: result.conflictIssues,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[onMergeResolve, schema, labels, theme, renderConflictIssueMarkers, showResultColumn, isResultManuallyEdited],\n\t);\n\n\t// Toggle input state (like VSCode's checkbox toggle)\n\tconst toggleInputState = useCallback(\n\t\t(conflictId: string, inputNumber: 1 | 2) => {\n\t\t\t// Reset manual edit flag when user clicks checkbox (they want auto-calculation)\n\t\t\tsetIsResultManuallyEdited(false);\n\n\t\t\tsetConflicts((prevConflicts) => {\n\t\t\t\tconst updatedConflicts = prevConflicts.map((conflict) => {\n\t\t\t\t\tif (conflict.id !== conflictId) return conflict;\n\n\t\t\t\t\tconst currentState = inputNumber === 1 ? conflict.input1State : conflict.input2State;\n\t\t\t\t\tconst newState = currentState === InputState.excluded ? InputState.first : InputState.excluded;\n\n\t\t\t\t\t// Update the appropriate state\n\t\t\t\t\tif (inputNumber === 1) {\n\t\t\t\t\t\treturn { ...conflict, input1State: newState };\n\t\t\t\t\t}\n\t\t\t\t\treturn { ...conflict, input2State: newState };\n\t\t\t\t});\n\n\t\t\t\t// Update result editor if enabled\n\t\t\t\tif (showResultColumn && resultEditorRef.current) {\n\t\t\t\t\tupdateResultEditor(updatedConflicts);\n\t\t\t\t}\n\n\t\t\t\treturn updatedConflicts;\n\t\t\t});\n\t\t},\n\t\t[showResultColumn, updateResultEditor],\n\t);\n\n\t// Render individual checkbox gutter item\n\tconst renderCheckboxGutterItem = useCallback(\n\t\t(\n\t\t\tgutterContainer: HTMLDivElement,\n\t\t\tkey: string,\n\t\t\tconflict: ModifiedBaseRange,\n\t\t\tinputNumber: 1 | 2,\n\t\t\tscrollTop: number,\n\t\t\tviewHeight: number,\n\t\t\t_isDark: boolean,\n\t\t) => {\n\t\t\tconst monacoInstance = monacoRef.current;\n\t\t\tif (!monacoInstance) return;\n\n\t\t\tconst editor = inputNumber === 1 ? input1EditorRef.current : input2EditorRef.current;\n\t\t\tif (!editor) return;\n\n\t\t\tconst range = inputNumber === 1 ? conflict.input1Range : conflict.input2Range;\n\t\t\tconst state = inputNumber === 1 ? conflict.input1State : conflict.input2State;\n\n\t\t\t// Validate range before calculating position\n\t\t\tconst model = editor.getModel();\n\t\t\tif (!model) return;\n\n\t\t\tconst lineCount = model.getLineCount();\n\t\t\tconst startLine = Math.max(1, Math.min(range.startLineNumber, lineCount));\n\t\t\tconst endLine = Math.max(1, Math.min(range.endLineNumberExclusive - 1, lineCount));\n\n\t\t\t// Skip if range is invalid\n\t\t\tif (startLine > lineCount || endLine < 1 || startLine > endLine) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Calculate position\n\t\t\tconst top = editor.getTopForLineNumber(startLine) - scrollTop;\n\t\t\tconst bottom = editor.getBottomForLineNumber(endLine) - scrollTop;\n\t\t\tconst height = bottom - top;\n\n\t\t\t// Get or create view\n\t\t\tlet viewDiv = gutterViewsRef.current.get(key);\n\t\t\tif (!viewDiv) {\n\t\t\t\tviewDiv = document.createElement(\"div\");\n\t\t\t\tviewDiv.className = \"merge-accept-gutter-marker\";\n\n\t\t\t\t// Create background\n\t\t\t\tconst background = document.createElement(\"div\");\n\t\t\t\tbackground.className = \"background\";\n\t\t\t\tviewDiv.appendChild(background);\n\n\t\t\t\t// Create checkbox container\n\t\t\t\tconst checkboxDiv = document.createElement(\"div\");\n\t\t\t\tcheckboxDiv.className = \"checkbox\";\n\n\t\t\t\t// Create checkbox background\n\t\t\t\tconst checkboxBg = document.createElement(\"div\");\n\t\t\t\tcheckboxBg.className = \"checkbox-background\";\n\n\t\t\t\t// Use the checkbox renderer\n\t\t\t\tconst checkboxBtn = renderCheckbox(state, inputNumber, conflict.id, () => toggleInputState(conflict.id, inputNumber));\n\n\t\t\t\tcheckboxBg.appendChild(checkboxBtn);\n\t\t\t\tcheckboxDiv.appendChild(checkboxBg);\n\t\t\t\tviewDiv.appendChild(checkboxDiv);\n\n\t\t\t\tgutterContainer.appendChild(viewDiv);\n\t\t\t\tgutterViewsRef.current.set(key, viewDiv);\n\t\t\t}\n\n\t\t\t// Update position\n\t\t\tviewDiv.style.top = `${top}px`;\n\t\t\tviewDiv.style.height = `${height}px`;\n\n\t\t\t// Update checkbox visual state by replacing with new renderer output\n\t\t\tconst checkboxBg = viewDiv.querySelector(\".checkbox-background\");\n\t\t\tif (checkboxBg) {\n\t\t\t\t// Clear existing checkbox\n\t\t\t\tcheckboxBg.innerHTML = \"\";\n\n\t\t\t\t// Create new checkbox with current state using the renderer\n\t\t\t\tconst newCheckboxBtn = renderCheckbox(state, inputNumber, conflict.id, () => toggleInputState(conflict.id, inputNumber));\n\n\t\t\t\tcheckboxBg.appendChild(newCheckboxBtn);\n\t\t\t}\n\n\t\t\t// Update classes based on state\n\t\t\tconst isHandled = conflict.handled;\n\t\t\tconst isFocused = conflict.focused;\n\t\t\tconst isMultiLine = height > 30;\n\n\t\t\tviewDiv.className = \"merge-accept-gutter-marker\";\n\t\t\tif (isHandled) viewDiv.classList.add(\"handled\");\n\t\t\tif (isFocused) viewDiv.classList.add(\"focused\");\n\t\t\tif (isMultiLine) viewDiv.classList.add(\"multi-line\");\n\t\t\telse viewDiv.classList.add(\"single-line\");\n\n\t\t\t// Position checkbox vertically (smart centering like VSCode)\n\t\t\tconst checkboxDiv = viewDiv.querySelector(\".checkbox\") as HTMLDivElement;\n\t\t\tif (checkboxDiv) {\n\t\t\t\tconst checkboxHeight = 24; // Fixed checkbox height\n\t\t\t\tconst middleHeight = height / 2 - checkboxHeight / 2;\n\t\t\t\tconst margin = checkboxHeight;\n\n\t\t\t\tlet effectiveCheckboxTop = middleHeight;\n\n\t\t\t\t// Preferred viewport range\n\t\t\t\tconst preferredViewPortMin = margin;\n\t\t\t\tconst preferredViewPortMax = viewHeight - margin - checkboxHeight;\n\n\t\t\t\t// Preferred parent range\n\t\t\t\tconst preferredParentMin = margin;\n\t\t\t\tconst preferredParentMax = height - checkboxHeight - margin;\n\n\t\t\t\tif (preferredParentMin < preferredParentMax) {\n\t\t\t\t\t// Clamp to viewport\n\t\t\t\t\teffectiveCheckboxTop = Math.max(preferredViewPortMin, Math.min(effectiveCheckboxTop + top, preferredViewPortMax)) - top;\n\t\t\t\t\t// Clamp to parent\n\t\t\t\t\teffectiveCheckboxTop = Math.max(preferredParentMin, Math.min(effectiveCheckboxTop, preferredParentMax));\n\t\t\t\t}\n\n\t\t\t\tcheckboxDiv.style.top = `${effectiveCheckboxTop + 5}px`;\n\t\t\t}\n\t\t},\n\t\t[toggleInputState, renderCheckbox],\n\t);\n\n\t// Render checkbox gutters\n\tconst renderCheckboxGutters = useCallback(() => {\n\t\t// Only render checkboxes when result column is visible\n\t\tif (!showResultColumn) {\n\t\t\t// Clear any existing checkboxes\n\t\t\tconst allViews = gutterViewsRef.current;\n\t\t\tfor (const [key, view] of allViews.entries()) {\n\t\t\t\tview.remove();\n\t\t\t\tallViews.delete(key);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (!input1EditorRef.current || !input2EditorRef.current || !input1GutterRef.current || !input2GutterRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst monacoInstance = monacoRef.current;\n\n\t\tif (!monacoInstance) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t// Position the gutter containers in Monaco's decorations area\n\t\tconst decorationsLeft1 = getDecorationsLeft(input1EditorRef.current);\n\t\tconst decorationsWidth1 = getDecorationsWidth(input1EditorRef.current);\n\t\tconst decorationsLeft2 = getDecorationsLeft(input2EditorRef.current);\n\t\tconst decorationsWidth2 = getDecorationsWidth(input2EditorRef.current);\n\n\t\t// Position gutters in the decorations area\n\t\tinput1GutterRef.current.style.left = `${decorationsLeft1}px`;\n\t\tinput1GutterRef.current.style.width = `${decorationsWidth1}px`;\n\t\tinput2GutterRef.current.style.left = `${decorationsLeft2}px`;\n\t\tinput2GutterRef.current.style.width = `${decorationsWidth2}px`;\n\n\t\t// Get visible ranges\n\t\tconst visibleRanges = input1EditorRef.current.getVisibleRanges();\n\t\tif (!visibleRanges || visibleRanges.length === 0) return;\n\n\t\tconst scrollTop = input1EditorRef.current.getScrollTop();\n\t\tconst viewHeight = input1GutterRef.current.clientHeight;\n\n\t\t// Track which views we need to keep\n\t\tconst viewsToKeep = new Set<string>();\n\n\t\t// Render checkbox for each conflict\n\t\tfor (const conflict of conflicts) {\n\t\t\tif (conflict.input1Diffs.length === 0 && conflict.input2Diffs.length === 0) continue;\n\n\t\t\t// Render input1 checkbox\n\t\t\tif (conflict.input1Diffs.length > 0) {\n\t\t\t\tconst key = `${conflict.id}-input1`;\n\t\t\t\tviewsToKeep.add(key);\n\t\t\t\trenderCheckboxGutterItem(input1GutterRef.current, key, conflict, 1, scrollTop, viewHeight, isDark);\n\t\t\t}\n\n\t\t\t// Render input2 checkbox\n\t\t\tif (conflict.input2Diffs.length > 0) {\n\t\t\t\tconst key = `${conflict.id}-input2`;\n\t\t\t\tviewsToKeep.add(key);\n\t\t\t\trenderCheckboxGutterItem(input2GutterRef.current, key, conflict, 2, scrollTop, viewHeight, isDark);\n\t\t\t}\n\t\t}\n\n\t\t// Remove unused views\n\t\tconst allViews = gutterViewsRef.current;\n\t\tfor (const [key, view] of allViews.entries()) {\n\t\t\tif (!viewsToKeep.has(key)) {\n\t\t\t\tview.remove();\n\t\t\t\tallViews.delete(key);\n\t\t\t}\n\t\t}\n\t}, [conflicts, theme, showResultColumn, getDecorationsLeft, getDecorationsWidth, renderCheckboxGutterItem]);\n\n\t// Get theme color from Monaco's color registry\n\tconst getThemeColor = useCallback((colorKey: string, fallback: string): string => {\n\t\ttry {\n\t\t\t// Try to get from Monaco's theme definition\n\t\t\tif (monacoRef.current) {\n\t\t\t\tconst currentTheme = (monacoRef.current.editor as { getTheme?: () => { colors?: Record<string, string> } }).getTheme?.();\n\t\t\t\tif (currentTheme?.colors?.[colorKey]) {\n\t\t\t\t\treturn currentTheme.colors[colorKey];\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (_e) {\n\t\t\t// Fall through to default\n\t\t}\n\t\treturn fallback;\n\t}, []);\n\n\t// Apply decorations using Monaco theme colors\n\tconst applyDecorations = useCallback(() => {\n\t\tif (!monacoRef.current || !input1EditorRef.current || !input2EditorRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst monacoInstance = monacoRef.current;\n\n\t\t// Detect if theme is dark or light\n\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\n\t\t// Use Monaco's merge editor theme colors\n\t\tconst conflictColor = getThemeColor(\"mergeEditor.change.background\", isDark ? \"rgba(255, 166, 0, 0.2)\" : \"rgba(255, 166, 0, 0.15)\");\n\n\t\tconst changeColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.2)\" : \"rgba(155, 185, 85, 0.15)\",\n\t\t);\n\n\t\tconst baseColor = getThemeColor(\n\t\t\t\"mergeEditor.changeBase.background\",\n\t\t\tisDark ? \"rgba(255, 100, 100, 0.2)\" : \"rgba(255, 100, 100, 0.15)\",\n\t\t);\n\n\t\t// Overview ruler colors - use theme colors with more opacity\n\t\tconst conflictOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.modifiedForeground\",\n\t\t\tisDark ? \"rgba(255, 166, 0, 0.8)\" : \"rgba(255, 166, 0, 1)\",\n\t\t);\n\t\tconst changeOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.addedForeground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.8)\" : \"rgba(155, 185, 85, 1)\",\n\t\t);\n\t\tconst baseOverviewColor = getThemeColor(\n\t\t\t\"editorOverviewRuler.deletedForeground\",\n\t\t\tisDark ? \"rgba(255, 100, 100, 0.8)\" : \"rgba(255, 100, 100, 1)\",\n\t\t);\n\n\t\t// Check if we're in 2-column mode (no base)\n\t\tconst isTwoColumnMode = !baseEditorRef.current;\n\n\t\t// Create decoration configuration\n\t\tconst decorationConfig: DecorationConfig = {\n\t\t\tconflictColor,\n\t\t\tchangeColor,\n\t\t\tbaseColor,\n\t\t\tconflictOverviewColor,\n\t\t\tchangeOverviewColor,\n\t\t\tbaseOverviewColor,\n\t\t};\n\n\t\t// Create all decorations using the extracted utility functions\n\t\tconst { input1Decorations, input2Decorations, baseDecorations } = createAllDecorations(\n\t\t\tconflicts,\n\t\t\tisTwoColumnMode,\n\t\t\tdecorationConfig,\n\t\t\tmonacoInstance,\n\t\t);\n\n\t\t// Get theme colors for checkbox UI\n\t\tconst checkboxBgColor = getThemeColor(\"input.background\", isDark ? \"#3c3c3c\" : \"#f3f3f3\");\n\t\tconst checkboxBorderColor = getThemeColor(\"input.border\", isDark ? \"#6b6b6b\" : \"#c8c8c8\");\n\t\tconst checkboxFocusBorderColor = getThemeColor(\"focusBorder\", isDark ? \"#007acc\" : \"#0078d4\");\n\t\tconst checkboxCheckedColor = getThemeColor(\"inputOption.activeForeground\", isDark ? \"#3794ff\" : \"#0078d4\");\n\n\t\t// Inject CSS using theme colors\n\t\tconst styleId = \"monaco-three-way-diff-dynamic\";\n\t\tlet styleEl = document.getElementById(styleId) as HTMLStyleElement;\n\t\tif (!styleEl) {\n\t\t\tstyleEl = document.createElement(\"style\");\n\t\t\tstyleEl.id = styleId;\n\t\t\tdocument.head.appendChild(styleEl);\n\t\t}\n\n\t\t// Compute colors for different conflict types\n\t\tconst sameChangeColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(100, 100, 255, 0.15)\" : \"rgba(100, 100, 255, 0.1)\",\n\t\t);\n\n\t\t// INPUT1_ONLY means theirs added something (incoming addition that's accepted)\n\t\t// Should be green (addition color), same as input2Only\n\t\tconst input1OnlyColor = getThemeColor(\n\t\t\t\"diffEditor.insertedTextBackground\",\n\t\t\tisDark ? \"rgba(155, 185, 85, 0.2)\" : \"rgba(155, 185, 85, 0.15)\",\n\t\t);\n\n\t\tstyleEl.textContent = `\n /* True conflict - both sides changed differently (orange/amber) */\n .monaco-editor .merge-conflict-incoming,\n .monaco-editor .merge-conflict-current {\n background-color: ${conflictColor};\n }\n\n /* Single-side change (green for input2/ours, orange for input1/theirs in 3-way) */\n .monaco-editor .merge-change-incoming {\n background-color: ${input1OnlyColor};\n }\n .monaco-editor .merge-change-current {\n background-color: ${changeColor};\n }\n\n /* 2-way diff mode: red for deletions (input1 column) */\n .monaco-editor .merge-2way-deletion {\n background-color: ${baseColor};\n }\n\n /* Same change on both sides (blue/purple) */\n .monaco-editor .merge-same-change {\n background-color: ${sameChangeColor};\n }\n\n /* Base changes */\n .monaco-editor .merge-conflict-base,\n .monaco-editor .merge-change-base {\n background-color: ${baseColor};\n }\n\n /* Invalid JSON in result column */\n .monaco-editor .merge-result-invalid {\n background-color: ${isDark ? \"rgba(255, 0, 0, 0.2)\" : \"rgba(255, 0, 0, 0.1)\"};\n outline: 1px solid ${isDark ? \"rgba(255, 100, 100, 0.5)\" : \"rgba(255, 0, 0, 0.3)\"};\n }\n\n /* VSCode-style checkbox gutter - positioned at Monaco's glyph margin */\n .merge-editor-gutter {\n position: absolute;\n height: 100%;\n top: 0;\n z-index: 10;\n pointer-events: none;\n overflow: visible;\n }\n\n .merge-accept-gutter-marker {\n position: absolute;\n pointer-events: all;\n }\n\n .merge-accept-gutter-marker .background {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n pointer-events: none;\n }\n\n .merge-accept-gutter-marker .checkbox {\n position: absolute;\n width: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n left: 6px;\n }\n\n .merge-accept-gutter-marker .checkbox-background {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 3px;\n background-color: ${checkboxBgColor};\n border: 1px solid ${checkboxBorderColor};\n }\n\n .merge-accept-gutter-marker.focused .checkbox-background {\n border-color: ${checkboxFocusBorderColor};\n border-width: 2px;\n }\n\n .merge-accept-gutter-marker.handled .checkbox-background {\n opacity: 0.6;\n }\n\n /* Native checkbox styles */\n .native-checkbox-container {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n cursor: pointer;\n }\n\n .native-checkbox {\n width: 16px;\n height: 16px;\n cursor: pointer;\n margin: 0;\n accent-color: ${checkboxCheckedColor};\n }\n\n /* Result column status indicator */\n .merge-result-status-indicator {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding-left: 4px;\n cursor: help;\n user-select: none;\n z-index: 10;\n }\n\n .merge-result-status-indicator .status-icon {\n font-weight: bold;\n line-height: 1;\n }\n\n .native-checkbox:hover {\n opacity: 0.8;\n }\n\n .native-checkbox:focus {\n outline: 2px solid ${checkboxFocusBorderColor};\n outline-offset: 2px;\n }\n `;\n\t\t// Apply decorations, replacing old ones\n\t\tif (!input1DecorationsRef.current) {\n\t\t\tinput1DecorationsRef.current = input1EditorRef.current.createDecorationsCollection([]);\n\t\t}\n\t\tinput1DecorationsRef.current.set(input1Decorations);\n\n\t\tif (!input2DecorationsRef.current) {\n\t\t\tinput2DecorationsRef.current = input2EditorRef.current.createDecorationsCollection([]);\n\t\t}\n\t\tinput2DecorationsRef.current.set(input2Decorations);\n\n\t\t// Only apply base decorations if base editor exists (3-column mode)\n\t\tif (baseEditorRef.current) {\n\t\t\tif (!baseDecorationsRef.current) {\n\t\t\t\tbaseDecorationsRef.current = baseEditorRef.current.createDecorationsCollection([]);\n\t\t\t}\n\t\t\tbaseDecorationsRef.current.set(baseDecorations);\n\t\t}\n\t}, [conflicts, theme, getThemeColor]);\n\n\tconst createEditor = useCallback(() => {\n\t\tif (!preventCreation.current && containerRef.current && monacoRef.current && !isMonacoMounting) {\n\t\t\tconst monacoInstance = monacoRef.current;\n\n\t\t\t// Clear container\n\t\t\tcontainerRef.current.innerHTML = \"\";\n\n\t\t\t// Create layout\n\t\t\tconst wrapper = document.createElement(\"div\");\n\t\t\twrapper.style.display = \"flex\";\n\t\t\twrapper.style.height = \"100%\";\n\t\t\twrapper.style.width = \"100%\";\n\n\t\t\t// Detect theme colors\n\t\t\tconst isDark = theme === \"vs-dark\" || (typeof theme === \"string\" && theme.includes(\"dark\"));\n\t\t\tconst borderColor = isDark ? \"#444\" : \"#ddd\";\n\t\t\tconst foregroundColor = isDark ? \"#fff\" : \"#333\";\n\n\t\t\t// Helper to get theme colors (same as getThemeColor but local to createEditor)\n\t\t\tconst getThemeColorLocal = (colorKey: string, fallback: string): string => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentTheme = (monacoInstance.editor as { getTheme?: () => { colors?: Record<string, string> } }).getTheme?.();\n\t\t\t\t\tif (currentTheme?.colors?.[colorKey]) {\n\t\t\t\t\t\treturn currentTheme.colors[colorKey];\n\t\t\t\t\t}\n\t\t\t\t} catch (_e) {\n\t\t\t\t\t// Fall through to default\n\t\t\t\t}\n\t\t\t\treturn fallback;\n\t\t\t};\n\n\t\t\t// Get theme colors for column headers\n\t\t\tconst input1HeaderBg = getThemeColorLocal(\"mergeEditor.conflict.input1.header.background\", isDark ? \"#4B1818\" : \"#FFE6E6\");\n\t\t\tconst baseHeaderBg = getThemeColorLocal(\"editorGutter.background\", isDark ? \"#333\" : \"#f0f0f0\");\n\t\t\tconst input2HeaderBg = getThemeColorLocal(\"mergeEditor.conflict.input2.header.background\", isDark ? \"#1B4B18\" : \"#E6FFE6\");\n\t\t\tconst resultHeaderBg = getThemeColorLocal(\"mergeEditor.result.header.background\", isDark ? \"#7F5F00\" : \"#FFECB3\");\n\n\t\t\t// Create editor containers\n\t\t\tconst createEditorContainer = (label: string, color: string, withGutter = false) => {\n\t\t\t\tconst container = document.createElement(\"div\");\n\t\t\t\tcontainer.style.flex = \"1\";\n\t\t\t\tcontainer.style.display = \"flex\";\n\t\t\t\tcontainer.style.flexDirection = \"column\";\n\t\t\t\tcontainer.style.borderRight = `1px solid ${borderColor}`;\n\n\t\t\t\tconst labelDiv = document.createElement(\"div\");\n\t\t\t\tlabelDiv.textContent = label;\n\t\t\t\tlabelDiv.style.padding = \"4px 8px\";\n\t\t\t\tlabelDiv.style.fontSize = \"11px\";\n\t\t\t\tlabelDiv.style.fontWeight = \"500\";\n\t\t\t\tlabelDiv.style.backgroundColor = color;\n\t\t\t\tlabelDiv.style.color = foregroundColor;\n\t\t\t\tlabelDiv.style.borderBottom = `1px solid ${borderColor}`;\n\t\t\t\tcontainer.appendChild(labelDiv);\n\n\t\t\t\tconst editorWrapper = document.createElement(\"div\");\n\t\t\t\teditorWrapper.style.flex = \"1\";\n\t\t\t\teditorWrapper.style.position = \"relative\";\n\t\t\t\teditorWrapper.style.overflow = `hidden`;\n\n\t\t\t\tconst editorDiv = document.createElement(\"div\");\n\t\t\t\teditorDiv.style.position = \"absolute\";\n\t\t\t\teditorDiv.style.left = \"0\";\n\t\t\t\teditorDiv.style.right = \"0\";\n\t\t\t\teditorDiv.style.top = \"0\";\n\t\t\t\teditorDiv.style.bottom = \"0\";\n\t\t\t\teditorWrapper.appendChild(editorDiv);\n\n\t\t\t\tlet gutterDiv: HTMLDivElement | null = null;\n\t\t\t\tif (withGutter) {\n\t\t\t\t\tgutterDiv = document.createElement(\"div\");\n\t\t\t\t\tgutterDiv.className = \"merge-editor-gutter\";\n\t\t\t\t\teditorWrapper.appendChild(gutterDiv);\n\t\t\t\t}\n\n\t\t\t\tcontainer.appendChild(editorWrapper);\n\n\t\t\t\treturn { container, editorDiv, gutterDiv };\n\t\t\t};\n\n\t\t\tconst input1 = createEditorContainer(labels?.input1 || \"Theirs\", input1HeaderBg, showResultColumn);\n\t\t\tconst input2 = createEditorContainer(labels?.input2 || \"Ours\", input2HeaderBg, showResultColumn);\n\n\t\t\t// Save gutter refs\n\t\t\tif (input1.gutterDiv) input1GutterRef.current = input1.gutterDiv;\n\t\t\tif (input2.gutterDiv) input2GutterRef.current = input2.gutterDiv;\n\n\t\t\t// 2-column mode (no base) vs 3-column mode (with base)\n\t\t\tconst hasBase = Boolean(base);\n\t\t\tlet baseC: ReturnType<typeof createEditorContainer> | null = null;\n\n\t\t\tif (hasBase) {\n\t\t\t\t// 3-column mode: create base column\n\t\t\t\tbaseC = createEditorContainer(labels?.base || \"Base\", baseHeaderBg, false);\n\n\t\t\t\t// Arrange columns based on baseIndex\n\t\t\t\tconst orderedColumns: HTMLDivElement[] = [];\n\n\t\t\t\tif (baseIndex === 0) {\n\t\t\t\t\t// Base on left: [base, input1, input2]\n\t\t\t\t\torderedColumns.push(baseC.container, input1.container, input2.container);\n\t\t\t\t} else if (baseIndex === 1) {\n\t\t\t\t\t// Base in middle: [input1, base, input2] (default)\n\t\t\t\t\torderedColumns.push(input1.container, baseC.container, input2.container);\n\t\t\t\t} else if (baseIndex === 2) {\n\t\t\t\t\t// Base on right: [input1, input2, base]\n\t\t\t\t\torderedColumns.push(input1.container, input2.container, baseC.container);\n\t\t\t\t}\n\n\t\t\t\torderedColumns.forEach((col) => {\n\t\t\t\t\twrapper.appendChild(col);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// 2-column mode: only input1 and input2\n\t\t\t\twrapper.appendChild(input1.container);\n\t\t\t\twrapper.appendChild(input2.container);\n\t\t\t}\n\n\t\t\t// Create result column if enabled\n\t\t\tlet resultC: { container: HTMLDivElement; editorDiv: HTMLDivElement; gutterDiv: HTMLDivElement | null } | null = null;\n\t\t\tif (showResultColumn) {\n\t\t\t\tresultC = createEditorContainer(labels?.result || \"Result\", resultHeaderBg, true); // Enable gutter for error indicators\n\t\t\t\t// Store reference to result label for validation error indicators\n\t\t\t\tresultLabelRef.current = resultC.container.querySelector(\"div\") as HTMLDivElement;\n\t\t\t\t// Store reference to result gutter for error/warning indicators\n\t\t\t\tif (resultC.gutterDiv) resultGutterRef.current = resultC.gutterDiv;\n\t\t\t\twrapper.appendChild(resultC.container);\n\t\t\t}\n\n\t\t\tcontainerRef.current.appendChild(wrapper);\n\n\t\t\t// Create models\n\t\t\tconst input1Model = monacoInstance.editor.createModel(original || \"\", language);\n\t\t\tconst baseModel = hasBase ? monacoInstance.editor.createModel(base || \"\", language) : null;\n\t\t\tconst input2Model = monacoInstance.editor.createModel(modified || \"\", language);\n\n\t\t\t// Create editors\n\t\t\tinput1EditorRef.current = monacoInstance.editor.create(input1.editorDiv, {\n\t\t\t\tmodel: input1Model,\n\t\t\t\treadOnly: true,\n\t\t\t\tautomaticLayout: true,\n\t\t\t\tfolding: !showResultColumn,\n\t\t\t\tglyphMargin: false,\n\t\t\t\t...options,\n\t\t\t\tlineDecorationsWidth: showResultColumn ? 26 : 10,\n\t\t\t});\n\n\t\t\t// Only create base editor if base exists\n\t\t\tif (hasBase && baseC) {\n\t\t\t\tbaseEditorRef.current = monacoInstance.editor.create(baseC.editorDiv, {\n\t\t\t\t\tmodel: baseModel,\n\t\t\t\t\treadOnly: true,\n\t\t\t\t\tautomaticLayout: true,\n\t\t\t\t\tfolding: !showResultColumn,\n\t\t\t\t\tglyphMargin: false,\n\t\t\t\t\t...options,\n\t\t\t\t\tlineDecorationsWidth: 10,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tinput2EditorRef.current = monacoInstance.editor.create(input2.editorDiv, {\n\t\t\t\tmodel: input2Model,\n\t\t\t\treadOnly: true,\n\t\t\t\tautomaticLayout: true,\n\t\t\t\tfolding: !showResultColumn,\n\t\t\t\tglyphMargin: false,\n\t\t\t\t...options,\n\t\t\t\tlineDecorationsWidth: showResultColumn ? 26 : 10,\n\t\t\t});\n\n\t\t\t// Create result editor if enabled\n\t\t\tif (showResultColumn && resultC) {\n\t\t\t\t// Initialize result with \"ours\" (modified/input2) content\n\t\t\t\tconst resultModel = monacoInstance.editor.createModel(modified || \"\", language);\n\t\t\t\tresultEditorRef.current = monacoInstance.editor.create(resultC.editorDiv, {\n\t\t\t\t\tmodel: resultModel,\n\t\t\t\t\tautomaticLayout: true,\n\t\t\t\t\tfolding: !showResultColumn,\n\t\t\t\t\tglyphMargin: false,\n\t\t\t\t\t...options,\n\t\t\t\t\treadOnly: false,\n\t\t\t\t\tlineDecorationsWidth: 26,\n\t\t\t\t});\n\n\t\t\t\t// Add onChange listener to detect manual edits\n\t\t\t\tresultModel.onDidChangeContent(() => {\n\t\t\t\t\t// Only mark as manually edited if this wasn't a programmatic update\n\t\t\t\t\tif (!isProgrammaticUpdate.current) {\n\t\t\t\t\t\tsetIsResultManuallyEdited(true);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Set theme\n\t\t\tmonacoInstance.editor.setTheme(theme);\n\n\t\t\t// Compute conflicts\n\t\t\tconst detectedConflicts = computeDiffs(baseModel, input1Model, input2Model);\n\t\t\tsetConflicts(detectedConflicts);\n\n\t\t\tpreventCreation.current = true;\n\n\t\t\t// Call onMount\n\t\t\tif (onMount && input1EditorRef.current) {\n\t\t\t\tonMount(input1EditorRef.current as unknown as monaco.editor.IStandaloneDiffEditor, monacoInstance);\n\t\t\t}\n\t\t}\n\t}, [options, theme, original, modified, base, showResultColumn, baseIndex, isMonacoMounting, computeDiffs, onMount, labels]);\n\n\t// Detect showResultColumn, baseIndex, comparisonMode, or base changes and trigger recreation\n\tconst prevShowResultRef = useRef(showResultColumn);\n\tconst prevBaseIndexRef = useRef(baseIndex);\n\tconst prevComparisonModeRef = useRef(comparisonMode);\n\tconst prevBaseRef = useRef(base);\n\tuseEffect(() => {\n\t\tconst showResultChanged = prevShowResultRef.current !== showResultColumn;\n\t\tconst baseIndexChanged = prevBaseIndexRef.current !== baseIndex;\n\t\tconst comparisonModeChanged = prevComparisonModeRef.current !== comparisonMode;\n\t\tconst baseChanged = prevBaseRef.current !== base;\n\n\t\tif ((showResultChanged || baseIndexChanged || comparisonModeChanged || baseChanged) && preventCreation.current) {\n\t\t\tprevShowResultRef.current = showResultColumn;\n\t\t\tprevBaseIndexRef.current = baseIndex;\n\t\t\tprevComparisonModeRef.current = comparisonMode;\n\t\t\tprevBaseRef.current = base;\n\n\t\t\t// Clear gutter views\n\t\t\tgutterViewsRef.current.forEach((view) => {\n\t\t\t\tview.remove();\n\t\t\t});\n\t\t\tgutterViewsRef.current.clear();\n\n\t\t\t// Clear decoration collections before disposing\n\t\t\tinput1DecorationsRef.current?.set([]);\n\t\t\tinput2DecorationsRef.current?.set([]);\n\t\t\tbaseDecorationsRef.current?.set([]);\n\t\t\tinput1DecorationsRef.current = null;\n\t\t\tinput2DecorationsRef.current = null;\n\t\t\tbaseDecorationsRef.current = null;\n\n\t\t\t// Dispose current editors and models\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst resultModel = resultEditorRef.current?.getModel();\n\n\t\t\tinput1EditorRef.current?.dispose();\n\t\t\tbaseEditorRef.current?.dispose();\n\t\t\tinput2EditorRef.current?.dispose();\n\t\t\tresultEditorRef.current?.dispose();\n\n\t\t\tinput1Model?.dispose();\n\t\t\tbaseModel?.dispose();\n\t\t\tinput2Model?.dispose();\n\t\t\tresultModel?.dispose();\n\n\t\t\tpreventCreation.current = false;\n\t\t\tsetEditorKey((prev) => prev + 1);\n\t\t}\n\t}, [showResultColumn, baseIndex, comparisonMode, base]);\n\n\t// Create editor when ready\n\tuseEffect(() => {\n\t\tif (!isMonacoMounting && monacoRef.current && containerRef.current && !preventCreation.current) {\n\t\t\tcreateEditor();\n\t\t}\n\t}, [isMonacoMounting, createEditor]);\n\n\t// Update editor options dynamically without recreating the editor\n\tuseEffect(() => {\n\t\tif (!isEditorReady || !options) return;\n\n\t\t// Update all editor instances\n\t\tif (input1EditorRef.current) {\n\t\t\tinput1EditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tinput2EditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (baseEditorRef.current) {\n\t\t\tbaseEditorRef.current.updateOptions(options);\n\t\t}\n\t\tif (resultEditorRef.current) {\n\t\t\tresultEditorRef.current.updateOptions(options);\n\t\t}\n\t}, [options, isEditorReady]);\n\n\t// Apply decorations when conflicts change\n\tuseEffect(() => {\n\t\tif (isEditorReady && conflicts.length > 0) {\n\t\t\tapplyDecorations();\n\t\t\t// Render checkbox gutters\n\t\t\trenderCheckboxGutters();\n\t\t}\n\t}, [isEditorReady, conflicts, applyDecorations, renderCheckboxGutters]);\n\n\t// Update result editor when conflicts or showResultColumn changes\n\tuseEffect(() => {\n\t\tif (isEditorReady && conflicts.length > 0 && showResultColumn && resultEditorRef.current) {\n\t\t\tupdateResultEditor(conflicts);\n\t\t}\n\t}, [isEditorReady, conflicts, showResultColumn, updateResultEditor]);\n\n\t// Add scroll listener for gutter updates (including result column indicators)\n\tuseEffect(() => {\n\t\tif (!isEditorReady) return;\n\n\t\t// Update result gutter indicators on scroll\n\t\tconst updateResultIndicators = () => {\n\t\t\tif (conflictIssues.length > 0) {\n\t\t\t\trenderConflictIssueMarkers(conflictIssues);\n\t\t\t}\n\t\t};\n\n\t\tconst disposables: monaco.IDisposable[] = [];\n\n\t\tconst updateGutters = () => {\n\t\t\trenderCheckboxGutters();\n\t\t};\n\n\t\t// Listen to scroll changes\n\t\tif (input1EditorRef.current) {\n\t\t\tdisposables.push(input1EditorRef.current.onDidScrollChange(updateGutters));\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tdisposables.push(input2EditorRef.current.onDidScrollChange(updateGutters));\n\t\t}\n\t\tif (resultEditorRef.current && showResultColumn) {\n\t\t\tdisposables.push(resultEditorRef.current.onDidScrollChange(updateResultIndicators));\n\t\t\tdisposables.push(resultEditorRef.current.onDidLayoutChange(updateResultIndicators));\n\t\t}\n\n\t\t// Listen to view zone changes (using onDidLayoutChange as alternative)\n\t\tif (input1EditorRef.current) {\n\t\t\tdisposables.push(input1EditorRef.current.onDidLayoutChange(updateGutters));\n\t\t}\n\t\tif (input2EditorRef.current) {\n\t\t\tdisposables.push(input2EditorRef.current.onDidLayoutChange(updateGutters));\n\t\t}\n\n\t\treturn () => {\n\t\t\tdisposables.forEach((d) => {\n\t\t\t\td?.dispose();\n\t\t\t});\n\t\t};\n\t}, [isEditorReady, renderCheckboxGutters, renderConflictIssueMarkers, showResultColumn, conflictIssues]);\n\n\t// Scroll synchronization\n\tuseEffect(() => {\n\t\tif (!isEditorReady) return;\n\n\t\tconst editors = [input1EditorRef.current, baseEditorRef.current, input2EditorRef.current];\n\t\tif (showResultColumn && resultEditorRef.current) {\n\t\t\teditors.push(resultEditorRef.current);\n\t\t}\n\n\t\tconst disposables: monaco.IDisposable[] = [];\n\t\tlet isScrolling = false;\n\n\t\tconst syncScroll = (source: monaco.editor.IStandaloneCodeEditor) => {\n\t\t\tif (isScrolling) return;\n\t\t\tisScrolling = true;\n\t\t\tconst scrollTop = source.getScrollTop();\n\t\t\tconst scrollLeft = source.getScrollLeft();\n\t\t\teditors.forEach((editor) => {\n\t\t\t\tif (editor && editor !== source) {\n\t\t\t\t\teditor.setScrollTop(scrollTop);\n\t\t\t\t\teditor.setScrollLeft(scrollLeft);\n\t\t\t\t}\n\t\t\t});\n\t\t\tsetTimeout(() => {\n\t\t\t\tisScrolling = false;\n\t\t\t}, 10);\n\t\t};\n\n\t\teditors.forEach((editor) => {\n\t\t\tif (editor) {\n\t\t\t\tdisposables.push(\n\t\t\t\t\teditor.onDidScrollChange(() => {\n\t\t\t\t\t\tsyncScroll(editor);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\treturn () => {\n\t\t\tdisposables.forEach((d) => {\n\t\t\t\td?.dispose();\n\t\t\t});\n\t\t};\n\t}, [isEditorReady, showResultColumn]);\n\n\t// Cleanup\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\t// Clear decoration collections before disposing\n\t\t\tinput1DecorationsRef.current?.set([]);\n\t\t\tinput2DecorationsRef.current?.set([]);\n\t\t\tbaseDecorationsRef.current?.set([]);\n\n\t\t\t// Get models before disposing editors\n\t\t\tconst input1Model = input1EditorRef.current?.getModel();\n\t\t\tconst baseModel = baseEditorRef.current?.getModel();\n\t\t\tconst input2Model = input2EditorRef.current?.getModel();\n\t\t\tconst resultModel = resultEditorRef.current?.getModel();\n\n\t\t\t// Dispose editors first\n\t\t\tinput1EditorRef.current?.dispose();\n\t\t\tbaseEditorRef.current?.dispose();\n\t\t\tinput2EditorRef.current?.dispose();\n\t\t\tresultEditorRef.current?.dispose();\n\n\t\t\t// Then dispose models\n\t\t\tinput1Model?.dispose();\n\t\t\tbaseModel?.dispose();\n\t\t\tinput2Model?.dispose();\n\t\t\tresultModel?.dispose();\n\n\t\t\tpreventCreation.current = false;\n\t\t\tsetIsEditorReady(false);\n\t\t};\n\t}, []);\n\n\tif (isMonacoMounting || !isEditorReady) {\n\t\treturn <>{loading ?? <DefaultLoader />}</>;\n\t}\n\n\treturn <div ref={containerRef} style={{ width, height }} className={className} />;\n}\n"],"names":["_arrayLikeToArray","r","a","e","_arrayWithHoles","_defineProperty","t","_toPropertyKey","_iterableToArrayLimit","l","n","u","f","o","_nonIterableRest","ownKeys","_objectSpread2","_objectWithoutProperties","i","_objectWithoutPropertiesLoose","_slicedToArray","_unsupportedIterableToArray","_toPrimitive","obj","key","value","object","enumerableOnly","keys","symbols","sym","target","source","compose","_len","fns","_key","x","y","curry","fn","curried","_this","_len2","args","_key2","_len3","nextArgs","_key3","isObject","isEmpty","isFunction","hasOwnProperty","property","validateChanges","initial","changes","errorHandler","field","validateSelector","selector","validateHandler","handler","_handler","validateInitial","throwError","errorMessages","type","validators","create","state","didUpdate","didStateUpdate","update","updateState","validate","getChanges","extractChanges","getState","setState","causedChanges","_handler$field","index","config","validateConfig","informAboutDeprecation","merge","CANCELATION_MESSAGE","makeCancelable","promise","hasCanceled_","wrappedPromise","resolve","reject","val","_excluded","_state$create","config$1","_state$create2","globalConfig","_validators$config","monaco","init","_ref","isInitialized","wrapperPromise","storeMonacoInstance","injectScripts","getMonacoLoaderScript","configureLoader","script","createScript","src","_ref2","loaderScript","_ref3","require","_ref4","error","__getMonacoInstance","_ref5","loader","InputState","ConflictType","createScanner","text","ignoreTrivia","len","pos","tokenOffset","token","lineNumber","lineStartOffset","tokenLineStartOffset","prevTokenLineStartOffset","scanError","scanHexDigits","count","exact","digits","ch","setPosition","newPosition","scanNumber","start","isDigit","end","scanString","result","ch3","isLineBreak","scanNext","code","isWhiteSpace","safeLength","commentClosed","isUnknownContentCharacter","scanNextNonTrivia","CharacterCodes","_","maxCachedValues","ParseOptions","parseTree","errors","options","currentParent","ensurePropertyComplete","endOffset","onValue","valueNode","visit","offset","name","length","getNodeType","sep","findNodeAtLocation","root","path","node","segment","found","propertyNode","visitor","_scanner","_jsonPath","suppressedCallbacks","toNoArgVisit","visitFunction","toOneArgVisit","arg","toOneArgVisitWithPath","toBeginVisit","toEndVisit","onObjectBegin","onObjectProperty","onObjectEnd","onArrayBegin","onArrayEnd","onLiteralValue","onSeparator","onComment","onError","disallowComments","allowTrailingComma","handleError","skipUntilAfter","skipUntil","parseString","isValue","parseLiteral","tokenValue","parseProperty","parseValue","parseObject","needsComma","parseArray","isFirstElement","ScanError","SyntaxKind","parser.parseTree","parser.findNodeAtLocation","ParseErrorCode","fastDeepEqual","equal","b","getValueAtPath","normalizedPath","current","__extends","extendStatics","d","p","__","_hasOwnProperty","_objectKeys","keys_1","k","_deepClone","isInteger","str","charCode","escapePathComponent","unescapePathComponent","hasUndefined","i_1","objKeys","objKeysLength","patchErrorMessageFormatter","message","messageParts","PatchError","_super","operation","tree","_newTarget","JsonPatchError","deepClone","objOps","document","removed","getValueByPointer","originalValue","applyOperation","valueToCopy","_areEquals","arrOps","arr","removedList","pointer","getOriginalDestination","validateOperation","mutateDocument","banPrototypeModifications","validator","returnValue","existingPathFragment","validateFunction","applyPatch","patch","results","length_1","applyReducer","operationResult","pathLen","existingPathLen","existingValue","sequence","externalValidator","arrA","arrB","beforeDict","Mirror","ObserverInfo","callback","observer","getMirror","getObserverFromMirror","mirror","removeObserverFromMirror","unobserve","observe","patches","observerInfo","dirtyCheck","generate","fastCheck","invertible","_generate","temp","newKeys","oldKeys","deleted","oldVal","newVal","compare","tree1","tree2","core","duplex","ONE_OF","ANY_OF","ALL_OF","hasSchemaVariants","schema","getSchemaVariants","variants","getSubschemaKeyword","findCommonDiscriminatorField","data","discriminatorFields","variant","props","propSchema","chooseSubschemaSync","_schemaKeyword","dataObj","discriminator","variantProp","_a","required","discriminatorMatches","constValue","dataType","determineConflictType","base","input1","input2","input1Changed","isEqual","input2Changed","getNodeLines","pathSegments","numericValue","getLineNumber","groupPatchesByRootPath","patches1","patches2","pathGroups","getRootPath","segments","rootPath","group","groupPatchesWithSchema","arrayPatchGroups1","arrayPatchGroups2","nonArrayPatches1","nonArrayPatches2","arrayItemMatch","arrayPath","group1","group2","allArrayPaths","baseArray","input1Array","input2Array","itemMatch","itemPath","itemGroup1","itemGroup2","arraySchema","getSchemaAtPath","itemSchemaRaw","itemSchema","matches","matchArrayItemsById","baseKeysByIndex","input1KeysByIndex","input2KeysByIndex","indices","itemIndexMatch","groupKey","groupKey1","groupKey2","groupItem1","groupItem2","getOneOfObjectPath","patchPath","parentPath","parentSchema","allNonArrayPatches1","allNonArrayPatches2","oneOfObjectPaths","oneOfPath","currentSchema","currentPath","numericIndex","isArrayIndex","keyword","currentData","resolvedSchema","itemAtIndex","findItemAnchorFields","anchors","properties","fieldName","format","commonIdFields","findItemIdField","matchArrayItemsByAnchors","anchorFields","getItemKey","item","keyParts","indexArray","version","match","idField","indexByArray","id","idKey","analyzeConflicts","baseObj","input1Obj","input2Obj","patch1","patch2","conflicts","processedPaths","checkOneOfVariantChange","baseValue","input1Value","input2Value","pathSchema","baseVariant","input1Variant","input2Variant","groupingKey","representativePath","objectPath","baseObjectValue","input1ObjectValue","input2ObjectValue","baseObjVal","input1ObjVal","input2ObjVal","conflictType","objectPatchesAll","objectPatches1","objectPatches2","patchBaseValue","patchInput1Value","patchInput2Value","existsInBase","existsInInput1","existsInInput2","analyzeTwoWayConflicts","arrayPathGroups","nonArrayPatches","arrayGroup","arrayPatches","itemGroups","itemPatches","createConflictsForGroup","matchedItemPatches","unmatchedPatches","matchedPatches","unmatchedItemGroups","_b","_c","propertyGroups","_d","pathPatches","filteredPatches1","filteredPatches2","patches1ToUse","patches2ToUse","patchesToUse","hasAdd","hasRemove","hasReplace","calculatePatchLineRange","minStart","maxEnd","foundAnyNode","lines","mapConflictsToRanges","baseText","input1Text","input2Text","ranges","conflict","baseLines","input1Lines","input2Lines","isConflicting","input1State","input2State","input1Diffs","input2Diffs","lineNum","_e","_f","range","computeDiffsJsonPatch","comparisonMode","allPaths","baseToInput1Changed","input1ToInput2Changed","computeLineConflictType","baseLine","input1Line","input2Line","computeDiffs","baseRanges","allChanges","rangeStart","currentConflictType","input1DiffsInRange","input2DiffsInRange","isLast","isGap","typeChanged","prevChange","rangeEnd","hasInput1Changes","hasInput2Changes","setValueAtPath","s","objCurrent","lastSegment","lastNumeric","findLinesForPath","jsonContent","startLine","endLine","smartMergeValues","value1","value2","obj1","obj2","merged","objectSchema","additionalProperties","propertySchema","nestedPath","recursiveMerge","buildResultContentWithValidation","warnings","conflictIssues","baseData","input1Data","input2Data","resultData","appliedPaths","explicitlySetProperties","mergedParents","findPathFromLines","_startLine","_endLine","_text","includesInput1","includesInput2","conflictPath","valueToApply","pathToApply","isArrayItemConflict","extractPath","conflictSchema","mergedValue","parentInInput1","childPath","parentInInput2","content","lineInfo","isValid","validationError","getDecorationClasses","isTwoColumnMode","input1Class","input2Class","baseClass","input1OverviewColor","input2OverviewColor","baseOverviewColor","ConflictTypeEnum","extractUniqueLines","diffs","uniqueLines","diff","createInput1Decorations","classes","monacoInstance","decorations","createInput2Decorations","createBaseDecorations","isDefaultRange","createConflictDecorations","createAllDecorations","input1Decorations","input2Decorations","baseDecorations","DefaultLoader","jsx","ISSUE_ICON","JsonDiffMergeEditor","original","modified","theme","width","height","className","loading","onMount","onMergeResolve","showResultColumn","baseIndex","labels","language","isEditorReady","setIsEditorReady","useState","isMonacoMounting","setIsMonacoMounting","setConflicts","_validationError","setValidationError","_validationWarnings","setValidationWarnings","setConflictIssues","isResultManuallyEdited","setIsResultManuallyEdited","renderCheckbox","useCallback","_inputNumber","_conflictId","onToggle","container","checkbox","_editorKey","setEditorKey","input1EditorRef","useRef","baseEditorRef","input2EditorRef","resultEditorRef","monacoRef","containerRef","preventCreation","isProgrammaticUpdate","input1GutterRef","input2GutterRef","resultGutterRef","gutterViewsRef","resultLabelRef","input1DecorationsRef","input2DecorationsRef","baseDecorationsRef","useEffect","isMounted","cancelable","baseModel","input1Model","input2Model","startTime","duration","getDecorationsLeft","editor","getDecorationsWidth","renderConflictIssueMarkers","issues","isDark","decorationsLeft","decorationsWidth","scrollTop","issue","topStart","topEnd","lineHeight","fullHeight","markerDiv","icon","updateResultEditor","updatedConflicts","resultModel","baseLabel","position","selection","lineCount","lastLineLength","validatedPosition","modelWithDecorations","invalidDecorations","collection","conflictIssueDecorations","conflictDecorations","backgroundColor","borderColor","toggleInputState","conflictId","inputNumber","prevConflicts","newState","renderCheckboxGutterItem","gutterContainer","viewHeight","_isDark","model","top","viewDiv","background","checkboxDiv","checkboxBg","checkboxBtn","newCheckboxBtn","isHandled","isFocused","isMultiLine","middleHeight","margin","effectiveCheckboxTop","preferredViewPortMin","preferredViewPortMax","preferredParentMin","preferredParentMax","renderCheckboxGutters","allViews","view","decorationsLeft1","decorationsWidth1","decorationsLeft2","decorationsWidth2","visibleRanges","viewsToKeep","getThemeColor","colorKey","fallback","currentTheme","applyDecorations","conflictColor","changeColor","baseColor","conflictOverviewColor","changeOverviewColor","decorationConfig","checkboxBgColor","checkboxBorderColor","checkboxFocusBorderColor","checkboxCheckedColor","styleId","styleEl","sameChangeColor","input1OnlyColor","createEditor","wrapper","foregroundColor","getThemeColorLocal","input1HeaderBg","baseHeaderBg","input2HeaderBg","resultHeaderBg","createEditorContainer","label","color","withGutter","labelDiv","editorWrapper","editorDiv","gutterDiv","hasBase","baseC","orderedColumns","col","resultC","detectedConflicts","prevShowResultRef","prevBaseIndexRef","prevComparisonModeRef","prevBaseRef","showResultChanged","baseIndexChanged","comparisonModeChanged","baseChanged","_g","_h","_i","_j","_k","prev","updateResultIndicators","disposables","updateGutters","editors","isScrolling","syncScroll","scrollLeft","Fragment"],"mappings":"yIAAA,SAASA,GAAkBC,EAAGC,EAAG,EACtBA,GAAR,MAAaA,EAAID,EAAE,UAAYC,EAAID,EAAE,QACtC,QAASE,EAAI,EAAG,EAAI,MAAMD,CAAC,EAAGC,EAAID,EAAGC,IAAK,EAAEA,CAAC,EAAIF,EAAEE,CAAC,EACpD,OAAO,CACT,CACA,SAASC,GAAgBH,EAAG,CAC1B,GAAI,MAAM,QAAQA,CAAC,EAAG,OAAOA,CAC/B,CACA,SAASI,GAAgB,EAAGJ,EAAGK,EAAG,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