const require_rolldown_runtime = require('../../../../../../../../../_virtual/rolldown_runtime.js');
const require_lift$1 = require('../util/lift.js');
const require_OperatorSubscriber$1 = require('./OperatorSubscriber.js');
const require_Subject$1 = require('../Subject.js');
const require_innerFrom$1 = require('../observable/innerFrom.js');

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/operators/windowWhen.js
var require_windowWhen = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/operators/windowWhen.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	var Subject_1 = require_Subject$1.require_Subject();
	var lift_1 = require_lift$1.require_lift();
	var OperatorSubscriber_1 = require_OperatorSubscriber$1.require_OperatorSubscriber();
	var innerFrom_1 = require_innerFrom$1.require_innerFrom();
	function windowWhen(closingSelector) {
		return lift_1.operate(function(source, subscriber) {
			var window;
			var closingSubscriber;
			var handleError = function(err) {
				window.error(err);
				subscriber.error(err);
			};
			var openWindow = function() {
				closingSubscriber === null || closingSubscriber === void 0 || closingSubscriber.unsubscribe();
				window === null || window === void 0 || window.complete();
				window = new Subject_1.Subject();
				subscriber.next(window.asObservable());
				var closingNotifier;
				try {
					closingNotifier = innerFrom_1.innerFrom(closingSelector());
				} catch (err) {
					handleError(err);
					return;
				}
				closingNotifier.subscribe(closingSubscriber = OperatorSubscriber_1.createOperatorSubscriber(subscriber, openWindow, openWindow, handleError));
			};
			openWindow();
			source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
				return window.next(value);
			}, function() {
				window.complete();
				subscriber.complete();
			}, handleError, function() {
				closingSubscriber === null || closingSubscriber === void 0 || closingSubscriber.unsubscribe();
				window = null;
			}));
		});
	}
	exports.windowWhen = windowWhen;
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_windowWhen();
  }
});