function location(e) {
	let n = String(e), r = [];
	return {
		toOffset: a,
		toPoint: i
	};
	function i(e) {
		if (typeof e == "number" && e > -1 && e <= n.length) {
			let i = 0;
			for (;;) {
				let a = r[i];
				if (a === void 0) {
					let e = next(n, r[i - 1]);
					a = e === -1 ? n.length + 1 : e + 1, r[i] = a;
				}
				if (a > e) return {
					line: i + 1,
					column: e - (i > 0 ? r[i - 1] : 0) + 1,
					offset: e
				};
				i++;
			}
		}
	}
	function a(e) {
		if (e && typeof e.line == "number" && typeof e.column == "number" && !Number.isNaN(e.line) && !Number.isNaN(e.column)) {
			for (; r.length < e.line;) {
				let e = r[r.length - 1], i = next(n, e), a = i === -1 ? n.length + 1 : i + 1;
				if (e === a) break;
				r.push(a);
			}
			let i = (e.line > 1 ? r[e.line - 2] : 0) + e.column - 1;
			if (i < r[e.line - 1]) return i;
		}
	}
}
function next(e, t) {
	let n = e.indexOf("\r", t), r = e.indexOf("\n", t);
	return r === -1 ? n : n === -1 || n + 1 === r ? r : n < r ? n : r;
}
export { location };
