const require_rolldown_runtime = require('../../../../../../../../../_virtual/rolldown_runtime.js');
const require_noop$1 = require('../util/noop.js');
const require_identity$1 = require('../util/identity.js');
const require_lift$1 = require('../util/lift.js');
const require_OperatorSubscriber$1 = require('./OperatorSubscriber.js');
const require_args$1 = require('../util/args.js');
const require_innerFrom$1 = require('../observable/innerFrom.js');

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/operators/withLatestFrom.js
var require_withLatestFrom = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/operators/withLatestFrom.js": ((exports) => {
	var __read = exports && exports.__read || function(o, n) {
		var m = typeof Symbol === "function" && o[Symbol.iterator];
		if (!m) return o;
		var i = m.call(o), r, ar = [], e;
		try {
			while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
		} catch (error) {
			e = { error };
		} finally {
			try {
				if (r && !r.done && (m = i["return"])) m.call(i);
			} finally {
				if (e) throw e.error;
			}
		}
		return ar;
	};
	var __spreadArray = exports && exports.__spreadArray || function(to, from) {
		for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
		return to;
	};
	Object.defineProperty(exports, "__esModule", { value: true });
	var lift_1 = require_lift$1.require_lift();
	var OperatorSubscriber_1 = require_OperatorSubscriber$1.require_OperatorSubscriber();
	var innerFrom_1 = require_innerFrom$1.require_innerFrom();
	var identity_1 = require_identity$1.require_identity();
	var noop_1 = require_noop$1.require_noop();
	var args_1 = require_args$1.require_args();
	function withLatestFrom() {
		var inputs = [];
		for (var _i = 0; _i < arguments.length; _i++) inputs[_i] = arguments[_i];
		var project = args_1.popResultSelector(inputs);
		return lift_1.operate(function(source, subscriber) {
			var len = inputs.length;
			var otherValues = new Array(len);
			var hasValue = inputs.map(function() {
				return false;
			});
			var ready = false;
			var _loop_1 = function(i$1) {
				innerFrom_1.innerFrom(inputs[i$1]).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
					otherValues[i$1] = value;
					if (!ready && !hasValue[i$1]) {
						hasValue[i$1] = true;
						(ready = hasValue.every(identity_1.identity)) && (hasValue = null);
					}
				}, noop_1.noop));
			};
			for (var i = 0; i < len; i++) _loop_1(i);
			source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
				if (ready) {
					var values = __spreadArray([value], __read(otherValues));
					subscriber.next(project ? project.apply(void 0, __spreadArray([], __read(values))) : values);
				}
			}));
		});
	}
	exports.withLatestFrom = withLatestFrom;
}) });

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