const require_rolldown_runtime = require('../../../../../../../../../_virtual/rolldown_runtime.js');
const require_Observable$1 = require('../Observable.js');
const require_OperatorSubscriber$1 = require('../operators/OperatorSubscriber.js');
const require_empty$1 = require('./empty.js');
const require_args$1 = require('../util/args.js');
const require_innerFrom$1 = require('./innerFrom.js');
const require_argsOrArgArray$1 = require('../util/argsOrArgArray.js');

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/observable/zip.js
var require_zip = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/cjs/internal/observable/zip.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 Observable_1 = require_Observable$1.require_Observable();
	var innerFrom_1 = require_innerFrom$1.require_innerFrom();
	var argsOrArgArray_1 = require_argsOrArgArray$1.require_argsOrArgArray();
	var empty_1 = require_empty$1.require_empty();
	var OperatorSubscriber_1 = require_OperatorSubscriber$1.require_OperatorSubscriber();
	var args_1 = require_args$1.require_args();
	function zip() {
		var args = [];
		for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
		var resultSelector = args_1.popResultSelector(args);
		var sources = argsOrArgArray_1.argsOrArgArray(args);
		return sources.length ? new Observable_1.Observable(function(subscriber) {
			var buffers = sources.map(function() {
				return [];
			});
			var completed = sources.map(function() {
				return false;
			});
			subscriber.add(function() {
				buffers = completed = null;
			});
			var _loop_1 = function(sourceIndex$1) {
				innerFrom_1.innerFrom(sources[sourceIndex$1]).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
					buffers[sourceIndex$1].push(value);
					if (buffers.every(function(buffer) {
						return buffer.length;
					})) {
						var result = buffers.map(function(buffer) {
							return buffer.shift();
						});
						subscriber.next(resultSelector ? resultSelector.apply(void 0, __spreadArray([], __read(result))) : result);
						if (buffers.some(function(buffer, i) {
							return !buffer.length && completed[i];
						})) subscriber.complete();
					}
				}, function() {
					completed[sourceIndex$1] = true;
					!buffers[sourceIndex$1].length && subscriber.complete();
				}));
			};
			for (var sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) _loop_1(sourceIndex);
			return function() {
				buffers = completed = null;
			};
		}) : empty_1.EMPTY;
	}
	exports.zip = zip;
}) });

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