import p from "../../factory.js";
import { nowTimestamp as D, getRangeTimestampsContextIntegerPropertyFactory as y, offsetsForNDays as F } from "../../utils.js";
import { startOfWeek as g } from "../../../utils.js";
import { clamp as E } from "../../../../../../../utils/value/number.js";
const r = 1, W = F(7), k = y(0, 6, r), C = (s = 0) => {
  const e = ~~E(0, s, 1 / 0) || 0;
  return (n = r) => {
    const a = e ? { offsets: W } : { to: D }, o = k(n);
    return p(
      {
        from: ({ now: f, timezone: m, systemToTimezone: i, timezoneToSystem: c }) => {
          const t = new Date(c(g(f, m, o.value)));
          return t.setDate(t.getDate() - e * 7), i(t);
        },
        ...a
      },
      { firstWeekDay: o.descriptor }
    )();
  };
};
export {
  r as DEFAULT_FIRST_WEEK_DAY,
  W as ONE_WEEK_OFFSETS,
  C as default
};
