import { DATE_FORMATS as j } from "./constants.js";
import V from "./utils/normalizeDate.js";
import { t as J, a as U, b as K } from "./toTimeZone-Coq1oPTt.js";
import { m as tt, a as A } from "./parseISO-wlfIB_QJ.js";
import { t as l, i as I } from "./isValid-DN-HkCoi.js";
function b(e, n) {
  return e instanceof Date ? new e.constructor(n) : new Date(n);
}
let et = {};
function S() {
  return et;
}
function v(e, n) {
  var u, d, c, m;
  const t = S(), r = (n == null ? void 0 : n.weekStartsOn) ?? ((d = (u = n == null ? void 0 : n.locale) == null ? void 0 : u.options) == null ? void 0 : d.weekStartsOn) ?? t.weekStartsOn ?? ((m = (c = t.locale) == null ? void 0 : c.options) == null ? void 0 : m.weekStartsOn) ?? 0, a = l(e), i = a.getDay(), o = (i < r ? 7 : 0) + i - r;
  return a.setDate(a.getDate() - o), a.setHours(0, 0, 0, 0), a;
}
function W(e) {
  return v(e, { weekStartsOn: 1 });
}
function B(e) {
  const n = l(e), t = n.getFullYear(), r = b(e, 0);
  r.setFullYear(t + 1, 0, 4), r.setHours(0, 0, 0, 0);
  const a = W(r), i = b(e, 0);
  i.setFullYear(t, 0, 4), i.setHours(0, 0, 0, 0);
  const o = W(i);
  return n.getTime() >= a.getTime() ? t + 1 : n.getTime() >= o.getTime() ? t : t - 1;
}
function q(e) {
  const n = l(e);
  return n.setHours(0, 0, 0, 0), n;
}
function z(e) {
  const n = l(e), t = new Date(
    Date.UTC(
      n.getFullYear(),
      n.getMonth(),
      n.getDate(),
      n.getHours(),
      n.getMinutes(),
      n.getSeconds(),
      n.getMilliseconds()
    )
  );
  return t.setUTCFullYear(n.getFullYear()), +e - +t;
}
function nt(e, n) {
  const t = q(e), r = q(n), a = +t - z(t), i = +r - z(r);
  return Math.round((a - i) / tt);
}
function rt(e) {
  const n = B(e), t = b(e, 0);
  return t.setFullYear(n, 0, 4), t.setHours(0, 0, 0, 0), W(t);
}
function at(e) {
  const n = l(e), t = b(e, 0);
  return t.setFullYear(n.getFullYear(), 0, 1), t.setHours(0, 0, 0, 0), t;
}
const it = {
  lessThanXSeconds: {
    one: "less than a second",
    other: "less than {{count}} seconds"
  },
  xSeconds: {
    one: "1 second",
    other: "{{count}} seconds"
  },
  halfAMinute: "half a minute",
  lessThanXMinutes: {
    one: "less than a minute",
    other: "less than {{count}} minutes"
  },
  xMinutes: {
    one: "1 minute",
    other: "{{count}} minutes"
  },
  aboutXHours: {
    one: "about 1 hour",
    other: "about {{count}} hours"
  },
  xHours: {
    one: "1 hour",
    other: "{{count}} hours"
  },
  xDays: {
    one: "1 day",
    other: "{{count}} days"
  },
  aboutXWeeks: {
    one: "about 1 week",
    other: "about {{count}} weeks"
  },
  xWeeks: {
    one: "1 week",
    other: "{{count}} weeks"
  },
  aboutXMonths: {
    one: "about 1 month",
    other: "about {{count}} months"
  },
  xMonths: {
    one: "1 month",
    other: "{{count}} months"
  },
  aboutXYears: {
    one: "about 1 year",
    other: "about {{count}} years"
  },
  xYears: {
    one: "1 year",
    other: "{{count}} years"
  },
  overXYears: {
    one: "over 1 year",
    other: "over {{count}} years"
  },
  almostXYears: {
    one: "almost 1 year",
    other: "almost {{count}} years"
  }
}, ot = (e, n, t) => {
  let r;
  const a = it[e];
  return typeof a == "string" ? r = a : n === 1 ? r = a.one : r = a.other.replace("{{count}}", n.toString()), t != null && t.addSuffix ? t.comparison && t.comparison > 0 ? "in " + r : r + " ago" : r;
};
function E(e) {
  return (n = {}) => {
    const t = n.width ? String(n.width) : e.defaultWidth;
    return e.formats[t] || e.formats[e.defaultWidth];
  };
}
const st = {
  full: "EEEE, MMMM do, y",
  long: "MMMM do, y",
  medium: "MMM d, y",
  short: "MM/dd/yyyy"
}, ut = {
  full: "h:mm:ss a zzzz",
  long: "h:mm:ss a z",
  medium: "h:mm:ss a",
  short: "h:mm a"
}, ct = {
  full: "{{date}} 'at' {{time}}",
  long: "{{date}} 'at' {{time}}",
  medium: "{{date}}, {{time}}",
  short: "{{date}}, {{time}}"
}, dt = {
  date: E({
    formats: st,
    defaultWidth: "full"
  }),
  time: E({
    formats: ut,
    defaultWidth: "full"
  }),
  dateTime: E({
    formats: ct,
    defaultWidth: "full"
  })
}, ft = {
  lastWeek: "'last' eeee 'at' p",
  yesterday: "'yesterday at' p",
  today: "'today at' p",
  tomorrow: "'tomorrow at' p",
  nextWeek: "eeee 'at' p",
  other: "P"
}, mt = (e, n, t, r) => ft[e];
function T(e) {
  return (n, t) => {
    const r = t != null && t.context ? String(t.context) : "standalone";
    let a;
    if (r === "formatting" && e.formattingValues) {
      const o = e.defaultFormattingWidth || e.defaultWidth, u = t != null && t.width ? String(t.width) : o;
      a = e.formattingValues[u] || e.formattingValues[o];
    } else {
      const o = e.defaultWidth, u = t != null && t.width ? String(t.width) : e.defaultWidth;
      a = e.values[u] || e.values[o];
    }
    const i = e.argumentCallback ? e.argumentCallback(n) : n;
    return a[i];
  };
}
const ht = {
  narrow: ["B", "A"],
  abbreviated: ["BC", "AD"],
  wide: ["Before Christ", "Anno Domini"]
}, lt = {
  narrow: ["1", "2", "3", "4"],
  abbreviated: ["Q1", "Q2", "Q3", "Q4"],
  wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
}, gt = {
  narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
  abbreviated: [
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
  ],
  wide: [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
  ]
}, wt = {
  narrow: ["S", "M", "T", "W", "T", "F", "S"],
  short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
  abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  wide: [
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
  ]
}, yt = {
  narrow: {
    am: "a",
    pm: "p",
    midnight: "mi",
    noon: "n",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  },
  abbreviated: {
    am: "AM",
    pm: "PM",
    midnight: "midnight",
    noon: "noon",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  },
  wide: {
    am: "a.m.",
    pm: "p.m.",
    midnight: "midnight",
    noon: "noon",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  }
}, bt = {
  narrow: {
    am: "a",
    pm: "p",
    midnight: "mi",
    noon: "n",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  },
  abbreviated: {
    am: "AM",
    pm: "PM",
    midnight: "midnight",
    noon: "noon",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  },
  wide: {
    am: "a.m.",
    pm: "p.m.",
    midnight: "midnight",
    noon: "noon",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  }
}, Ot = (e, n) => {
  const t = Number(e), r = t % 100;
  if (r > 20 || r < 10)
    switch (r % 10) {
      case 1:
        return t + "st";
      case 2:
        return t + "nd";
      case 3:
        return t + "rd";
    }
  return t + "th";
}, Mt = {
  ordinalNumber: Ot,
  era: T({
    values: ht,
    defaultWidth: "wide"
  }),
  quarter: T({
    values: lt,
    defaultWidth: "wide",
    argumentCallback: (e) => e - 1
  }),
  month: T({
    values: gt,
    defaultWidth: "wide"
  }),
  day: T({
    values: wt,
    defaultWidth: "wide"
  }),
  dayPeriod: T({
    values: yt,
    defaultWidth: "wide",
    formattingValues: bt,
    defaultFormattingWidth: "wide"
  })
};
function k(e) {
  return (n, t = {}) => {
    const r = t.width, a = r && e.matchPatterns[r] || e.matchPatterns[e.defaultMatchWidth], i = n.match(a);
    if (!i)
      return null;
    const o = i[0], u = r && e.parsePatterns[r] || e.parsePatterns[e.defaultParseWidth], d = Array.isArray(u) ? Pt(u, (g) => g.test(o)) : (
      // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
      xt(u, (g) => g.test(o))
    );
    let c;
    c = e.valueCallback ? e.valueCallback(d) : d, c = t.valueCallback ? (
      // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
      t.valueCallback(c)
    ) : c;
    const m = n.slice(o.length);
    return { value: c, rest: m };
  };
}
function xt(e, n) {
  for (const t in e)
    if (Object.prototype.hasOwnProperty.call(e, t) && n(e[t]))
      return t;
}
function Pt(e, n) {
  for (let t = 0; t < e.length; t++)
    if (n(e[t]))
      return t;
}
function Tt(e) {
  return (n, t = {}) => {
    const r = n.match(e.matchPattern);
    if (!r) return null;
    const a = r[0], i = n.match(e.parsePattern);
    if (!i) return null;
    let o = e.valueCallback ? e.valueCallback(i[0]) : i[0];
    o = t.valueCallback ? t.valueCallback(o) : o;
    const u = n.slice(a.length);
    return { value: o, rest: u };
  };
}
const kt = /^(\d+)(th|st|nd|rd)?/i, vt = /\d+/i, Wt = {
  narrow: /^(b|a)/i,
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
  wide: /^(before christ|before common era|anno domini|common era)/i
}, Dt = {
  any: [/^b/i, /^(a|c)/i]
}, St = {
  narrow: /^[1234]/i,
  abbreviated: /^q[1234]/i,
  wide: /^[1234](th|st|nd|rd)? quarter/i
}, Yt = {
  any: [/1/i, /2/i, /3/i, /4/i]
}, Et = {
  narrow: /^[jfmasond]/i,
  abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
  wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
}, Ft = {
  narrow: [
    /^j/i,
    /^f/i,
    /^m/i,
    /^a/i,
    /^m/i,
    /^j/i,
    /^j/i,
    /^a/i,
    /^s/i,
    /^o/i,
    /^n/i,
    /^d/i
  ],
  any: [
    /^ja/i,
    /^f/i,
    /^mar/i,
    /^ap/i,
    /^may/i,
    /^jun/i,
    /^jul/i,
    /^au/i,
    /^s/i,
    /^o/i,
    /^n/i,
    /^d/i
  ]
}, Ct = {
  narrow: /^[smtwf]/i,
  short: /^(su|mo|tu|we|th|fr|sa)/i,
  abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
  wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
}, Nt = {
  narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
  any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
}, Xt = {
  narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
  any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
}, pt = {
  any: {
    am: /^a/i,
    pm: /^p/i,
    midnight: /^mi/i,
    noon: /^no/i,
    morning: /morning/i,
    afternoon: /afternoon/i,
    evening: /evening/i,
    night: /night/i
  }
}, qt = {
  ordinalNumber: Tt({
    matchPattern: kt,
    parsePattern: vt,
    valueCallback: (e) => parseInt(e, 10)
  }),
  era: k({
    matchPatterns: Wt,
    defaultMatchWidth: "wide",
    parsePatterns: Dt,
    defaultParseWidth: "any"
  }),
  quarter: k({
    matchPatterns: St,
    defaultMatchWidth: "wide",
    parsePatterns: Yt,
    defaultParseWidth: "any",
    valueCallback: (e) => e + 1
  }),
  month: k({
    matchPatterns: Et,
    defaultMatchWidth: "wide",
    parsePatterns: Ft,
    defaultParseWidth: "any"
  }),
  day: k({
    matchPatterns: Ct,
    defaultMatchWidth: "wide",
    parsePatterns: Nt,
    defaultParseWidth: "any"
  }),
  dayPeriod: k({
    matchPatterns: Xt,
    defaultMatchWidth: "any",
    parsePatterns: pt,
    defaultParseWidth: "any"
  })
}, zt = {
  code: "en-US",
  formatDistance: ot,
  formatLong: dt,
  formatRelative: mt,
  localize: Mt,
  match: qt,
  options: {
    weekStartsOn: 0,
    firstWeekContainsDate: 1
  }
};
function _t(e) {
  const n = l(e);
  return nt(n, at(n)) + 1;
}
function Ht(e) {
  const n = l(e), t = +W(n) - +rt(n);
  return Math.round(t / A) + 1;
}
function $(e, n) {
  var m, g, x, P;
  const t = l(e), r = t.getFullYear(), a = S(), i = (n == null ? void 0 : n.firstWeekContainsDate) ?? ((g = (m = n == null ? void 0 : n.locale) == null ? void 0 : m.options) == null ? void 0 : g.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((P = (x = a.locale) == null ? void 0 : x.options) == null ? void 0 : P.firstWeekContainsDate) ?? 1, o = b(e, 0);
  o.setFullYear(r + 1, 0, i), o.setHours(0, 0, 0, 0);
  const u = v(o, n), d = b(e, 0);
  d.setFullYear(r, 0, i), d.setHours(0, 0, 0, 0);
  const c = v(d, n);
  return t.getTime() >= u.getTime() ? r + 1 : t.getTime() >= c.getTime() ? r : r - 1;
}
function Lt(e, n) {
  var u, d, c, m;
  const t = S(), r = (n == null ? void 0 : n.firstWeekContainsDate) ?? ((d = (u = n == null ? void 0 : n.locale) == null ? void 0 : u.options) == null ? void 0 : d.firstWeekContainsDate) ?? t.firstWeekContainsDate ?? ((m = (c = t.locale) == null ? void 0 : c.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, a = $(e, n), i = b(e, 0);
  return i.setFullYear(a, 0, r), i.setHours(0, 0, 0, 0), v(i, n);
}
function Qt(e, n) {
  const t = l(e), r = +v(t, n) - +Lt(t, n);
  return Math.round(r / A) + 1;
}
function s(e, n) {
  const t = e < 0 ? "-" : "", r = Math.abs(e).toString().padStart(n, "0");
  return t + r;
}
const w = {
  // Year
  y(e, n) {
    const t = e.getFullYear(), r = t > 0 ? t : 1 - t;
    return s(n === "yy" ? r % 100 : r, n.length);
  },
  // Month
  M(e, n) {
    const t = e.getMonth();
    return n === "M" ? String(t + 1) : s(t + 1, 2);
  },
  // Day of the month
  d(e, n) {
    return s(e.getDate(), n.length);
  },
  // AM or PM
  a(e, n) {
    const t = e.getHours() / 12 >= 1 ? "pm" : "am";
    switch (n) {
      case "a":
      case "aa":
        return t.toUpperCase();
      case "aaa":
        return t;
      case "aaaaa":
        return t[0];
      case "aaaa":
      default:
        return t === "am" ? "a.m." : "p.m.";
    }
  },
  // Hour [1-12]
  h(e, n) {
    return s(e.getHours() % 12 || 12, n.length);
  },
  // Hour [0-23]
  H(e, n) {
    return s(e.getHours(), n.length);
  },
  // Minute
  m(e, n) {
    return s(e.getMinutes(), n.length);
  },
  // Second
  s(e, n) {
    return s(e.getSeconds(), n.length);
  },
  // Fraction of second
  S(e, n) {
    const t = n.length, r = e.getMilliseconds(), a = Math.trunc(
      r * Math.pow(10, t - 3)
    );
    return s(a, n.length);
  }
}, O = {
  midnight: "midnight",
  noon: "noon",
  morning: "morning",
  afternoon: "afternoon",
  evening: "evening",
  night: "night"
}, _ = {
  // Era
  G: function(e, n, t) {
    const r = e.getFullYear() > 0 ? 1 : 0;
    switch (n) {
      // AD, BC
      case "G":
      case "GG":
      case "GGG":
        return t.era(r, { width: "abbreviated" });
      // A, B
      case "GGGGG":
        return t.era(r, { width: "narrow" });
      // Anno Domini, Before Christ
      case "GGGG":
      default:
        return t.era(r, { width: "wide" });
    }
  },
  // Year
  y: function(e, n, t) {
    if (n === "yo") {
      const r = e.getFullYear(), a = r > 0 ? r : 1 - r;
      return t.ordinalNumber(a, { unit: "year" });
    }
    return w.y(e, n);
  },
  // Local week-numbering year
  Y: function(e, n, t, r) {
    const a = $(e, r), i = a > 0 ? a : 1 - a;
    if (n === "YY") {
      const o = i % 100;
      return s(o, 2);
    }
    return n === "Yo" ? t.ordinalNumber(i, { unit: "year" }) : s(i, n.length);
  },
  // ISO week-numbering year
  R: function(e, n) {
    const t = B(e);
    return s(t, n.length);
  },
  // Extended year. This is a single number designating the year of this calendar system.
  // The main difference between `y` and `u` localizers are B.C. years:
  // | Year | `y` | `u` |
  // |------|-----|-----|
  // | AC 1 |   1 |   1 |
  // | BC 1 |   1 |   0 |
  // | BC 2 |   2 |  -1 |
  // Also `yy` always returns the last two digits of a year,
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
  u: function(e, n) {
    const t = e.getFullYear();
    return s(t, n.length);
  },
  // Quarter
  Q: function(e, n, t) {
    const r = Math.ceil((e.getMonth() + 1) / 3);
    switch (n) {
      // 1, 2, 3, 4
      case "Q":
        return String(r);
      // 01, 02, 03, 04
      case "QQ":
        return s(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "Qo":
        return t.ordinalNumber(r, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "QQQ":
        return t.quarter(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "QQQQQ":
        return t.quarter(r, {
          width: "narrow",
          context: "formatting"
        });
      // 1st quarter, 2nd quarter, ...
      case "QQQQ":
      default:
        return t.quarter(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone quarter
  q: function(e, n, t) {
    const r = Math.ceil((e.getMonth() + 1) / 3);
    switch (n) {
      // 1, 2, 3, 4
      case "q":
        return String(r);
      // 01, 02, 03, 04
      case "qq":
        return s(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "qo":
        return t.ordinalNumber(r, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "qqq":
        return t.quarter(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "qqqqq":
        return t.quarter(r, {
          width: "narrow",
          context: "standalone"
        });
      // 1st quarter, 2nd quarter, ...
      case "qqqq":
      default:
        return t.quarter(r, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // Month
  M: function(e, n, t) {
    const r = e.getMonth();
    switch (n) {
      case "M":
      case "MM":
        return w.M(e, n);
      // 1st, 2nd, ..., 12th
      case "Mo":
        return t.ordinalNumber(r + 1, { unit: "month" });
      // Jan, Feb, ..., Dec
      case "MMM":
        return t.month(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // J, F, ..., D
      case "MMMMM":
        return t.month(r, {
          width: "narrow",
          context: "formatting"
        });
      // January, February, ..., December
      case "MMMM":
      default:
        return t.month(r, { width: "wide", context: "formatting" });
    }
  },
  // Stand-alone month
  L: function(e, n, t) {
    const r = e.getMonth();
    switch (n) {
      // 1, 2, ..., 12
      case "L":
        return String(r + 1);
      // 01, 02, ..., 12
      case "LL":
        return s(r + 1, 2);
      // 1st, 2nd, ..., 12th
      case "Lo":
        return t.ordinalNumber(r + 1, { unit: "month" });
      // Jan, Feb, ..., Dec
      case "LLL":
        return t.month(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // J, F, ..., D
      case "LLLLL":
        return t.month(r, {
          width: "narrow",
          context: "standalone"
        });
      // January, February, ..., December
      case "LLLL":
      default:
        return t.month(r, { width: "wide", context: "standalone" });
    }
  },
  // Local week of year
  w: function(e, n, t, r) {
    const a = Qt(e, r);
    return n === "wo" ? t.ordinalNumber(a, { unit: "week" }) : s(a, n.length);
  },
  // ISO week of year
  I: function(e, n, t) {
    const r = Ht(e);
    return n === "Io" ? t.ordinalNumber(r, { unit: "week" }) : s(r, n.length);
  },
  // Day of the month
  d: function(e, n, t) {
    return n === "do" ? t.ordinalNumber(e.getDate(), { unit: "date" }) : w.d(e, n);
  },
  // Day of year
  D: function(e, n, t) {
    const r = _t(e);
    return n === "Do" ? t.ordinalNumber(r, { unit: "dayOfYear" }) : s(r, n.length);
  },
  // Day of week
  E: function(e, n, t) {
    const r = e.getDay();
    switch (n) {
      // Tue
      case "E":
      case "EE":
      case "EEE":
        return t.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "EEEEE":
        return t.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "EEEEEE":
        return t.day(r, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "EEEE":
      default:
        return t.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Local day of week
  e: function(e, n, t, r) {
    const a = e.getDay(), i = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (n) {
      // Numerical value (Nth day of week with current locale or weekStartsOn)
      case "e":
        return String(i);
      // Padded numerical value
      case "ee":
        return s(i, 2);
      // 1st, 2nd, ..., 7th
      case "eo":
        return t.ordinalNumber(i, { unit: "day" });
      case "eee":
        return t.day(a, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "eeeee":
        return t.day(a, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "eeeeee":
        return t.day(a, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "eeee":
      default:
        return t.day(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone local day of week
  c: function(e, n, t, r) {
    const a = e.getDay(), i = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (n) {
      // Numerical value (same as in `e`)
      case "c":
        return String(i);
      // Padded numerical value
      case "cc":
        return s(i, n.length);
      // 1st, 2nd, ..., 7th
      case "co":
        return t.ordinalNumber(i, { unit: "day" });
      case "ccc":
        return t.day(a, {
          width: "abbreviated",
          context: "standalone"
        });
      // T
      case "ccccc":
        return t.day(a, {
          width: "narrow",
          context: "standalone"
        });
      // Tu
      case "cccccc":
        return t.day(a, {
          width: "short",
          context: "standalone"
        });
      // Tuesday
      case "cccc":
      default:
        return t.day(a, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // ISO day of week
  i: function(e, n, t) {
    const r = e.getDay(), a = r === 0 ? 7 : r;
    switch (n) {
      // 2
      case "i":
        return String(a);
      // 02
      case "ii":
        return s(a, n.length);
      // 2nd
      case "io":
        return t.ordinalNumber(a, { unit: "day" });
      // Tue
      case "iii":
        return t.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "iiiii":
        return t.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "iiiiii":
        return t.day(r, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "iiii":
      default:
        return t.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM or PM
  a: function(e, n, t) {
    const a = e.getHours() / 12 >= 1 ? "pm" : "am";
    switch (n) {
      case "a":
      case "aa":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "aaa":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "aaaaa":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "aaaa":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM, PM, midnight, noon
  b: function(e, n, t) {
    const r = e.getHours();
    let a;
    switch (r === 12 ? a = O.noon : r === 0 ? a = O.midnight : a = r / 12 >= 1 ? "pm" : "am", n) {
      case "b":
      case "bb":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "bbb":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "bbbbb":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "bbbb":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // in the morning, in the afternoon, in the evening, at night
  B: function(e, n, t) {
    const r = e.getHours();
    let a;
    switch (r >= 17 ? a = O.evening : r >= 12 ? a = O.afternoon : r >= 4 ? a = O.morning : a = O.night, n) {
      case "B":
      case "BB":
      case "BBB":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "BBBBB":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "BBBB":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Hour [1-12]
  h: function(e, n, t) {
    if (n === "ho") {
      let r = e.getHours() % 12;
      return r === 0 && (r = 12), t.ordinalNumber(r, { unit: "hour" });
    }
    return w.h(e, n);
  },
  // Hour [0-23]
  H: function(e, n, t) {
    return n === "Ho" ? t.ordinalNumber(e.getHours(), { unit: "hour" }) : w.H(e, n);
  },
  // Hour [0-11]
  K: function(e, n, t) {
    const r = e.getHours() % 12;
    return n === "Ko" ? t.ordinalNumber(r, { unit: "hour" }) : s(r, n.length);
  },
  // Hour [1-24]
  k: function(e, n, t) {
    let r = e.getHours();
    return r === 0 && (r = 24), n === "ko" ? t.ordinalNumber(r, { unit: "hour" }) : s(r, n.length);
  },
  // Minute
  m: function(e, n, t) {
    return n === "mo" ? t.ordinalNumber(e.getMinutes(), { unit: "minute" }) : w.m(e, n);
  },
  // Second
  s: function(e, n, t) {
    return n === "so" ? t.ordinalNumber(e.getSeconds(), { unit: "second" }) : w.s(e, n);
  },
  // Fraction of second
  S: function(e, n) {
    return w.S(e, n);
  },
  // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
  X: function(e, n, t) {
    const r = e.getTimezoneOffset();
    if (r === 0)
      return "Z";
    switch (n) {
      // Hours and optional minutes
      case "X":
        return L(r);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XX`
      case "XXXX":
      case "XX":
        return y(r);
      // Hours, minutes and optional seconds with `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XXX`
      case "XXXXX":
      case "XXX":
      // Hours and minutes with `:` delimiter
      default:
        return y(r, ":");
    }
  },
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
  x: function(e, n, t) {
    const r = e.getTimezoneOffset();
    switch (n) {
      // Hours and optional minutes
      case "x":
        return L(r);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xx`
      case "xxxx":
      case "xx":
        return y(r);
      // Hours, minutes and optional seconds with `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xxx`
      case "xxxxx":
      case "xxx":
      // Hours and minutes with `:` delimiter
      default:
        return y(r, ":");
    }
  },
  // Timezone (GMT)
  O: function(e, n, t) {
    const r = e.getTimezoneOffset();
    switch (n) {
      // Short
      case "O":
      case "OO":
      case "OOO":
        return "GMT" + H(r, ":");
      // Long
      case "OOOO":
      default:
        return "GMT" + y(r, ":");
    }
  },
  // Timezone (specific non-location)
  z: function(e, n, t) {
    const r = e.getTimezoneOffset();
    switch (n) {
      // Short
      case "z":
      case "zz":
      case "zzz":
        return "GMT" + H(r, ":");
      // Long
      case "zzzz":
      default:
        return "GMT" + y(r, ":");
    }
  },
  // Seconds timestamp
  t: function(e, n, t) {
    const r = Math.trunc(e.getTime() / 1e3);
    return s(r, n.length);
  },
  // Milliseconds timestamp
  T: function(e, n, t) {
    const r = e.getTime();
    return s(r, n.length);
  }
};
function H(e, n = "") {
  const t = e > 0 ? "-" : "+", r = Math.abs(e), a = Math.trunc(r / 60), i = r % 60;
  return i === 0 ? t + String(a) : t + String(a) + n + s(i, 2);
}
function L(e, n) {
  return e % 60 === 0 ? (e > 0 ? "-" : "+") + s(Math.abs(e) / 60, 2) : y(e, n);
}
function y(e, n = "") {
  const t = e > 0 ? "-" : "+", r = Math.abs(e), a = s(Math.trunc(r / 60), 2), i = s(r % 60, 2);
  return t + a + n + i;
}
const Q = (e, n) => {
  switch (e) {
    case "P":
      return n.date({ width: "short" });
    case "PP":
      return n.date({ width: "medium" });
    case "PPP":
      return n.date({ width: "long" });
    case "PPPP":
    default:
      return n.date({ width: "full" });
  }
}, Z = (e, n) => {
  switch (e) {
    case "p":
      return n.time({ width: "short" });
    case "pp":
      return n.time({ width: "medium" });
    case "ppp":
      return n.time({ width: "long" });
    case "pppp":
    default:
      return n.time({ width: "full" });
  }
}, Rt = (e, n) => {
  const t = e.match(/(P+)(p+)?/) || [], r = t[1], a = t[2];
  if (!a)
    return Q(e, n);
  let i;
  switch (r) {
    case "P":
      i = n.dateTime({ width: "short" });
      break;
    case "PP":
      i = n.dateTime({ width: "medium" });
      break;
    case "PPP":
      i = n.dateTime({ width: "long" });
      break;
    case "PPPP":
    default:
      i = n.dateTime({ width: "full" });
      break;
  }
  return i.replace("{{date}}", Q(r, n)).replace("{{time}}", Z(a, n));
}, Gt = {
  p: Z,
  P: Rt
}, At = /^D+$/, It = /^Y+$/, Bt = ["D", "DD", "YY", "YYYY"];
function $t(e) {
  return At.test(e);
}
function Zt(e) {
  return It.test(e);
}
function jt(e, n, t) {
  const r = Vt(e, n, t);
  if (console.warn(r), Bt.includes(e)) throw new RangeError(r);
}
function Vt(e, n, t) {
  const r = e[0] === "Y" ? "years" : "days of the month";
  return `Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${n}\`) for formatting ${r} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
const Jt = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Ut = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Kt = /^'([^]*?)'?$/, te = /''/g, ee = /[a-zA-Z]/;
function ne(e, n, t) {
  var m, g, x, P, C, N, X, p;
  const r = S(), a = (t == null ? void 0 : t.locale) ?? r.locale ?? zt, i = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((g = (m = t == null ? void 0 : t.locale) == null ? void 0 : m.options) == null ? void 0 : g.firstWeekContainsDate) ?? r.firstWeekContainsDate ?? ((P = (x = r.locale) == null ? void 0 : x.options) == null ? void 0 : P.firstWeekContainsDate) ?? 1, o = (t == null ? void 0 : t.weekStartsOn) ?? ((N = (C = t == null ? void 0 : t.locale) == null ? void 0 : C.options) == null ? void 0 : N.weekStartsOn) ?? r.weekStartsOn ?? ((p = (X = r.locale) == null ? void 0 : X.options) == null ? void 0 : p.weekStartsOn) ?? 0, u = l(e);
  if (!I(u))
    throw new RangeError("Invalid time value");
  let d = n.match(Ut).map((h) => {
    const f = h[0];
    if (f === "p" || f === "P") {
      const Y = Gt[f];
      return Y(h, a.formatLong);
    }
    return h;
  }).join("").match(Jt).map((h) => {
    if (h === "''")
      return { isToken: !1, value: "'" };
    const f = h[0];
    if (f === "'")
      return { isToken: !1, value: re(h) };
    if (_[f])
      return { isToken: !0, value: h };
    if (f.match(ee))
      throw new RangeError(
        "Format string contains an unescaped latin alphabet character `" + f + "`"
      );
    return { isToken: !1, value: h };
  });
  a.localize.preprocessor && (d = a.localize.preprocessor(u, d));
  const c = {
    firstWeekContainsDate: i,
    weekStartsOn: o,
    locale: a
  };
  return d.map((h) => {
    if (!h.isToken) return h.value;
    const f = h.value;
    (!(t != null && t.useAdditionalWeekYearTokens) && Zt(f) || !(t != null && t.useAdditionalDayOfYearTokens) && $t(f)) && jt(f, n, String(e));
    const Y = _[f[0]];
    return Y(u, f, a.localize, c);
  }).join("");
}
function re(e) {
  const n = e.match(Kt);
  return n ? n[1].replace(te, "'") : e;
}
function R(e, n, t) {
  const r = oe(e, t.timeZone, t.locale);
  return "formatToParts" in r ? ae(r, n) : ie(r, n);
}
function ae(e, n) {
  const t = e.formatToParts(n);
  for (let r = t.length - 1; r >= 0; --r)
    if (t[r].type === "timeZoneName")
      return t[r].value;
}
function ie(e, n) {
  const t = e.format(n).replace(/\u200E/g, ""), r = / [\w-+ ]+$/.exec(t);
  return r ? r[0].substr(1) : "";
}
function oe(e, n, t) {
  return new Intl.DateTimeFormat(t ? [t.code, "en-US"] : void 0, {
    timeZone: n,
    timeZoneName: e
  });
}
const se = 60 * 1e3, ue = {
  // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
  X: function(e, n, t) {
    const r = F(t.timeZone, e);
    if (r === 0)
      return "Z";
    switch (n) {
      // Hours and optional minutes
      case "X":
        return G(r);
      // Hours, minutes and optional seconds without `:` delimeter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XX`
      case "XXXX":
      case "XX":
        return M(r);
      // Hours, minutes and optional seconds with `:` delimeter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XXX`
      case "XXXXX":
      case "XXX":
      // Hours and minutes with `:` delimeter
      default:
        return M(r, ":");
    }
  },
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
  x: function(e, n, t) {
    const r = F(t.timeZone, e);
    switch (n) {
      // Hours and optional minutes
      case "x":
        return G(r);
      // Hours, minutes and optional seconds without `:` delimeter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xx`
      case "xxxx":
      case "xx":
        return M(r);
      // Hours, minutes and optional seconds with `:` delimeter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xxx`
      case "xxxxx":
      case "xxx":
      // Hours and minutes with `:` delimeter
      default:
        return M(r, ":");
    }
  },
  // Timezone (GMT)
  O: function(e, n, t) {
    const r = F(t.timeZone, e);
    switch (n) {
      // Short
      case "O":
      case "OO":
      case "OOO":
        return "GMT" + ce(r, ":");
      // Long
      case "OOOO":
      default:
        return "GMT" + M(r, ":");
    }
  },
  // Timezone (specific non-location)
  z: function(e, n, t) {
    switch (n) {
      // Short
      case "z":
      case "zz":
      case "zzz":
        return R("short", e, t);
      // Long
      case "zzzz":
      default:
        return R("long", e, t);
    }
  }
};
function F(e, n) {
  const t = e ? J(e, n, !0) / se : (n == null ? void 0 : n.getTimezoneOffset()) ?? 0;
  if (Number.isNaN(t))
    throw new RangeError("Invalid time zone specified: " + e);
  return t;
}
function D(e, n) {
  const t = e < 0 ? "-" : "";
  let r = Math.abs(e).toString();
  for (; r.length < n; )
    r = "0" + r;
  return t + r;
}
function M(e, n = "") {
  const t = e > 0 ? "-" : "+", r = Math.abs(e), a = D(Math.floor(r / 60), 2), i = D(Math.floor(r % 60), 2);
  return t + a + n + i;
}
function G(e, n) {
  return e % 60 === 0 ? (e > 0 ? "-" : "+") + D(Math.abs(e) / 60, 2) : M(e, n);
}
function ce(e, n = "") {
  const t = e > 0 ? "-" : "+", r = Math.abs(e), a = Math.floor(r / 60), i = r % 60;
  return i === 0 ? t + String(a) : t + String(a) + n + D(i, 2);
}
const de = /([xXOz]+)|''|'(''|[^'])+('|$)/g;
function fe(e, n, t = {}) {
  n = String(n);
  const r = n.match(de);
  if (r) {
    const a = U(t.originalDate || e, t);
    n = r.reduce(function(i, o) {
      if (o[0] === "'")
        return i;
      const u = i.indexOf(o), d = i[u - 1] === "'", c = i.replace(o, "'" + ue[o[0]](a, o, t) + "'");
      return d ? c.substring(0, u - 1) + c.substring(u + 1) : c;
    }, n);
  }
  return ne(e, n, t);
}
function ye(e, n) {
  const { format: t = j.YYYY_MM_DD_DATE_FNS, timeZone: r = "UTC" } = n || {};
  if (!e)
    return "";
  const a = V(e);
  return I(a) ? fe(K(a, r), t, { timeZone: r }) : e;
}
export {
  $ as a,
  W as b,
  b as c,
  Qt as d,
  Ht as e,
  z as f,
  S as g,
  zt as h,
  Zt as i,
  $t as j,
  ye as k,
  Gt as l,
  q as m,
  v as s,
  jt as w
};
//# sourceMappingURL=formatDateTime-Dz8bXV0R.js.map
