import { n as e } from "./rolldown-runtime-C266TIVP.js";
import { M as t, P as n, Z as r, ct as i, f as a, g as o, h as s, it as c, p as l, st as u, u as d, x as f } from "./draggable-P6QWzy4g.js";
import { Pt as p, ln as m } from "./features-DzIN-Nua.js";
//#region src/components/blocks/CountdownBlock.vue?vue&type=script&setup=true&lang.ts
var h = {
	key: 0,
	class: "tpl:flex tpl:items-center tpl:justify-center tpl:py-8 tpl:text-sm tpl:text-[var(--tpl-text-dim)]"
}, g = {
	key: 1,
	class: "tpl:flex tpl:items-center tpl:justify-center tpl:py-4 tpl:text-xs tpl:text-[var(--tpl-text-dim)] tpl:opacity-50"
}, _ = { class: "tpl:text-center" }, v = /* @__PURE__ */ f({
	__name: "CountdownBlock",
	props: {
		block: {},
		viewport: {}
	},
	setup(e) {
		let f = e, { t: v } = p(), y = r(Date.now());
		m(() => {
			y.value = Date.now();
		}, 1e3);
		let b = a(() => {
			if (!f.block.targetDate) return null;
			let e = new Date(f.block.targetDate);
			return isNaN(e.getTime()) ? null : e.getTime();
		}), x = a(() => b.value ? y.value >= b.value : !1), S = a(() => {
			if (!b.value || x.value) return {
				days: 0,
				hours: 0,
				minutes: 0,
				seconds: 0
			};
			let e = b.value - y.value, t = Math.floor(e / 1e3);
			return {
				days: Math.floor(t / 86400),
				hours: Math.floor(t % 86400 / 3600),
				minutes: Math.floor(t % 3600 / 60),
				seconds: t % 60
			};
		}), C = a(() => {
			let e = [];
			return f.block.showDays && e.push({
				value: String(S.value.days).padStart(2, "0"),
				label: f.block.labelDays
			}), f.block.showHours && e.push({
				value: String(S.value.hours).padStart(2, "0"),
				label: f.block.labelHours
			}), f.block.showMinutes && e.push({
				value: String(S.value.minutes).padStart(2, "0"),
				label: f.block.labelMinutes
			}), f.block.showSeconds && e.push({
				value: String(S.value.seconds).padStart(2, "0"),
				label: f.block.labelSeconds
			}), e;
		}), w = a(() => ({
			backgroundColor: f.block.backgroundColor,
			fontFamily: f.block.fontFamily || "inherit"
		})), T = a(() => ({
			fontSize: `${f.block.digitFontSize}px`,
			fontWeight: "bold",
			color: f.block.digitColor,
			lineHeight: "1.2"
		})), E = a(() => ({
			fontSize: `${f.block.labelFontSize}px`,
			color: f.block.labelColor,
			marginTop: "4px"
		})), D = a(() => ({
			fontSize: `${f.block.digitFontSize}px`,
			color: f.block.digitColor,
			fontFamily: f.block.fontFamily || "inherit"
		}));
		return (r, a) => e.block.targetDate ? x.value && e.block.hideOnExpiry ? (t(), o("div", g, i(c(v).countdown.hidden), 1)) : x.value ? (t(), o("div", {
			key: 2,
			style: u(w.value),
			class: "tpl:py-4 tpl:text-center"
		}, [l("span", { style: u({
			fontSize: `${e.block.digitFontSize}px`,
			color: e.block.digitColor
		}) }, i(e.block.expiredMessage), 5)], 4)) : (t(), o("div", {
			key: 3,
			style: u(w.value),
			class: "tpl:flex tpl:items-center tpl:justify-center tpl:gap-2 tpl:py-4"
		}, [(t(!0), o(d, null, n(C.value, (n, r) => (t(), o(d, { key: n.label }, [r > 0 ? (t(), o("span", {
			key: 0,
			style: u(D.value),
			class: "tpl:self-start"
		}, i(e.block.separator), 5)) : s("", !0), l("div", _, [l("div", { style: u(T.value) }, i(n.value), 5), l("div", { style: u(E.value) }, i(n.label), 5)])], 64))), 128))], 4)) : (t(), o("div", h, i(c(v).countdown.setDate), 1));
	}
}), y = /* @__PURE__ */ e({ default: () => b }), b = v;
//#endregion
export { y as n, b as t };

//# sourceMappingURL=CountdownBlock-D1RoaOgF.js.map