import { configureYaml } from "../configure-language-support.js";
import { getYamlNodeRangeFromPath } from "./get-yaml-node-range-from-path.js";
import * as monaco from "monaco-editor";
//#region src/v2/features/editor/helpers/yaml/create-yaml-model.ts
/**
* Creates a YAML model for use in the Monaco editor.
*
* @param value - The initial YAML string value for the model.
* @returns An object containing the Monaco model and a method to get a range from a YAML path.
*
* The created model is configured for YAML language support.
* The `getRangeFromPath` method returns a Monaco Range object indicating the text range
* that corresponds to a given path in the YAML document, or null if the path is not found.
*/
var createYamlModel = (value) => {
	const model = monaco.editor.createModel(value ?? "", "yaml");
	configureYaml(model.uri.toString());
	return {
		model,
		getRangeFromPath: (path) => {
			const range = getYamlNodeRangeFromPath(model.getValue(), path);
			if (!range) return null;
			const start = model.getPositionAt(range.startOffset);
			const end = model.getPositionAt(range.endOffset);
			return new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
		}
	};
};
//#endregion
export { createYamlModel };

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