const k = 6048e5, O = 864e5, S = 6e4, W = 36e5, Z = 1e3;
function F(t, e) {
  const n = g(t);
  let i;
  if (n.date) {
    const r = T(n.date, 2);
    i = I(r.restDateString, r.year);
  }
  if (!i || isNaN(i.getTime()))
    return /* @__PURE__ */ new Date(NaN);
  const a = i.getTime();
  let o = 0, c;
  if (n.time && (o = U(n.time), isNaN(o)))
    return /* @__PURE__ */ new Date(NaN);
  if (n.timezone) {
    if (c = w(n.timezone), isNaN(c))
      return /* @__PURE__ */ new Date(NaN);
  } else {
    const r = new Date(a + o), u = /* @__PURE__ */ new Date(0);
    return u.setFullYear(
      r.getUTCFullYear(),
      r.getUTCMonth(),
      r.getUTCDate()
    ), u.setHours(
      r.getUTCHours(),
      r.getUTCMinutes(),
      r.getUTCSeconds(),
      r.getUTCMilliseconds()
    ), u;
  }
  return new Date(a + o + c);
}
const d = {
  dateTimeDelimiter: /[T ]/,
  timeZoneDelimiter: /[Z ]/i,
  timezone: /([Z+-].*)$/
}, D = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, p = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, N = /^([+-])(\d{2})(?::?(\d{2}))?$/;
function g(t) {
  const e = {}, s = t.split(d.dateTimeDelimiter);
  let n;
  if (s.length > 2)
    return e;
  if (/:/.test(s[0]) ? n = s[0] : (e.date = s[0], n = s[1], d.timeZoneDelimiter.test(e.date) && (e.date = t.split(d.timeZoneDelimiter)[0], n = t.substr(
    e.date.length,
    t.length
  ))), n) {
    const i = d.timezone.exec(n);
    i ? (e.time = n.replace(i[1], ""), e.timezone = i[1]) : e.time = n;
  }
  return e;
}
function T(t, e) {
  const s = new RegExp(
    "^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
  ), n = t.match(s);
  if (!n) return { year: NaN, restDateString: "" };
  const i = n[1] ? parseInt(n[1]) : null, a = n[2] ? parseInt(n[2]) : null;
  return {
    year: a === null ? i : a * 100,
    restDateString: t.slice((n[1] || n[2]).length)
  };
}
function I(t, e) {
  if (e === null) return /* @__PURE__ */ new Date(NaN);
  const s = t.match(D);
  if (!s) return /* @__PURE__ */ new Date(NaN);
  const n = !!s[4], i = l(s[1]), a = l(s[2]) - 1, o = l(s[3]), c = l(s[4]), r = l(s[5]) - 1;
  if (n)
    return Y(e, c, r) ? h(e, c, r) : /* @__PURE__ */ new Date(NaN);
  {
    const u = /* @__PURE__ */ new Date(0);
    return !x(e, a, o) || !y(e, i) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(e, a, Math.max(i, o)), u);
  }
}
function l(t) {
  return t ? parseInt(t) : 1;
}
function U(t) {
  const e = t.match(p);
  if (!e) return NaN;
  const s = f(e[1]), n = f(e[2]), i = f(e[3]);
  return M(s, n, i) ? s * 36e5 + n * 6e4 + i * 1e3 : NaN;
}
function f(t) {
  return t && parseFloat(t.replace(",", ".")) || 0;
}
function w(t) {
  if (t === "Z") return 0;
  const e = t.match(N);
  if (!e) return 0;
  const s = e[1] === "+" ? -1 : 1, n = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
  return z(n, i) ? s * (n * 36e5 + i * 6e4) : NaN;
}
function h(t, e, s) {
  const n = /* @__PURE__ */ new Date(0);
  n.setUTCFullYear(t, 0, 4);
  const i = n.getUTCDay() || 7, a = (e - 1) * 7 + s + 1 - i;
  return n.setUTCDate(n.getUTCDate() + a), n;
}
const C = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function m(t) {
  return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
}
function x(t, e, s) {
  return e >= 0 && e <= 11 && s >= 1 && s <= (C[e] || (m(t) ? 29 : 28));
}
function y(t, e) {
  return e >= 1 && e <= (m(t) ? 366 : 365);
}
function Y(t, e, s) {
  return e >= 1 && e <= 53 && s >= 0 && s <= 6;
}
function M(t, e, s) {
  return t === 24 ? e === 0 && s === 0 : s >= 0 && s < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
}
function z(t, e) {
  return e >= 0 && e <= 59;
}
export {
  k as a,
  W as b,
  S as c,
  Z as d,
  O as m,
  F as p
};
//# sourceMappingURL=parseISO-wlfIB_QJ.js.map
