const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_SalesSdkMultiDayTimeSelectModal = require("../components/SalesSdkMultiDayTimeSelectModal.js");
const require_multiDayHostController = require("../addProductFlow/multiDayHostController.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
//#region src/plus/salesSdk/hosts/MultiDayHostRenderer.tsx
/**
* 承接 `openMultiDaySelect` Promise Host 的跨日弹窗渲染。
*/
const MultiDayHostRenderer = () => {
	const pending = (0, react.useSyncExternalStore)(require_multiDayHostController.subscribeMultiDayHost, require_multiDayHostController.getMultiDayHostPending, () => null);
	const open = !!pending;
	const payload = pending === null || pending === void 0 ? void 0 : pending.payload;
	const defaultStartDate = (payload === null || payload === void 0 ? void 0 : payload.defaultStartDate) ? (0, dayjs.default)(payload.defaultStartDate) : (0, dayjs.default)();
	if (!open) return null;
	return /* @__PURE__ */ react.default.createElement(require_SalesSdkMultiDayTimeSelectModal.SalesSdkMultiDayTimeSelectModal, {
		open,
		productName: payload === null || payload === void 0 ? void 0 : payload.productName,
		locale: _pisell_utils.locales.locale,
		defaultStartDate: defaultStartDate.isValid() ? defaultStartDate : (0, dayjs.default)(),
		onCancel: () => require_multiDayHostController.completeMultiDayHost(null),
		onConfirm: (startDate, endDate, duration) => {
			require_multiDayHostController.completeMultiDayHost({
				startDate: startDate.format("YYYY-MM-DD"),
				endDate: endDate.format("YYYY-MM-DD"),
				duration
			});
		}
	});
};
//#endregion
exports.MultiDayHostRenderer = MultiDayHostRenderer;
