import { GTE, LT, PGTE } from "../operator.js";
import { parseRanges, satisfiesRange, stringifyRanges } from "../range.js";
import { increment, pgteUpperBound } from "../version.js";
import { replacePart } from "./replace.js";

//#region lib/modules/versioning/ruby/strategies/widen.ts
var widen_default = ({ range, to }) => {
	return stringifyRanges(parseRanges(range).flatMap((part) => {
		if (satisfiesRange(to, part)) return [part];
		const { operator, version: ver, companion } = part;
		switch (operator) {
			case PGTE: {
				const baseVersion = companion ? companion.version : ver;
				const limit = increment(pgteUpperBound(ver), to);
				return [{
					operator: GTE,
					delimiter: " ",
					version: baseVersion
				}, {
					operator: LT,
					delimiter: " ",
					version: limit
				}];
			}
			default: return [replacePart(part, to)];
		}
	}));
};

//#endregion
export { widen_default as default };
//# sourceMappingURL=widen.js.map