import { cancellation_exports as e } from "./cancellation.js";
//#region ../../node_modules/langium/lib/utils/promise-utils.js
function t() {
	return new Promise((e) => {
		typeof setImmediate > "u" ? setTimeout(e, 0) : setImmediate(e);
	});
}
var n = 0, r = 10;
function i() {
	return n = performance.now(), new e.CancellationTokenSource();
}
var a = Symbol("OperationCancelled");
function o(e) {
	return e === a;
}
async function s(i) {
	if (i === e.CancellationToken.None) return;
	let o = performance.now();
	if (o - n >= r && (n = o, await t(), n = performance.now()), i.isCancellationRequested) throw a;
}
var c = class {
	constructor() {
		this.promise = new Promise((e, t) => {
			this.resolve = (t) => (e(t), this), this.reject = (e) => (t(e), this);
		});
	}
};
//#endregion
export { c as Deferred, a as OperationCancelled, s as interruptAndCheck, o as isOperationCancelled, i as startCancelableOperation };
