//#region src/plus/salesSdk/addProductFlow/holderHostController.ts
let pending = null;
const listeners = /* @__PURE__ */ new Set();
function subscribeHolderHost(listener) {
	listeners.add(listener);
	return () => listeners.delete(listener);
}
function getHolderHostPending() {
	return pending;
}
function requestOpenHolderSelect(payload) {
	if (pending) {
		pending.resolve(null);
		pending = null;
	}
	return new Promise((resolve) => {
		pending = {
			payload,
			resolve
		};
		listeners.forEach((l) => l());
	});
}
function completeHolderHost(result) {
	if (pending) {
		pending.resolve(result);
		pending = null;
		listeners.forEach((l) => l());
	}
}
//#endregion
exports.completeHolderHost = completeHolderHost;
exports.getHolderHostPending = getHolderHostPending;
exports.requestOpenHolderSelect = requestOpenHolderSelect;
exports.subscribeHolderHost = subscribeHolderHost;
