import { getJsonAstNodeFromPath } from "./get-json-ast-node-from-path.js";
import { configureJson } from "../configure-language-support.js";
import * as monaco from "monaco-editor";
//#region src/v2/features/editor/helpers/json/create-json-model.ts
/**
* Creates a JSON Monaco editor model with enhanced language support.
*
* @param value - The initial JSON content for the model.
* @returns An object containing the Monaco model and a function to get a range from a JSON path.
*
* The returned `getRangeFromPath` function asynchronously finds the AST node for a JSON path,
* converts its offset and length to a Monaco Range, or returns null if not found.
*/
var createJsonModel = (value) => {
	const model = monaco.editor.createModel(value ?? "", "json");
	configureJson(model.uri.toString());
	return {
		model,
		getRangeFromPath: async (path) => {
			const node = await getJsonAstNodeFromPath(model, path);
			if (!node) return null;
			const start = model.getPositionAt(node.offset);
			const end = model.getPositionAt(node.offset + node.length);
			return new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
		}
	};
};
//#endregion
export { createJsonModel };

//# sourceMappingURL=create-json-model.js.map