const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
//#region src/plus/salesSdk/utils/bookingDate.ts
/** OS BookingContext 日期变更事件名（配合 `store.bookingContext.effectsOn` 使用）。 */
const BOOKING_CONTEXT_DATE_EVENT = "onDateChange";
/**
* 将 BookingContext / dayjs / 字符串统一格式化为 `YYYY-MM-DD HH:mm:ss`。
*
* @example
* formatBookingDateTime(dayjs()); // '2026-05-25 14:30:00'
* formatBookingDateTime('2026-05-25'); // '2026-05-25 00:00:00'
*/
function formatBookingDateTime(raw) {
	if (raw == null || raw === "") return null;
	const parsed = (0, dayjs.default)(raw);
	return parsed.isValid() ? parsed.format("YYYY-MM-DD HH:mm:ss") : null;
}
/**
* 订阅 BookingContext 日期变更；返回取消订阅函数。
*
* @example
* const off = subscribeBookingDateChange(bookingTicket, (date) => {
*   console.log('booking date changed', date);
* });
* off();
*/
function subscribeBookingDateChange(bookingTicket, callback) {
	var _store;
	const module = bookingTicket === null || bookingTicket === void 0 || (_store = bookingTicket.store) === null || _store === void 0 ? void 0 : _store.bookingContext;
	if (!module || typeof module.effectsOn !== "function") return () => {};
	const off = module.effectsOn(BOOKING_CONTEXT_DATE_EVENT, callback);
	return typeof off === "function" ? off : () => {};
}
//#endregion
exports.formatBookingDateTime = formatBookingDateTime;
exports.subscribeBookingDateChange = subscribeBookingDateChange;
