import { CronExpressionParser } from "cron-parser";

//#region src/utils/compute-next-run-at.ts
function computeNextRunAt(params) {
	const { cronExpression, cronTimezone, runAt, lastScheduledFor } = params;
	if (runAt && !cronExpression) return runAt;
	if (cronExpression) {
		const baseDate = lastScheduledFor ? new Date(lastScheduledFor) : /* @__PURE__ */ new Date();
		return CronExpressionParser.parse(cronExpression, {
			currentDate: baseDate,
			tz: cronTimezone || "UTC"
		}).next().toISOString();
	}
	return null;
}

//#endregion
export { computeNextRunAt };