import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { formatTimeStr } from "./utils.js";
import React from "react";
import { useCountDown, useUpdateEffect } from "ahooks";
//#region src/components/pisellCountdown/index.tsx
const _excluded = [
	"leftTime",
	"targetDate",
	"interval",
	"onChange",
	"onFinish",
	"format"
];
const PisellCountdown = (props) => {
	const { leftTime, targetDate, interval, onChange, onFinish, format = "HH:mm:ss" } = props, others = _objectWithoutProperties(props, _excluded);
	const [countdown] = useCountDown(_objectSpread2(_objectSpread2({}, leftTime ? { leftTime } : {}), {}, {
		targetDate,
		interval,
		onEnd: () => {
			onFinish === null || onFinish === void 0 || onFinish();
		}
	}));
	useUpdateEffect(() => {
		onChange === null || onChange === void 0 || onChange(countdown);
	}, [countdown]);
	return /* @__PURE__ */ React.createElement("span", others, formatTimeStr(countdown, format || "HH:mm:ss"));
};
//#endregion
export { PisellCountdown as default };
