"use client";
import { t as e } from "../chunks/clsx.js";
import { FlipCard as t } from "./FlipCard.js";
import { useEffect as n, useState as r } from "react";
import { jsx as i, jsxs as a } from "react/jsx-runtime";
//#region lib/ui/Countdown.tsx
var o = 1e3, s = o * 60, c = s * 60, l = c * 24, u = (e) => Math.max(Math.floor(e / l), 0), d = (e) => Math.max(Math.floor(e % l / c), 0), f = (e) => Math.max(Math.floor(e % c / s), 0), p = (e) => Math.max(Math.floor(e % s / o), 0);
function m({ className: n, countdown: r, theme: o = "white", ...s }) {
	let { to: c, labels: l } = r, [u, d, f, p] = h(c), m = [
		[u, l.days],
		[d, l.hours],
		[f, l.minutes],
		[p, l.seconds]
	];
	return /* @__PURE__ */ i("div", {
		"data-name": "Countdown",
		role: "timer",
		...s,
		dir: "ltr",
		className: e("flex gap-x-4", n),
		children: m.map(([e, n], r) => {
			let s = m.slice(0, r).every(([e]) => e === 0), c = e === 0 && s ? "black" : o;
			return /* @__PURE__ */ a("div", {
				className: "space-y-4",
				children: [/* @__PURE__ */ i("div", {
					className: "flex flex-row items-center gap-x-2 px-2",
					children: e.toString().padStart(2, "0").split("").map((e, n) => /* @__PURE__ */ i(t, {
						theme: c,
						value: parseInt(e)
					}, n))
				}), /* @__PURE__ */ i("span", {
					className: "text-b5 block max-w-58 truncate text-center",
					children: n
				})]
			}, n);
		})
	});
}
function h(e) {
	let t = new Date(e).getTime(), i = t - Date.now(), [a, o] = r(() => u(i)), [s, c] = r(() => d(i)), [l, m] = r(() => f(i)), [h, g] = r(() => p(i));
	return n(() => {
		let e = setInterval(() => {
			let n = t - Date.now();
			if (n < 0) {
				clearInterval(e);
				return;
			}
			o(u(n)), c(d(n)), m(f(n)), g(p(n));
		}, 1e3);
		return () => clearInterval(e);
	}, [t]), [
		a,
		s,
		l,
		h
	];
}
//#endregion
export { m as Countdown };

//# sourceMappingURL=Countdown.js.map