import { timezoneToSystem as p, systemToTimezone as T } from "../../../../../core/Localization/datetime/restamper/utils.js";
import { clamp as l, isBitSafeInteger as z } from "../../../../../utils/value/number.js";
import { struct as g } from "../../../../../utils/struct/main.js";
import { enumerable as c, getter as u, hasOwnProperty as a } from "../../../../../utils/struct/property.js";
import { noop as R } from "../../../../../utils/common.js";
import { isUndefined as w, isFunction as d, isNullish as y } from "../../../../../utils/value/is.js";
const V = (e) => Object.freeze({
  systemToTimezone: c((t) => T(e, t)),
  timezoneToSystem: c((t) => p(e, t)),
  timezoneOffset: c((t) => e(t).offset)
}), x = (e, t, o = e) => {
  const m = (n, i) => {
    let s = n;
    y(n) ? s = o : z(n) || (s = i ?? o);
    const r = l(e, s, t);
    return r === s ? r : i ?? o;
  };
  return (n) => {
    const i = u(() => s);
    let s = m(n);
    return g({
      value: i,
      descriptor: c({
        ...i,
        set(r) {
          const f = s;
          s = m(r, s), f !== s && (this.now = this.now);
        }
      })
    });
  };
}, P = (e, t) => (o) => d(o) ? o.call(e, t) : o, j = (e) => !a(e, "offsets"), D = (e) => a(e, "from"), U = (({ now: e }) => e), W = /* @__PURE__ */ (() => {
  const e = /* @__PURE__ */ new Map();
  return (t) => {
    let o = e.get(t);
    return w(o) && (o = Object.freeze([0, 0, t, 0, 0, 0, -1]), e.set(t, o)), o;
  };
})(), _ = (e) => {
  try {
    const t = e instanceof Date || +e === e ? e : void 0, o = new Date(t).getTime();
    return isNaN(o) ? void 0 : o;
  } catch {
  }
}, B = (e, t, o) => {
  let m = R;
  try {
    const n = e.now, i = e.timezone;
    m = () => {
      e.now = n, e.timezone = i;
    }, e.now = t, e.timezone = o;
    const { from: s, to: r } = e;
    return { from: s, to: r };
  } finally {
    m();
  }
};
export {
  V as createRangeTimestampsConfigRestampingContext,
  B as getDateRangeTimestamps,
  P as getRangeTimestampsConfigParameterUnwrapper,
  x as getRangeTimestampsContextIntegerPropertyFactory,
  D as isRangeTimestampsConfigWithFromOffsets,
  j as isRangeTimestampsConfigWithoutOffsets,
  U as nowTimestamp,
  W as offsetsForNDays,
  _ as parseRangeTimestamp
};
