;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "beef0602-3e73-42e9-a49f-8be7b7981235", e._sentryDebugIdIdentifier = "sentry-dbid-beef0602-3e73-42e9-a49f-8be7b7981235");
  } catch (e) {
  }
}
;
import { jsx } from "preact/jsx-runtime";
import { useMemo } from "preact/hooks";
import { a as InputBase } from "./InputText-DRSK56ma.js";
const checkDateInputSupport = () => {
  const input = document.createElement("input");
  input.setAttribute("type", "date");
  return input.type === "date";
};
const formatDate = (value) => {
  const date = value.replace(/\D|\s/g, "").replace(/^(00)(.*)?/, "01$2").replace(/^(3[2-9])(.*)?/, "0$1$2").replace(/^([4-9])(.*)?/, "0$1").replace(/^([0-9]{2})(00)(.*)?/, "$101").replace(/^(3[01])(02)(.*)?/, "29$2").replace(/^([0-9]{2})([2-9]|1[3-9])(.*)?/, "$10$2").replace(/^([0-9]{2})([0-9]{2})([0-9])/, "$1/$2/$3").replace(/^([0-9]{2})([0-9])/, "$1/$2");
  const [day = "", month = "", year = ""] = date.split("/");
  if (year.length === 4 && day === "29" && month === "02" && (Number(year) % 4 !== 0 || year.substring(2, 4) === "00" && Number(year) % 400 !== 0)) {
    return date.replace(/^29/, "28");
  }
  return date;
};
const formatDateObj = (date) => date.toJSON().slice(0, 10);
function InputDate(props) {
  const isDateInputSupported = useMemo(checkDateInputSupport, []);
  const { onInput } = props;
  const handleInput = (e) => {
    const { value } = e.currentTarget;
    e.currentTarget.value = formatDate(value);
    onInput(e);
  };
  if (isDateInputSupported) {
    return /* @__PURE__ */ jsx(InputBase, { ...props, type: "date" });
  }
  return /* @__PURE__ */ jsx(InputBase, { ...props, onInput: handleInput, maxLength: 10 });
}
export {
  InputDate as I,
  formatDateObj as f
};
