import u from "./validateDayForMonth.js";
function h(a, l) {
  if (!a) return a;
  const s = a.replace(/\D/g, "");
  if (!s) return "";
  const n = [];
  let o = 0;
  for (const e of l) {
    let t = s.slice(o, o + e.length);
    if (!t) break;
    if (t.length === e.length) {
      const r = parseInt(t, 10);
      e.type === "d" && r > 31 && (t = "31"), e.type === "m" && r > 12 && (t = "12");
    }
    if (n.push({ type: e.type, value: t, separator: e.separator }), o += t.length, t.length < e.length) break;
  }
  return u(n), n.map((e, t) => {
    const r = l[t], p = t < n.length - 1 && e.value.length === r.length;
    return e.value + (p ? e.separator : "");
  }).join("");
}
export {
  h as default
};
//# sourceMappingURL=formatDateInput.js.map
