//#region src/plus/salesSdk/bookingEditService/bookingEditHostController.ts
let pending = null;
const listeners = /* @__PURE__ */ new Set();
function subscribeBookingEditHost(listener) {
	listeners.add(listener);
	return () => listeners.delete(listener);
}
function getBookingEditHostPending() {
	return pending;
}
function requestOpenBookingEdit(payload) {
	if (pending) {
		pending.resolve(null);
		pending = null;
	}
	return new Promise((resolve) => {
		pending = {
			payload,
			resolve
		};
		listeners.forEach((l) => l());
	});
}
function completeBookingEditHost(cacheItem) {
	if (pending) {
		pending.resolve(cacheItem);
		pending = null;
		listeners.forEach((l) => l());
	}
}
//#endregion
exports.completeBookingEditHost = completeBookingEditHost;
exports.getBookingEditHostPending = getBookingEditHostPending;
exports.requestOpenBookingEdit = requestOpenBookingEdit;
exports.subscribeBookingEditHost = subscribeBookingEditHost;
