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] = "3904aed6-7045-4235-88c1-9ae68d054e16", e._sentryDebugIdIdentifier = "sentry-dbid-3904aed6-7045-4235-88c1-9ae68d054e16");
} catch (e) {}
import { r as InputBase } from "./InputText-CadVntiC.js";
import { useMemo } from "preact/hooks";
import { jsx } from "preact/jsx-runtime";
//#region src/components/ui/molecules/InputDate/InputDate.utils.ts
/**
* Returns either the date input is supported or not in the current browser
*/
var checkDateInputSupport = () => {
	const input = document.createElement("input");
	input.setAttribute("type", "date");
	return input.type === "date";
};
/**
* Returns a formatted date
* @param value -
* @example
* formatDate('22111990');
* // '22/11/1990'
*/
var 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;
};
var formatDateObj = (date) => date.toJSON().slice(0, 10);
//#endregion
//#region src/components/ui/molecules/InputDate/InputDate.tsx
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
	});
}
//#endregion
export { formatDateObj as n, InputDate as t };
